JXTA

net.jxta.impl.proxy
Class ProxyService

java.lang.Object
  extended by net.jxta.impl.proxy.ProxyService
All Implemented Interfaces:
EventListener, EndpointListener, CacheEntryListener, OutputPipeListener, PipeMsgListener, Module, Service

public class ProxyService
extends Object
implements Service, EndpointListener, PipeMsgListener, OutputPipeListener, CacheEntryListener


Nested Class Summary
(package private)  class ProxyService.ClientMessage
           
(package private)  class ProxyService.PendingPipe
           
(package private) static class ProxyService.PipeListenerList
           
 
Field Summary
(package private) static String ARG_TAG
           
(package private) static String ATTRIBUTE_TAG
           
static int DEFAULT_LIFETIME
           
static int DEFAULT_THRESHOLD
           
(package private) static String ERROR_MESSAGE_TAG
           
(package private) static String ID_TAG
           
(package private) static String NAME_TAG
           
(package private) static String PROXYNS
           
static String REQUEST_CLOSE
           
static String REQUEST_CREATE
           
static String REQUEST_JOIN
          ********************************************************************* Define the proxy request types ********************************************************************
static String REQUEST_LISTEN
           
static String REQUEST_SEARCH
           
static String REQUEST_SEND
           
static String REQUEST_TAG
          ********************************************************************* Define the proxy message tags ********************************************************************
(package private) static String REQUESTID_TAG
           
static String RESPONSE_ERROR
           
static String RESPONSE_INFO
           
static String RESPONSE_MESSAGE
           
static String RESPONSE_RESULT
           
static String RESPONSE_SUCCESS
          ********************************************************************* Define the proxy response types ********************************************************************
static String RESPONSE_TAG
           
(package private) static String THRESHOLD_TAG
           
static String TYPE_GROUP
           
static String TYPE_PEER
          ********************************************************************* Define the proxy type tags ********************************************************************
static String TYPE_PIPE
           
(package private) static String TYPE_TAG
           
(package private) static String VALUE_TAG
           
 
Fields inherited from interface net.jxta.platform.Module
START_AGAIN_PROGRESS, START_AGAIN_STALLED, START_DISABLED, START_OK
 
Constructor Summary
ProxyService()
           
 
Method Summary
 void discoveryEvent(DiscoveryEvent event)
           
 ModuleImplAdvertisement getImplAdvertisement()
          Returns the advertisement for this service.
 ProxyService getInterface()
          Service objects are not manipulated directly to protect usage of the service.
 void init(PeerGroup group, ID assignedID, Advertisement implAdv)
          Initialize the module, passing it its peer group and advertisement.
protected static void logMessage(Message message, Logger log)
           
 void outputPipeEvent(OutputPipeEvent event)
          Called when a input pipe has been located for a previously registered pipe.
 void pipeMsgEvent(PipeMsgEvent event)
          Called for each pipe message event that occurs.
 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.
 void purged(CacheEntry ce)
          
 int startApp(String[] args)
          Complete any remaining initialization of the module.
 void stopApp()
          Stop a module.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_THRESHOLD

public static final int DEFAULT_THRESHOLD
See Also:
Constant Field Values

DEFAULT_LIFETIME

public static final int DEFAULT_LIFETIME
See Also:
Constant Field Values

REQUEST_TAG

public static final String REQUEST_TAG
********************************************************************* Define the proxy message tags ********************************************************************

See Also:
Constant Field Values

RESPONSE_TAG

public static final String RESPONSE_TAG
See Also:
Constant Field Values

REQUESTID_TAG

static final String REQUESTID_TAG
See Also:
Constant Field Values

TYPE_TAG

static final String TYPE_TAG
See Also:
Constant Field Values

NAME_TAG

static final String NAME_TAG
See Also:
Constant Field Values

ID_TAG

static final String ID_TAG
See Also:
Constant Field Values

ARG_TAG

static final String ARG_TAG
See Also:
Constant Field Values

ATTRIBUTE_TAG

static final String ATTRIBUTE_TAG
See Also:
Constant Field Values

VALUE_TAG

static final String VALUE_TAG
See Also:
Constant Field Values

THRESHOLD_TAG

static final String THRESHOLD_TAG
See Also:
Constant Field Values

ERROR_MESSAGE_TAG

static final String ERROR_MESSAGE_TAG
See Also:
Constant Field Values

PROXYNS

static final String PROXYNS
See Also:
Constant Field Values

REQUEST_JOIN

public static final String REQUEST_JOIN
********************************************************************* Define the proxy request types ********************************************************************

See Also:
Constant Field Values

REQUEST_CREATE

public static final String REQUEST_CREATE
See Also:
Constant Field Values

REQUEST_SEARCH

public static final String REQUEST_SEARCH
See Also:
Constant Field Values

REQUEST_LISTEN

public static final String REQUEST_LISTEN
See Also:
Constant Field Values

REQUEST_CLOSE

public static final String REQUEST_CLOSE
See Also:
Constant Field Values

REQUEST_SEND

public static final String REQUEST_SEND
See Also:
Constant Field Values

RESPONSE_SUCCESS

public static final String RESPONSE_SUCCESS
********************************************************************* Define the proxy response types ********************************************************************

See Also:
Constant Field Values

RESPONSE_ERROR

public static final String RESPONSE_ERROR
See Also:
Constant Field Values

RESPONSE_INFO

public static final String RESPONSE_INFO
See Also:
Constant Field Values

RESPONSE_RESULT

public static final String RESPONSE_RESULT
See Also:
Constant Field Values

RESPONSE_MESSAGE

public static final String RESPONSE_MESSAGE
See Also:
Constant Field Values

TYPE_PEER

public static final String TYPE_PEER
********************************************************************* Define the proxy type tags ********************************************************************

See Also:
Constant Field Values

TYPE_GROUP

public static final String TYPE_GROUP
See Also:
Constant Field Values

TYPE_PIPE

public static final String TYPE_PIPE
See Also:
Constant Field Values
Constructor Detail

ProxyService

public ProxyService()
Method Detail

init

public void init(PeerGroup group,
                 ID assignedID,
                 Advertisement implAdv)
          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.
implAdv - 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[] args)
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:
args - 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

getImplAdvertisement

public ModuleImplAdvertisement getImplAdvertisement()
Returns the advertisement for this service.

Specified by:
getImplAdvertisement in interface Service
Returns:
Advertisement the advertisement. This is always a ModuleImplAdvertisement.

getInterface

public ProxyService getInterface()
Service objects are not manipulated directly to protect usage of the service. A Service interface is returned to access the service methods.

Specified by:
getInterface in interface Service
Returns:
Service public interface of the service

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.

discoveryEvent

public void discoveryEvent(DiscoveryEvent event)

pipeMsgEvent

public void pipeMsgEvent(PipeMsgEvent event)
Called for each pipe message event that occurs.

Specified by:
pipeMsgEvent in interface PipeMsgListener
Parameters:
event - The event being received.

outputPipeEvent

public void outputPipeEvent(OutputPipeEvent event)
Called when a input pipe has been located for a previously registered pipe. The event contains an OutputPipe which can be used to communicate with the remote peer.

Specified by:
outputPipeEvent in interface OutputPipeListener
Parameters:
event - the event

logMessage

protected static void logMessage(Message message,
                                 Logger log)

purged

public void purged(CacheEntry ce)

Specified by:
purged in interface CacheEntryListener

JXSE