JXTA

net.jxta.impl.protocol
Class RelayConfigAdv

java.lang.Object
  extended by net.jxta.document.Advertisement
      extended by net.jxta.document.ExtendableAdvertisement
          extended by net.jxta.impl.protocol.RelayConfigAdv
All Implemented Interfaces:
Cloneable

public final class RelayConfigAdv
extends ExtendableAdvertisement
implements Cloneable

Contains parameters for configuration of the Reference Implemenation Relay Service.


 


Nested Class Summary
static class RelayConfigAdv.Instantiator
          Instantiator for RelayConfigAdv
 
Method Summary
 void addSeedingURI(String addr)
           
 void addSeedingURI(URI addr)
           
 void addSeedRelay(EndpointAddress addr)
           
 void addSeedRelay(String addr)
           
 void clearSeedingURIs()
           
 void clearSeedRelays()
           
 RelayConfigAdv clone()
          
 URI getAclUri()
          Return ACL URI if set
static String getAdvertisementType()
          Returns the identifying type of this Advertisement.
 String getAdvType()
          Returns the identifying type of this Advertisement.
 long getAnnounceInterval()
          The interval in relative milliseconds at which relay server will announce its presence.
 String getBaseAdvType()
          Returns the base type of this advertisement hierarchy.
 long getClientLeaseDuration()
          The interval in relative milliseconds of leases accepted by clients.
 int getClientMessageQueueSize()
          Return the client message queue length size.
 Document getDocument(MimeMediaType encodeAs)
          Write this advertisement into a document of the requested type.
 ID getID()
          Returns an ID which identifies this Advertisement as uniquely as possible.
 String[] getIndexFields()
          Returns the element names on which this advertisement should be indexed.
 int getMaxClients()
          Return the maximum number of relay clients.
 int getMaxRelays()
          Return the maximum number of relay clients.
 long getMessengerPollInterval()
          The interval in relative milliseconds of at which clients will poll for messengers
 URI[] getSeedingURIs()
           
 EndpointAddress[] getSeedRelays()
           
 long getServerLeaseDuration()
          The interval in relative milliseconds of leases offered by servers.
 long getStallTimeout()
          The interval in relative milliseconds after which a client is assumed to no longer be connected if it fails to request messages.
 boolean getUseOnlySeeds()
          If true then this peer will use only seed rendezvous when configured as an edge peer.
protected  boolean handleElement(Element raw)
          Process an individual element from the document during parse.
 boolean isClientEnabled()
          If true then this peer will act as a relay client.
 boolean isServerEnabled()
          If true then this peer will act as a relay server.
 boolean removeSeedingURI(URI addr)
           
 boolean removeSeedRelay(EndpointAddress addr)
           
 void setAclUri(URI uri)
          Sets ACL URI
 void setAnnounceInterval(long newvalue)
          Sets interval in relative milliseconds at which relay server will announce its presence or -1 for default value.
 void setClientEnabled(boolean enabled)
          If true then this peer will act as a relay client.
 void setClientLeaseDuration(long newvalue)
          Sets interval in relative milliseconds of leases accepted by clients.
 void setClientMessageQueueSize(int newvalue)
          Sets the client message queue length size.
 void setMaxClients(int newvalue)
          Sets he maximum number of relay clients.
 void setMaxRelays(int newvalue)
          Sets the maximum number of relay clients.
 void setMessengerPollInterval(long newvalue)
          Sets interval in relative milliseconds of at which clients will poll for messengers.
 void setServerEnabled(boolean enabled)
          If true then this peer will act as a relay server.
 void setServerLeaseDuration(long newvalue)
          Sets interval in relative milliseconds of leases offered by servers.
 void setStallTimeout(long newvalue)
          Sets interval in relative milliseconds after which a client is assumed to no longer be connected if it fails to request messages.
 void setUseOnlySeeds(boolean onlySeeds)
          Set whether this peer will use only seed rendezvous when configured as an edge peer.
 
Methods inherited from class net.jxta.document.ExtendableAdvertisement
handleAttribute
 
Methods inherited from class net.jxta.document.Advertisement
toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getAdvertisementType

public static String getAdvertisementType()
Returns the identifying type of this Advertisement.

