|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.jxta.impl.discovery.DiscoveryServiceInterface
public final class DiscoveryServiceInterface
Provides a pure interface object that permits interaction with the actual Discovery Service implementation without giving access to the real object.
Field Summary |
---|
Fields inherited from interface net.jxta.discovery.DiscoveryService |
---|
ADV, DEFAULT_EXPIRATION, DEFAULT_LIFETIME, GROUP, INFINITE_LIFETIME, NO_EXPIRATION, PEER |
Fields inherited from interface net.jxta.platform.Module |
---|
START_AGAIN_PROGRESS, START_AGAIN_STALLED, START_DISABLED, START_OK |
Constructor Summary | |
---|---|
protected |
DiscoveryServiceInterface(DiscoveryServiceImpl theRealThing)
Only authorized constructor |
Method Summary | |
---|---|
void |
addDiscoveryListener(DiscoveryListener listener)
Register a Discovery listener. |
void |
flushAdvertisement(Advertisement adv)
Removes the specified Advertisement from the cache of locally stored Advertisements. |
void |
flushAdvertisements(String id,
int type)
Removes the specified Advertisement from the cache of locally stored Advertisements. |
long |
getAdvExpirationTime(Advertisement adv)
Returns the maximum duration in milliseconds for which this document will be cached by peers other than the publisher. |
long |
getAdvExpirationTime(ID id,
int type)
Returns the maximum duration in milliseconds for which this document will be cached by peers other than the publisher. |
long |
getAdvLifeTime(Advertisement adv)
Returns the maximum duration in milliseconds for which this document should be kept in local cache. |
long |
getAdvLifeTime(ID id,
int type)
Returns the maximum duration in milliseconds for which this document should be kept in local cache. |
Advertisement |
getImplAdvertisement()
Returns the advertisement for this service. |
Service |
getInterface()
Service objects are not manipulated directly to protect usage of the service. |
Enumeration |
getLocalAdvertisements(int type,
String attribute,
String value)
Retrieve locally stored Advertisements. |
int |
getRemoteAdvertisements(String peer,
int type,
String attribute,
String value,
int threshold)
Discover advertisements from remote peers. |
int |
getRemoteAdvertisements(String peer,
int type,
String attribute,
String value,
int threshold,
DiscoveryListener listener)
Discover advertisements from remote peers. |
void |
init(PeerGroup pg,
ID assignedID,
Advertisement impl)
Initialize the module, passing it its peer group and advertisement. |
void |
publish(Advertisement adv)
Publish an Advertisement. |
void |
publish(Advertisement adv,
long lifetime,
long expiration)
Publish an Advertisement. |
void |
remotePublish(Advertisement adv)
Publish an Advertisement via propagation to other peers on the network. |
void |
remotePublish(Advertisement adv,
long expiration)
Publish an Advertisement via propagation to other peers on the network. |
void |
remotePublish(String peerid,
Advertisement adv)
Publish an Advertisement to another peer on the network. |
void |
remotePublish(String peerid,
Advertisement adv,
long expiration)
Publish an Advertisement to another peer on the network. |
boolean |
removeDiscoveryListener(DiscoveryListener listener)
Remove a Discovery listener which was previously registered with getRemoteAdvertisements()
or addDiscoveryListener() . |
int |
startApp(String[] arg)
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 |
Constructor Detail |
---|
protected DiscoveryServiceInterface(DiscoveryServiceImpl theRealThing)
theRealThing
- The actual discovery implementationMethod Detail |
---|
public Service getInterface()
getInterface
in interface Service
public Advertisement getImplAdvertisement()
getImplAdvertisement
in interface Service
ModuleImplAdvertisement
.public void init(PeerGroup pg, ID assignedID, Advertisement impl)
init
in interface Module
pg
- 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.public int startApp(String[] arg)
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.
This is here for temporary class hierarchy reasons.
it is ALWAYS ignored. By definition, the interface object
protects the real object's start/stop methods from being called
startApp
in interface Module
arg
- An array of Strings forming the parameters for this
Module.
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.public void stopApp()
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.
This is here for temporary class hierarchy reasons.
it is ALWAYS ignored. By definition, the interface object
protects the real object's start/stop methods from being called
This request is currently ignored.
stopApp
in interface Module
public int getRemoteAdvertisements(String peer, int type, String attribute, String value, int threshold)
attribute
and value
pair. The attribute
is
a case-sensitive string matching the name of an Advertisement XML tag
who's values will be matched by the value
. Only a limited number
of Advertisement XML fields are indexed. Advertisement.getIndexFields()
will return the
fields on which you may query for a particular Advertisement type.
The value
is a case-insensitive string who's value is
matched against the values of attribute
fields of Advertisements.
The
value may be of several forms :
null
- Don't care. All advertisements with the matching
attribute
will be returned.attribute
field who's value exactly matches the string value
will be
returned.attribute
field who's value matches the wild card expression value
will be returned. eg. The following expressions all match against
"FooBar":
foO*
*Bar
*oBA*
getRemoteAdvertisements
in interface DiscoveryService
peer
- If provided the query will be forwarded to the specified
peer. If null
then the query will be propagated through the
network to peers with matching Advertisements.type
- Discovery type; PEER, GROUP or ADV.attribute
- indexed element name (see advertisement(s) for a
list of indexed fields. A null attribute indicates any advertisement
of specified typevalue
- value of attribute to narrow discovery to. Valid values for
this parameter are null (don't care), Exact value, or use of wild
card(s) (e.g. if a Advertisement defines threshold
- The maximum number of matching advertisements which
be returned by each responding peer. A threshold
of 0, and
type
of PEER
has a special behaviour.
public int getRemoteAdvertisements(String peer, int type, String attribute, String value, int threshold, DiscoveryListener listener)
null
peerid - The discovery query is
propagated on via the Rendezvous Service and via local sub-net
utilizing IP multicast.attribute
and value
pair. The attribute
is
a case-sensitive string matching the name of an Advertisement XML tag
who's values will be matched by the value
. Only a limited number
of Advertisement XML fields are indexed. Advertisement.getIndexFields()
will return the
fields on which you may query for a particular Advertisement type.
The value
is a case-insensitive string who's value is
matched against the values of attribute
fields of Advertisements.
The
value may be of several forms :
null
- Don't care. All advertisements with the matching
attribute
will be returned.attribute
field who's value exactly matches the string value
will be
returned.attribute
field who's value matches the wild card expression value
will be returned. eg. The following expressions all match against
"FooBar":
fOo*
*bAr
*OBa*
getRemoteAdvertisements
in interface DiscoveryService
peer
- If provided the query will be forwarded to the specified
peer. If null
then the query will be propagated through the
network to peers with matching Advertisements.type
- Discovery type; PEER, GROUP or ADV.attribute
- indexed element name (see Advertisement(s) for a
list of indexed fields. A null attribute indicates any advertisement
of specified typevalue
- value of attribute to narrow discovery to. Valid values
for this parameter or null
(don't care), Exact value, or use
of wild card(s) (e.g. if a Advertisement defines threshold
- The maximum number of matching advertisements which
be returned by each responding peer. A threshold
of 0, and
type
of PEER
has a special behaviour.listener
- The listener which will be called when advertisement
which match this query are discovered or null
if no
callback is desired.
public Enumeration getLocalAdvertisements(int type, String attribute, String value) throws IOException
getLocalAdvertisements
in interface DiscoveryService
type
- Discovery type; PEER, GROUP or ADV.attribute
- indexed element name (see Advertisement(s) for a
list of indexed fields. null
indicates any advertisement
of specified typevalue
- value of attribute to narrow discovery to valid
values for this parameter are null
(don't care), Exact
value, or use of wild card(s) (e.g. if a Advertisement defines
IOException
- Thrown if an error occurs during retrieval.public void flushAdvertisement(Advertisement adv) throws IOException
flushAdvertisement
in interface DiscoveryService
adv
- Advertisement to remove.
IOException
- If there is a problem removing the advertisement.public void flushAdvertisements(String id, int type) throws IOException
flushAdvertisements
in interface DiscoveryService
id
- The Advertisement.getID()
value of the
Advertisement to be removed.type
- Discovery type PEER, GROUP, ADV.
IOException
- If there is a problem removing the advertisement.public long getAdvExpirationTime(ID id, int type)
getAdvExpirationTime
in interface DiscoveryService
id
- Document ID, Peer ID, or PeerGroup IDtype
- Discovery type PEER, GROUP, ADV
public long getAdvLifeTime(ID id, int type)
getAdvLifeTime
in interface DiscoveryService
id
- Document ID, Peer ID, or PeerGroup IDtype
- Discovery type PEER, GROUP, ADV
public long getAdvExpirationTime(Advertisement adv)
getAdvExpirationTime
in interface DiscoveryService
adv
- Advertisement
public long getAdvLifeTime(Advertisement adv)
getAdvLifeTime
in interface DiscoveryService
adv
- Advertisement
public void publish(Advertisement adv) throws IOException
DEFAULT_LIFETIME
and will expire on
other peers after DEFAULT_EXPIRATION
.
When an Advertisement is published, it is stored, and indexed in the
peer's local cache. The Advertisement indexes are also shared with
Rendezvous peers. Advertisement indexes may not be shared with other
peers immediately, but may be updated as part of a periodic process. The
Discovery Service currently publishes index updates every 30 seconds.
publish
in interface DiscoveryService
adv
- The Advertisement to publish.
IOException
- When an error occurs during Advertisement publication.public void publish(Advertisement adv, long lifetime, long expiration) throws IOException
publish
in interface DiscoveryService
adv
- The Advertisement to publish.lifetime
- Duration in relative milliseconds that this advertisement will exist.expiration
- Duration in relative milliseconds that this advertisement will be cached by other peers.
IOException
- When an error occurs during Advertisement publication.public void remotePublish(Advertisement adv)
remotePublish
in interface DiscoveryService
adv
- Advertisement to publish.public void remotePublish(Advertisement adv, long expiration)
remotePublish
in interface DiscoveryService
adv
- The Advertisement to publish.expiration
- Duration in relative milliseconds that this
Advertisement will be cached by other peers.public void remotePublish(String peerid, Advertisement adv)
remotePublish
in interface DiscoveryService
peerid
- The ID of a peer, specifying null results in
propagation within the group.adv
- The Advertisement to publish.public void remotePublish(String peerid, Advertisement adv, long expiration)
remotePublish
in interface DiscoveryService
peerid
- id of a peer, specifying null results in a propagate
within the groupadv
- The Advertisement to publish.expiration
- Duration in relative milliseconds that this
Advertisement will be cached by other peers.public void addDiscoveryListener(DiscoveryListener listener)
addDiscoveryListener
in interface DiscoveryService
listener
- the DiscoveryListenerpublic boolean removeDiscoveryListener(DiscoveryListener listener)
getRemoteAdvertisements()
or addDiscoveryListener()
.
removeDiscoveryListener
in interface DiscoveryService
listener
- The listener to be removed.
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |