public abstract class BaseDestination extends java.lang.Object implements Destination
BaseDestination represent the end-points that the transport
can use.
init() -> connect() ->
start() -> close()
Users must take care of this sequence while providing the Destination's implementation
| Modifier and Type | Field and Description |
|---|---|
protected BaseChannel |
channel
Reference to the Channel that this Destination is part of.
|
protected java.lang.String |
defaultEventUri
Stores the default Event's URI associated to this
Destination |
protected java.lang.String |
destinationName
Stores the name of the destination
|
protected java.util.Properties |
destinationProperties
Stores the destination properties
|
protected EventProcessor |
eventProcessor
The instance of
EventProcessor.This is used to process
events received on the destination |
protected Logger |
logger
Stores the Logger instance associated
|
protected BaseEventSerializer |
serializer
Stores the serializer used to serialize events into objects that the
underlying transport can use, and deserialize those objects into events.
|
protected boolean |
suspended
Flag denoting that the Destination is suspended or not
|
protected java.lang.String |
uri
Stores the URI of the
Destination |
| Modifier and Type | Method and Description |
|---|---|
void |
bind(EventProcessor eventProcessor)
Initializes the listener(s) for the specified EventProcessor.
|
abstract void |
close()
Closes the Destination and frees up all its resources.
|
abstract void |
connect()
Connects the
Destination to its underlying end-point. |
BaseChannel |
getChannel()
Gets the
Channel instance
associated with this destination |
java.lang.String |
getDefaultEventUri()
Gets the default Event URI associated with this
Destination |
java.lang.String |
getDestinationName()
Gets the name of the
Destination |
java.util.Properties |
getDestinationProperties()
Gets the Properties associated with the
Destination |
EventContext |
getEventContext(Event event)
Gets the user
EventContext
You can override to provide custom implementation for EventContext
If not defined the DefaultEventContext will be used. |
EventProcessor |
getEventProcessor()
Gets the instance of
EventProcessor.This
is used to process events received on the destination |
BaseEventSerializer |
getSerializer()
Gets the
BaseEventSerializer instance
associated with this destination |
java.lang.String |
getUri()
Gets the URI of this
Destination |
abstract void |
init()
Initializes the
Destination by allocating necessary resources, creating pools, etc. |
boolean |
isSuspended()
Returns the suspension state of Destination.
|
abstract Event |
requestEvent(Event outevent,
java.lang.String responseEventURI,
BaseEventSerializer serializer,
long timeout,
java.util.Map userData)
Sends an event on the specified destination and waits for a response.
|
void |
resume()
Sets the flag suspended to "false".
|
abstract void |
send(EventWithId event,
java.util.Map userData)
Sends an event on this
Destination. |
abstract void |
start()
Starts the destination, so that it can receive data from the end-point.
|
void |
suspend()
Sets the flag suspended to "true".
|
protected BaseChannel channel
protected java.lang.String destinationName
protected boolean suspended
protected java.lang.String uri
Destinationprotected java.lang.String defaultEventUri
Destinationprotected BaseEventSerializer serializer
protected Logger logger
protected java.util.Properties destinationProperties
protected EventProcessor eventProcessor
EventProcessor.This is used to process
events received on the destinationpublic abstract void init()
Destination by allocating necessary resources, creating pools, etc.
After this call, you will be able to
connect, start or close this Destination.java.lang.Exception - when initialization failedBaseDestination.connect(),
BaseDestination.close()public abstract void connect()
Destination to its underlying end-point.
After this call, you will be able to start or close
the Destination.
Do not start sending or receiving data here.
connect in interface Destinationjava.lang.Exception - when the Destination could not be connected to the underlying
endpoint.BaseDestination.start(),
BaseDestination.close()public abstract void start()
Only valid on a connected Destination After this
call, you will be able to stop and close the
Destination.
start in interface Destinationjava.lang.Exception - when the Destination could not be started.BaseDestination.connect(),
BaseDestination.close()public abstract void close()
After this call, you will be able to init the
Destination.
close in interface Destinationjava.lang.Exception - encountered exceptionpublic void suspend()
public boolean isSuspended()
public void resume()
public abstract void send(EventWithId event, java.util.Map userData)
Destination.
This method is invoked when the BE application code invokes Event.send()event - the Event to send. The user's Destination implementation should use the Destination's serializer as configured in the project and send this data to its configured end-pointuserData - During runtime, the application code can optionally pass a map of key/value pairs using Event.sendEvent.
The users destination may choose to make use of this additional data.java.lang.Exception - when the event could not be sentpublic void bind(EventProcessor eventProcessor)
start.
The threading model is left to the programmer.java.lang.Exception - encountered exceptionpublic abstract Event requestEvent(Event outevent, java.lang.String responseEventURI, BaseEventSerializer serializer, long timeout, java.util.Map userData)
outevent - The outgoing EventresponseEventURI - the URI of the response eventserializer - the instance of serializertimeout - timeoutuserData - During runtime, the application code can optionally pass a map of key/value pairs using Event.requestEvent.
The users destination may choose to make use of this additional data.Event of type responseEventURIjava.lang.Exception - Exception when request failedpublic java.lang.String getDestinationName()
DestinationDestination namepublic java.util.Properties getDestinationProperties()
DestinationDestination Propertiespublic java.lang.String getUri()
Destinationpublic java.lang.String getDefaultEventUri()
DestinationDestinationpublic BaseChannel getChannel()
Channel instance
associated with this destinationChannel associated with
this destinationpublic BaseEventSerializer getSerializer()
BaseEventSerializer instance
associated with this destinationBaseEventSerializer instance associated with
this destinationpublic EventProcessor getEventProcessor()
EventProcessor.This
is used to process events received on the destinationEventProcessorr.public EventContext getEventContext(Event event)
EventContext
You can override to provide custom implementation for EventContext
If not defined the DefaultEventContext will be used.event - the event for which EventContext is required.EventContext.