pawn.services.presence
Class PresenceServiceImpl

java.lang.Object
  |
  +--pawn.services.presence.PresenceServiceImpl
All Implemented Interfaces:
net.jxta.discovery.DiscoveryListener, java.util.EventListener, net.jxta.platform.Module, PresenceService, net.jxta.service.Service

public class PresenceServiceImpl
extends java.lang.Object
implements PresenceService, net.jxta.discovery.DiscoveryListener

The implementation of the PresenceService interface. This service builds on top of the Discovery service to provide the functionality for requesting and providing presence information.


Field Summary
static java.lang.String refModuleSpecID
          The Module Specification ID for the Presence service.
 
Fields inherited from interface pawn.services.presence.PresenceService
AWAY, BUSY, OFFLINE, ONLINE, refModuleClassID
 
Constructor Summary
PresenceServiceImpl()
          PresenceServiceImpl constructor comment.
 
Method Summary
 void addListener(pawn.services.presence.PresenceListener listener)
          Add a listener object to the service.
 void announcePresence(int presenceStatus, java.lang.String emailAddress, java.lang.String name)
          Announce presence status information to the peer group.
 void discoveryEvent(net.jxta.discovery.DiscoveryEvent event)
          Handle notification of arriving discovery response messages, determine if the response contains presence information, and if so, dispatches the presence information to registered PresenceListeners.
 void findPresence(java.lang.String emailAddress)
          Sends a query to find presence information for the user specified by the given email address.
 net.jxta.document.Advertisement getImplAdvertisement()
          Returns the advertisement for this service.
 net.jxta.service.Service getInterface()
          Returns an interface used to protect this service.
 void init(net.jxta.peergroup.PeerGroup group, net.jxta.id.ID assignedID, net.jxta.document.Advertisement implAdv)
          Initialize the service.
 boolean removeListener(pawn.services.presence.PresenceListener listener)
          Remove a given listener object from the service.
 int startApp(java.lang.String[] args)
          Start the service.
 void stopApp()
          Stop the service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

refModuleSpecID

public static final java.lang.String refModuleSpecID
The Module Specification ID for the Presence service.

See Also:
Constant Field Values
Constructor Detail

PresenceServiceImpl

public PresenceServiceImpl()
PresenceServiceImpl constructor comment.

Method Detail

addListener

public void addListener(pawn.services.presence.PresenceListener listener)
Add a listener object to the service. When a new Presence Response Message arrives, the service will notify each registered listener. This method is synchronized to prevent multiple threads from altering the set of registered listeners simultaneously.

Specified by:
addListener in interface PresenceService
Parameters:
listener - the listener object to register with the service.

announcePresence

public void announcePresence(int presenceStatus,
                             java.lang.String emailAddress,
                             java.lang.String name)
Announce presence status information to the peer group.

Specified by:
announcePresence in interface PresenceService
Parameters:
presenceStatus - the current status to announce.
emailAddress - the user's email address.
name - the user's display name.

discoveryEvent

public void discoveryEvent(net.jxta.discovery.DiscoveryEvent event)
Handle notification of arriving discovery response messages, determine if the response contains presence information, and if so, dispatches the presence information to registered PresenceListeners.

Specified by:
discoveryEvent in interface net.jxta.discovery.DiscoveryListener
Parameters:
event - the object containing the discovery response.

findPresence

public void findPresence(java.lang.String emailAddress)
Sends a query to find presence information for the user specified by the given email address. Any response received by the service will be dispatched to registered PresenceListener objects.

Specified by:
findPresence in interface PresenceService
Parameters:
emailAddress - the email address to use to find presence info.

getImplAdvertisement

public net.jxta.document.Advertisement getImplAdvertisement()
Returns the advertisement for this service. In this case, this is the ModuleImplAdvertisement passed in when the service was initialized.

Specified by:
getImplAdvertisement in interface net.jxta.service.Service
Returns:
the advertisement describing this service.

getInterface

public net.jxta.service.Service getInterface()
Returns an interface used to protect this service.

Specified by:
getInterface in interface net.jxta.service.Service
Returns:
the wrapper object to use to manipulate this service.

init

public void init(net.jxta.peergroup.PeerGroup group,
                 net.jxta.id.ID assignedID,
                 net.jxta.document.Advertisement implAdv)
          throws net.jxta.exception.PeerGroupException
Initialize the service.

Specified by:
init in interface net.jxta.platform.Module
Parameters:
group - the PeerGroup containing this service.
assignedID - the identifier for this service.
implAdv - the advertisement specifying this service.
Throws:
net.jxta.exception.PeerGroupException - is not thrown ever by this implementation.

removeListener

public boolean removeListener(pawn.services.presence.PresenceListener listener)
Remove a given listener object from the service. Once removed, a listener will no longer be notified when a new Presence Response Message arrives. This method is synchronized to prevent multiple threads from altering the set of registered listeners simultaneously.

Specified by:
removeListener in interface PresenceService
Parameters:
listener - the listener object to unregister.

startApp

public int startApp(java.lang.String[] args)
Start the service.

Specified by:
startApp in interface net.jxta.platform.Module
Parameters:
args - the arguments to the service. Not used.
Returns:
0 to indicate the service started.

stopApp

public void stopApp()
Stop the service.

Specified by:
stopApp in interface net.jxta.platform.Module