org.apache.geronimo.kernel.basic
Class BasicKernel

java.lang.Object
  extended byorg.apache.geronimo.kernel.basic.BasicKernel
All Implemented Interfaces:
Kernel

public class BasicKernel
extends java.lang.Object
implements Kernel

The core of a Geronimo instance. A Kernel is responsible for managing the Configurations that comprise a Geronimo system and exposing them using JMX. Each Kernel is associated with an MBeanServer that is used to register the Configurations themselves and the MBeans they define.

Dependencies between MBeans are handled by a dedicated DependencyManager that is responsible for tracking those dependencies and ensuring that the dependent objects follow the appropriate lifecycle and receive appropriate notifications.

The Kernel also provides a ConfigurationStore which is used to stage installed Configurations (providing a local filesystem based classpath) and used hold the persistent state of each Configuration. This allows Configurations to restart in the event of system failure. TODO: Describe the order of method invocation (e.g. if loadGbean may be before boot)

Version:
$Rev: 154947 $ $Date: 2005-02-22 20:10:45 -0800 (Tue, 22 Feb 2005) $

Field Summary
private  java.util.Date bootTime
          The timestamp when the kernel was started
private  DependencyManager dependencyManager
          This manager is used by the kernel to manage dependencies between gbeans
private  java.lang.String kernelName
          Name of this kernel
private  BasicLifecycleMonitor lifecycleMonitor
          Monitors the lifecycle of all gbeans.
private  Log log
          The log
private static java.lang.Object[] NO_ARGS
           
private static java.lang.String[] NO_TYPES
          Helper objects for invoke and getAttribute
private  ProxyManager proxyManager
          This factory gbean proxies, and tracks all proxies in the system
private  LifecycleMonitor publicLifecycleMonitor
           
private  BasicRegistry registry
          The registry
private  boolean running
          Is this kernel running?
private  java.util.LinkedList shutdownHooks
          Listeners for when the kernel shutdown
 
Fields inherited from interface org.apache.geronimo.kernel.Kernel
KERNEL
 
Constructor Summary
BasicKernel(java.lang.String kernelName)
          Construct a Kernel with the specified name.
 
Method Summary
 void boot()
          Boot this Kernel, triggering the instantiation of the MBeanServer and DependencyManager, and the registration of ConfigurationStore
private  GBeanName createGBeanName(javax.management.ObjectName objectName)
           
 java.lang.Object getAttribute(javax.management.ObjectName objectName, java.lang.String attributeName)
          Gets the value of an attribute on the specified gbean
 java.util.Date getBootTime()
          Returns the time this kernel was last booted.
 java.lang.ClassLoader getClassLoaderFor(javax.management.ObjectName name)
          Gets the ClassLoader used to register the specified GBean
 DependencyManager getDependencyManager()
          Gets the dependency manager kernel service
 GBeanData getGBeanData(javax.management.ObjectName name)
          Return the GBeanData for a GBean instance.
 GBeanInfo getGBeanInfo(javax.management.ObjectName name)
          Return the GBeanInfo for a registered GBean instance.
 long getGBeanStartTime(javax.management.ObjectName name)
          Gets the time the specified GBean was started
 int getGBeanState(javax.management.ObjectName name)
          Gets the state of the specified GBean.
 java.lang.String getKernelName()
          Get the name of this kernel
 LifecycleMonitor getLifecycleMonitor()
          Deprecated. don't use this yet... it may change or go away
 ProxyManager getProxyManager()
          Deprecated. don't use this yet... it may change or go away
 java.lang.Object invoke(javax.management.ObjectName objectName, java.lang.String methodName)
          Invokes a no-argument method on the specified GBean
 java.lang.Object invoke(javax.management.ObjectName objectName, java.lang.String methodName, java.lang.Object[] args, java.lang.String[] types)
          Invokes a method on the specified GBean with the specified arguments
 boolean isGBeanEnabled(javax.management.ObjectName name)
          Is the specified GBean enabled?
 boolean isLoaded(javax.management.ObjectName name)
          Is there a GBean registered with the kernel under the specified name?
 boolean isRunning()
          Has the kernel been booted
 java.util.Set listGBeans(javax.management.ObjectName pattern)
          Returns a Set of all GBeans matching the object name pattern
 java.util.Set listGBeans(java.util.Set patterns)
          Returns a Set of all GBeans matching the set of object name pattern
 void loadGBean(GBeanData gbeanData, java.lang.ClassLoader classLoader)
          Load a specific GBean into this kernel.
