|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.xbean.kernel.standard.ServiceManager
public class ServiceManager
The ServiceManager handles the life cycle of a single service. The manager is responsible for gaurenteeing that all start conditions have been satisfied before the service is constructed, and that all stop conditions have been satisfied before the service is destroyed. The ServiceManager can be started and stopped several times, but once destroyed no methods may be called.
Constructor Summary | |
---|---|
ServiceManager(Kernel kernel,
long serviceId,
ServiceName serviceName,
ServiceFactory serviceFactory,
ServiceMonitor serviceMonitor,
long timeoutDuration,
TimeUnit timeoutUnits)
Creates a service manager for a single service. |
Method Summary | |
---|---|
int |
compareTo(Object o)
|
void |
destroy(StopStrategy stopStrategy)
Attempts to stop and destroy the service. |
boolean |
equals(Object o)
|
ClassLoader |
getClassLoader()
Gets the class loader for this service. |
Object |
getService()
Gets the service instance. |
ServiceFactory |
getServiceFactory()
Gets the factory used to create and destroy the service instance. |
long |
getServiceId()
Gets the unique id of this service in the kernel. |
ServiceName |
getServiceName()
Gets the unique name of this service in the kernel. |
Set |
getServiceTypes()
Gets the types of the service that will be managed by this service manager. |
long |
getStartTime()
Gets the time at which this service entered the STARTING state or 0 if the service is STOPPED. |
ServiceState |
getState()
Gets the current state of this service. |
int |
hashCode()
|
void |
initialize()
Initializes the service. |
void |
start(boolean recursive,
StartStrategy startStrategy)
Attempts to starts the service. |
boolean |
stop(StopStrategy stopStrategy)
Attempts to stop the service. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ServiceManager(Kernel kernel, long serviceId, ServiceName serviceName, ServiceFactory serviceFactory, ServiceMonitor serviceMonitor, long timeoutDuration, TimeUnit timeoutUnits)
kernel
- the kernel in which this wraper will be registeredserviceId
- the unique id of this service in the kernelserviceName
- the unique name of this service in the kernelserviceFactory
- the factory used to create and destroy the service instanceserviceMonitor
- the monitor of service eventstimeoutDuration
- the maximum duration to wait for a locktimeoutUnits
- the unit of measure for the timeoutDurationMethod Detail |
---|
public void initialize() throws IllegalServiceStateException, UnsatisfiedConditionsException, Exception
IllegalServiceStateException
- if the service is not restartable and is disabled
UnsatisfiedConditionsException
- if the service is not restartable and there were unsatisfied start conditions
Exception
- if the service is not restartable and service construction threw an exceptionKernel#registerService(ServiceName, ServiceFactory, ClassLoader)
public void destroy(StopStrategy stopStrategy) throws IllegalServiceStateException, UnsatisfiedConditionsException
stopStrategy
- the strategy used to determine how to handle unsatisfied stop conditions
IllegalServiceStateException
- is the service did not stop
UnsatisfiedConditionsException
- if there were unsatisfied stop conditionsKernel.unregisterService(ServiceName, StopStrategy)
public long getServiceId()
public ServiceName getServiceName()
public Set getServiceTypes()
public ServiceFactory getServiceFactory()
Kernel.getServiceFactory(ServiceName)
public ClassLoader getClassLoader()
Kernel.getClassLoaderFor(ServiceName)
public Object getService()
Kernel.getService(ServiceName)
public ServiceState getState()
Kernel.getServiceState(ServiceName)
public long getStartTime()
Kernel.getServiceStartTime(ServiceName)
public void start(boolean recursive, StartStrategy startStrategy) throws IllegalServiceStateException, UnregisterServiceException, UnsatisfiedConditionsException, Exception
recursive
- if start is successful should we start recursive the services owned by this servicstartStrategy
- the strategy used to determine how to handle unsatisfied start conditions and start errors
IllegalServiceStateException
- if the service is in a state in which it can not be started
UnregisterServiceException
- if the kernel should unregister this service
UnsatisfiedConditionsException
- if there were unsatisfied start conditions
Exception
- it service creation threw an exceptionKernel.startService(ServiceName)
,
Kernel.startServiceRecursive(ServiceName)
public boolean stop(StopStrategy stopStrategy) throws UnsatisfiedConditionsException
stopStrategy
- the strategy used to determine how to handle unsatisfied stop conditions
UnsatisfiedConditionsException
- if there were unsatisfied stop conditionsKernel.stopService(ServiceName)
public int hashCode()
hashCode
in class Object
public boolean equals(Object o)
equals
in class Object
public int compareTo(Object o)
compareTo
in interface Comparable
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |