|
Configuration Platform SDK 7.6 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.DuplexChannel
Allows for asynchronous two-way communication between a Platform SDK
application and a server. It is the parent class of ClientChannel
.
beginOpen()
, beginClose()
, and all
event-firing operations.
AbstractChannel.configure(com.genesyslab.platform.commons.connection.ConnectionConfiguration)
method. Another is to pass configuration parametrs in the URL. Second way
will work only if first one wasn't used.
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 | |
DuplexChannel(Endpoint endpoint,
ProtocolFactory protocolFactory)
Create channel. |
|
DuplexChannel(Endpoint endpoint,
ProtocolFactory protocolFactory,
long timeout)
Create channel. |
Method Summary | |
void |
beginClose()
Method is asynchronous. |
void |
beginOpen()
Method is asynchronous. |
void |
clearInput()
Clears input queue of the channel. |
void |
close()
|
void |
close(long timeout)
|
int |
getInputSize()
Return the amount of messages this Receiver can hold before start to "forget stale messages" |
com.genesyslab.platform.commons.connection.interceptor.Interceptor |
getInterceptor()
Return interceptor of the connection behind this channel. |
ProtocolDescription |
getProtocolDescription()
|
void |
open()
Open the channel by opening underlying connection. |
void |
open(long timeout)
Open connection. |
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. |
void |
releaseReceivers()
Notify receivers (threads waiting on receive() methods) they should stop waiting and return null. |
void |
resetReceiver()
Reset receiver for this channel to default. |
void |
send(Message message)
Send message to remote party. |
void |
setConnectionInvoker(AsyncInvoker connectionInvoker)
Set AsyncInvoker to be used by underlying connection layer. |
void |
setInputSize(int inputSize)
Set the amount of messages this Receiver can hold before start to "forget stale messages" |
void |
setReceiver(MessageReceiverSupport receiver)
Set receiver for this channel. |
java.lang.String |
toString()
|
Methods inherited from class com.genesyslab.platform.commons.protocol.AbstractChannel |
addChannelListener, configure, getConfiguration, getEndpoint, getState, getTimeout, removeChannelListener, setEndpoint, setInvoker, setTimeout |
Methods inherited from class java.lang.Object |
equals, 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 |
Constructor Detail |
public DuplexChannel(Endpoint endpoint, ProtocolFactory protocolFactory)
endpoint
- Parameters of the connection to createprotocolFactory
- Factory to create messages.public DuplexChannel(Endpoint endpoint, ProtocolFactory protocolFactory, long timeout)
endpoint
- Parameters of the connection to createprotocolFactory
- Factory to create messages.timeout
- timeout to waitResponse for message in
receive()
or open()
methodMethod Detail |
public void open() throws ProtocolException, java.lang.InterruptedException, java.lang.IllegalStateException
open(long)
method to set timeouts.
open
in interface Channel
ProtocolException
- if there is problems opening the connection
java.lang.InterruptedException
java.lang.IllegalStateException
public void open(long timeout) throws ProtocolException, java.lang.InterruptedException, java.lang.IllegalStateException
open
in interface Channel
timeout
- time to waitResponse for the connection
ProtocolException
- if there is problems oening the connection
java.lang.InterruptedException
java.lang.IllegalStateException
public void beginOpen() throws ProtocolException
AsyncChannel
beginOpen
in interface AsyncChannel
ProtocolException
- in case of problems establishing connectionpublic void close() throws ProtocolException, java.lang.InterruptedException, java.lang.IllegalStateException
close
in interface Channel
ProtocolException
java.lang.InterruptedException
java.lang.IllegalStateException
public void close(long timeout) throws ProtocolException, java.lang.InterruptedException, java.lang.IllegalStateException
close
in interface Channel
ProtocolException
java.lang.InterruptedException
java.lang.IllegalStateException
public void beginClose() throws java.lang.IllegalStateException
AsyncChannel
beginClose
in interface AsyncChannel
java.lang.IllegalStateException
public Message receive() throws java.lang.InterruptedException
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
public Message receive(long timeout) throws java.lang.InterruptedException
receive()
.
See
Channel
for the meaning of the timeout values.
receive
in interface MessageReceiver
timeout
- timeout to waitResponse for message
java.lang.InterruptedException
- if thread is interrupted during this method
executionpublic void send(Message message) throws ProtocolException, java.lang.IllegalStateException
OutputChannel
send
in interface OutputChannel
message
- Message to send
ProtocolException
- some generic problems
java.lang.IllegalStateException
public int getInputSize()
Receiver
getInputSize
in interface Receiver
public void setInputSize(int inputSize)
Receiver
setInputSize
in interface Receiver
inputSize
- maximum count of messages stored in receiverpublic void releaseReceivers()
Receiver
releaseReceivers
in interface Receiver
public com.genesyslab.platform.commons.connection.interceptor.Interceptor getInterceptor()
ConnectionConfiguration
class and AbstractChannel.configure(
com.genesyslab.platform.commons.connection.ConnectionConfiguration)
method.
getInterceptor
in interface InterceptorSupport
public void clearInput()
clearInput
in interface Receiver
public void setReceiver(MessageReceiverSupport receiver)
setReceiver
in interface MessageReceiverManagement
receiver
- new Receiverpublic void resetReceiver()
resetReceiver
in interface ReceiverManagement
public void setConnectionInvoker(AsyncInvoker connectionInvoker)
AbstractChannel
setConnectionInvoker
in interface ConnectionInvokerSupport
setConnectionInvoker
in class AbstractChannel
connectionInvoker
- invoker for connection layerpublic ProtocolDescription getProtocolDescription()
getProtocolDescription
in interface ProtocolDescriptionSupport
public java.lang.String toString()
|
Configuration Platform SDK 7.6 API Reference | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |