|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.genesyslab.platform.commons.protocol.AbstractChannel
com.genesyslab.platform.commons.protocol.ServerChannel
public class ServerChannel
This channel accepts client connections on given local Endpoint
.
Method AbstractChannel.addChannelListener(ChannelListener)
accepts ServerChannelListener
,
which provides notifications on incoming clients.
When a new client connection is established
onClientChannelOpened()
method is notified.
By default, if no protocol name option is specified, Server Channel adds ADDP
support
for incoming connections.
The AddpInterceptor.ACTIVE_KEY
option is always set to false
,
because ADDP
is to be initialized by client side.
ExternalServiceProtocolListener
,
InteractionServerProtocolListener
,
ChatProtocolsListener
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.genesyslab.platform.commons.protocol.AbstractChannel |
---|
AbstractChannel.AsyncErrorNotifier |
Field Summary |
---|
Fields inherited from interface com.genesyslab.platform.commons.protocol.Channel |
---|
DEFAULT_TIMEOUT, INFINITE_TIMEOUT |
Fields inherited from interface com.genesyslab.platform.commons.protocol.Receiver |
---|
DEF_INPUT_SIZE |
Constructor Summary | |
---|---|
ServerChannel(Endpoint endpoint,
java.lang.Class<T> clientChannelClass)
Deprecated. |
|
ServerChannel(Endpoint endpoint,
ClientChannelHandlerFactory clientChannelHandlerFactory)
Creates ServerChannel instance to accept and handle incoming clients connections
on the given Endpoint . |
|
ServerChannel(Endpoint endpoint,
long timeout,
ProtocolFactory protocolFactory)
The old style constructor for ServerChannel instance creation. |
|
ServerChannel(Endpoint endpoint,
ProtocolFactory protocolFactory)
The old style constructor for ServerChannel instance creation. |
Method Summary | |
---|---|
void |
addListener(OutputChannelListener listener)
Attaches listener to OutputChannel implementer instance. |
protected void |
applyConfiguration()
|
void |
beginClose()
Method is asynchronous. |
void |
beginOpen()
Method is asynchronous. |
void |
clearInput()
Clears input of the receiver. |
void |
close()
Closes listening socket and all its active clients connections. |
void |
close(long timeout)
Closes listening socket and all its active clients connections. |
void |
closeClientChannels()
Closes all connected client's channels, but the server socket remains in listening mode. |
void |
closeListener()
Closes listening socket only, sets channel state to Closed. |
java.util.Collection<? extends Channel> |
getChannels()
|
int |
getInputSize()
Returns the amount of messages this Receiver can hold before start to "forget stale messages". |
java.net.InetSocketAddress |
getLocalEndPoint()
Gets local address of the listening socket. |
ProtocolDescription |
getProtocolDescription()
|
protected ProtocolFactory |
getProtocolFactory()
|
protected void |
modifyNewChannel(DuplexChannel channel)
This method modifies the new channel to support server mode of operation suggested by ServerChannel. |
void |
open()
Opens channel synchronously. |
void |
open(long timeout)
Opens channel synchronously. |
Message |
receive()
|
Message |
receive(long timeout)
|
RequestContext |
receiveRequest()
Receives request from the client. |
RequestContext |
receiveRequest(long timeout)
Receives request from the client. |
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 the clients requests receiver. |
void |
send(Message message)
Sends the given protocol message to all connected clients channels of this ServerChannel . |
protected void |
sendToChannelsExcept(java.util.Collection<OutputChannel> channels,
Message message,
OutputChannel except)
Sends message to all channels in the collection except the one. |
void |
sendToChannelsExcept(Message message,
OutputChannel except)
Sends message to all channels except the one. |
void |
setClientRequestHandler(ClientRequestHandler handler)
ServerChannel calls the handler on each new incoming message.While the handler is assigned the receiver (external or internal) is ignored. |
void |
setInputSize(int inputSize)
Sets the amount of messages this Receiver can hold before start to "forget stale messages". |
void |
setReceiver(RequestReceiverSupport receiver)
Deprecated. |
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 |
---|
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 |
Methods inherited from interface com.genesyslab.platform.commons.protocol.EndpointSupport |
---|
getEndpoint, setEndpoint |
Methods inherited from interface com.genesyslab.platform.commons.protocol.ConfigurationSupport |
---|
configure, getConfiguration |
Constructor Detail |
---|
public ServerChannel(Endpoint endpoint, ProtocolFactory protocolFactory)
ServerChannel
instance creation.
endpoint
- the local Endpoint to accept connections on.protocolFactory
- the specific protocol factory.ServerChannel(Endpoint, ClientChannelHandlerFactory)
public ServerChannel(Endpoint endpoint, ClientChannelHandlerFactory clientChannelHandlerFactory)
ServerChannel
instance to accept and handle incoming clients connections
on the given Endpoint
.
endpoint
- the local Endpoint to accept connections on.clientChannelHandlerFactory
- the factory of handlers for clients connections.@Deprecated public ServerChannel(Endpoint endpoint, java.lang.Class<T> clientChannelClass)
ServerChannel(Endpoint, ClientChannelHandlerFactory)
public ServerChannel(Endpoint endpoint, long timeout, ProtocolFactory protocolFactory)
ServerChannel
instance creation.
endpoint
- the local Endpoint to accept connections on.timeout
- the protocol timeout value for the server channel.protocolFactory
- the specific protocol factory.ServerChannel(Endpoint, ClientChannelHandlerFactory)
Method Detail |
---|
public java.net.InetSocketAddress getLocalEndPoint()
public void open() throws ProtocolException, java.lang.InterruptedException, ChannelNotClosedException
open
in interface Channel
ChannelNotClosedException
- when channel isn't closed
RegistrationException
- if there is an error related to registration procedure
like server error about wrong client name, user password, etc
ProtocolException
- if there is any problem related to the connection open
java.lang.InterruptedException
Channel.setTimeout(long)
,
Channel.open(long)
public void open(long timeout) throws ProtocolException, java.lang.InterruptedException, ChannelNotClosedException
open
in interface Channel
timeout
- timeout in milliseconds
ChannelNotClosedException
- when channel isn't closed
RegistrationException
- if there is an error related to registration procedure
like server error about wrong client name, user password, etc
ProtocolException
- if there is any problem related to the connection open
java.lang.InterruptedException
Channel.open()
public void close() throws ProtocolException, java.lang.InterruptedException, java.lang.IllegalStateException
close
in interface Channel
ProtocolException
- exception will not be thrown in current implementation.
java.lang.InterruptedException
- in case the close operation was interrupted.
java.lang.IllegalStateException
- exception will not be thrown in current implementation.public void close(long timeout) throws ProtocolException, java.lang.InterruptedException, java.lang.IllegalStateException
close
in interface Channel
timeout
- currently not used.
ProtocolException
- exception will not be thrown in current implementation.
java.lang.InterruptedException
- in case the close operation was interrupted.
java.lang.IllegalStateException
- exception will not be thrown in current implementation.public void closeListener() throws ProtocolException, java.lang.InterruptedException, java.lang.IllegalStateException
close()
to close it all,
or closeClientChannels()
to close clients connections separately.
ProtocolException
- exception will not be thrown in current implementation.
java.lang.InterruptedException
- in case the close operation was interrupted.
java.lang.IllegalStateException
- exception will not be thrown in current implementation.public void closeClientChannels() throws java.lang.InterruptedException
java.lang.InterruptedException
- in case the close operation was interrupted.public void send(Message message) throws ProtocolException
ServerChannel
.
send
in interface OutputChannel
message
- Message to send
ProtocolException
- if there is some problems with message structurepublic void addListener(OutputChannelListener listener)
OutputChannel
addListener
in interface OutputChannel
listener
- listener to be attached.public void removeListener(OutputChannelListener listener)
OutputChannel
removeListener
in interface OutputChannel
listener
- listener to be detached.public void sendToChannelsExcept(Message message, OutputChannel except) throws ProtocolException
message
- Message to sendexcept
- channel to miss from sending
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.public void beginOpen() throws ProtocolException
AsyncChannel
beginOpen
in interface AsyncChannel
ProtocolException
- in case of problems establishing connectionpublic void beginClose()
AsyncChannel
beginClose
in interface AsyncChannel
public RequestContext receiveRequest() throws java.lang.InterruptedException
RequestReceiver
receiveRequest
in interface RequestReceiver
receiveRequest
in interface ResponseChannel
java.lang.InterruptedException
- if thread is interrupted during this method
executionpublic RequestContext receiveRequest(long timeout) throws java.lang.InterruptedException
Channel
description for timeout values meaning.
receiveRequest
in interface RequestReceiver
receiveRequest
in interface ResponseChannel
timeout
- timeout to waitResponse for message
java.lang.InterruptedException
- if thread is interrupted during this method
execution
ChannelNotOpenedException
- if channel is not in appropriate state
to call the method
ChannelReceiverInitializationException
- if external receiver or client request handler is set.public java.util.Collection<? extends Channel> getChannels()
protected ProtocolFactory getProtocolFactory()
protected void modifyNewChannel(DuplexChannel channel)
channel
- incoming (accepted) channelprotected void sendToChannelsExcept(java.util.Collection<OutputChannel> channels, Message message, OutputChannel except) throws ProtocolException
channels
- list of channels to sendmessage
- Message to sendexcept
- channel to miss from sending or null if no channel
should be missed
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.public ProtocolDescription getProtocolDescription()
getProtocolDescription
in interface ProtocolDescriptionSupport
public Message receive() throws java.lang.InterruptedException, java.lang.IllegalStateException
java.lang.InterruptedException
java.lang.IllegalStateException
public Message receive(long timeout) throws java.lang.InterruptedException, java.lang.IllegalStateException
java.lang.InterruptedException
java.lang.IllegalStateException
public void clearInput()
Receiver
clearInput
in interface Receiver
public int getInputSize()
Receiver
getInputSize
in interface Receiver
public void setInputSize(int inputSize)
setClientRequestHandler(ClientRequestHandler)
) or external receiver
(setReceiver(RequestReceiverSupport)
) is in use.
setInputSize
in interface Receiver
inputSize
- maximum count of messages stored in receiverpublic void releaseReceivers()
setClientRequestHandler(ClientRequestHandler)
) or external receiver
(setReceiver(RequestReceiverSupport)
) is in use.
releaseReceivers
in interface Receiver
protected void applyConfiguration()
applyConfiguration
in class AbstractChannel
public void setClientRequestHandler(ClientRequestHandler handler)
ServerChannel
calls the handler on each new incoming message.
handler
- the handler for client requests procession.@Deprecated public void setReceiver(RequestReceiverSupport receiver)
setReceiver
in interface RequestReceiverManagement
receiver
- the receiver of client request messages.
ChannelNotClosedException
- if the channel isn't closed.setClientRequestHandler(ClientRequestHandler)
public void resetReceiver()
resetReceiver
in interface ReceiverManagement
ChannelNotClosedException
- when channel isn't closed
|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |