|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.GenericService SK.gnome.dwarf.GenericServer
Provides a generic Server
implementation.
It extends the base GenericService
class by adding functionality for storing
and manipulating of internal list of contained services.
Implementation note:
The contained services are stored internally in a java.util.List collection,
therefore the getService(String)
method searches for the services by iterating
over the list elements.
Thread-safety note:
All methods dealing with the contained services are thread-safe and the list returned by
the getServices()
method is synchronized. However, if you need to iterate over the
contained services, you must synchronize on the returned List object:
List services = getServices(); synchronized (services) { Iterator it = services.iterator(); while (it.hasNext()) { Service s = (Service)it.next(); ... // do something with the given service } }
Field Summary |
Fields inherited from class SK.gnome.dwarf.GenericService |
initParameters, parent |
Fields inherited from interface SK.gnome.dwarf.Service |
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED |
Constructor Summary | |
GenericServer(java.lang.String name)
Constructs a new GenericServer. |
Method Summary | |
void |
addService(int index,
Service service)
Inserts a service to the server. |
void |
addService(Service service)
Adds a service to the server. |
protected Authenticator |
getAuthenticator()
Returns an authentication service. |
protected Logger |
getLogger()
Returns a logging service. |
Parameters |
getParameters()
Returns the service parameters. |
Service |
getService(java.lang.String name)
Returns a service by its name. |
java.util.List |
getServices()
Returns all services contained by the server. |
java.util.List |
getServices(java.lang.Class serviceClass)
Returns the list of contained services which are instances of the given class. |
void |
init(Server parent)
Initializes the server. |
Service |
removeService(java.lang.String name)
Removes a service from the server. |
java.lang.String |
report()
Returns the service report. |
void |
shutdown()
Shuts down the server. |
void |
start()
Starts the server. |
void |
stop()
Stops the server. |
Methods inherited from class SK.gnome.dwarf.GenericService |
getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getName, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface SK.gnome.dwarf.Service |
getFullName, getName, getState, log, log, login, logout |
Constructor Detail |
public GenericServer(java.lang.String name)
Method Detail |
public void addService(Service service) throws ServiceException
Server
The service is added to the end of the service list.
addService
in interface Server
service
- the service being added to the server
ServiceException
- if the process fails for any other reasonpublic Service getService(java.lang.String name)
Server
It returns null if the name argument is null or there is no service contained by the server with the given name.
The method must accept also a full service name with each name component separated by the slash character. In this case, it should traverse the service object subtree and find the nested service at any level.
getService
in interface Server
name
- the nested service name
public java.util.List getServices()
Server
An empty list is returned if there are no services contained by the server, otherwise an unmodifiable list of contained services is returned.
The method is not traversing. If a service contained by the server is also a server, i.e. it contains another services, these nested services are not included in the resulting list.
getServices
in interface Server
public Service removeService(java.lang.String name)
Server
It returns null if the name argument is null or there is no service in the server with the given name, otherwise it returns a reference to the removed service.
The method is not traversing. If a service contained by the server is also a server, i.e. it contains another services, these nested services are not searched for the given service to remove.
removeService
in interface Server
name
- the nested service name
public Parameters getParameters()
Returns a service implementing the Parameters
interface, directly contained
by this server. If no such service exists, it calls the overriden method.
getParameters
in interface Service
getParameters
in class GenericService
public void init(Server parent) throws ServiceException
First initializes the superclass and then initializes all services contained
by the server by calling their Service.init(Server)
methods. Services will be
initialized in the order they were added to the server. It is left to the developer
to take care of the eventual service dependencies.
init
in interface Service
init
in class GenericService
ServiceException
public void start() throws ServiceException
First starts the superclass and then starts all services contained by the server
by calling their Service.start()
methods. Services will be started in the
order they were added to the server. It is left to the developer to take care of the
eventual service dependencies.
start
in interface Service
start
in class GenericService
ServiceException
public void stop() throws ServiceException
First stops the superclass and then stops all services contained by the server
by calling their Service.stop()
methods. Services will be stopped in the
reverse order they were added to the server. It is left to the developer to take care of
the eventual service dependencies.
The service must implement the Stoppable
interface in order to allow this
method to make the desired state transition.
stop
in interface Service
stop
in class GenericService
ServiceException
public void shutdown()
First shuts down the superclass and then shuts down all services contained by the
server by calling their Service.shutdown()
methoda. Services will be processed
in the reverse order they were added to the server. It is left to the developer to take
care of the eventual service dependencies.
shutdown
in interface Service
shutdown
in class GenericService
public void addService(int index, Service service) throws ServiceException
The service is inserted at the specified position to the list of contained services.
The addService(Service)
method uses this method to add the given service to the
end of the service list.
service
- the service being added to the server
java.lang.NullPointerException
- if the argument is null
java.lang.IllegalArgumentException
- if a service with the same name exists
ServiceException
- if an error occured during the addingpublic java.util.List getServices(java.lang.Class serviceClass)
If there are no such services contained by the server, an empty list is returned.
This method creates and returns a new modifiable List each time it is called.
The method is not traversing. If a service contained by the server is also a Server
,
i.e. it contains another services, these nested services are not included in the result.
public java.lang.String report()
Returns the report of all contained services which implements the Reportable
interface and are not instances of either the Server
or the Parameters
interface. The individual service reports are separated by the platform-default line
separator.
report
in interface Reportable
protected Logger getLogger()
Returns a reference to directly contained service, which implements the Logger
interface. If no such service exists, the result of the overriden getLogger()
method is returned.
getLogger
in class GenericService
protected Authenticator getAuthenticator()
Returns a reference to directly contained service, which implements the Authenticator
interface. If no such service exists, the result of the overriden' getAuthenticator()
method is returned.
getAuthenticator
in class GenericService
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |