no.ubicollab.osgi
Class ClientList

java.lang.Object
  extended by no.ubicollab.osgi.ClientList

public class ClientList
extends java.lang.Object

The Class ClientList is used to represent all clients which have registered with the Service Discovery Manager.

The class provide the methods neccessary to handle Client related tasks.

Since:
0.1
Version:
0.5
Author:
Kim-Steve Johansen

Constructor Summary
ClientList()
          A Constructor which creates an instance with a empty client list and a reset client counter.
 
Method Summary
 boolean addServiceToQueue(int clientID, Service s)
          Adds a service to the client queue for the client identified by clientID.
 int createNewClient()
          Creates a new client and returns the unique identifier for this client.
 void decreaseTimeToLive(int time)
          Decrease the time to live for all clients.
 java.lang.String getServiceQueue(int clientID)
          Gets the service queue for the given clientID in XML-format, and clears the queue at the same time.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientList

public ClientList()
A Constructor which creates an instance with a empty client list and a reset client counter.

Method Detail

createNewClient

public int createNewClient()
Creates a new client and returns the unique identifier for this client.

Returns:
the int that is the unique id for the client.

getServiceQueue

public java.lang.String getServiceQueue(int clientID)
Gets the service queue for the given clientID in XML-format, and clears the queue at the same time.

Parameters:
clientID - the client ID
Returns:
the service list

addServiceToQueue

public boolean addServiceToQueue(int clientID,
                                 Service s)
Adds a service to the client queue for the client identified by clientID. Can also add a service to all listening clients by specifying clientID = 1.

Parameters:
clientID - the client ID, or -1 for all clients
s - the service to add
Returns:
true, if service is added, false othervise

decreaseTimeToLive

public void decreaseTimeToLive(int time)
Decrease the time to live for all clients. Clients with time-to-live <= 0 are assumed to have disconnected and will be removed.

Parameters:
time - the time in millisecounds to decrease