Skip to content

Commit

Permalink
refactor: Started cleaning up the Subscription API
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdutz committed Apr 2, 2024
1 parent 1f8885c commit 719ff2c
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 298 deletions.
2 changes: 1 addition & 1 deletion .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
-XX:+EnableDynamicAgentLoading --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ public interface PlcConnection extends AutoCloseable {
*
* @throws PlcRuntimeException If the string cannot be parsed
*/
@Deprecated
default PlcTag parseTagAddress(String tagAddress) throws PlcInvalidTagException {
throw new PlcRuntimeException("Parse method is not implemented for this connection / driver");
}
PlcTag parseTagAddress(String tagAddress) throws PlcInvalidTagException;

/**
* Provides connection metadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,28 @@
*/
package org.apache.plc4x.java.api.messages;

import org.apache.plc4x.java.api.model.PlcPublicationTag;
import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.java.api.value.PlcValue;

import java.time.Duration;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.concurrent.CompletableFuture;

public interface PlcPublicationRequest extends PlcPublicationTagRequest {
public interface PlcPublicationRequest extends PlcRequest {

@Override
CompletableFuture<? extends PlcPublicationResponse> execute();

int getNumberOfTags();

LinkedHashSet<String> getTagNames();

PlcPublicationTag getTag(String name);

List<PlcPublicationTag> getTags();

interface Builder extends PlcRequestBuilder {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,21 @@
*/
package org.apache.plc4x.java.api.messages;

import org.apache.plc4x.java.api.model.PlcPublicationHandle;
import org.apache.plc4x.java.api.model.PlcSubscriptionHandle;
import org.apache.plc4x.java.api.model.PlcPublicationTag;
import org.apache.plc4x.java.api.types.PlcResponseCode;

import java.util.Collection;

public interface PlcPublicationResponse extends PlcPublicationTagResponse {
public interface PlcPublicationResponse extends PlcResponse {

@Override
PlcPublicationRequest getRequest();

/**
* Returns a {@link PlcPublicationHandle} associated with a {@code name} from {@link PlcPublicationRequest#getTag(String)}
*
* @param name the tag name which a {@link PlcPublicationHandle} is required to
* @return a {@link PlcPublicationHandle}
*/
PlcPublicationHandle getPublicationHandle(String name);

/**
* @return all {@link PlcPublicationHandle}s
*/
Collection<PlcPublicationHandle> getPublicationHandles();
Collection<String> getTagNames();

PlcPublicationTag getTag(String name);

PlcResponseCode getResponseCode(String name);


}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@
* Base type for all messages sent from the plc4x system to a connected plc.
*/
public interface PlcRequest extends PlcMessage {

CompletableFuture<? extends PlcResponse> execute();

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,32 @@
*/
package org.apache.plc4x.java.api.messages;

import org.apache.plc4x.java.api.model.PlcConsumerRegistration;
import org.apache.plc4x.java.api.model.PlcSubscriptionTag;
import org.apache.plc4x.java.api.model.PlcTag;

import java.time.Duration;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

public interface PlcSubscriptionRequest extends PlcSubscriptionTagRequest {
public interface PlcSubscriptionRequest extends PlcRequest {

@Override
CompletableFuture<? extends PlcSubscriptionResponse> execute();

CompletableFuture<? extends PlcSubscriptionResponse> executeWithConsumer(Consumer<PlcSubscriptionEvent> subscriptionConsumer);

int getNumberOfTags();

LinkedHashSet<String> getTagNames();

PlcSubscriptionTag getTag(String name);

List<PlcSubscriptionTag> getTags();

List<Consumer<PlcSubscriptionEvent>> getConsumers();

interface Builder extends PlcRequestBuilder {

@Override
Expand Down Expand Up @@ -99,18 +113,6 @@ interface Builder extends PlcRequestBuilder {
*/
PlcSubscriptionRequest.Builder addEventTag(String name, PlcTag tag);

/**
* Convenience method which attaches the {@link Consumer<PlcSubscriptionEvent>} directly to the handles once the
* requests succeeds.
* Note: opposed to register on the {@link org.apache.plc4x.java.api.model.PlcSubscriptionHandle} directly you
* won't retrieve a {@link PlcConsumerRegistration} which is useful to cancel registrations.
*
* @param name alias of the tag.
* @param preRegisteredConsumer {@link Consumer<PlcSubscriptionEvent>} to be attached
* @return builder.
*/
PlcSubscriptionRequest.Builder addPreRegisteredConsumer(String name, Consumer<PlcSubscriptionEvent> preRegisteredConsumer);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,25 @@
*/
package org.apache.plc4x.java.api.messages;

import org.apache.plc4x.java.api.model.PlcSubscriptionHandle;
import org.apache.plc4x.java.api.model.PlcSubscriptionTag;
import org.apache.plc4x.java.api.types.PlcResponseCode;

import java.util.Collection;
import java.util.function.Consumer;

public interface PlcSubscriptionResponse extends PlcSubscriptionTagResponse {
public interface PlcSubscriptionResponse extends PlcResponse {

@Override
PlcSubscriptionRequest getRequest();

/**
* Returns a {@link PlcSubscriptionHandle} associated with a {@code name} from {@link PlcSubscriptionRequest#getTag(String)}
*
* @param name the tag name which a {@link PlcSubscriptionHandle} is required to
* @return a {@link PlcSubscriptionHandle}
*/
PlcSubscriptionHandle getSubscriptionHandle(String name);

/**
* @return all {@link PlcSubscriptionHandle}s
*/
Collection<PlcSubscriptionHandle> getSubscriptionHandles();
PlcUnsubscriptionRequest getUnsubscriptionRequest();

Collection<String> getTagNames();

PlcSubscriptionTag getTag(String name);

PlcResponseCode getResponseCode(String name);

void registerConsumer(Consumer<PlcSubscriptionEvent> subscriptionConsumer);

}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 719ff2c

Please sign in to comment.