|
Project JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.util.AbstractSimpleSelectable
net.jxta.endpoint.AbstractMessenger
net.jxta.impl.endpoint.BlockingMessenger
net.jxta.impl.endpoint.tcp.TcpMessenger
class TcpMessenger
Implements a messenger which sends messages via raw TCP sockets.
FIXME jice@jxta.org 20021007: Although in theory not too clean, we could merge connection and messenger. there is a one-to-one mapping between them except that for incoming connections we sometimes throw the messenger away. Merging them would add only a message element and an endpoint address to the connection object and would simplify close() isclosed() and GC's life quite a bit. (Look Ma, no synch ! All synchronized() have been removed. With the help of a volatile reference to the TcpConnection, this is no longer necessary this optimizes at least one critical function: isClosed().
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface net.jxta.util.SimpleSelectable |
---|
SimpleSelectable.IdentityReference |
Field Summary | |
---|---|
(package private) TcpConnection |
conn
The connection |
(package private) boolean |
incoming
If this is an incoming connection we must not close it when this messenger disapears. |
Fields inherited from class net.jxta.endpoint.AbstractMessenger |
---|
DEFAULT_MTU, dstAddress |
Fields inherited from class net.jxta.util.AbstractSimpleSelectable |
---|
identityReference |
Fields inherited from interface net.jxta.endpoint.Messenger |
---|
ANYSTATE, BREAKING, BROKEN, CLOSED, CLOSING, CONNECTED, DISCONNECTED, DISCONNECTING, IDLE, RECONCLOSING, RECONNECTING, RECONSATURATED, RESOLCLOSING, RESOLPENDING, RESOLSATURATED, RESOLVED, RESOLVING, SATURATED, SENDING, SENDINGSATURATED, TERMINAL, UNRESOLVABLE, UNRESOLVED, UNRESOLVING, USABLE |
Constructor Summary | |
---|---|
TcpMessenger(EndpointAddress destaddr,
TcpConnection conn,
TcpTransport p)
Create a new TcpNonBlockingMessenger for the specified address. |
|
TcpMessenger(EndpointAddress destaddr,
TcpTransport p)
Create a new TcpNonBlockingMessenger for the specified address. |
Method Summary | |
---|---|
void |
closeImpl()
Close connection. |
EndpointAddress |
getLogicalDestinationImpl()
Obtain the logical destination address from the implementer (a transport for example). |
(package private) TransportBindingMeter |
getTransportBindingMeter()
|
boolean |
isClosed()
We overload isClosed because many messengers still invoke super.isClosed() for their own implementation and they expect it to be true only when all is shutdown; not while we're closing gently. |
boolean |
isIdleImpl()
return true if this messenger has not been used for a long time. Since we probe the connection status, we'll keep a messenger as long as the connection is active, even if only on the incoming side. |
boolean |
sendMessageBImpl(Message message,
String service,
String serviceParam)
Sends a message to the destination |
protected void |
start()
Starts the underlying connection receive thread if any. |
Methods inherited from class net.jxta.impl.endpoint.BlockingMessenger |
---|
close, getChannelMessenger, getDestAddressToUse, getLogicalDestinationAddress, getState, resolve, sendMessageB, sendMessageN, setOwner, shutdown |
Methods inherited from class net.jxta.endpoint.AbstractMessenger |
---|
flush, getDestinationAddress, getDestinationAddressObject, getMTU, isIdle, isSynchronous, itemChanged, sendMessage, sendMessage, sendMessage, setStateLock, waitState |
Methods inherited from class net.jxta.util.AbstractSimpleSelectable |
---|
getIdentityReference, haveListeners, notifyChange, register, registerListener, unregister, unregisterListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.jxta.util.SimpleSelectable |
---|
getIdentityReference, register, unregister |
Field Detail |
---|
volatile TcpConnection conn
boolean incoming
Constructor Detail |
---|
TcpMessenger(EndpointAddress destaddr, TcpConnection conn, TcpTransport p) throws IOException
destaddr
- the destination of the messengerp
- the tcp MessageSender we are working for.
IOException
TcpMessenger(EndpointAddress destaddr, TcpTransport p) throws IOException
destaddr
- the destination of the messengerp
- the tcp MessageSender we are working for.
IOException
Method Detail |
---|
protected void start()
public void closeImpl()
closeImpl
in class BlockingMessenger
public boolean isClosed()
BlockingMessenger
isClosed
in interface Messenger
isClosed
in class BlockingMessenger
TransportBindingMeter getTransportBindingMeter()
public boolean isIdleImpl()
isIdleImpl
in class BlockingMessenger
public EndpointAddress getLogicalDestinationImpl()
getLogicalDestinationImpl
in class BlockingMessenger
public boolean sendMessageBImpl(Message message, String service, String serviceParam) throws IOException
sendMessageBImpl
in class BlockingMessenger
msg
- the message to send.destService
- Optionally replaces the service in the destination
address. If null then the destination address's default service
will be used.destServiceParam
- Optionally replaces the service param in the
destination address. If null then the destination address's default service
parameter will be used.
IOException
|
JXTA J2SE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |