Platform SDK Java 8.5 API Reference

com.genesyslab.platform.commons.protocol
Class DuplexChannel

java.lang.Object
  extended by com.genesyslab.platform.commons.protocol.AbstractChannel
      extended by com.genesyslab.platform.commons.protocol.DuplexChannel
All Implemented Interfaces:
AsyncChannel, AsyncChannelOperations, AsyncInvokerSupport, Channel, ChannelListenerSupport, ConfigurationSupport, ConnectionInvokerSupport, EndpointSupport, InputChannel, InterceptorSupport, LogMessageFilterSupport, MessageReceiver, MessageReceiverManagement, OutputChannel, ProtocolDescriptionSupport, Receiver, ReceiverManagement
Direct Known Subclasses:
ClientChannel, ClientChannelHandler

public class DuplexChannel
extends AbstractChannel
implements InputChannel, OutputChannel, InterceptorSupport, MessageReceiverManagement, ProtocolDescriptionSupport, LogMessageFilterSupport, AsyncChannelOperations

Allows for asynchronous two-way communication between a Platform SDK application and a server. It is the parent class of ClientChannel.



Please note that instances of this class require some explicit lifecycle management. You have to do your best to ensure that channel is closed whenever it's not used any more — for example, on application exit. Do not rely on GC for this. Although the finalizer will try to close the underlying connection, finalizers by their very nature cannot guarantee proper resource deallocation.



Also note that the channel performs some of its operations in a thread that is different from the one the operation was called in. These asynchronous operations are beginOpen(), beginClose(), and all event-firing operations.



By default, such asynchronous operations are performed using the default invoker, which uses a single daemon thread for all channels of "this VM". So, if you are writing a of server application which uses a lot of channels and open and closes them with asynchronous operations, consider using a more sophisticated invoker. Otherwise, your open and close requests would be queued in line for completion and some of them might possibly time out.

There are two ways to configure the channel. First is AbstractChannel.configure(com.genesyslab.platform.commons.connection.configuration.ConnectionConfiguration) method. Another is to pass configuration parameters in the URL. Second way will work only if first one wasn't used.

For Genesys internal use only.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.genesyslab.platform.commons.protocol.AbstractChannel
AbstractChannel.AsyncErrorNotifier
 
Field Summary
protected  MessageFilter messageFilter
           
 
Fields inherited from interface com.genesyslab.platform.commons.protocol.Receiver
DEF_INPUT_SIZE
 
Fields inherited from interface com.genesyslab.platform.commons.protocol.Channel
DEFAULT_TIMEOUT, INFINITE_TIMEOUT
 
Constructor Summary
protected DuplexChannel(Connection conn, Endpoint endpoint, ProtocolFactory factory)
          Creates channel for server connection.
protected DuplexChannel(Connection conn, ProtocolFactory factory, long timeout)
          Deprecated. 
  DuplexChannel(Endpoint endpoint, ProtocolFactory protocolFactory)
          Creates channel.
  DuplexChannel(Endpoint endpoint, ProtocolFactory protocolFactory, long timeout)
          Creates channel.
 
Method Summary
 void addListener(OutputChannelListener listener)
          Attaches listener to OutputChannel implementer instance.
protected  void applyConfiguration()
           
 void beginClose()
          Closes channel asynchronously.
 void beginOpen()
          Begins channel opening asynchronously.
protected  void cancelCloseTimeout()
           
protected  void cancelOpenTimeout()
           
 void clearInput()
          Clears input queue of the channel.
 void close()
          Closes channel synchronously.
 void close(boolean force)
          Closes channel synchronously.
 void close(long timeout)
          Closes channel synchronously.
 java.util.concurrent.Future<ChannelClosedEvent> closeAsync()
          Close the channel asynchronously.
<A> void
closeAsync(CompletionHandler<ChannelClosedEvent,A> handler, A attachment)
          Close channel asynchronously.
<A> void
closeAsync(long timeout, CompletionHandler<ChannelClosedEvent,A> handler, A attachment)
          Open channel asynchronously.
