|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Kernel
This iterface defines the API for managing and monitoring service life-cycle. A kernel can be constructed with the following code:
Services can be registered, unregistered, started and stopped. The lifecycle model is loosly based on the J2ee Management Specification (JSR 77). All lifecycle transitions are broadcasted via a ServiceMonitor. Each kernel must have a name that is unique with in the KernelFactory (there should only be one KernelFactory per VM but class loader tricks can result in several KernelFactory) This class is loosely based on the J2ee management MEJB and JMX MBeanServer interfaces.Kernel kernel = KernelFactory.newInstance().createKernel(name);
Method Summary | |
---|---|
void |
addKernelMonitor(KernelMonitor kernelMonitor)
Adds a kernel monitor. |
void |
addServiceMonitor(ServiceMonitor serviceMonitor)
Adds a service monitor for all services registered with the kernel. |
void |
addServiceMonitor(ServiceMonitor serviceMonitor,
ServiceName serviceName)
Adds a service monitor for a specific service. |
void |
destroy()
Destroys this kernel. |
ClassLoader |
getClassLoaderFor(ServiceName serviceName)
Gets the class loader associated with the specifed service. |
String |
getKernelName()
Gets the unique name of this kernel within the KernelFactory. |
Object |
getService(Class type)
Gets the first running service registered with the kernel that is an instance of the specified type. |
Object |
getService(ServiceName serviceName)
Gets the service registered under the specified name. |
List |
getServiceFactories(Class type)
Gets the all of the service factories registered with the kernel that create an instances of the specified type. |
ServiceFactory |
getServiceFactory(Class type)
Gets the first service factory registered with the kernel that creates an instance of the specified type. |
ServiceFactory |
getServiceFactory(ServiceName serviceName)
Gets the service factory registered under the specified name. |
List |
getServices(Class type)
Gets the all of running service registered with the kernel that are an instances of the specified type. |
long |
getServiceStartTime(ServiceName serviceName)
Gets the time the specified service entered the RUNNING state since the epoch (January 1, 1970, 00:00:00) in milliseconds. |
ServiceState |
getServiceState(ServiceName serviceName)
Gets the ServiceState of the specified service. |
boolean |
isRegistered(ServiceName serviceName)
Determines if there is a service registered under the specified name. |
boolean |
isRunning()
Gets the running status of the kernel. |
boolean |
isServiceEnabled(ServiceName serviceName)
Determines if the service can be instantiated in a kernel. |
void |
registerService(ServiceName serviceName,
ServiceFactory serviceFactory)
Registers a service with this kernel. |
void |
removeKernelMonitor(KernelMonitor kernelMonitor)
Removes a kernel monitor. |
void |
removeServiceMonitor(ServiceMonitor serviceMonitor)
Removes a service monitor. |
void |
setServiceEnabled(ServiceName serviceName,
boolean enabled)
Sets the enabled status of a service. |
void |
startService(ServiceName serviceName)
Immediately starts the service using the SYNCHRONOUS start strategy. |
void |
startService(ServiceName serviceName,
StartStrategy startStrategy)
Immediately starts the service using the specified start strategy. |
void |
startServiceRecursive(ServiceName serviceName)
Immediately starts the service, and if the start ultimately completes successfully, all services owned by the specified service, all services that are owned by those services, and so on, will be started using the startServiceRecursive(ServiceName) method. |
void |
startServiceRecursive(ServiceName serviceName,
StartStrategy startStrategy)
Immediately starts the service, and if the start ultimately completes successfully, all services owned by the specified service, all services that are owned by those services, and so on, will be started using the startServiceRecursive(ServiceName, StartStrategy) method. |
void |
stopService(ServiceName serviceName)
Immediately stops the service using the SYNCHRONOUS stop strategy. |
void |
stopService(ServiceName serviceName,
StopStrategy stopStrategy)
Immediately stops the service using the specified stop strategy. |
void |
unregisterService(ServiceName serviceName)
Unregisters a service from this kernel. |
void |
unregisterService(ServiceName serviceName,
StopStrategy stopStrategy)
Unregisters a service from this kernel. |
void |
waitForDestruction()
Waits for the kernel to be destroyed. |
Method Detail |
---|
void destroy()
void waitForDestruction()
boolean isRunning()
String getKernelName()
void registerService(ServiceName serviceName, ServiceFactory serviceFactory) throws ServiceAlreadyExistsException, ServiceRegistrationException
serviceName
- the unique name of the service in the kernelserviceFactory
- the factory used to create the service
ServiceAlreadyExistsException
- if service is already registered with the specified name
ServiceRegistrationException
- if the service is not restartable and an error occured while starting the servicevoid unregisterService(ServiceName serviceName) throws ServiceNotFoundException, ServiceRegistrationException
serviceName
- the unique name of the service in the kernel
ServiceNotFoundException
- if there is no service registered under the specified name
ServiceRegistrationException
- if the service could not be stoppedvoid unregisterService(ServiceName serviceName, StopStrategy stopStrategy) throws ServiceNotFoundException, ServiceRegistrationException
serviceName
- the unique name of the service in the kernelstopStrategy
- the strategy that determines how unsatisfied conditions are handled
ServiceNotFoundException
- if there is no service registered under the specified name
ServiceRegistrationException
- if the service could not be stoppedboolean isRegistered(ServiceName serviceName)
serviceName
- the unique name of the service
ServiceState getServiceState(ServiceName serviceName) throws ServiceNotFoundException
serviceName
- the unique name of the service in the kernel
ServiceNotFoundException
- if there is no service registered under the specified namelong getServiceStartTime(ServiceName serviceName) throws ServiceNotFoundException
serviceName
- the unique name of the service in the kernel
ServiceNotFoundException
- if there is no service registered under the specified namevoid startService(ServiceName serviceName) throws ServiceNotFoundException, IllegalServiceStateException, UnsatisfiedConditionsException, Exception
serviceName
- the unique name of the service to start
ServiceNotFoundException
- if there is no service registered under the specified name
IllegalServiceStateException
- if the service is restartable and is in the STOPPING state or if the
service is disabled
UnsatisfiedConditionsException
- if some of the start conditions can not be immediately satisfied
Exception
- if service construction threw an Exceptionvoid startService(ServiceName serviceName, StartStrategy startStrategy) throws ServiceNotFoundException, IllegalServiceStateException, UnsatisfiedConditionsException, Exception
serviceName
- the unique name of the service to startstartStrategy
- the strategy that determines how unsatisfied conditions and construction exceptions are handled
ServiceNotFoundException
- if there is no service registered under the specified name
IllegalServiceStateException
- if the service is restartable and is in the STOPPING state or if the
service is disabled
UnsatisfiedConditionsException
- if some of the start conditions can not be immediately satisfied
Exception
- if service construction threw an Exceptionvoid startServiceRecursive(ServiceName serviceName) throws ServiceNotFoundException, IllegalServiceStateException, UnsatisfiedConditionsException, Exception
serviceName
- the unique name of the service to start recursively
ServiceNotFoundException
- if there is no service registered under the specified name
IllegalServiceStateException
- if the service is restartable and is in the STOPPING state or if the
service is disabled
UnsatisfiedConditionsException
- if some of the start conditions can not be immediately satisfied
Exception
- if service construction threw an Exceptionvoid startServiceRecursive(ServiceName serviceName, StartStrategy startStrategy) throws ServiceNotFoundException, IllegalServiceStateException, UnsatisfiedConditionsException, Exception
serviceName
- the unique name of the service to start recursivelystartStrategy
- the strategy that determines how unsatisfied conditions and construction exceptions are handled
ServiceNotFoundException
- if there is no service registered under the specified name
IllegalServiceStateException
- if the service is restartable and is in the STOPPING state or if the
service is disabled
UnsatisfiedConditionsException
- if some of the start conditions can not be immediately satisfied
Exception
- if service construction threw an Exceptionvoid stopService(ServiceName serviceName) throws ServiceNotFoundException, UnsatisfiedConditionsException
serviceName
- the unique name of the service to stop
ServiceNotFoundException
- if there is no service registered under the specified name
UnsatisfiedConditionsException
void stopService(ServiceName serviceName, StopStrategy stopStrategy) throws ServiceNotFoundException, UnsatisfiedConditionsException
serviceName
- the unique name of the service to stopstopStrategy
- the strategy that determines how unsatisfied conditions are handled
ServiceNotFoundException
- if there is no service registered under the specified name
UnsatisfiedConditionsException
boolean isServiceEnabled(ServiceName serviceName) throws ServiceNotFoundException
kernel.getServiceFactory(serviceName).isEnabled();
serviceName
- the unique name of the service
ServiceNotFoundException
- if there is no service registered under the specified namevoid setServiceEnabled(ServiceName serviceName, boolean enabled) throws ServiceNotFoundException
kernel.getServiceFactory(serviceName).setEnabled(enabled);
serviceName
- the unique name of the serviceenabled
- the new enabled state of this factory
ServiceNotFoundException
- if there is no service registered under the specified nameObject getService(ServiceName serviceName) throws ServiceNotFoundException, IllegalArgumentException
serviceName
- the unique name of the service
ServiceNotFoundException
- if there is no service registered under the specified name
IllegalArgumentException
- if the service is not in the RUNNING, or STARTING stateObject getService(Class type)
type
- the of the desired service
List getServices(Class type)
type
- the of the desired service
ServiceFactory getServiceFactory(ServiceName serviceName) throws ServiceNotFoundException
serviceName
- the unique name of the service
ServiceNotFoundException
- if there is no service registered under the specified nameServiceFactory getServiceFactory(Class type)
type
- the of the desired service
List getServiceFactories(Class type)
type
- the of the desired service
ClassLoader getClassLoaderFor(ServiceName serviceName) throws ServiceNotFoundException
serviceName
- the unique name of the service
ServiceNotFoundException
- if there is no service registered under the specified namevoid addKernelMonitor(KernelMonitor kernelMonitor)
kernelMonitor
- the kernel monitor to addvoid removeKernelMonitor(KernelMonitor kernelMonitor)
kernelMonitor
- the kernel monitor to removevoid addServiceMonitor(ServiceMonitor serviceMonitor)
Note: the order in which service monitors are notified is not specified.addServiceMonitor(serviceMonitor, null);
serviceMonitor
- the service monitor to addvoid addServiceMonitor(ServiceMonitor serviceMonitor, ServiceName serviceName)
serviceMonitor
- the service monitor to addserviceName
- the unique name of the service to monitor or null to monitor all servicesvoid removeServiceMonitor(ServiceMonitor serviceMonitor)
serviceMonitor
- the service monitor to remove
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |