org.apache.xbean.kernel
Class KernelFactory

java.lang.Object
  extended by org.apache.xbean.kernel.KernelFactory
Direct Known Subclasses:
StandardKernelFactory

public abstract class KernelFactory
extends Object

The Kernel factory is used to construct and locate Kernels. This class is loosly based on the SAXParserFactory and the JMX MBeanServerFactory. To constuct a kernel use the following:

 Kernel kernel = KernelFactory.newInstance().createKernel(name);
 

Since:
2.0
Author:
Dain Sundstrom

Field Summary
static String KERNEL_FACTORY_KEY
          The name of the system property and META-INF/services used to locate the kernel factory class.
 
Constructor Summary
KernelFactory()
           
 
Method Summary
 Kernel createKernel(String name)
          Creates a new kernel instance and registers it with the static KernelFactory registry.
protected abstract  Kernel createKernelInternal(String name)
          Creates the actual kernel instance which will be registerd in the KernelFactory.
static void destroyInstance(Kernel kernel)
          Removes the kernel instance from the internal kernel registry.
static Kernel getKernel(String name)
          Gets the kernel registered under the specified name.
static Map getKernels()
          Gets a map of the existing kernels by kernel name.
static KernelFactory newInstance()
          Creates a kernel with the specified name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KERNEL_FACTORY_KEY

public static final String KERNEL_FACTORY_KEY
The name of the system property and META-INF/services used to locate the kernel factory class.

Constructor Detail

KernelFactory

public KernelFactory()
Method Detail

getKernel

public static Kernel getKernel(String name)
Gets the kernel registered under the specified name. If no kernel is registered with the specified name, null is returned.

Parameters:
name - the name of the kernel to return
Returns:
the kernel or null if no kernel is registered under the specified name

getKernels

public static Map getKernels()
Gets a map of the existing kernels by kernel name.

Returns:
the existing kernels by kernel name.

newInstance

public static KernelFactory newInstance()
                                 throws KernelFactoryError
Creates a kernel with the specified name. This method will attempt to locate a KernelFactory implementation using the following procedure The factory class is loaded and constucted using the thread context class loader, if present, or the class loader of this class.

Returns:
the kernel factory implementation
Throws:
KernelFactoryError - if the specified kernel factory can not be created

destroyInstance

public static void destroyInstance(Kernel kernel)
                            throws KernelFactoryError
Removes the kernel instance from the internal kernel registry. This method should only be called by the kernel instance itself during destruction.

Parameters:
kernel - the kernel to destroy
Throws:
KernelFactoryError - if the kernel is still running

createKernel

public final Kernel createKernel(String name)
                          throws KernelAlreadyExistsException
Creates a new kernel instance and registers it with the static KernelFactory registry. This allows the kernel to be retrieved from the getKernel(String) method.

Parameters:
name - the name of the kernel to create
Returns:
the new kernel
Throws:
KernelAlreadyExistsException - is a kernel already exists with the specified name

createKernelInternal

protected abstract Kernel createKernelInternal(String name)
Creates the actual kernel instance which will be registerd in the KernelFactory.

Parameters:
name - the kernel name
Returns:
a new kernel instance


Copyright © 2005-2009 Apache Software Foundation. All Rights Reserved.