|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.xbean.kernel.standard.StandardKernel
public class StandardKernel
The standard kernel implementation.
Constructor Summary | |
---|---|
StandardKernel(String kernelName)
Creates a kernel using the specified name. |
|
StandardKernel(String kernelName,
ExecutorService serviceExecutor,
long timeoutDuration,
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. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StandardKernel(String kernelName)
kernelName
- the unique name of this kernelpublic StandardKernel(String kernelName, ExecutorService serviceExecutor, long timeoutDuration, 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 String getKernelName()
getKernelName
in interface Kernel
public void registerService(ServiceName serviceName, ServiceFactory serviceFactory) throws ServiceAlreadyExistsException, ServiceRegistrationException
registerService
in interface Kernel
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 servicepublic 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, Exception
startService
in interface Kernel
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 Exceptionpublic void startService(ServiceName serviceName, StartStrategy startStrategy) throws ServiceNotFoundException, IllegalServiceStateException, UnsatisfiedConditionsException, 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
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 Exceptionpublic void startServiceRecursive(ServiceName serviceName) throws ServiceNotFoundException, IllegalServiceStateException, UnsatisfiedConditionsException, Exception
startServiceRecursive
in interface Kernel
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 Exceptionpublic void startServiceRecursive(ServiceName serviceName, StartStrategy startStrategy) throws ServiceNotFoundException, IllegalServiceStateException, UnsatisfiedConditionsException, 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
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 Exceptionpublic 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 Object getService(ServiceName serviceName) throws ServiceNotFoundException, IllegalArgumentException
getService
in interface Kernel
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 statepublic Object getService(Class type)
getService
in interface Kernel
type
- the of the desired service
public List getServices(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(Class type)
getServiceFactory
in interface Kernel
type
- the of the desired service
public List getServiceFactories(Class type)
getServiceFactories
in interface Kernel
type
- the of the desired service
public 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 |