private  void notifyShutdownHooks()
           
 void registerShutdownHook(java.lang.Runnable hook)
          Registers a runnable to execute when the kernel is shutdown
 void setAttribute(javax.management.ObjectName objectName, java.lang.String attributeName, java.lang.Object attributeValue)
          Sets the value of an attribute on the specified gbean
 void setGBeanEnabled(javax.management.ObjectName name, boolean enabled)
          Sets the eneabled status of the specified GBean.
 void shutdown()
          Shut down this kernel instance, unregistering the MBeans and releasing the MBeanServer.
 void startGBean(javax.management.ObjectName name)
          Start a specific GBean.
 void startRecursiveGBean(javax.management.ObjectName name)
          Start a specific GBean and its children.
 void stopGBean(javax.management.ObjectName name)
          Stop a specific GBean.
 void unloadGBean(javax.management.ObjectName name)
          Unload a specific GBean.
 void unregisterShutdownHook(java.lang.Runnable hook)
          Unregisters a runnable from the list to execute when the kernel is shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_TYPES

private static final java.lang.String[] NO_TYPES
Helper objects for invoke and getAttribute


NO_ARGS

private static final java.lang.Object[] NO_ARGS

kernelName

private final java.lang.String kernelName
Name of this kernel


log

private Log log
The log


running

private boolean running
Is this kernel running?


bootTime

private java.util.Date bootTime
The timestamp when the kernel was started


registry

private final BasicRegistry registry
The registry


shutdownHooks

private java.util.LinkedList shutdownHooks
Listeners for when the kernel shutdown


dependencyManager

private DependencyManager dependencyManager
This manager is used by the kernel to manage dependencies between gbeans


lifecycleMonitor

private BasicLifecycleMonitor lifecycleMonitor
Monitors the lifecycle of all gbeans.


publicLifecycleMonitor

private LifecycleMonitor publicLifecycleMonitor

proxyManager

private ProxyManager proxyManager
This factory gbean proxies, and tracks all proxies in the system

Constructor Detail

BasicKernel

public BasicKernel(java.lang.String kernelName)
Construct a Kernel with the specified name.

Parameters:
kernelName - the name of the kernel
Method Detail

getKernelName

public java.lang.String getKernelName()
Description copied from interface: Kernel
Get the name of this kernel

Specified by:
getKernelName in interface Kernel
Returns:
the name of this kernel

getDependencyManager

public DependencyManager getDependencyManager()
Deprecated. this will be removed as when we add generalized dependencies to gbeans... the only current user is Configuration

Description copied from interface: Kernel
Gets the dependency manager kernel service

Specified by:
getDependencyManager in interface Kernel
Returns:
the dependency manager or null if the kernel is not running

getLifecycleMonitor

public LifecycleMonitor getLifecycleMonitor()
Deprecated. don't use this yet... it may change or go away

Gets the lifecycle monitor.

Specified by:
getLifecycleMonitor in interface Kernel
Returns:
the lifecycle monitor or null if the kernel is not running

getProxyManager

public ProxyManager getProxyManager()
Deprecated. don't use this yet... it may change or go away

Gets the proxy manager.

Specified by:
getProxyManager in interface Kernel
Returns:
the proxy manager or null if the kernel is not running

getAttribute

public java.lang.Object getAttribute(javax.management.ObjectName objectName,
                                     java.lang.String attributeName)
                              throws GBeanNotFoundException,
                                     NoSuchAttributeException,
                                     java.lang.Exception
Description copied from interface: Kernel
Gets the value of an attribute on the specified gbean

Specified by:
getAttribute in interface Kernel
Parameters:
objectName - the name of the gbean from which the attribute will be retrieved
attributeName - the name of the attribute to fetch
Returns:
the value of the attribute
Throws:
NoSuchAttributeException - if the gbean does not contain the specified attribute
java.lang.Exception - if the gbean throws an exception from the getter
GBeanNotFoundException - if there is not a gbean under the specified name

setAttribute

public void setAttribute(javax.management.ObjectName objectName,
                         java.lang.String attributeName,
                         java.lang.Object attributeValue)
                  throws GBeanNotFoundException,
                         NoSuchAttributeException,
                         java.lang.Exception
Description copied from interface: Kernel
Sets the value of an attribute on the specified gbean

Specified by:
setAttribute in interface Kernel
Parameters:
objectName - the name of the gbean from in which the new attribute value will be set
attributeName - the name of the attribute to set
attributeValue - the new value of the attribute
Throws:
java.lang.Exception - if the gbean throws an exception from the setter
NoSuchAttributeException - if the gbean does not contain the specified attribute
GBeanNotFoundException - if there is not a gbean under the specified name

invoke

public java.lang.Object invoke(javax.management.ObjectName objectName,
                               java.lang.String methodName)
                        throws GBeanNotFoundException,
                               NoSuchOperationException,
                               InternalKernelException,
                               java.lang.Exception
Description copied from interface: Kernel
Invokes a no-argument method on the specified GBean