protected  ChannelClosedEvent createChannelClosedEvent(ChannelState prevState, java.lang.Throwable cause)
           
protected  Connection createConnection(Endpoint endpoint)
           
protected  ConnectionClosedEvent createConnectionClosedEvent(java.lang.Throwable e)
           
protected  void doBeginClose()
          Closes the channel without checking it's state.
protected  void doClose(long closeTimeout)
          Closes the channel without checking it's state.
protected  void doSend(Message message)
          Sends the message unconditionally.
protected  boolean downgradeConnection()
           
protected  com.genesyslab.platform.commons.protocol.runtime.license.LicenseRestriction getDefaultRestriction()
          Returns default restriction for protocol.
protected  java.lang.String getEnpointPrefixInfo()
           
 int getInputSize()
          Returns the amount of messages this Receiver can hold before start to "forget stale messages".
 com.genesyslab.platform.commons.connection.interceptor.Interceptor getInterceptor()
          Returns interceptor of the connection behind this channel.
 java.net.InetSocketAddress getLocalEndPoint()
          Gets current local InetSocketAddress of socket, if it is created.
protected  java.lang.String getLocalEndpointInfo(Endpoint endpoint)
           
 MessageFilter getLogMessageFilter()
          Gets current message logining filter.
protected  ProtocolException getOpenTimeoutException(long timeout)
          Creates open timeout exception and logs it.
 ProtocolDescription getProtocolDescription()
           
protected  ProtocolFactory getProtocolFactory()
           
 int getProtocolId()
          Returns unique identification number of the channel instance.
 java.net.InetSocketAddress getRemoteEndPoint()
          Gets current remote InetSocketAddress of socket, if it is created.
protected  ProtocolException getTimeoutException(java.lang.String operation, long timeout)
          Creates timeout exception and logs it.
protected  void initPackager(Connection connection, java.lang.Object protocolData)
           
protected  boolean isMessageAllowed(Message message)
          Checks if message is allowed to be sent with the restrictions in effect.
protected
<N> void
notifyWithObject(Slot<N> syncObject, N notification)
          Notifies syncObject with some notification object.
protected  void onClose(ConnectionClosedEvent event)
           
protected  void onFireClosed(ChannelClosedEvent event)
           
protected  void onFireErrorEvent(ChannelErrorEvent event)
           
protected  void onFireOpened(java.util.EventObject event)
           
protected  void onOpen()
          This method is called when channel is opened and just about to call event handler.
protected  void onReceiveMessage(Message msg)
          Gives to subclass a chance to perform some operations on incoming message arrival before delivering it to connection user code.
protected  void onSend(Message message)
          Gives to subclass a chance to modify message before sending it to remote party.
 void open()
          Opens the channel by opening underlying connection including protocol specific handshake procedure.
This method will block until connection is opened or detects an error condition, possibly forever.
 void open(long openTimeout)
          Opens the channel by opening underlying connection including protocol specific handshake procedure using specified protocol timeout value.
Timeout can be set to following values: positive value - time in ms.
 java.util.concurrent.Future<ChannelOpenedEvent> openAsync()
          Method is asynchronous.
<A> void
openAsync(CompletionHandler<java.util.EventObject,A> handler, A attachment)
          Open channel asynchronously.
 java.util.concurrent.Future<ChannelOpenedEvent> openAsync(java.lang.Long timeout)
          Method is asynchronous.
<A> void
openAsync(long timeout, CompletionHandler<java.util.EventObject,A> handler, A attachment)
          Open channel asynchronously.
protected  void processClose(ConnectionClosedEvent event)
           
protected  void processCloseAll(ConnectionClosedEvent event)
           
 Message receive()
          This synchronous method blocks until it receives a message from the server.
 Message receive(long timeout)
          This synchronous method blocks until it receives a message from the server or until it reaches the length of the designated timeout.
protected  void receivedMessage(Message message, Endpoint endpoint)
           
 void releaseReceivers()
          Notifies receivers (threads waiting on receive() methods) they should stop waiting and return null.
 void removeListener(OutputChannelListener listener)
          Detaches listener from OutputChannel implementer instance.
 void resetReceiver()
          Resets receiver for this channel to default.
protected  boolean resumeReading()
           
 void send(Message message)
          Sends message.
 void setConnectionInvoker(AsyncInvoker connectionInvoker)
          Deprecated.  
 void setExternalTransport(ExternalTransport transport)
           
 void setInputSize(int inputSize)
          Sets the amount of messages this Receiver can hold before start to "forget stale messages".
 void setLogMessageFilter(MessageFilter filter)
          Sets current message logining filter.
 void setMessageHandler(MessageHandler msgHandler)
          Sets asynchronous handler for incoming messages.
Incoming messages on this channel will be handled with its connection invoker (see AbstractChannel.setInvoker(AsyncInvoker)).
protected  void setProtocolData(java.lang.Object protocolData)
           
 void setReceiver(MessageReceiverSupport receiver)
          Sets receiver for this channel.
protected  void setState(ChannelState state, ConnectionClosedEvent closedEvent)
           
protected  boolean startUpgradeConnection(java.lang.Runnable notificationCallback)
           
protected  boolean stopReading()
           
 java.lang.String toString()
           
protected
<N> boolean
triggerWithObject(Slot<N> syncObject, N notification)
          Notifies IF SOMEONE is waiting, doesn't block notifier thread.
protected  boolean upgradeConnection()
           
protected
<N> N
waitForObject(Slot<N> syncObject, long timeout)
          Deprecated. 
 
Methods inherited from class com.genesyslab.platform.commons.protocol.AbstractChannel
addChannelListener, configure, connectionContext, copyTLSSettings, fireClosed, fireErrorEvent, fireErrorEvent, generateChannelId, getChannelId, getConfiguration, getDefaultInvoker, getEndpoint, getInvoker, getListenerHelper, getServerContext, getState, getStateMods, getTimeout, internal, onSetEndpoint, releaseDefaultInvoker, removeChannelListener, setConfiguration, setEndpoint, setInvoker, setServerContext, setState, setTimeout, throwNotClosed, throwNotOpened, throwNotOpenedOnClose, throwNotOpenedOnSend, throwNull, throwNullEndpoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.Channel
getTimeout, setTimeout
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.AsyncChannel
getState
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.ChannelListenerSupport
addChannelListener, removeChannelListener
 

Field Detail

messageFilter

protected volatile MessageFilter messageFilter
Constructor Detail

DuplexChannel

public DuplexChannel(Endpoint endpoint,
                     ProtocolFactory protocolFactory)
Creates channel. Timeout can be set to following values:

Parameters:
endpoint - Parameters of the connection to create
protocolFactory - Factory to create messages.

DuplexChannel

public DuplexChannel(Endpoint endpoint,
                     ProtocolFactory protocolFactory,
                     long timeout)
Creates channel. Timeout can be set to following values:

Parameters:
endpoint - Parameters of the connection to create
protocolFactory - Factory to create messages.
timeout - timeout to waitResponse for message in receive() or open() method

DuplexChannel

protected DuplexChannel(Connection conn,
                        Endpoint endpoint,
                        ProtocolFactory factory)
Creates channel for server connection.

Parameters:
conn - the incoming connection
endpoint - configured endpoint
factory - the protocol factory

DuplexChannel

@Deprecated
protected DuplexChannel(Connection conn,
                                   ProtocolFactory factory,
                                   long timeout)
Deprecated. 

Method Detail

getProtocolId

public int getProtocolId()
Returns unique identification number of the channel instance.

It's going to be obsolete - see its' replacement: AbstractChannel.getChannelId().

Returns:
unique channel instance id
See Also:
AbstractChannel.getChannelId()

open

public void open()
          throws RegistrationException,
                 ProtocolException,
                 java.lang.IllegalStateException,
                 java.lang.InterruptedException
Opens the channel by opening underlying connection including protocol specific handshake procedure.
This method will block until connection is opened or detects an error condition, possibly forever. Use open(long) method to use custom timeout or change the protocol timeout value with AbstractChannel.setTimeout(long) before opening.

Specified by:
open in interface Channel
Throws:
ProtocolSecurityException - if any security problems occurs on a channel
ProtocolIOException - will thrown if connection IO exception occurs
ProtocolTimeoutException - if channel wasn't opened for the specified time
ChannelEmergencyClosedException - if channel was closed while opening
RegistrationException - if there is an error related to registration procedure like server error about wrong client name, user password, etc
RegistrationTimeoutException - if connection to server was established but handshake procedure has timed out
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
java.lang.IllegalStateException - when channel endpoint is not assigned
ChannelNotClosedException - if channel is not in Closed state
java.lang.InterruptedException - in case the open operation was interrupted.
See Also:
AbstractChannel.setTimeout(long), open(long)

open

public void open(long openTimeout)
          throws RegistrationException,
                 ProtocolException,
                 ChannelNotClosedException,
                 java.lang.InterruptedException
Opens the channel by opening underlying connection including protocol specific handshake procedure using specified protocol timeout value.
Timeout can be set to following values:

Specified by:
open in interface Channel
Parameters:
openTimeout - time to waitResponse for the connection
Throws:
ProtocolSecurityException - if any security problems occurs on a channel
ProtocolIOException - will thrown if connection IO exception occurs
ProtocolTimeoutException - if channel wasn't opened for the specified time
ChannelEmergencyClosedException - if channel was closed while opening
RegistrationException - if there is an error related to registration procedure like server error about wrong client name, user password, etc
RegistrationTimeoutException - if connection to server was established but handshake procedure has timed out
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
java.lang.IllegalStateException - when channel endpoint is not assigned
ChannelNotClosedException - if channel is not in Closed state
java.lang.InterruptedException - in case the open operation was interrupted.
See Also:
open()

beginOpen

public void beginOpen()
               throws ProtocolException
Begins channel opening asynchronously.

Specified by:
beginOpen in interface AsyncChannel
Throws:
java.lang.IllegalArgumentException - when channel endpoint is not assigned
ChannelNotClosedException - when channel state isn't closed
ProtocolException - in case of problems establishing connection

close

public void close()
           throws ProtocolException,
                  java.lang.InterruptedException,
                  java.lang.IllegalStateException
Closes channel synchronously.

Specified by:
close in interface Channel
Throws:
ProtocolTimeoutException - if channel wasn't closed for the specified time
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
java.lang.InterruptedException - in case the close operation was interrupted.
java.lang.IllegalStateException - exception will not be thrown in current implementation.

close

public void close(boolean force)
           throws ProtocolException,
                  java.lang.InterruptedException,
                  java.lang.IllegalStateException
Closes channel synchronously.

Parameters:
force - if this flag is true then sending messages from queue will be canceled and channel will be closed immediately
Throws:
ProtocolTimeoutException - if channel wasn't closed for the specified time (when force == false)
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
java.lang.InterruptedException - in case the close operation was interrupted.
java.lang.IllegalStateException - Exception will not be thrown in current implementation even if the channel is closed.

close

public void close(long timeout)
           throws ProtocolException,
                  java.lang.InterruptedException,
                  java.lang.IllegalStateException
Closes channel synchronously.

Specified by:
close in interface Channel
Parameters:
timeout - time in milliseconds
Throws:
ProtocolTimeoutException - if channel wasn't closed for the specified time
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
java.lang.InterruptedException - in case the close operation was interrupted.
java.lang.IllegalStateException - exception will not be thrown in current implementation.

beginClose

public void beginClose()
                throws java.lang.IllegalStateException
Closes channel asynchronously.

Specified by:
beginClose in interface AsyncChannel
Throws:
java.lang.IllegalStateException - Exception will not be thrown in current implementation even if the channel is closed.

getLocalEndPoint

public java.net.InetSocketAddress getLocalEndPoint()
Gets current local InetSocketAddress of socket, if it is created.

Returns:
connection local endpoint or null

getRemoteEndPoint

public java.net.InetSocketAddress getRemoteEndPoint()
Gets current remote InetSocketAddress of socket, if it is created.

Returns:
connection remote endpoint or null

receive

public Message receive()
                throws java.lang.InterruptedException
This synchronous method blocks until it receives a message from the server. It can be used after the send method to wait for the response. It can also be used on its own, in which case it will wait for the next event from the server that is directed at the issuing application.

Here is a sample of how to use the send and receive methods:


 interactionServerProtocol.send(requestAgentLogin);
 Message response = interactionServerProtocol.receive();
 

You can also use receive on its own, like this:


 Message unsolicitedEvent = interactionServerProtocol.receive();
 

Note, that when the channel is closed for any reason it tries to "release" all receive() methods that are currently waiting, which causes them to return null. If this method is called during that process than this or some another receive() won't be released. So, its strongly recommended to avoid calling it during the close process.

Specified by:
receive in interface MessageReceiver
Returns:
Message from the channel or null if the channel is "empty"
Throws:
java.lang.InterruptedException - if thread is interrupted during this method execution
See Also:
setMessageHandler(MessageHandler)

receive

public Message receive(long timeout)
                throws java.lang.InterruptedException
This synchronous method blocks until it receives a message from the server or until it reaches the length of the designated timeout. See receive().

See Channel for the meaning of the timeout values.

Specified by:
receive in interface MessageReceiver
Parameters:
timeout - timeout to waitResponse for message
Returns:
Message from the channel or null if the channel is "empty"
Throws:
java.lang.InterruptedException - if thread is interrupted during this method execution
See Also:
setMessageHandler(MessageHandler)

send

public void send(Message message)
          throws ProtocolException,
                 java.lang.IllegalStateException
Sends message.

Specified by:
send in interface OutputChannel
Parameters:
message - message to send
Throws:
java.lang.IllegalArgumentException - if message is null
ChannelClosedOnSendException - if channel is in inappropriate state to execute the request
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
java.lang.IllegalStateException

addListener

public void addListener(OutputChannelListener listener)
Description copied from interface: OutputChannel
Attaches listener to OutputChannel implementer instance. Checks for duplication, will not add the same listener twice

Specified by:
addListener in interface OutputChannel
Parameters:
listener - listener to be attached.

removeListener

public void removeListener(OutputChannelListener listener)
Description copied from interface: OutputChannel
Detaches listener from OutputChannel implementer instance. Does nothing if listener was not attached before.

Specified by:
removeListener in interface OutputChannel
Parameters:
listener - listener to be detached.

getInputSize

public int getInputSize()
Description copied from interface: Receiver
Returns the amount of messages this Receiver can hold before start to "forget stale messages".

Specified by:
getInputSize in interface Receiver
Returns:
maximum count of messages stored in receiver

setInputSize

public void setInputSize(int inputSize)
Description copied from interface: Receiver
Sets the amount of messages this Receiver can hold before start to "forget stale messages".

Specified by:
setInputSize in interface Receiver
Parameters:
inputSize - maximum count of messages stored in receiver

releaseReceivers

public void releaseReceivers()
Description copied from interface: Receiver
Notifies receivers (threads waiting on receive() methods) they should stop waiting and return null.

Specified by:
releaseReceivers in interface Receiver

getInterceptor

public com.genesyslab.platform.commons.connection.interceptor.Interceptor getInterceptor()
Returns interceptor of the connection behind this channel. You can use that interceptor to reconfigure it or to issue special command on it. One example of such interceptor is ADDP. Note, that by default connection has no interceptor, so this method can return null. Interceptors are created using ConnectionConfiguration class and AbstractChannel.configure( com.genesyslab.platform.commons.connection.configuration.ConnectionConfiguration) method.

Specified by:
getInterceptor in interface InterceptorSupport
Returns:
interceptor for this channel or null if there is no interceptor configured.

clearInput

public void clearInput()
Clears input queue of the channel. Please note, that there is no strict guarantees that input queue will be empty after this method has returned, the messages could be put into the queue by another thread.

Specified by:
clearInput in interface Receiver

setReceiver

