JXTA

net.jxta.impl.endpoint.cbjx
Class CbJxTransport

java.lang.Object
  extended by net.jxta.impl.endpoint.cbjx.CbJxTransport
All Implemented Interfaces:
EndpointListener, MessageReceiver, MessageSender, MessageTransport, Module

public class CbJxTransport
extends Object
implements Module, MessageSender, MessageReceiver, EndpointListener

A JXTA MessageTransport implementation which which provides message verification by examining message signatures. A virtual transport, the messages are transfered between peers using some other message transport.


Nested Class Summary
 class CbJxTransport.CbJxInputFilter
          this class filters incoming messages.
 class CbJxTransport.CbJxOutputFilter
          this class filters all outgoing messages that are not sent with messengers.
 
Field Summary
(package private) static String CBJX_MSG_BODY
          the name of the cbjx body element
(package private) static String CBJX_MSG_INFO
          the name of the cbjx crypto element
static String CBJX_MSG_NS
          the name of the cbjx valid element
(package private) static String CBJX_MSG_SIG
          the name of the cbjx body element
(package private) static String cbjxProtocolName
          the cbjx protocol name
(package private) static String cbjxServiceName
          the cbjx service name
(package private)  EndpointService endpoint
          the endpoint service in my group
(package private)  PeerGroup group
          the peer group to which this module belongs
(package private) static EndpointAddress localPeerAddr
          the endpoint address of this peer
(package private) static PeerID localPeerID
          the local peer ID
(package private)  PSEMembershipService membership
          the membership service in my group
 
Fields inherited from interface net.jxta.platform.Module
START_AGAIN_PROGRESS, START_AGAIN_STALLED, START_DISABLED, START_OK
 
Constructor Summary
CbJxTransport()
          Default constructor
 
Method Summary
 Message addCryptoInfo(Message submessage, EndpointAddress destAddress)
          add the CryptoInfo into the message
 boolean allowsRouting()
          Returns true if the Message Transport can be used by the EndpointRouter.
 Message checkCryptoInfo(Message message, MessageElement cryptoElement, CbJxMessageInfo cryptoInfo)
           
 EndpointService getEndpointService()
          Returns the endpoint service with which this MessageTransport is registered.
 Messenger getMessenger(EndpointAddress dest, Object hintIgnored)
          Return a Messenger for sending messages to the specified destination EndpointAddress.
 String getProtocolName()
          Returns a String containing the name of the protocol used by this MessageTransport.
 EndpointAddress getPublicAddress()
          Returns the EndpointAddress which will be used as the source address for all messages sent by this message sender.
 Iterator getPublicAddresses()
          Returns an Iterator of all of the EndpointAddresses by which this MessageReceiver is reachable.
 void init(PeerGroup group, ID assignedID, Advertisement impl)
          Initialize the module, passing it its peer group and advertisement.
 boolean isConnectionOriented()
          Returns true if the Message Transport is connection oriented (like TCP/IP).
 boolean ping(EndpointAddress addr)
          Deprecated. 
 void processIncomingMessage(Message message, EndpointAddress srcAddr, EndpointAddress dstAddr)
          This method is invoked by the EndpointService for each incoming message which is addressed to this listener.
 int startApp(String[] arg)
          Complete any remaining initialization of the module.
 void stopApp()
          Stop a module.
 Object transportControl(Object operation, Object value)
          Pass a transport control object to a message transport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CBJX_MSG_NS

public static final String CBJX_MSG_NS
the name of the cbjx valid element

See Also:
Constant Field Values

CBJX_MSG_INFO

static final String CBJX_MSG_INFO
the name of the cbjx crypto element

See Also:
Constant Field Values

CBJX_MSG_BODY

static final String CBJX_MSG_BODY
the name of the cbjx body element

See Also:
Constant Field Values

CBJX_MSG_SIG

static final String CBJX_MSG_SIG
the name of the cbjx body element

See Also:
Constant Field Values

cbjxProtocolName

static final String cbjxProtocolName
the cbjx protocol name

See Also:
Constant Field Values

cbjxServiceName

static final String cbjxServiceName
the cbjx service name

See Also:
Constant Field Values

localPeerID

static PeerID localPeerID
the local peer ID


localPeerAddr

static EndpointAddress localPeerAddr
the endpoint address of this peer


group

PeerGroup group
the peer group to which this module belongs


endpoint

EndpointService endpoint
the endpoint service in my group


membership

PSEMembershipService membership
the membership service in my group

Constructor Detail

CbJxTransport

public CbJxTransport()
Default constructor

Method Detail

init

public void init(PeerGroup group,
                 ID assignedID,
                 Advertisement impl)
          throws PeerGroupException
Initialize the module, passing it its peer group and advertisement.

Note: when subclassing one of the existing PeerGroup implementations (which implement Module), it may not be recommended to overload the init method. See the documentation of the PeerGroup class being subclassed.

Specified by:
init in interface Module
Parameters:
group - The PeerGroup from which this Module can obtain services. If this module is a Service, this is also the PeerGroup of which this module is a service.
assignedID - Identity of Module within group. modules can use it as a the root of their namespace to create names that are unique within the group but predictable by the same module on another peer. This is normally the ModuleClassID which is also the name under which the module is known by other modules. For a group it is the PeerGroupID itself. The parameters of a service, in the Peer configuration, are indexed by the assignedID of that service, and a Service must publish its run-time parameters in the Peer Advertisement under its assigned ID.
impl - The implementation advertisement for this Module. It is permissible to pass null if no implementation advertisement is available. This may happen if the implementation was selected by explicit class name rather than by following an implementation advertisement. Modules are not required to support that style of loading, but if they do, then their documentation should mention it.
Throws:
PeerGroupException - This module failed to initialize.

