Platform SDK Java 8.5 API Reference

com.genesyslab.platform.commons.protocol
Class AbstractChannel

java.lang.Object
  extended by com.genesyslab.platform.commons.protocol.AbstractChannel
All Implemented Interfaces:
AsyncChannel, AsyncInvokerSupport, Channel, ChannelListenerSupport, ConfigurationSupport, ConnectionInvokerSupport, EndpointSupport
Direct Known Subclasses:
DuplexChannel, ServerChannel

public abstract class AbstractChannel
extends java.lang.Object
implements Channel, ConfigurationSupport, EndpointSupport, AsyncInvokerSupport, ConnectionInvokerSupport


Nested Class Summary
protected  class AbstractChannel.AsyncErrorNotifier
           
 
Field Summary
 
Fields inherited from interface com.genesyslab.platform.commons.protocol.Channel
DEFAULT_TIMEOUT, INFINITE_TIMEOUT
 
Constructor Summary
protected AbstractChannel(long timeout, Endpoint endpoint)
           
 
Method Summary
 void addChannelListener(ChannelListener listener)
          Adds listener about connection lifecycle events.
protected abstract  void applyConfiguration()
           
 void configure(ConnectionConfiguration config)
          Deprecated.  
 ConnectionContext<? extends ServerContext> connectionContext()
           
protected  void copyTLSSettings(Endpoint endpoint)
          Copies TLS parameters to channel context Reason: underlying connection has access to the context, but not endpoint.
protected  ChannelClosedEvent createChannelClosedEvent(ChannelState prevState, java.lang.Throwable cause)
           
protected  void fireClosed(java.lang.Throwable reason, ChannelState prevState)
           
protected  void fireErrorEvent(ChannelErrorEvent event)
           
protected  void fireErrorEvent(java.lang.Throwable exception)
           
static int generateChannelId()
           
 int getChannelId()
          Returns unique identification number of the channel instance.
 ConnectionConfiguration getConfiguration()
          Deprecated.  
protected  AsyncInvoker getDefaultInvoker()
           
 Endpoint getEndpoint()
           
protected  java.lang.String getEnpointPrefixInfo()
           
protected  AsyncInvoker getInvoker()
           
protected  ListenerHelper getListenerHelper()
           
protected  java.lang.String getLocalEndpointInfo(Endpoint endpoint)
           
 ServerContext getServerContext()
           
 ChannelState getState()
          Returns channel state.
 int getStateMods()
           
 long getTimeout()
          Returns default timeout for synchronous operations on channel.
protected
<T> T
internal(java.lang.Object internal)
          For internal use only.
protected  void onFireClosed(ChannelClosedEvent event)
           
protected  void onFireErrorEvent(ChannelErrorEvent event)
           
protected  void onFireOpened(java.util.EventObject event)
           
protected  void onSetEndpoint(Endpoint endpoint)
          This method is notified before setting a endpoint to the channel.
protected  void releaseDefaultInvoker()
           
 void removeChannelListener(ChannelListener listener)
          Removes listener about connection lifecycle events.
protected  void setConfiguration(ConnectionConfiguration config)
           
 void setConnectionInvoker(AsyncInvoker connectionInvoker)
          Deprecated.  
 void setEndpoint(Endpoint endpoint)
          Sets channel endpoint.
 void setInvoker(AsyncInvoker invoker)
          Invoker is used for calling user's code when various protocol events occur (open, close, error, etc).
protected  void setServerContext(ServerContext serverContext)
           
protected  void setState(ChannelState state)
           
protected  void setState(ChannelState newState, ConnectionClosedEvent closedEvent)
           
 void setTimeout(long timeout)
          Sets default timeout for synchronous operations on channel.
protected  void throwNotClosed()
           
protected  void throwNotOpened()
           
protected  void throwNotOpenedOnClose()
           
protected  void throwNotOpenedOnSend()
           
protected  void throwNull(java.lang.Object o, java.lang.String name)
           
protected  void throwNullEndpoint()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.Channel
close, close, open, open
 
Methods inherited from interface com.genesyslab.platform.commons.protocol.AsyncChannel
beginClose, beginOpen
 

Constructor Detail

AbstractChannel

protected AbstractChannel(long timeout,
                          Endpoint endpoint)
Method Detail

getEnpointPrefixInfo

protected java.lang.String getEnpointPrefixInfo()

getLocalEndpointInfo

protected java.lang.String getLocalEndpointInfo(Endpoint endpoint)

getChannelId

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

Returns:
unique channel instance id

getStateMods

public int getStateMods()

getState

public ChannelState getState()
Description copied from interface: AsyncChannel
Returns channel state. Note that the state returned is just a hint. It could change any time (e.g. just after this method returns).

Specified by:
getState in interface AsyncChannel
Returns:
State of the connection

connectionContext

public ConnectionContext<? extends ServerContext> connectionContext()

getServerContext

public ServerContext getServerContext()

setTimeout

public void setTimeout(long timeout)
Sets default timeout for synchronous operations on channel. Please see class description for timeout values meaning.

Specified by:
setTimeout in interface Channel
Parameters:
timeout - timeout in milliseconds

getTimeout

public long getTimeout()
Returns default timeout for synchronous operations on channel. Please see class description for timeout values meaning.

Specified by:
getTimeout in interface Channel
Returns:
timeout

addChannelListener

public void addChannelListener(ChannelListener listener)
Description copied from interface: ChannelListenerSupport
Adds listener about connection lifecycle events.

Specified by:
addChannelListener in interface ChannelListenerSupport
Parameters:
listener - listener

removeChannelListener

public void removeChannelListener(ChannelListener listener)
Description copied from interface: ChannelListenerSupport
Removes listener about connection lifecycle events.

Specified by:
removeChannelListener in interface ChannelListenerSupport
Parameters:
listener - listener

setInvoker

public void setInvoker(AsyncInvoker invoker)
Invoker is used for calling user's code when various protocol events occur (open, close, error, etc).

Specified by:
setInvoker in interface AsyncInvokerSupport
Parameters:
invoker - Invoker to use

setConnectionInvoker

@Deprecated
public void setConnectionInvoker(AsyncInvoker connectionInvoker)
Deprecated. 

Sets AsyncInvoker to be used by underlying connection layer. Please be sure you have a good understanding of ways the connection layer works before you use this method.

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
Parameters:
connectionInvoker - invoker for connection layer

getConfiguration

@Deprecated
public ConnectionConfiguration getConfiguration()
Deprecated. 

Connection configuration is an Endpoint property now.

Specified by:
getConfiguration in interface ConfigurationSupport
See Also:
getEndpoint(), Endpoint.getConfiguration()

configure

@Deprecated
public void configure(ConnectionConfiguration config)
Deprecated. 

Connection configuration options belong to target endpoint configuration.
Use Endpoint class to pass connection configuration.
It is also possible to change some connection parameters after the channel was opened: For example:
 ConnectionConfiguration config = protocol.getEndpoint().getConfiguration();
 config.setOption(AddpInterceptor.PROTOCOL_NAME_KEY,   AddpInterceptor.NAME);
 config.setOption(AddpInterceptor.TIMEOUT_KEY,         "10");
 config.setOption(AddpInterceptor.REMOTE_TIMEOUT_KEY,  "11");
 config.setOption(AddpInterceptor.TRACE_KEY,           "full");
 

Note, that starting from PSDK 8.1.3 endpoint returns wrapped configuration object - ManagedConfiguration. It provides ability to handle configuration change events.
        Handler OnChange = new Handler() {              
                public void onPropertyChanged(Object sender, ChangeEvent event) {
                System.out.println(String.format("%1$s >> %2$s -> %3$s", event.getKey(), event.getOldValue(), event.getNewValue()));
                }
        };
  ManagedConfiguration config = (ManagedConfiguration)protocol.getEndpoint().getConfiguration();
  config.addAfterPropertyChangeHandler(AddpInterceptor.TIMEOUT_KEY, OnChange); 
        

Specified by:
configure in interface ConfigurationSupport
See Also:
Endpoint, Endpoint(String, String, int, ConnectionConfiguration), setEndpoint(Endpoint)

getEndpoint

public Endpoint getEndpoint()
Specified by:
getEndpoint in interface EndpointSupport

onSetEndpoint

protected void onSetEndpoint(Endpoint endpoint)
This method is notified before setting a endpoint to the channel.

Parameters:
endpoint - new endpoint

setEndpoint

public void setEndpoint(Endpoint endpoint)
Sets channel endpoint.

Specified by:
setEndpoint in interface EndpointSupport
Parameters:
endpoint - endpoint
Throws:
ChannelNotClosedException - when channel isn't closed

copyTLSSettings

protected void copyTLSSettings(Endpoint endpoint)
Copies TLS parameters to channel context Reason: underlying connection has access to the context, but not endpoint.

Parameters:
endpoint - Endpoint instance to copy from

setState

protected void setState(ChannelState state)

setState

protected void setState(ChannelState newState,
                        ConnectionClosedEvent closedEvent)

createChannelClosedEvent

protected ChannelClosedEvent createChannelClosedEvent(ChannelState prevState,
                                                      java.lang.Throwable cause)

setServerContext

protected final void setServerContext(ServerContext serverContext)

generateChannelId

public static int generateChannelId()

throwNull

protected void throwNull(java.lang.Object o,
                         java.lang.String name)

throwNullEndpoint

protected void throwNullEndpoint()

throwNotOpenedOnSend

protected void throwNotOpenedOnSend()
                             throws ChannelClosedOnSendException
Throws:
ChannelClosedOnSendException

throwNotClosed

protected void throwNotClosed()
                       throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

throwNotOpened

protected void throwNotOpened()
                       throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

throwNotOpenedOnClose

protected void throwNotOpenedOnClose()
                              throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

fireClosed

protected void fireClosed(java.lang.Throwable reason,
                          ChannelState prevState)

onFireOpened

protected void onFireOpened(java.util.EventObject event)

onFireClosed

protected void onFireClosed(ChannelClosedEvent event)

onFireErrorEvent

protected void onFireErrorEvent(ChannelErrorEvent event)

getListenerHelper

protected ListenerHelper getListenerHelper()

applyConfiguration

protected abstract void applyConfiguration()

getInvoker

protected AsyncInvoker getInvoker()

getDefaultInvoker

protected AsyncInvoker getDefaultInvoker()

releaseDefaultInvoker

protected void releaseDefaultInvoker()

setConfiguration

protected void setConfiguration(ConnectionConfiguration config)

fireErrorEvent

protected void fireErrorEvent(java.lang.Throwable exception)

fireErrorEvent

protected void fireErrorEvent(ChannelErrorEvent event)

internal

protected final <T> T internal(java.lang.Object internal)
For internal use only.

Throws:
java.lang.RuntimeException

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.