public void setReceiver(MessageReceiverSupport receiver)
Sets receiver for this channel. Please note, that some channel parameters related to receiver (e.g. inputSize) can be changed by this call.

Note: message receiver approach is going to be deprecated and replaced with message handler solution (setMessageHandler(MessageHandler)).

Specified by:
setReceiver in interface MessageReceiverManagement
Parameters:
receiver - new Receiver
Throws:
ChannelNotClosedException - when channel isn't closed
ChannelReceiverInitializationException - when protocol has MessageHandler initialized
See Also:
setMessageHandler(MessageHandler)

setMessageHandler

public void setMessageHandler(MessageHandler msgHandler)
Sets asynchronous handler for incoming messages.
Incoming messages on this channel will be handled with its connection invoker (see AbstractChannel.setInvoker(AsyncInvoker)).

Specified by:
setMessageHandler in interface InputChannel
Parameters:
msgHandler - incoming messages handler
Throws:
ChannelReceiverInitializationException - when protocol has external Receiver initialized
ChannelNotClosedException - when channel isn't closed

resetReceiver

public void resetReceiver()
Resets receiver for this channel to default. Please note, that some channel parameters related to receiver (e.g. inputSize) can be set to default values by this call.

Specified by:
resetReceiver in interface ReceiverManagement
Throws:
ChannelNotClosedException - when channel isn't closed

setConnectionInvoker

@Deprecated
public void setConnectionInvoker(AsyncInvoker connectionInvoker)
Deprecated. 

