|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.xbean.kernel.standard.StandardKernel
The standard kernel implementation.
Constructor Summary | |
StandardKernel(java.lang.String kernelName)
Creates a kernel using the specified name. |
|
StandardKernel(java.lang.String kernelName,
edu.emory.mathcs.backport.java.util.concurrent.Executor serviceExecutor,
long timeoutDuration,
edu.emory.mathcs.backport.java.util.concurrent.TimeUnit timeoutUnits)
Creates a kernel using the specified 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. This method is equivalent to: Note: the order in which service monitors are notified is not specified.addServiceMonitor(serviceMonitor, null); |
void |
addServiceMonitor(ServiceMonitor serviceMonitor,
ServiceName serviceName)
Adds a service monitor for a specific service. Note: the order in which service monitors are notified is not specified. |
void |
destroy()
Destroys this kernel. This method causes all services to be stopped and unregistered. |
java.lang.ClassLoader |
getClassLoaderFor(ServiceName serviceName)
Gets the class loader associated with the specifed service. |
java.lang.String |
getKernelName()
Gets the unique name of this kernel within the KernelFactory. |
java.lang.Object |
getService(java.lang.Class type)
Gets the first running service registered with the kernel that is an instance of the specified type. If no running services are instances of the specified type, null is returned. |
java.lang.Object |
getService(ServiceName serviceName)
Gets the service registered under the specified name. If the service is not in the RUNNING, or STARTING state this method will throw an IllegalArgumentException. |
java.util.List |
getServiceFactories(java.lang.Class type)
Gets the all of the service factories registered with the kernel that create an instances of the specified type. If no service factories create an instance of the specified type, an empty list is returned. |
ServiceFactory |
getServiceFactory(java.lang.Class type)
Gets the first service factory registered with the kernel that creates an instance of the specified type. If no service factories create an instance of the specified type, null is returned. |
ServiceFactory |
getServiceFactory(ServiceName serviceName)
Gets the service factory registered under the specified name. |
java.util.List |
getServices(java.lang.Class type)
Gets the all of running service registered with the kernel that are an instances of the specified type. If no running services are instances of the specified type, an empty list is returned |
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. If the service is in the STOPPED or STARTING states, this method will return 0. |
ServiceState |
getServiceState(ServiceName serviceName)
Gets the ServiceState of the specified service. If the service is not restartable, this method will always return RUNNING. |
boolean |
isRegistered(ServiceName serviceName)
Determines if there is a service registered under the specified name. |
boolean |
isRunning()
Gets the running status of the kernel. Services can not be registered or started on a stopped kernel. |
boolean |
isServiceEnabled(ServiceName serviceName)
Determines if the service can be instantiated in a kernel. A disabled restartable service can not be started. This method is equivalent to: kernel.getServiceFactory(serviceName).isEnabled(); |
void |
registerService(ServiceName serviceName,
ServiceFactory serviceFactory,
java.lang.ClassLoader classLoader)
Registers a service with this kernel. If the service is restartable, it will enter the server in the STOPPED state. If a service is not restartable, the kernel will assure that all dependencies are satisfied and service will enter the kernel in the RUNNING state. If a dependency for a non-restartable service is not immediately satisfiable, this method will throw a ServiceRegistrationException. |
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. A disabled restartable service can not be started. This state has no effect on a service that is already started, but if a running service is disabled, it can not be restarted. This method is equivalent to: kernel.getServiceFactory(serviceName).setEnabled(enabled); |
void |
startService(ServiceName serviceName)
Immediately starts the service using the SYNCHRONOUS start strategy. Any exception throw from service constuction is throw directly from this method. If a start condition can not be immediately satisfied, a UnsatisfiedConditionsException will be thrown. If a service already in the RUNNING state, or is not restartable, this method is a noop. If the service is in the STOPPING state an IllegalServiceStateException will be thrown. If the service is disabled, this method will throw an IllegalServiceStateException. This method has no effect on as service that is not restartable. |
void |
startService(ServiceName serviceName,
StartStrategy startStrategy)
Immediately starts the service using the specified start strategy. The start strategy determines how any exception thrown from service constuction is handled including throwing the exception directly from this method. The start strategy determines what to do if a start condition can not be immediately satisfied. Possibilities include throwing an UnsatisfiedConditionsException, blocking, leaving the service in the RUNNING state, or unregistering the service. If a service already in the RUNNING state, or is not restartable, this method is a noop. If the service is in the STOPPING state an IllegalServiceStateException will be thrown. If the service is disabled, this method will throw an IllegalServiceStateException. This method has no effect on as service that is not restartable. |
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. If a stop condition can not be immediately satisfied, an UnsatisfiedConditionsException will be thrown. If a service already in the STOPPED state, this method is a noop. If the service is not restartable, this method only attempts to satify the stop conditions. This is useful for stopping all dependent services of a non-restartable service before unregistering the service. |
void |
stopService(ServiceName serviceName,
StopStrategy stopStrategy)
Immediately stops the service using the specified stop strategy. If a stop condition can not be immediately satisfied, an UnsatisfiedConditionsException will be thrown. If a service already in the STOPPED state, this method is a noop. If the service is not restartable, this method only attempts to satify the stop conditions. This is useful for stopping all dependent services of a non-restartable service before unregistering the service. |
void |
unregisterService(ServiceName serviceName)
Unregisters a service from this kernel. The kernel will attempt to stop the service using the SYNCHRONOUS stop strategy, but if it can not stop the service a ServiceRegistrationException will be thrown containing an UnsatisfiedConditionsException. |
void |
unregisterService(ServiceName serviceName,
StopStrategy stopStrategy)
Unregisters a service from this kernel. The kernel will attempt to stop the service using the specified stop strategy, but if it can not stop the service a ServiceRegistrationException will be thrown containing either an UnsatisfiedConditionsException or a IllegalServiceStateException. |
void |
waitForDestruction()
Waits for the kernel to be destroyed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StandardKernel(java.lang.String kernelName)
kernelName
- the unique name of this kernelpublic StandardKernel(java.lang.String kernelName, edu.emory.mathcs.backport.java.util.concurrent.Executor serviceExecutor, long timeoutDuration, edu.emory.mathcs.backport.java.util.concurrent.TimeUnit timeoutUnits)
kernelName
- the unique name of this kernelserviceExecutor
- the executor to use for asynchronous service operationstimeoutDuration
- the maximum duration to wait for a service event to completetimeoutUnits
- the unit of measure for the timeoutDurationMethod Detail |
public void destroy() throws KernelErrorsError
destroy
in interface Kernel
KernelErrorsError
public void waitForDestruction()
waitForDestruction
in interface Kernel
public boolean isRunning()
isRunning
in interface Kernel
public java.lang.String getKernelName()
getKernelName
in interface Kernel
public void registerService(ServiceName serviceName, ServiceFactory serviceFactory, java.lang.ClassLoader classLoader) throws ServiceAlreadyExistsException, ServiceRegistrationException
registerService
in interface Kernel
serviceName
- the unique name of the service in the kernelserviceFactory
- the factory used to create the serviceclassLoader
- the class loader to use for this service
ServiceRegistrationException
- if the service is not restartable and an error occured while starting the service
ServiceAlreadyExistsException
- if service is already registered with the specified namepublic void unregisterService(ServiceName serviceName) throws ServiceNotFoundException, ServiceRegistrationException
unregisterService
in interface Kernel
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 stoppedpublic void unregisterService(ServiceName serviceName, StopStrategy stopStrategy) throws ServiceNotFoundException, ServiceRegistrationException
unregisterService
in interface Kernel
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 stoppedpublic boolean isRegistered(ServiceName serviceName)
isRegistered
in interface Kernel
serviceName
- the unique name of the service
public ServiceState getServiceState(ServiceName serviceName) throws ServiceNotFoundException
getServiceState
in interface Kernel
serviceName
- the unique name of the service in the kernel
ServiceNotFoundException
- if there is no service registered under the specified namepublic long getServiceStartTime(ServiceName serviceName) throws ServiceNotFoundException
getServiceStartTime
in interface Kernel
serviceName
- the unique name of the service in the kernel
ServiceNotFoundException
- if there is no service registered under the specified namepublic void startService(ServiceName serviceName) throws ServiceNotFoundException, IllegalServiceStateException, UnsatisfiedConditionsException, java.lang.Exception
startService
in interface Kernel
serviceName
- the unique name of the service to start
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
ServiceNotFoundException
- if there is no service registered under the specified name
java.lang.Exception
- if service construction threw an Exceptionpublic void startService(ServiceName serviceName, StartStrategy startStrategy) throws ServiceNotFoundException, IllegalServiceStateException, UnsatisfiedConditionsException, java.lang.Exception
startService
in interface Kernel
serviceName
- the unique name of the service to startstartStrategy
- the strategy that determines how unsatisfied conditions and construction exceptions are handled
java.lang.Exception
- if service construction threw an Exception
UnsatisfiedConditionsException
- if some of the start conditions can not be immediately satisfied
IllegalServiceStateException
- if the service is restartable and is in the STOPPING state or if the
service is disabled
ServiceNotFoundException
- if there is no service registered under the specified namepublic void startServiceRecursive(ServiceName serviceName) throws ServiceNotFoundException, IllegalServiceStateException, UnsatisfiedConditionsException, java.lang.Exception
startServiceRecursive
in interface Kernel
serviceName
- the unique name of the service to start recursively
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
ServiceNotFoundException
- if there is no service registered under the specified name
java.lang.Exception
- if service construction threw an Exceptionpublic void startServiceRecursive(ServiceName serviceName, StartStrategy startStrategy) throws ServiceNotFoundException, IllegalServiceStateException, UnsatisfiedConditionsException, java.lang.Exception
startServiceRecursive
in interface Kernel
serviceName
- the unique name of the service to start recursivelystartStrategy
- the strategy that determines how unsatisfied conditions and construction exceptions are handled
UnsatisfiedConditionsException
- if some of the start conditions can not be immediately satisfied
ServiceNotFoundException
- if there is no service registered under the specified name
java.lang.Exception
- if service construction threw an Exception
IllegalServiceStateException
- if the service is restartable and is in the STOPPING state or if the
service is disabledpublic void stopService(ServiceName serviceName) throws ServiceNotFoundException, UnsatisfiedConditionsException
stopService
in interface Kernel
serviceName
- the unique name of the service to stop
ServiceNotFoundException
- if there is no service registered under the specified name
UnsatisfiedConditionsException
public void stopService(ServiceName serviceName, StopStrategy stopStrategy) throws ServiceNotFoundException, UnsatisfiedConditionsException
stopService
in interface Kernel
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
public boolean isServiceEnabled(ServiceName serviceName) throws ServiceNotFoundException
kernel.getServiceFactory(serviceName).isEnabled();
isServiceEnabled
in interface Kernel
serviceName
- the unique name of the service
ServiceNotFoundException
- if there is no service registered under the specified namepublic void setServiceEnabled(ServiceName serviceName, boolean enabled) throws ServiceNotFoundException
kernel.getServiceFactory(serviceName).setEnabled(enabled);
setServiceEnabled
in interface Kernel
serviceName
- the unique name of the serviceenabled
- the new enabled state of this factory
ServiceNotFoundException
- if there is no service registered under the specified namepublic java.lang.Object getService(ServiceName serviceName) throws ServiceNotFoundException, java.lang.IllegalArgumentException
getService
in interface Kernel
serviceName
- the unique name of the service
java.lang.IllegalArgumentException
- if the service is not in the RUNNING, or STARTING state
ServiceNotFoundException
- if there is no service registered under the specified namepublic java.lang.Object getService(java.lang.Class type)
getService
in interface Kernel
type
- the of the desired service
public java.util.List getServices(java.lang.Class type)
getServices
in interface Kernel
type
- the of the desired service
public ServiceFactory getServiceFactory(ServiceName serviceName) throws ServiceNotFoundException
getServiceFactory
in interface Kernel
serviceName
- the unique name of the service
ServiceNotFoundException
- if there is no service registered under the specified namepublic ServiceFactory getServiceFactory(java.lang.Class type)
getServiceFactory
in interface Kernel
type
- the of the desired service
public java.util.List getServiceFactories(java.lang.Class type)
getServiceFactories
in interface Kernel
type
- the of the desired service
public java.lang.ClassLoader getClassLoaderFor(ServiceName serviceName) throws ServiceNotFoundException
getClassLoaderFor
in interface Kernel
serviceName
- the unique name of the service
ServiceNotFoundException
- if there is no service registered under the specified namepublic void addKernelMonitor(KernelMonitor kernelMonitor)
addKernelMonitor
in interface Kernel
kernelMonitor
- the kernel monitor to addpublic void removeKernelMonitor(KernelMonitor kernelMonitor)
removeKernelMonitor
in interface Kernel
kernelMonitor
- the kernel monitor to removepublic void addServiceMonitor(ServiceMonitor serviceMonitor)
Note: the order in which service monitors are notified is not specified.addServiceMonitor(serviceMonitor, null);
addServiceMonitor
in interface Kernel
serviceMonitor
- the service monitor to addpublic void addServiceMonitor(ServiceMonitor serviceMonitor, ServiceName serviceName)
addServiceMonitor
in interface Kernel
serviceMonitor
- the service monitor to addserviceName
- the unique name of the service to monitor or null to monitor all servicespublic void removeServiceMonitor(ServiceMonitor serviceMonitor)
removeServiceMonitor
in interface Kernel
serviceMonitor
- the service monitor to remove
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |