uk.ac.lancs.relate.gateways.services.architecture
Class Service

java.lang.Object
  extended by uk.ac.lancs.relate.gateways.services.architecture.Service
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
MulticastService, PresentationService, PresentationShowService, RMIService, SocketService

public class Service
extends java.lang.Object
implements java.io.Serializable

This models a generic Service offered by a Device.

Author:
Dominique Guinard
Personal Homepage
See Also:
Serialized Form

Constructor Summary
Service(java.lang.String name, java.lang.String description, TrackableDevice device, java.lang.String serviceHost, int servicePort)
          Creates a new instance of Service.
 
Method Summary
 java.lang.String getDescription()
          Gets the full, human-readable, description of the service semantics, i.e.
 TrackableDevice getDevice()
          Gets the device running this service.
 java.lang.String getName()
          Gets the human-readable name of the service.
 ServiceProvider getProvider()
          Returns the provider part (i.e server) of this service.
 ServiceRequester getRequester()
          Returns the provider part (i.e client stub) of this service.
 java.lang.String getServiceHost()
          Gets the name of the host currently running the service.
 int getServicePort()
          Gets the port of the host currently running the service.
 void setDescription(java.lang.String description)
          Sets the full, human-readable, description of the service semantics, i.e.
 void setName(java.lang.String name)
          Sets the name of the service.
 void setProvider(ServiceProvider provider)
          Sets the providers of the current service.
 void setRequester(ServiceRequester requester)
          Sets the requester of the current service.
 void setServiceHost(java.lang.String serviceHost)
          Sets the name of the host currently running the service.
 void setServicePort(int servicePort)
          Gets the port of the host currently running the service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Service

public Service(java.lang.String name,
               java.lang.String description,
               TrackableDevice device,
               java.lang.String serviceHost,
               int servicePort)
Creates a new instance of Service. Note: This constructor also takes care of setting a reference to the Service (this) to both the ServiceProvider and ServiceRequester.

Parameters:
name - a unique, humand-readable name for this service (e.g. PrintOnA4Color).
description - human-readable description of the service (e.g This service offers to open an openoffice presentation on a public screen).
device - device running the service (e.g a printer, a display, a keyboard).
serviceHost - hostname used to access the service (e.g. diufpc324.unifr.ch).
servicePort - port used to access the service (e.g 9188).
Method Detail

getName

public java.lang.String getName()
Gets the human-readable name of the service.

Returns:
A human-readable name for the service.

setName

public void setName(java.lang.String name)
Sets the name of the service. The name of a service is meant to be as human-readable as possible. It should be unique (local host wide) and should be a summary of the service description.

Parameters:
name - A human-readable and unique name for the service.

getDescription

public java.lang.String getDescription()
Gets the full, human-readable, description of the service semantics, i.e. it is an answer to the question what task does the service proposes to solve for the clients ?

Returns:
A human-readable description of the service.

setDescription

public void setDescription(java.lang.String description)
Sets the full, human-readable, description of the service semantics, i.e. it should be an answer to the question what task does the service proposes to solve for the clients ?

Parameters:
description - A human-readable description of the service.

getProvider

public ServiceProvider getProvider()
                            throws ServiceException
Returns the provider part (i.e server) of this service. Since providers and requesters are decoupled, a provider should be the only thing a device has to know about a service in order to provide it. As a service does not necessarily contain a provider calling this method might end up with throwing a ServiceException.

Returns:
the service provider.
Throws:
ServiceException - As a service does not necessarily contain a provider calling this method might end up with throwing a ServiceException.

getRequester

public ServiceRequester getRequester()
                              throws ServiceException
Returns the provider part (i.e client stub) of this service. Since providers and requesters are decoupled, this requester should be the only thing a mobile client has to know about a discovered service in order to consume it. As a service on a particular host does not necessarily contain a requester calling this method might end up with throwing a ServiceException.

Returns:
the service requester
Throws:
ServiceException - As a service does not necessarily contain a requester calling this method might end up with throwing a ServiceException.

getDevice

public TrackableDevice getDevice()
Gets the device running this service.

Returns:
the device running this service.

getServiceHost

public java.lang.String getServiceHost()
Gets the name of the host currently running the service.

Returns:
hostname of the device currently running the service.

setServiceHost

public void setServiceHost(java.lang.String serviceHost)
Sets the name of the host currently running the service. This method is to be called when the host of a service is changed at runtime.

Parameters:
serviceHost - this is the name of the host currently running the service. e.g: diufpc347.unifr.ch

getServicePort

public int getServicePort()
Gets the port of the host currently running the service. This method is to be called when the host of a service is changed at runtime.

Returns:
the port on which to which the service is currently bound.

setServicePort

public void setServicePort(int servicePort)
Gets the port of the host currently running the service. This method is to be called when the host of a service is changed at runtime.

Parameters:
servicePort - the port to which the service should be bound. e.g. 9087

setProvider

public void setProvider(ServiceProvider provider)
Sets the providers of the current service. Important note: since this method is called automatically when creating a provider for this service, it does not need to be invoked manually.

Parameters:
provider - the ServiceProvider (i.e. server class) for this service.

setRequester

public void setRequester(ServiceRequester requester)
Sets the requester of the current service. Important note: since this method is called automatically when creating a requester for this service, it does not need to be invoked manually.

Parameters:
requester - the ServiceRequester (i.e. consumer class) used to access this service.