Specified by:
invoke in interface Kernel
Parameters:
objectName - the name of the gbean from in which the new attribute value will be set
methodName - the name of the method to invoke
Returns:
the return value of the method or null if the specified method does not return a value
Throws:
java.lang.Exception - if the method throws an exception
InternalKernelException - if an error occurs within the kernel itself
NoSuchOperationException - if the gbean does not have the specified operation
GBeanNotFoundException - if there is not a gbean under the specified name

invoke

public java.lang.Object invoke(javax.management.ObjectName objectName,
                               java.lang.String methodName,
                               java.lang.Object[] args,
                               java.lang.String[] types)
                        throws GBeanNotFoundException,
                               NoSuchOperationException,
                               InternalKernelException,
                               java.lang.Exception
Description copied from interface: Kernel
Invokes a method on the specified GBean with the specified arguments

Specified by:
invoke in interface Kernel
Parameters:
objectName - the name of the gbean from in which the new attribute value will be set
methodName - the name of the method to invoke
args - the arguments to pass to the method
types - the types of the arguments; the types are used to determine the signature of the mehod that should be invoked
Returns:
the return value of the method or null if the specified method does not return a value
Throws:
GBeanNotFoundException - if there is not a gbean under the specified name
NoSuchOperationException - if the gbean does not have the specified operation
InternalKernelException - if an error occurs within the kernel itself
java.lang.Exception - if the method throws an exception

isLoaded

public boolean isLoaded(javax.management.ObjectName name)
Description copied from interface: Kernel
Is there a GBean registered with the kernel under the specified name?

Specified by:
isLoaded in interface Kernel
Parameters:
name - the name to check
Returns:
true if there is a gbean registered under the specified name; false otherwise

getGBeanInfo

public GBeanInfo getGBeanInfo(javax.management.ObjectName name)
                       throws GBeanNotFoundException
Description copied from interface: Kernel
Return the GBeanInfo for a registered GBean instance.

Specified by:
getGBeanInfo in interface Kernel
Parameters:
name - the name of the GBean whose info should be returned
Returns:
the info for that instance
Throws:
GBeanNotFoundException - if there is no instance with the supplied name

getGBeanData

public GBeanData getGBeanData(javax.management.ObjectName name)
                       throws GBeanNotFoundException,
                              InternalKernelException
Description copied from interface: Kernel
Return the GBeanData for a GBean instance.

Specified by:
getGBeanData in interface Kernel
Parameters:
name - the name of the GBean whose info should be returned
Returns:
the info for that instance
Throws:
GBeanNotFoundException - if there is no instance with the supplied name
InternalKernelException

loadGBean

public void loadGBean(GBeanData gbeanData,
                      java.lang.ClassLoader classLoader)
               throws GBeanAlreadyExistsException,
                      InternalKernelException
Description copied from interface: Kernel
Load a specific GBean into this kernel. This is intended for applications that are embedding the kernel.

Specified by:
loadGBean in interface Kernel
Parameters:
gbeanData - the GBean to load
classLoader - the class loader to use to load the gbean
Throws:
GBeanAlreadyExistsException - if the name is already used
InternalKernelException - if there is a problem during registration

startGBean

public void startGBean(javax.management.ObjectName name)
                throws GBeanNotFoundException,
                       InternalKernelException,
                       java.lang.IllegalStateException
Description copied from interface: Kernel
Start a specific GBean.

Specified by:
startGBean in interface Kernel
Parameters:
name - the GBean to start
Throws:
java.lang.IllegalStateException - If the gbean is disabled
GBeanNotFoundException - if the GBean could not be found
InternalKernelException - if there GBean is not state manageable or if there is a general error

startRecursiveGBean

public void startRecursiveGBean(javax.management.ObjectName name)
                         throws GBeanNotFoundException,
                                InternalKernelException,
                                java.lang.IllegalStateException
Description copied from interface: Kernel
Start a specific GBean and its children.

Specified by:
startRecursiveGBean in interface Kernel
Parameters:
name - the GBean to start
Throws:
java.lang.IllegalStateException - If the gbean is disabled
GBeanNotFoundException - if the GBean could not be found
InternalKernelException - if there GBean is not state manageable or if there is a general error

stopGBean

public void stopGBean(javax.management.ObjectName name)
               throws GBeanNotFoundException,
                      InternalKernelException,
                      java.lang.IllegalStateException
Description copied from interface: Kernel
Stop a specific GBean.

Specified by:
stopGBean in interface Kernel
Parameters:
name - the GBean to stop
Throws:
GBeanNotFoundException - if the GBean could not be found
InternalKernelException - if there GBean is not state manageable or if there is a general error
java.lang.IllegalStateException - If the gbean is disabled

unloadGBean

public void unloadGBean(javax.management.ObjectName name)
                 throws GBeanNotFoundException,
                        InternalKernelException,
                        java.lang.IllegalStateException
Description copied from interface: Kernel
Unload a specific GBean. This is intended for applications that are embedding the kernel.

Specified by:
unloadGBean in interface Kernel
Parameters:
name - the name of the GBean to unregister
Throws:
InternalKernelException - if there GBean is a problem while unloading the GBean
GBeanNotFoundException - if the GBean could not be found
java.lang.IllegalStateException

getGBeanState

public int getGBeanState(javax.management.ObjectName name)
                  throws GBeanNotFoundException
Description copied from interface: Kernel
Gets the state of the specified GBean.

Specified by:
getGBeanState in interface Kernel
Parameters:
name - the name of the GBean
Returns:
the state of the GBean
Throws:
GBeanNotFoundException - if the GBean could not be found

getGBeanStartTime

public long getGBeanStartTime(javax.management.ObjectName name)
                       throws GBeanNotFoundException
Description copied from interface: Kernel
Gets the time the specified GBean was started

Specified by:
getGBeanStartTime in interface Kernel
Parameters:
name - the name of the GBean
Returns:
the start time of the GBean or 0 if not running
Throws:
GBeanNotFoundException - if the GBean could not be found

isGBeanEnabled

public boolean isGBeanEnabled(javax.management.ObjectName name)
                       throws GBeanNotFoundException
Description copied from interface: Kernel
Is the specified GBean enabled?

Specified by:
isGBeanEnabled in interface Kernel
Parameters:
name - the name if the GBean
Returns:
true if the gbean is enabled
Throws:
GBeanNotFoundException - if the GBean could not be found

setGBeanEnabled

public void setGBeanEnabled(javax.management.ObjectName name,
                            boolean enabled)
                     throws GBeanNotFoundException
Description copied from interface: Kernel
Sets the eneabled status of the specified GBean. A disabled gbean can not be started, and will not be started via startRecursive.

Specified by:
setGBeanEnabled in interface Kernel
Parameters:
name - the name if the GBean
enabled - the new enabled status
Throws:
GBeanNotFoundException - if the GBean could not be found

listGBeans

public java.util.Set listGBeans(javax.management.ObjectName pattern)
Description copied from interface: Kernel
Returns a Set of all GBeans matching the object name pattern

Specified by:
listGBeans in interface Kernel
Returns:
a List of javax.management.ObjectName of matching GBeans registered with this kernel

listGBeans

public java.util.Set listGBeans(java.util.Set patterns)
Description copied from interface: Kernel
Returns a Set of all GBeans matching the set of object name pattern

Specified by:
listGBeans in interface Kernel
Returns:
a List of javax.management.ObjectName of matching GBeans registered with this kernel

boot

public void boot()
          throws java.lang.Exception
Boot this Kernel, triggering the instantiation of the MBeanServer and DependencyManager, and the registration of ConfigurationStore

Specified by:
boot in interface Kernel
Throws:
java.lang.Exception - if the boot fails

getBootTime

public java.util.Date getBootTime()
Description copied from interface: Kernel
Returns the time this kernel was last booted.

Specified by:
getBootTime in interface Kernel
Returns:
the time this kernel was last booted; null if the kernel has not been

registerShutdownHook

public void registerShutdownHook(java.lang.Runnable hook)
Description copied from interface: Kernel
Registers a runnable to execute when the kernel is shutdown

Specified by:
registerShutdownHook in interface Kernel
Parameters:
hook - a runnable to execute when the kernel is shutdown

unregisterShutdownHook

public void unregisterShutdownHook(java.lang.Runnable hook)
Description copied from interface: Kernel
Unregisters a runnable from the list to execute when the kernel is shutdown

Specified by:
unregisterShutdownHook in interface Kernel
Parameters:
hook - the runnable that should be removed

shutdown

public void shutdown()
Shut down this kernel instance, unregistering the MBeans and releasing the MBeanServer.

Specified by:
shutdown in interface Kernel

notifyShutdownHooks

private void notifyShutdownHooks()

isRunning

public boolean isRunning()
Description copied from interface: Kernel
Has the kernel been booted

Specified by:
isRunning in interface Kernel
Returns:
true if the kernel has been booted; false otherwise

getClassLoaderFor

public java.lang.ClassLoader getClassLoaderFor(javax.management.ObjectName name)
                                        throws GBeanNotFoundException
Description copied from interface: Kernel
Gets the ClassLoader used to register the specified GBean

Specified by:
getClassLoaderFor in interface Kernel
Parameters:
name - the name of the gbean from which the class loader should be extracted
Returns:
the class loader associated with the specified GBean
Throws:
GBeanNotFoundException - if the specified GBean is not registered with the kernel

createGBeanName

private GBeanName createGBeanName(javax.management.ObjectName objectName)


Copyright © 2005 Apache Software Foundation. All Rights Reserved.