Connection can use invoker (if it's set) to perform some operations asynchronously. One such operation is message parsing. So it's reasonable to use the invoker if you know that it can take long to parse the message.
Warning: On the other hand improper usage of the connection invoker can result in problems that are hard to reproduce and debug. For instance it seems a good idea to set some kind of thread pool as invoker for some busy connections, but you can break the order of message arrival by doing so. So be extremely careful and make sure you know exactly what you're doing using this feature.

Note: This invoker was used by old implementation of connection layer (MUX).
Now PSDK by default provides Netty based connections which do not use it, so, this method has no real effect.

Specified by:
setConnectionInvoker in interface ConnectionInvokerSupport
Overrides:
setConnectionInvoker in class AbstractChannel
Parameters:
connectionInvoker - asynchronous invoker for connection
Throws:
ChannelNotClosedException - if channels isn't closed

getProtocolDescription

public ProtocolDescription getProtocolDescription()
Specified by:
getProtocolDescription in interface ProtocolDescriptionSupport

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setProtocolData

protected void setProtocolData(java.lang.Object protocolData)

initPackager

protected void initPackager(Connection connection,
                            java.lang.Object protocolData)

getProtocolFactory

protected ProtocolFactory getProtocolFactory()

doSend

protected void doSend(Message message)
               throws ProtocolException
Sends the message unconditionally. Doesn't check channel state. Use with caution. Intended for using in registration process.

Parameters:
message - message to send
Throws:
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.

isMessageAllowed

protected final boolean isMessageAllowed(Message message)
                                  throws ProtocolException
Checks if message is allowed to be sent with the restrictions in effect. Complain to error handler if message is restricted.

Parameters:
message - message to check
Returns:
true if message is allowed and false if message is softly forbidden (i.e. should be just ignored)
Throws:
ProtocolException - if message is strictly forbidden

getDefaultRestriction

protected com.genesyslab.platform.commons.protocol.runtime.license.LicenseRestriction getDefaultRestriction()
Returns default restriction for protocol. By default returns empty restriction, so that all operations are allowed.

Returns:
licensing restriction

doClose

protected void doClose(long closeTimeout)
                throws ProtocolException,
                       java.lang.InterruptedException
Closes the channel without checking it's state. Use with caution. Intended for using inside of protocol (e.g. registration process).

Parameters:
closeTimeout - timeout to wait success
Throws:
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.
java.lang.InterruptedException - in case the close operation was interrupted.

doBeginClose

protected void doBeginClose()
Closes the channel without checking it's state. Use with caution. Intended for using inside of protocol (e.g. registration process).


onOpen

protected void onOpen()
               throws ProtocolException
This method is called when channel is opened and just about to call event handler. You usually will need to add some logic here and call super.onOpen() at the end of your method. Please note, that calling super.onOpen() on the thread other then open() was called will most probably result in deadlock for some scenarios (like calling close() inside of onChannelOpened())

Throws:
ProtocolException - if there are problems during post open operations (e.g. registration)

onSend

protected void onSend(Message message)
               throws ProtocolException
Gives to subclass a chance to modify message before sending it to remote party.

Parameters:
message - Message to modify
Throws:
ProtocolException - In the case of an unrecoverable protocol error. Client applications should not try to deal with these exceptions, except for logging or displaying to users or technical administrators. Check the exception cause for more details.

onClose

protected void onClose(ConnectionClosedEvent event)

onReceiveMessage

protected void onReceiveMessage(Message msg)
Gives to subclass a chance to perform some operations on incoming message arrival before delivering it to connection user code. We don't use AsyncInvoker here, because the message handling in this class probably doesn't worth it - this method is quick and shouldn't load connection thread too much. But if this method is overridden in some classes and contains some long-running logic, consider using AsyncInvoker

Parameters:
msg - received message

createConnection

protected Connection createConnection(Endpoint endpoint)

waitForObject

@Deprecated
protected <N> N waitForObject(Slot<N> syncObject,
                                         long timeout)
                   throws java.lang.InterruptedException
Deprecated. 

Blocks until either syncObject is notified or timeout expires. By contract syncObject is notified with some object and null is used to signal timeout in this method. So do not use null to notify syncObject

Parameters:
syncObject - synchronization object
timeout - timeout in ms. to waitResponse for object
Returns:
Object which this syncObject was notified with or null if timeout expires
Throws:
java.lang.InterruptedException - if thread is interrupted

notifyWithObject

protected <N> void notifyWithObject(Slot<N> syncObject,
                                    N notification)
                         throws java.lang.InterruptedException
Notifies syncObject with some notification object. By contract syncObject is notified with object and null is used to signal timeout in this method. So do not use null to notify syncObject unless you're trying to simulate timeout.

Parameters:
syncObject - synchronization object
notification - notification object
Throws:
java.lang.InterruptedException - if thread is interrupted

triggerWithObject

protected <N> boolean triggerWithObject(Slot<N> syncObject,
                                        N notification)
                             throws java.lang.InterruptedException
Notifies IF SOMEONE is waiting, doesn't block notifier thread.

Parameters:
syncObject - object to use for notification
notification - data object passed from notifier
Returns:
true if accepted, else false
Throws:
java.lang.InterruptedException - if thread is interrupted
See Also:
notifyWithObject(Slot, Object)

getTimeoutException

protected ProtocolException getTimeoutException(java.lang.String operation,
                                                long timeout)
Creates timeout exception and logs it.

Parameters:
operation - operation which is timed out
timeout - timeout was used to wait
Returns:
timeout exception

getOpenTimeoutException

protected ProtocolException getOpenTimeoutException(long timeout)
Creates open timeout exception and logs it.

Parameters:
timeout - timeout was used to wait
Returns:
timeout exception

setState

protected void setState(ChannelState state,
                        ConnectionClosedEvent closedEvent)
Overrides:
setState in class AbstractChannel

cancelOpenTimeout

protected void cancelOpenTimeout()

cancelCloseTimeout

protected void cancelCloseTimeout()

getEnpointPrefixInfo

protected java.lang.String getEnpointPrefixInfo()
Overrides:
getEnpointPrefixInfo in class AbstractChannel

getLocalEndpointInfo

protected java.lang.String getLocalEndpointInfo(Endpoint endpoint)
Overrides:
getLocalEndpointInfo in class AbstractChannel

applyConfiguration

protected void applyConfiguration()
Specified by:
applyConfiguration in class AbstractChannel

processCloseAll

protected void processCloseAll(ConnectionClosedEvent event)

processClose

protected void processClose(ConnectionClosedEvent event)

upgradeConnection

protected boolean upgradeConnection()

startUpgradeConnection

protected boolean startUpgradeConnection(java.lang.Runnable notificationCallback)

downgradeConnection

protected boolean downgradeConnection()

stopReading

protected boolean stopReading()

resumeReading

protected boolean resumeReading()

setExternalTransport

public void setExternalTransport(ExternalTransport transport)

receivedMessage

protected void receivedMessage(Message message,
                               Endpoint endpoint)

getLogMessageFilter

public MessageFilter getLogMessageFilter()
Description copied from interface: LogMessageFilterSupport
Gets current message logining filter.

Specified by:
getLogMessageFilter in interface LogMessageFilterSupport
Returns:
current message logining filter.

setLogMessageFilter

public void setLogMessageFilter(MessageFilter filter)
Description copied from interface: LogMessageFilterSupport
Sets current message logining filter.

Specified by:
setLogMessageFilter in interface LogMessageFilterSupport
Parameters:
filter - new message logining filter.

createConnectionClosedEvent

protected ConnectionClosedEvent createConnectionClosedEvent(java.lang.Throwable e)

createChannelClosedEvent

protected ChannelClosedEvent createChannelClosedEvent(ChannelState prevState,
                                                      java.lang.Throwable cause)
Overrides:
createChannelClosedEvent in class AbstractChannel

openAsync

public <A> void openAsync(CompletionHandler<java.util.EventObject,A> handler,
                          A attachment)
Description copied from interface: AsyncChannelOperations
Open channel asynchronously.

Specified by:
openAsync in interface AsyncChannelOperations
Parameters:
handler - success/fail result handling.

openAsync

public <A> void openAsync(long timeout,
                          CompletionHandler<java.util.EventObject,A> handler,
                          A attachment)
Description copied from interface: AsyncChannelOperations
Open channel asynchronously.

Specified by:
openAsync in interface AsyncChannelOperations
Parameters:
timeout - operation timeout in milliseconds. Timeout will cancel the opening.
handler - success/fail result handling.

closeAsync

public <A> void closeAsync(CompletionHandler<ChannelClosedEvent,A> handler,
                           A attachment)
Description copied from interface: AsyncChannelOperations
Close channel asynchronously.

Specified by:
closeAsync in interface AsyncChannelOperations
Parameters:
handler - success/fail result handling.

closeAsync

public <A> void closeAsync(long timeout,
                           CompletionHandler<ChannelClosedEvent,A> handler,
                           A attachment)
Description copied from interface: AsyncChannelOperations
Open channel asynchronously.

Specified by:
closeAsync in interface AsyncChannelOperations
Parameters:
timeout - operation timeout in milliseconds. Timeout do not cancel the closing and do not close forcly the channel.
handler - success/fail result handling.

onFireOpened

protected void onFireOpened(java.util.EventObject event)
Overrides:
onFireOpened in class AbstractChannel

onFireClosed

protected void onFireClosed(ChannelClosedEvent event)
Overrides:
onFireClosed in class AbstractChannel

onFireErrorEvent

protected void onFireErrorEvent(ChannelErrorEvent event)
Overrides:
onFireErrorEvent in class AbstractChannel

openAsync

public java.util.concurrent.Future<ChannelOpenedEvent> openAsync()
Method is asynchronous. It will start connection sequence and return. Whether connection is established on return is not specified.

Throws:
ProtocolException - in case of some protocol specific problems while connection opening initialization.

openAsync

public java.util.concurrent.Future<ChannelOpenedEvent> openAsync(java.lang.Long timeout)
Method is asynchronous. It will start connection sequence and return. Whether connection is established on return is not specified.

Parameters:
timeout - it specifies channel opening timeout in milliseconds.
Throws:
ProtocolException - in case of some protocol specific problems while connection opening initialization.

closeAsync

public java.util.concurrent.Future<ChannelClosedEvent> closeAsync()
Close the channel asynchronously.

Note: It hasn't related with the channel timeout. Use the future.get() with a timeout instead.

Throws:
ProtocolException - in case of some protocol specific problems while connection opening initialization.

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.