JXTA

net.jxta.impl.protocol
Class DiscoveryConfigAdv

java.lang.Object
  extended by net.jxta.document.Advertisement
      extended by net.jxta.document.ExtendableAdvertisement
          extended by net.jxta.impl.protocol.DiscoveryConfigAdv

public final class DiscoveryConfigAdv
extends ExtendableAdvertisement

Contains parameters for configuration of the Reference Implemenation Rendezvous Service.



 


Nested Class Summary
static class DiscoveryConfigAdv.Instantiator
          Instantiator for DiscoveryConfigAdv
 
Constructor Summary
DiscoveryConfigAdv()
          Use the Instantiator through the factory
DiscoveryConfigAdv(Element root)
          Use the Instantiator through the factory
 
Method Summary
 DiscoveryConfigAdv clone()
          Make a safe clone of this DiscoveryConfigAdv.
static String getAdvertisementType()
          Returns the identifying type of this Advertisement.
 String getAdvType()
          Returns the identifying type of this Advertisement.
 String getBaseAdvType()
          Returns the base type of this advertisement hierarchy.
 Document getDocument(MimeMediaType encodeAs)
          Write this advertisement into a document of the requested type.
 boolean getForwardAlwaysReplica()
          True if this discovery service will forward queries to the replica peer in all cases, rather than only in the absence of local responses.
 boolean getForwardBelowTreshold()
          True if this discovery service will forward queries when the number of local responses is below the specified treshold, rather than only in the absence of local responses.
 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.
 boolean getLocalOnly()
          True if this discovery service performs only local discovery.
 void setForwardAlwaysReplica(boolean newvalue)
          Specifies if this discovery service will forward queries to the replica peer in all cases, rather than only in the absence of local responses.
 void setForwardBelowTreshold(boolean newvalue)
          Specifies if this discovery service will forward queries when the number of local responses is below the specified treshold, rather than only in the absence of local responses.
 void setLocalOnly(boolean newvalue)
          Specifies if this discovery service will perform local only discovery.
 
Methods inherited from class net.jxta.document.ExtendableAdvertisement
handleAttribute, handleElement
 
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
 

Constructor Detail

DiscoveryConfigAdv

DiscoveryConfigAdv()
Use the Instantiator through the factory


DiscoveryConfigAdv

DiscoveryConfigAdv(Element root)
Use the Instantiator through the factory

Parameters:
root - the element
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 DiscoveryConfigAdv clone()
                         throws CloneNotSupportedException
Make a safe clone of this DiscoveryConfigAdv.

Overrides:
clone in class Advertisement
Returns:
Object A copy of this DiscoveryConfigAdv
Throws:
CloneNotSupportedException

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.

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.

getForwardAlwaysReplica

public boolean getForwardAlwaysReplica()
True if this discovery service will forward queries to the replica peer in all cases, rather than only in the absence of local responses.

Returns:
The current setting.

setForwardAlwaysReplica

public void setForwardAlwaysReplica(boolean newvalue)
Specifies if this discovery service will forward queries to the replica peer in all cases, rather than only in the absence of local responses.

Parameters:
newvalue - The new setting.

getForwardBelowTreshold

public boolean getForwardBelowTreshold()
True if this discovery service will forward queries when the number of local responses is below the specified treshold, rather than only in the absence of local responses.

Returns:
The current setting.

setForwardBelowTreshold

public void setForwardBelowTreshold(boolean newvalue)
Specifies if this discovery service will forward queries when the number of local responses is below the specified treshold, rather than only in the absence of local responses.

Parameters:
newvalue - The new setting.

getLocalOnly

public boolean getLocalOnly()
True if this discovery service performs only local discovery.

Returns:
The current setting.

setLocalOnly

public void setLocalOnly(boolean newvalue)
Specifies if this discovery service will perform local only discovery.

Parameters:
newvalue - The new setting.

JXSE