com.sun.sgs.service
Interface Service

All Known Subinterfaces:
ClientSessionService, DataService, NodeMappingService, TaskService, WatchdogService

public interface Service

This is the base interface used for all services. Services support specific funcationality and work in a transactional context. See TransactionParticipant for details on when interaction between Services is allowed.

On startup of an application, services are constructed (see details below). This provides access to the non-transactional core components of the system as well as the other Services that have already been created. Services are created in a known order based on dependencies: DataService, WatchdogService, NodeMappingService, TaskService, ClientSessionService, and the ChannelManager, finishing with any custom Services ordered based on the application's configuration.

All implementations of Service must have a constructor with parameters of types Properties, ComponentRegistry, and TransactionProxy. This is how the Service is created on startup. The Properties parameter provides application and service-specific properties. The ComponentRegistry provides access to non-transactional kernel and system components like the TransactionScheduler. The TransactionProxy provides access to transactional state (when active) and the other available Services. If any error occurs in creating a Service, the constructor may throw any Exception, causing the application to shutdown.

Note that Services are not created in the context of a transaction. If a given constructor needs to do any work transactionally, it may do so by calling TransactionScheduler.runTask.


Method Summary
 String getName()
          Returns the name used to identify this service.
 void ready()
          Notifies this Service that the application is fully configured and ready to start running.
 void shutdown()
          Shuts down this service.
 

Method Detail

getName

String getName()
Returns the name used to identify this service.

Returns:
the service's name

ready

void ready()
           throws Exception
Notifies this Service that the application is fully configured and ready to start running. This means that all other Services associated with this application have been successfully created. If the method throws an exception, then the application will be shutdown.

Throws:
Exception - if an error occurs

shutdown

void shutdown()
Shuts down this service. Any call to this method will block until the shutdown has completed. If a shutdown has been completed already, this method will return immediately.

This method does not require a transaction, and should not be called from one because this method will typically not succeed if there are outstanding transactions.

When this method returns, it is assumed that the service has been shutdown.

Callers should assume that, in a worst case, this method may block indefinitely, and so should arrange to take other action (for example, calling System.exit) if the call fails to complete successfully in a certain amount of time.


RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved