Class SubscriptionHandler
java.lang.Object
org.opentrafficsim.sim0mq.publisher.SubscriptionHandler
Data collection that can be listed and has subscription to change events.
Copyright (c) 2020-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe commands that a SubscriptionHandler understands. -
Constructor Summary
ConstructorsConstructorDescriptionSubscriptionHandler(String id, TransceiverInterface listTransceiver, LookupEventProducer eventProducerForAddRemoveOrChange, org.djutils.event.EventType addedEventType, org.djutils.event.EventType removedEventType, org.djutils.event.EventType changeEventType, SubscriptionHandler elementSubscriptionHandler) Create a new SubscriptionHandler. -
Method Summary
Modifier and TypeMethodDescriptionvoidexecuteCommand(SubscriptionHandler.Command command, Object[] address, ReturnWrapper returnWrapper) Execute one command.voidget(Object[] address, ReturnWrapper returnWrapper) Retrieve a data collection.final StringgetId()Retrieve the id of this SubscriptionHandler.Retrieve the list transceiver (only for testing).org.djutils.metadata.MetaDataReport what payload is required to retrieve a list of all elements, or data and what format a result would have.org.djutils.metadata.MetaDataReport what the payload format of the result of the list transceiver.static SubscriptionHandler.CommandlookupCommand(String commandString) Convert a String representing a Command into that Command.Return the set of supported commands.toString()
-
Constructor Details
-
SubscriptionHandler
public SubscriptionHandler(String id, TransceiverInterface listTransceiver, LookupEventProducer eventProducerForAddRemoveOrChange, org.djutils.event.EventType addedEventType, org.djutils.event.EventType removedEventType, org.djutils.event.EventType changeEventType, SubscriptionHandler elementSubscriptionHandler) Create a new SubscriptionHandler.- Parameters:
id- id of the new SubscriptionHandlerlistTransceiver- transceiver to retrieve the data of the addressed object right noweventProducerForAddRemoveOrChange- the event producer that can emit theaddedEventType,removedEventType, orchangeEventTypeeventsaddedEventType- event type that signals that a new element has been added, should be null if there is no added event type for the dataremovedEventType- event type that signals that an element has been removed, should be null if there is no removed event type for the datachangeEventType- event type that signals that an element has been changed, should be null if there is no change event type for the dataelementSubscriptionHandler- SubscriptionHandler for events produced by the underlying elements
-
-
Method Details
-
listRequestMetaData
public org.djutils.metadata.MetaData listRequestMetaData()Report what payload is required to retrieve a list of all elements, or data and what format a result would have.- Returns:
- description of the payload required to retrieve a list of all elements, or data and what format a result would have
-
listResultMetaData
public org.djutils.metadata.MetaData listResultMetaData()Report what the payload format of the result of the list transceiver.- Returns:
- the payload format of the result of the list transceiver
-
get
public void get(Object[] address, ReturnWrapper returnWrapper) throws RemoteException, org.sim0mq.Sim0MQException, org.djutils.serialization.SerializationException Retrieve a data collection.- Parameters:
address- address of the requested data collectionreturnWrapper- to send back the result- Throws:
RemoteException- when communication failsorg.djutils.serialization.SerializationException- on context errororg.sim0mq.Sim0MQException- on DSOL error
-
getListTransceiver
Retrieve the list transceiver (only for testing).- Returns:
- the list transceiver
-
subscriptionOptions
Return the set of supported commands.- Returns:
- the set of supported commands.
-
getId
Retrieve the id of this SubscriptionHandler.- Returns:
- the id of this SubscriptionHandler
-
lookupCommand
Convert a String representing a Command into that Command.- Parameters:
commandString- the string- Returns:
- the corresponding Command, or null if the
commandStringis not a valid Command
-
executeCommand
public void executeCommand(SubscriptionHandler.Command command, Object[] address, ReturnWrapper returnWrapper) throws RemoteException, org.sim0mq.Sim0MQException, org.djutils.serialization.SerializationException Execute one command.- Parameters:
command- the commandaddress- Object[] the address of the object on which the command must be appliedreturnWrapper- envelope generator for replies- Throws:
RemoteException- on communication failureorg.djutils.serialization.SerializationException- on illegal type in serializationorg.sim0mq.Sim0MQException- on communication error
-
toString
-