Note: This is a static method. It cannot be used to determine the runtime type of an advertisment. ie.

      Advertisement adv = module.getSomeAdv();
      String advType = adv.getAdvertisementType();
  

This is wrong and does not work the way you might expect. This call is not polymorphic and calls Advertiement.getAdvertisementType() no matter what the real type of the advertisment.

Returns:
String the type of advertisement

clone

public RelayConfigAdv clone()

Overrides:
clone in class Advertisement

getAdvType

public String getAdvType()
Returns the identifying type of this Advertisement. Unlike Advertisement.getAdvertisementType() this method will return the correct runtime type of an Advertisement object.

This implementation is provided for existing advertisements which do not provide their own implementation. In most cases you should provide your own implementation for efficiency reasons.

Overrides:
getAdvType in class Advertisement
Returns:
The identifying type of this Advertisement.

getBaseAdvType

public final String getBaseAdvType()
Returns the base type of this advertisement hierarchy. Typically, only the most basic advertisement of a type will implement this method and declare it as final.

Specified by:
getBaseAdvType in class ExtendableAdvertisement
Returns:
String the base type of advertisements in this hierarchy.

getID

public ID getID()
Returns an ID which identifies this Advertisement as uniquely as possible. This ID is typically used as the primary key for indexing of the Advertisement within databases.

Each advertisement sub-class must choose an appropriate implementation which returns canonical and relatively unique ID values for it's instances. Since this ID is commonly used for indexing, the IDs returned must be as unique as possible to avoid collisions. The value for the ID returned can either be:

For Advertisement types which normally return non-ID.nullID values no ID should be returned when asked to generate an ID while the Advertisement is an inconsistent state (example: uninitialized index fields). Instead IllegalStateException should be thrown.

Specified by:
getID in class Advertisement
Returns:
An ID that relatively uniquely identifies this advertisement or ID.nullID if this advertisement is of a type that is not normally indexed.

handleElement

protected boolean handleElement(Element raw)
Process an individual element from the document during parse. Normally, implementations will allow the base advertisements a chance to handle the element before attempting to handle the element themselves. ie.


  protected boolean handleElement(Element elem) {

      if (super.handleElement()) {
           // it's been handled.
           return true;
           }
      ... handle elements here ...

      // we don't know how to handle the element
      return false;
      }
  

Overrides:
handleElement in class ExtendableAdvertisement
Parameters:
raw - The element to be processed.
Returns:
true if the element was recognized, otherwise false.

getDocument

public Document getDocument(MimeMediaType encodeAs)
Write this advertisement into a document of the requested type. Two standard document forms are defined. "text/plain" encodes the document in a "pretty-print" format for human viewing and "text/xml" which provides an XML format.

We don't have any content to add, just build the document instance and return it to implementations that actually do something with it.

Overrides:
getDocument in class ExtendableAdvertisement
Parameters:
encodeAs - MimeMediaType format representation requested.
Returns:
The Advertisement represented as a Document of the requested MIME Media Type.

getIndexFields

public String[] getIndexFields()
Returns the element names on which this advertisement should be indexed.

Specified by:
getIndexFields in class Advertisement
Returns:
The element names on which this advertisement should be indexed.

isClientEnabled

public boolean isClientEnabled()
If true then this peer will act as a relay client.

Returns:
If true then this peer will act as a relay client.

setClientEnabled

public void setClientEnabled(boolean enabled)
If true then this peer will act as a relay client.

Parameters:
enabled - If true then this peer will act as a relay client.

getMaxRelays

public int getMaxRelays()
Return the maximum number of relay clients.

Returns:
The maximum number of relay clients or -1 for default value.

setMaxRelays

public void setMaxRelays(int newvalue)
Sets the maximum number of relay clients.

Parameters:
newvalue - The maximum number of relay clients or -1 for default value or -1 for default value.

getClientLeaseDuration

public long getClientLeaseDuration()
The interval in relative milliseconds of leases accepted by clients.

Returns:
The interval in relative milliseconds of leases accepted by clients or -1 for default value.

setClientLeaseDuration

public void setClientLeaseDuration(long newvalue)
Sets interval in relative milliseconds of leases accepted by clients.

Parameters:
newvalue - The interval in relative milliseconds of leases accepted by clients or -1 for default value.