startApp

public int startApp(String[] arg)
Complete any remaining initialization of the module. The module should be fully functional after startApp() is completed. That is also the opportunity to supply arbitrary arguments (mostly to applications).

If this module is a PeerGroup service, it may be invoked several times depending on its return value.

Specified by:
startApp in interface Module
Parameters:
arg - An array of Strings forming the parameters for this Module.
Returns:
int A status indication which may be one of Module.START_OK, Module.START_AGAIN_PROGRESS, Module.START_AGAIN_STALLED, which indicates partial or complete success, or any other value (negative values are recommended for future compatibility), which indicates failure.

stopApp

public void stopApp()
Stop a module. This may be called any time after init() completes and should not assume that startApp() has been called or completed.

The Module cannot be forced to comply, but in the future we might be able to deny it access to anything after some timeout.

Specified by:
stopApp in interface Module

getPublicAddress

public EndpointAddress getPublicAddress()
Returns the EndpointAddress which will be used as the source address for all messages sent by this message sender. This is the "preferred" address to which replies should be sent. This address is not necessarily the best or only address by which the peer may be reached.

The public address may also be for a different message transport.

Specified by:
getPublicAddress in interface MessageSender
Returns:
an EndpointAddress containing the public address for this message receiver.

isConnectionOriented

public boolean isConnectionOriented()
Returns true if the Message Transport is connection oriented (like TCP/IP). Indicates that the Message Transport can provide efficient transport of a series of messages to the same destination.

Specified by:
isConnectionOriented in interface MessageSender
Returns:
true if the Message Transport is connection oriented.

allowsRouting

public boolean allowsRouting()
Returns true if the Message Transport can be used by the EndpointRouter. Indicates that the Message Transport can be used in the routing of messages to destinations which are not directly reachable via this transport.

More specifically, this Message Transport will be used to route messages who's final destination is not one of the endpoint addresses available from getReachableEndpointAddresses.

Specified by:
allowsRouting in interface MessageSender
Returns:
true if the protocol can be used by the EndpointRouter

getEndpointService

public EndpointService getEndpointService()
Returns the endpoint service with which this MessageTransport is registered. If it is unregistered then null will be returned.

Specified by:
getEndpointService in interface MessageTransport
Returns:
the EndpointService with which this MessageTransport is registered.

transportControl

public Object transportControl(Object operation,
                               Object value)
Pass a transport control object to a message transport.

Specified by:
transportControl in interface MessageTransport
Parameters:
operation - Object that specifies the type of control operation to be performed
value - Object that specifies a value object associated with the control operation
Returns:
returned object

getPublicAddresses

public Iterator getPublicAddresses()
Returns an Iterator of all of the EndpointAddresses by which this MessageReceiver is reachable. The list is in order of "preference" with the most "preferred" EndpointAddress being at the beginning of the list.

Specified by:
getPublicAddresses in interface MessageReceiver
Returns:
an Iterator of EndpointAddresses.

getProtocolName

public String getProtocolName()
Returns a String containing the name of the protocol used by this MessageTransport. The value will match the "protocol" portion of all EndpointAddress.

Specified by:
getProtocolName in interface MessageTransport
Returns:
a String containing the name of the protocol used by this MessageTransport.

getMessenger

public Messenger getMessenger(EndpointAddress dest,
                              Object hintIgnored)
Return a Messenger for sending messages to the specified destination EndpointAddress.

Specified by:
getMessenger in interface MessageSender
Parameters:
dest - The destination address for which a messenger is requested.
hintIgnored - An optional hint for the transport to use when creating the messenger. The format of the hint is specific to each Message Transport and may be null if no hint is provided.
Returns:
a Messenger or null if the destination is not reachable.

ping

@Deprecated
public boolean ping(EndpointAddress addr)
Deprecated. 

Returns true if the specified destination address is reachable via this Message Transport otherwise returns false.

Specified by:
ping in interface MessageSender
Parameters:
addr - Address to ping
Returns:
true if the specified destination address is reachable via this Message Transport otherwise returns false.

processIncomingMessage

public void processIncomingMessage(Message message,
                                   EndpointAddress srcAddr,
                                   EndpointAddress dstAddr)
This method is invoked by the EndpointService for each incoming message which is addressed to this listener.

Specified by:
processIncomingMessage in interface EndpointListener
Parameters:
message - Incoming message
srcAddr - Endpoint Address of the source of the message.
dstAddr - Endpoint Address of the destination of the message.

addCryptoInfo

public Message addCryptoInfo(Message submessage,
                             EndpointAddress destAddress)
                      throws IOException
add the CryptoInfo into the message

Parameters:
submessage - the message
destAddress - the destination
Returns:
Message the message with the CbJxMessageInfo added
Throws:
IOException

checkCryptoInfo

public Message checkCryptoInfo(Message message,
                               MessageElement cryptoElement,
                               CbJxMessageInfo cryptoInfo)

JXSE