Project JXTA

net.jxta.impl.endpoint.cbjx
Class CbJxMessenger

java.lang.Object
  extended by net.jxta.util.AbstractSimpleSelectable
      extended by net.jxta.endpoint.AbstractMessenger
          extended by net.jxta.impl.endpoint.BlockingMessenger
              extended by net.jxta.impl.endpoint.cbjx.CbJxMessenger
All Implemented Interfaces:
Messenger, SimpleSelectable

public class CbJxMessenger
extends BlockingMessenger

This class is the Messenger used to send CbJx Messages


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.jxta.util.SimpleSelectable
SimpleSelectable.IdentityReference
 
Field Summary
 
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
CbJxMessenger(CbJxTransport transport, EndpointAddress dest)
          constructor
CbJxMessenger(CbJxTransport transport, EndpointAddress dest, Object hintIgnored)
          constructor
 
Method Summary
 void closeImpl()
          Close connection.
 EndpointAddress getLogicalDestinationImpl()
          Obtain the logical destination address from the implementer (a transport for example).
 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.
 boolean sendMessageBImpl(Message msg, String service, String serviceParam)
          send message. block as needed. throw IOException or runtime exception as needed.
(package private)  boolean sendTo(Message msg)
          sendTo is used in order to send a message via the underlying messenger
 
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
 

Constructor Detail

CbJxMessenger

public CbJxMessenger(CbJxTransport transport,
                     EndpointAddress dest,
                     Object hintIgnored)
              throws IOException
constructor

Parameters:
dest - the destination address
Throws:
IOException

CbJxMessenger

public CbJxMessenger(CbJxTransport transport,
                     EndpointAddress dest)
              throws IOException
constructor

Parameters:
dest - the destination address
Throws:
IOException
Method Detail

closeImpl

public void closeImpl()
Close connection. May fail current send.

Specified by:
closeImpl in class BlockingMessenger

getLogicalDestinationImpl

public EndpointAddress getLogicalDestinationImpl()
Obtain the logical destination address from the implementer (a transport for example).

Specified by:
getLogicalDestinationImpl in class BlockingMessenger

isClosed

public 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. FIXME - jice@jxta.org 20040413: transports should get a deeper retrofit eventually.

Specified by:
isClosed in interface Messenger
Overrides:
isClosed in class BlockingMessenger

isIdleImpl

public boolean isIdleImpl()
return true if this messenger has not been used for a long time. The definition of long time is: "so long that closing it is worth the risk of having to re-open". A messenger should self close if it thinks it meets the definition of idle. BlockingMessenger leaves the evaluation to the transport but does the work automatically. Important: if self destruction is used, this method must work; not just return false. See the constructor. In general, if closeImpl does not need to do anyhing, then self destruction is not needed.

Specified by:
isIdleImpl in class BlockingMessenger

sendMessageBImpl

public boolean sendMessageBImpl(Message msg,
                                String service,
                                String serviceParam)
                         throws IOException
send message. block as needed. throw IOException or runtime exception as needed. The boolean return value is for historical reasons: so that transports just need to rename their sendMessage() methods. No need to change a bit of the code.

Specified by:
sendMessageBImpl in class BlockingMessenger
Throws:
IOException

sendTo

boolean sendTo(Message msg)
         throws IOException
sendTo is used in order to send a message via the underlying messenger

Parameters:
message - message to send to the remote peer.
Returns:
if true then message was sent, otherwise false.
Throws:
IOException - if there was a problem sending the message.

JXTA J2SE