|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.exolab.core.messenger.PacketChannel
A PacketConnection is a Connection that minimises resource usage.
This is achieved by:
Channel instances
PacketConnection,
PacketPool,
PacketInputStream,
PacketOutputStream| Field Summary | |
static int |
ACCEPTOR_CHANNEL_ID
The identifier for the channel to accept open and close requests |
static int |
CONNECTION_ACCEPT_CHANNEL_ID
The identifier for the connection acceptor channel |
static int |
CONNECTION_CHANNEL_ID
The identifier for the connection channel |
static int |
HANDSHAKE_CHANNEL_ID
The identifier for the handshaking channel |
static int |
LAST_SYSTEM_ID
The last system channel identifier |
static int |
SYSTEM_CHANNEL_ID
The identifier for the system channel |
| Constructor Summary | |
PacketChannel(PacketConnection connection,
int channelId,
int destinationId,
PacketQueue inputQueue)
Create a new channel |
|
| Method Summary | |
void |
close()
Close the channel. |
protected void |
closeListener()
Closes the listener |
protected void |
doClose()
Closes the channel, without notifying the opposing channel instance |
protected java.lang.Object |
doReceive(long timeout)
Receive the next message that arrives within the specified timeout interval. |
protected void |
enqueue(org.exolab.core.messenger.Packet packet)
Enqueues a packet on the inbound queue, for de-serializing. If a ChannelHandler is registered, it will be queued for
notification using the thread pool |
int |
getChannelId()
Returns the channel identifier. |
protected PacketConnection |
getConnection()
Returns a reference to the owning connection |
protected void |
handlerCompleted()
|
java.lang.Object |
invoke(java.lang.Object request)
Send a message and wait for a response |
boolean |
isClosed()
Returns true if this channel is closed |
java.lang.Object |
receive()
Receive a message. |
java.lang.Object |
receive(long timeout)
Receive the next message that arrives within the specified timeout interval. |
void |
send(java.lang.Object message)
Send a message |
protected void |
send(java.lang.Object message,
byte type,
int destinationId)
Send a message to the specified destination channel |
void |
setChannelListener(ChannelListener listener)
Register a listener to process messages asynchronously. Only a single listener may be registered at any one time. Setting the listener to null deregisters the listener.> NOTE: the listener will be invoked in a separate thread - to maintain the single threaded nature of channels, it is an error to call send(java.lang.Object), receive(), or invoke(java.lang.Object) from any other
thread other than that running the listener, while the listener is
registered. |
protected void |
setInvoke(boolean invoke)
Sets the 'invoke handler' flag. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int CONNECTION_CHANNEL_ID
public static final int CONNECTION_ACCEPT_CHANNEL_ID
public static final int SYSTEM_CHANNEL_ID
public static final int ACCEPTOR_CHANNEL_ID
public static final int HANDSHAKE_CHANNEL_ID
public static final int LAST_SYSTEM_ID
| Constructor Detail |
public PacketChannel(PacketConnection connection,
int channelId,
int destinationId,
PacketQueue inputQueue)
connection - the owning connectionchannelId - the channel identifierdestinationId - the destination channel identifierinputQueue - the inbound packet queue, to deserialize messages from
java.lang.IllegalArgumentException - if any argument is null| Method Detail |
public int getChannelId()
public void send(java.lang.Object message)
throws java.rmi.RemoteException
send in interface Channelmessage - the object to send
java.rmi.RemoteException - if the message can't be sent
public java.lang.Object receive()
throws java.rmi.RemoteException
receive in interface Channeljava.rmi.RemoteException - if the message can't be received
public java.lang.Object receive(long timeout)
throws java.rmi.RemoteException
This call blocks until a message arrives, the timeout expires, or the channel is closed. A timeout of zero never expires and the call blocks indefinitely.
receive in interface Channeltimeout - the timeout value (in milliseconds)
java.rmi.RemoteException - if a message can't be received
ReceiveTimeoutException - if no message is available within
the specified interval
public java.lang.Object invoke(java.lang.Object request)
throws java.lang.Exception,
java.rmi.RemoteException
invoke in interface Channelrequest - the object to send
java.lang.Exception - if the server throws an exception
java.rmi.RemoteException - if the message can't be sent or the response
can't be receivedpublic void setChannelListener(ChannelListener listener)
send(java.lang.Object), receive(), or invoke(java.lang.Object) from any other
thread other than that running the listener, while the listener is
registered.
setChannelListener in interface Channellistener - the listener to process messages, or null,
to deregister the current listener
public void close()
throws java.rmi.RemoteException
ChannelListener if one is
registered.
close in interface Channeljava.rmi.RemoteException - if an I/O error occurs closing the channelpublic boolean isClosed()
true if this channel is closed
protected java.lang.Object doReceive(long timeout)
throws java.rmi.RemoteException
This call blocks until a message arrives, the timeout expires, or the channel is closed. A timeout of zero never expires and the call blocks indefinitely.
timeout - the timeout value (in milliseconds)
java.rmi.RemoteException - if a message can't be received
ReceiveTimeoutException - if no message is available within
the specified intervalprotected void doClose()
protected void closeListener()
protected void setInvoke(boolean invoke)
invoke - if true prevent the channel being used
for send(java.lang.Object), receive(), and invoke(java.lang.Object)protected PacketConnection getConnection()
protected void send(java.lang.Object message,
byte type,
int destinationId)
throws java.rmi.RemoteException
message - the message to sendtype - the message typedestinationId - the destination channel id
java.rmi.RemoteException - if an I/O error occursprotected void enqueue(org.exolab.core.messenger.Packet packet)
ChannelHandler is registered, it will be queued for
notification using the thread pool
packet - the packet to queue on the inbound queueprotected void handlerCompleted()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||