|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.comm.AbstractConnection
public abstract class AbstractConnection
An abstract implementation for the connection interface. To be derived by more specific connections.
Its generic type defines the in- and output type for en- and decoder. This generic type has to be replaced by a concrete type in the subclass.
Manages a map which contains message classes as keys and possible handler for these classes as values. Handlers are grouped into a collection.
| Constructor Summary | |
|---|---|
AbstractConnection()
|
|
| Method Summary | ||
|---|---|---|
void |
addConnectionListener(ConnectionListener listener)
Adds a new ConnectionListener to the internal list notification subscribers. |
|
|
addMessageHandler(Class<M> messageClass,
MessageHandler<M> handler)
Generic method to append a MessageHandler for a message type to the internal list of message handlers. |
|
boolean |
awaitIsConnected(boolean expectedValue,
long timeoutInMs)
This method will block until { Connection.isConnected() returns the expected value or the timeout (in milliseconds)
as been reached. |
|
void |
disconnect()
Disconnects (or closes) the connection asynchronously. |
|
protected int |
dispatchMessages(List<Object> messages)
Dispatches a list of message objects to another thread to reduce message handling time. |
|
protected void |
fireConnectionClosed()
Callback called upon closing the connection. |
|
protected void |
fireConnectionFailed(Exception reason)
Callback called upon failed connection establishment. |
|
protected void |
fireConnectionSuccessful()
Callback called upon successful connection establishment. |
|
protected void |
fireConnectionTimedOut()
Callback called upon failed connection establishment. |
|
protected void |
fireReceiveError(Exception reason)
Callback called upon receive errors. |
|
ReconnectStrategy |
getAutoReconnectStrategy()
Returns the currently set auto reconnection strategy. |
|
boolean |
isAbleToReceive()
Returns true if the current state of the connection allows to receive messages. |
|
boolean |
isAbleToSend()
Returns true if the current state of the connection allows to send messages. |
|
void |
removeConnectionListener(ConnectionListener listener)
Removes a given listener from list of ConnectionListener. |
|
|
removeMessageHandler(Class<M> messageClass,
MessageHandler<M> handler)
Generic method to remove a message handler from internal list of message handlers. |
|
void |
setAutoReconnectStrategy(ReconnectStrategy strategy)
Sets the auto reconnection strategy. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.kuka.comm.Connection |
|---|
connect, getStatistics, hasDecoder, hasEncoder, isConnected, isConnectionless, send |
| Constructor Detail |
|---|
public AbstractConnection()
| Method Detail |
|---|
public final boolean awaitIsConnected(boolean expectedValue,
long timeoutInMs)
ConnectionConnection.isConnected() returns the expected value or the timeout (in milliseconds)
as been reached.
awaitIsConnected in interface ConnectionexpectedValue - the expected value to wait for (true or false)timeoutInMs - the maximum time (in milliseconds) to wait for the expected value
protected final int dispatchMessages(List<Object> messages)
MessageDispatcher thread.
messages - List of Objects to be handled.
public void disconnect()
ConnectionConnection.isConnected(). A disconnected connection cannot be used for sending and will not receive any messages. A
disconnected connection can be reconnected by calling Connection.connect().
disconnect in interface Connection
public final <M> void addMessageHandler(Class<M> messageClass,
MessageHandler<M> handler)
ConnectionMessageHandler for a message type to the internal list of message handlers.
Its type parameter M is used to store different message classes and associated handlers.
addMessageHandler in interface ConnectionM - the type of the messagemessageClass - Defines the type of message for this handler so that the connection is able to choose the right
handler for an incoming messagehandler - The message handler to handle an incoming message.
public final <M> void removeMessageHandler(Class<M> messageClass,
MessageHandler<M> handler)
Connection
removeMessageHandler in interface ConnectionM - the type of the messagemessageClass - Defines the type of message for the associated handlerhandler - message handler that handles incoming messages.public final void addConnectionListener(ConnectionListener listener)
ConnectionConnectionListener to the internal list notification subscribers.
An added listener will be notified if a connection event, like e.g. successful or failed establishment of connection, will occur.
addConnectionListener in interface Connectionlistener - The ConnectionListener to add to listener list.public final void removeConnectionListener(ConnectionListener listener)
ConnectionConnectionListener. If there is no such listener in internal list
nothing would be removed.
removeConnectionListener in interface Connectionlistener - The ConnectionListener to remove.public boolean isAbleToSend()
ConnectionConnection.isConnected()) and an Encoder must have been set in the concrete
class implementing the Connection interface. The method Connection.hasEncoder() can be used to check
if an Encoder has been set.
isAbleToSend in interface Connectionpublic boolean isAbleToReceive()
Connectiontrue if the current state of the connection allows to receive messages. For this, the
connection at least must be connected (see also Connection.isConnected()) and an encoder must have been set. The
method Connection.hasDecoder() can be used to check if a Decoder has been set.
isAbleToReceive in interface Connectiontrue, if the connection can be used to receive messagesprotected final void fireConnectionSuccessful()
protected final void fireConnectionFailed(Exception reason)
reason - the reason of the connection failureprotected final void fireConnectionTimedOut()
reason - the reason of the connection failureprotected final void fireConnectionClosed()
protected final void fireReceiveError(Exception reason)
reason - the reason of the connection failurepublic final void setAutoReconnectStrategy(ReconnectStrategy strategy)
Connection
setAutoReconnectStrategy in interface Connectionstrategy - the strategy implementing the ReconnectStrategypublic final ReconnectStrategy getAutoReconnectStrategy()
Connection
getAutoReconnectStrategy in interface Connection
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||