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-2023 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- String; id of the new SubscriptionHandlerlistTransceiver- TransceiverInterface; transceiver to retrieve the data of the addressed object right noweventProducerForAddRemoveOrChange- LookupEventProducer; the event producer that can emit theaddedEventType,removedEventType, orchangeEventTypeeventsaddedEventType- EventType; event type that signals that a new element has been added, should be null if there is no added event type for the dataremovedEventType- EventType; event type that signals that an element has been removed, should be null if there is no removed event type for the datachangeEventType- EventType; event type that signals that an element has been changed, should be null if there is no change event type for the dataelementSubscriptionHandler- SubscriptionHandler; 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:
- MetaData; 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:
- MetaData; the payload format of the result of the list transceiver
-
get
public void get(Object[] address, ReturnWrapper returnWrapper) throws RemoteException, Sim0MQException, SerializationException Retrieve a data collection.- Parameters:
address- Object[]; address of the requested data collectionreturnWrapper- ReturnWrapper; to send back the result- Throws:
RemoteException- when communication failsSerializationException- on context errorSim0MQException- on DSOL error
-
getListTransceiver
Retrieve the list transceiver (only for testing).- Returns:
- TransceiverInterface; the list transceiver
-
subscriptionOptions
Return the set of supported commands.- Returns:
- EnumSet<Command>; the set of supported commands.
-
getId
Retrieve the id of this SubscriptionHandler.- Returns:
- String; the id of this SubscriptionHandler
-
lookupCommand
Convert a String representing a Command into that Command.- Parameters:
commandString- String; the string- Returns:
- Command; 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, Sim0MQException, SerializationException Execute one command.- Parameters:
command- Command; the commandaddress- Object[] the address of the object on which the command must be appliedreturnWrapper- ReturnWrapper; envelope generator for replies- Throws:
RemoteException- on communication failureSerializationException- on illegal type in serializationSim0MQException- on communication error
-
toString
-