p2ps.imp.group
Class GroupServiceImp

java.lang.Object
  extended byp2ps.imp.group.GroupServiceImp
All Implemented Interfaces:
EndpointMessageListener, GroupService

public class GroupServiceImp
extends java.lang.Object
implements GroupService, EndpointMessageListener

Implementation of the GroupService interface.

Version:
$Revision: 295 $
Author:
Ian Wang

Constructor Summary
GroupServiceImp(Peer peer)
           
 
Method Summary
 void dataMessageReceived(DataMessageEvent event)
          Called when the endpoint receives a data message
 AuthorizationMechanism getAuthorizationMechanism(java.lang.String type)
           
 java.lang.String[] getAuthorizationTypes()
           
 GroupAdvertisement getGroupAdvertisement()
           
 java.lang.String[] getGroupIDs()
           
 void init()
          Initializes the group service
 void joinGroup(GroupAdvertisement groupad, Peer parent)
          Join the group specified in the advertisement.
 void registerAuthorizationMechanism(java.lang.String authtype, AuthorizationMechanism authmech)
          Registers an authorization mechanism for the specified authorization type
 void unregisterAuthorizationMechanism(java.lang.String authtype)
          Unregisters the authorization mechanism for the specified authorization type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupServiceImp

public GroupServiceImp(Peer peer)
Method Detail

joinGroup

public void joinGroup(GroupAdvertisement groupad,
                      Peer parent)
               throws UnknownAuthorizationMechanismException,
                      AuthorizationException,
                      java.io.IOException
Join the group specified in the advertisement. Must be called before the group service is initialized

Specified by:
joinGroup in interface GroupService
Parameters:
groupad - the group advertisement
parent - the parent of the group peer (if known)
Throws:
UnknownAuthorizationMechanismException
AuthorizationException
java.io.IOException

init

public void init()
          throws InitializationException,
                 java.io.IOException
Initializes the group service

Specified by:
init in interface GroupService
Throws:
InitializationException
java.io.IOException

getGroupIDs

public java.lang.String[] getGroupIDs()
Specified by:
getGroupIDs in interface GroupService
Returns:
the group id hierarchy for the current group (current group id at index 0)

getGroupAdvertisement

public GroupAdvertisement getGroupAdvertisement()
Specified by:
getGroupAdvertisement in interface GroupService
Returns:
an advertisement for the current group

registerAuthorizationMechanism

public void registerAuthorizationMechanism(java.lang.String authtype,
                                           AuthorizationMechanism authmech)
Registers an authorization mechanism for the specified authorization type

Specified by:
registerAuthorizationMechanism in interface GroupService

unregisterAuthorizationMechanism

public void unregisterAuthorizationMechanism(java.lang.String authtype)
Unregisters the authorization mechanism for the specified authorization type

Specified by:
unregisterAuthorizationMechanism in interface GroupService

getAuthorizationMechanism

public AuthorizationMechanism getAuthorizationMechanism(java.lang.String type)
Specified by:
getAuthorizationMechanism in interface GroupService
Returns:
the authorization mechanism for the specified type (or null if none)

getAuthorizationTypes

public java.lang.String[] getAuthorizationTypes()
Specified by:
getAuthorizationTypes in interface GroupService
Returns:
a list of the registered authorization types

dataMessageReceived

public void dataMessageReceived(DataMessageEvent event)
Called when the endpoint receives a data message

Specified by:
dataMessageReceived in interface EndpointMessageListener