getMessengerPollInterval

public long getMessengerPollInterval()
The interval in relative milliseconds of at which clients will poll for messengers

Returns:
The interval in relative milliseconds of at which clients will poll for messengers or -1 for default value.

setMessengerPollInterval

public void setMessengerPollInterval(long newvalue)
Sets interval in relative milliseconds of at which clients will poll for messengers.

Parameters:
newvalue - The interval in relative milliseconds of at which clients will poll for messengers or -1 for default value.

getUseOnlySeeds

public boolean getUseOnlySeeds()
If true then this peer will use only seed rendezvous when configured as an edge peer.

Returns:
If true then this peer will use only seed rendezvous when configured as an edge peer.

setUseOnlySeeds

public void setUseOnlySeeds(boolean onlySeeds)
Set whether this peer will use only seed rendezvous when configured as an edge peer.

Parameters:
onlySeeds - If true then this peer will use only seed rendezvous when configured as an edge peer.

getSeedRelays

public EndpointAddress[] getSeedRelays()

addSeedRelay

public void addSeedRelay(EndpointAddress addr)

addSeedRelay

public void addSeedRelay(String addr)

removeSeedRelay

public boolean removeSeedRelay(EndpointAddress addr)

clearSeedRelays

public void clearSeedRelays()

getSeedingURIs

public URI[] getSeedingURIs()

addSeedingURI

public void addSeedingURI(URI addr)

addSeedingURI

public void addSeedingURI(String addr)

removeSeedingURI

public boolean removeSeedingURI(URI addr)

clearSeedingURIs

public void clearSeedingURIs()

isServerEnabled

public boolean isServerEnabled()
If true then this peer will act as a relay server.

Returns:
If true then this peer will act as a relay server.

setServerEnabled

public void setServerEnabled(boolean enabled)
If true then this peer will act as a relay server.

Parameters:
enabled - If true then this peer will act as a relay server.

getMaxClients

public int getMaxClients()
Return the maximum number of relay clients.

Returns:
The maximum number of relay clients or -1 for default value.

setMaxClients

public void setMaxClients(int newvalue)
Sets he maximum number of relay clients.

Parameters:
newvalue - The maximum number of relay clients or -1 for default value.

getClientMessageQueueSize

public int getClientMessageQueueSize()
Return the client message queue length size.

Returns:
The client message queue length size or -1 for default value.

setClientMessageQueueSize

public void setClientMessageQueueSize(int newvalue)
Sets the client message queue length size.

Parameters:
newvalue - The client message queue length size or -1 for default value.

getServerLeaseDuration

public long getServerLeaseDuration()
The interval in relative milliseconds of leases offered by servers.

Returns:
The interval in relative milliseconds of leases offered by servers.

setServerLeaseDuration

public void setServerLeaseDuration(long newvalue)
Sets interval in relative milliseconds of leases offered by servers.

Parameters:
newvalue - The interval in relative milliseconds of leases offered by servers or -1 for default value.

getStallTimeout

public long getStallTimeout()
The interval in relative milliseconds after which a client is assumed to no longer be connected if it fails to request messages.

Returns:
The interval in relative milliseconds after which a client is assumed to no longer be connected if it fails to request messages or -1 for default value.

setStallTimeout

public void setStallTimeout(long newvalue)
Sets interval in relative milliseconds after which a client is assumed to no longer be connected if it fails to request messages.

Parameters:
newvalue - The interval in relative milliseconds after which a client is assumed to no longer be connected if it fails to request messages or -1 for default value.

getAnnounceInterval

public long getAnnounceInterval()
The interval in relative milliseconds at which relay server will announce its presence.

Returns:
The interval in relative milliseconds at which relay server will broadcast its presence or -1 for default value.

setAnnounceInterval

public void setAnnounceInterval(long newvalue)
Sets interval in relative milliseconds at which relay server will announce its presence or -1 for default value.

Parameters:
newvalue - The interval in relative milliseconds at which relay server will announce its presence.

getAclUri

public URI getAclUri()
Return ACL URI if set

Returns:
ACL URI if set, null otherwise

setAclUri

public void setAclUri(URI uri)
Sets ACL URI

Parameters:
uri - URI if set, null otherwise

JXSE