service.id
Class IdentificationService

java.lang.Object
  extended by service.Service
      extended by service.id.IdentificationService
All Implemented Interfaces:
java.lang.Runnable, IIdentification

public class IdentificationService
extends Service
implements IIdentification, java.lang.Runnable

Identification service allowing for a process to know all process identifiers of the system.


Field Summary
protected  java.net.InetAddress group
          IP address of the multicast group
protected  java.util.Vector<ProcessIdentifier> identifiers
          Identifiers of all processes of the system.
protected  java.net.MulticastSocket socket
          Multicast socket used to communication with the identification server.
 
Fields inherited from class service.Service
buffer, commElt, dispatcher, myType
 
Fields inherited from interface service.IIdentification
ipGroup, port
 
Constructor Summary
IdentificationService()
           
 
Method Summary
 java.util.Vector<ProcessIdentifier> getAllIdentifiers()
           
 ProcessIdentifier getMyIdentifier()
           
 void initialize(MessageDispatcher dispatcher, ICommunication commElt, MessageType myType)
          Initialize the service: register the service on the message dispatcher
 void leaveSystem()
          Leave the system: the identification server remove the current process from the process list identifiers and inform the other processes of the leaving of the current process.
protected  void printIdentifiers()
          Print on the standard output the set of process identifiers.
 void run()
          Wait for data coming from the identification server.
protected  void sendData(IdentificationData data)
          Send a data (i.e. a request) to the identification server.
protected  void sendIdRequestToServer()
          Send a request to the identification server for getting the process identifier.
 
Methods inherited from class service.Service
sendMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

identifiers

protected java.util.Vector<ProcessIdentifier> identifiers
Identifiers of all processes of the system.


socket

protected java.net.MulticastSocket socket
Multicast socket used to communication with the identification server.


group

protected java.net.InetAddress group
IP address of the multicast group

Constructor Detail

IdentificationService

public IdentificationService()
Method Detail

getMyIdentifier

public ProcessIdentifier getMyIdentifier()
Specified by:
getMyIdentifier in interface IIdentification
Returns:
the identifier of the current process

getAllIdentifiers

public java.util.Vector<ProcessIdentifier> getAllIdentifiers()
Specified by:
getAllIdentifiers in interface IIdentification
Returns:
the list of identifiers of all processes of the system (excepting the one of the current process)

leaveSystem

public void leaveSystem()
Description copied from interface: IIdentification
Leave the system: the identification server remove the current process from the process list identifiers and inform the other processes of the leaving of the current process.

Specified by:
leaveSystem in interface IIdentification

sendIdRequestToServer

protected void sendIdRequestToServer()
Send a request to the identification server for getting the process identifier. Do not wait for the response to be received.


sendData

protected void sendData(IdentificationData data)
Send a data (i.e. a request) to the identification server.

Parameters:
data - the data to send

initialize

public void initialize(MessageDispatcher dispatcher,
                       ICommunication commElt,
                       MessageType myType)
Description copied from class: Service
Initialize the service: register the service on the message dispatcher

Overrides:
initialize in class Service
Parameters:
dispatcher - the message dispatcher to use for associating the current service with its type of message
commElt - the communication element to use to send messages to service parts on other processes
myType - the type of the service

printIdentifiers

protected void printIdentifiers()
Print on the standard output the set of process identifiers.


run

public void run()
Wait for data coming from the identification server.

Specified by:
run in interface java.lang.Runnable