You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by do...@apache.org on 2001/04/12 07:32:54 UTC
cvs commit: jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine Embeddor.java PhoenixEmbeddor.java PhoenixKernel.java DefaultSarDeployer.java Main.java AbstractServerKernel.java DefaultServerKernel.java ServerKernel.java
donaldp 01/04/11 22:32:54
Modified: src/java/org/apache/phoenix/engine DefaultSarDeployer.java
Main.java
Added: src/java/org/apache/phoenix/engine Embeddor.java
PhoenixEmbeddor.java PhoenixKernel.java
Removed: src/java/org/apache/phoenix/engine AbstractServerKernel.java
DefaultServerKernel.java ServerKernel.java
Log:
Sync across some of Leos ideas/implementations.
Namely that of embeddor and how it is set up.
Also merged ServerKernel + AbstractServerKernel + DefaultServerKernel into PhoenixKernel
Revision Changes Path
1.5 +31 -30 jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/DefaultSarDeployer.java
Index: DefaultSarDeployer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/DefaultSarDeployer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultSarDeployer.java 2001/04/02 09:10:56 1.4
+++ DefaultSarDeployer.java 2001/04/12 05:32:54 1.5
@@ -22,11 +22,9 @@
import org.apache.avalon.ComponentManager;
import org.apache.avalon.ComponentManagerException;
import org.apache.avalon.Composer;
-import org.apache.avalon.configuration.Configuration;
-import org.apache.avalon.configuration.ConfigurationException;
import org.apache.avalon.DefaultComponentManager;
-import org.apache.avalon.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.DefaultContext;
+import org.apache.avalon.atlantis.Kernel;
import org.apache.avalon.camelot.AbstractCamelotDeployer;
import org.apache.avalon.camelot.CamelotUtil;
import org.apache.avalon.camelot.ContainerException;
@@ -37,13 +35,16 @@
import org.apache.avalon.camelot.Locator;
import org.apache.avalon.camelot.Registry;
import org.apache.avalon.camelot.RegistryException;
+import org.apache.avalon.configuration.Configuration;
+import org.apache.avalon.configuration.ConfigurationException;
+import org.apache.avalon.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.util.io.FileUtil;
import org.apache.avalon.util.io.IOUtil;
import org.apache.phoenix.BlockContext;
-import org.apache.phoenix.metainfo.BlockInfo;
import org.apache.phoenix.engine.blocks.BlockEntry;
-import org.apache.phoenix.engine.blocks.RoleEntry;
import org.apache.phoenix.engine.blocks.DefaultBlockDeployer;
+import org.apache.phoenix.engine.blocks.RoleEntry;
+import org.apache.phoenix.metainfo.BlockInfo;
/**
* This class deploys a .sar file.
@@ -85,7 +86,7 @@
{
final ZipFile zipFile = DeployerUtil.getZipFileFor( file );
- if( !needsExpanding( zipFile, directory ) )
+ if( !needsExpanding( zipFile, directory ) )
{
return;
}
@@ -151,21 +152,21 @@
}
}
- protected ServerKernel getKernel()
+ protected Kernel getKernel()
throws DeploymentException
{
- if( !(m_container instanceof ServerKernel) )
+ if( !(m_container instanceof Kernel) )
{
throw new DeploymentException( "Can only deploy to a kernel container" );
}
else
{
- return (ServerKernel)m_container;
+ return (Kernel)m_container;
}
}
- protected void buildEntry( final String name,
- final ServerApplicationEntry entry,
+ protected void buildEntry( final String name,
+ final ServerApplicationEntry entry,
final File archive,
final File directory )
throws DeploymentException
@@ -193,8 +194,8 @@
entry.setConfiguration( configuration );
}
- protected void deployFromDirectory( final File archive,
- final String name,
+ protected void deployFromDirectory( final File archive,
+ final String name,
final File directory )
throws DeploymentException
{
@@ -205,23 +206,23 @@
buildEntry( name, entry, archive, directory );
addEntry( name, entry );
- final ServerKernel kernel = getKernel();
+ final Kernel kernel = getKernel();
ServerApplication serverApplication = null;
- try
- {
- serverApplication = (ServerApplication)kernel.getApplication( name );
+ try
+ {
+ serverApplication = (ServerApplication)kernel.getApplication( name );
}
- catch( final ContainerException ce )
+ catch( final ContainerException ce )
{
throw new DeploymentException( "Error preparingserver application", ce );
}
//rework next bit so it grabs deployments from archive
final Deployer deployer = getBlockDeployer( entry );
- final File blocksDirectory = new File( directory, "blocks" );
+ final File blocksDirectory = new File( directory, "blocks" );
CamelotUtil.deployFromDirectory( deployer, blocksDirectory, ".bar" );
- final File file =
+ final File file =
new File( directory, "conf" + File.separator + "assembly.xml" );
try
@@ -279,7 +280,7 @@
{
final ComponentManager componentManager = saEntry.getComponentManager();
- final Registry infoRegistry =
+ final Registry infoRegistry =
(Registry)componentManager.lookup( "org.apache.avalon.camelot.Registry" );
final Registry locatorRegistry = (Registry)componentManager.
@@ -294,20 +295,20 @@
BlockInfo info = null;
try { info = (BlockInfo)infoRegistry.getInfo( className, BlockInfo.class ); }
- catch( final RegistryException re )
+ catch( final RegistryException re )
{
- throw new DeploymentException( "Failed to aquire BlockInfo for " + className,
+ throw new DeploymentException( "Failed to aquire BlockInfo for " + className,
re );
}
Locator locator = null;
try { locator = (Locator)locatorRegistry.getInfo( className, Locator.class ); }
- catch( final RegistryException re )
+ catch( final RegistryException re )
{
- throw new DeploymentException( "Failed to aquire Locator for " + className,
+ throw new DeploymentException( "Failed to aquire Locator for " + className,
re );
}
-
+
final Configuration[] provides = block.getChildren( "provide" );
final ArrayList roleList = new ArrayList();
for( int j = 0; j < provides.length; j++ )
@@ -315,9 +316,9 @@
final Configuration provide = provides[ j ];
final String requiredName = provide.getAttribute("name");
final String role = provide.getAttribute("role");
-
+
roleList.add( new RoleEntry( requiredName, role ) );
- }
+ }
final RoleEntry[] roles = (RoleEntry[]) roleList.toArray( new RoleEntry[ 0 ] );
final BlockEntry entry = new BlockEntry( locator, roles );
@@ -330,8 +331,8 @@
{
throw new DeploymentException( "Error adding component to container", ce );
}
-
+
getLogger().debug( "Adding " + m_type + "Entry " + name + " as " + entry );
- }
+ }
}
}
1.7 +20 -80 jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/Main.java
Index: Main.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/Main.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Main.java 2001/04/02 01:39:51 1.6
+++ Main.java 2001/04/12 05:32:54 1.7
@@ -7,27 +7,17 @@
*/
package org.apache.phoenix.engine;
-import java.io.File;
-import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.List;
-import org.apache.avalon.Composer;
-import org.apache.avalon.DefaultComponentManager;
-import org.apache.avalon.Loggable;
-import org.apache.avalon.camelot.CamelotUtil;
-import org.apache.avalon.camelot.Deployer;
+import org.apache.avalon.configuration.Parameters;
import org.apache.avalon.util.cli.CLArgsParser;
import org.apache.avalon.util.cli.CLOption;
import org.apache.avalon.util.cli.CLOptionDescriptor;
import org.apache.avalon.util.cli.CLUtil;
-import org.apache.avalon.util.log.AvalonLogFormatter;
import org.apache.log.LogKit;
-import org.apache.log.LogTarget;
-import org.apache.log.Logger;
import org.apache.log.Priority;
-import org.apache.log.output.FileOutputLogTarget;
/**
* The class to load the kernel and start it running.
@@ -43,7 +33,7 @@
private static final String DEFAULT_APPS_PATH = PHOENIX_HOME + "/apps";
private static final String DEFAULT_KERNEL_CLASS =
- System.getProperty( "phoenix.kernel", "org.apache.phoenix.engine.DefaultServerKernel" );
+ System.getProperty( "phoenix.kernel", "org.apache.phoenix.engine.PhoenixKernel" );
private static final int DEBUG_LOG_OPT = 'd';
private static final int HELP_OPT = 'h';
@@ -52,7 +42,6 @@
protected String m_appsPath = DEFAULT_APPS_PATH;
protected String m_logFile = DEFAULT_LOG_FILE;
- protected Logger m_logger;
protected CLOptionDescriptor[] m_options;
@@ -68,11 +57,6 @@
try { main.execute( args ); }
catch( final Throwable throwable )
{
- if( null != main.m_logger )
- {
- main.m_logger.fatalError( "Unhandled exception", throwable );
- }
-
System.out.println( "There was an uncaught exception:" );
System.out.println( "---------------------------------------------------------" );
throwable.printStackTrace( System.out );
@@ -83,6 +67,8 @@
System.out.println( "http://jakarta.apache.org/avalon for more information." );
System.exit( 1 );
}
+
+ System.exit( 0 );
}
/**
@@ -201,70 +187,24 @@
protected void execute()
throws Exception
{
- //temporary logging hack ....
-
- // create a log channel for the loader.
- final FileOutputLogTarget logTarget = new FileOutputLogTarget( m_logFile );
- final AvalonLogFormatter formatter = new AvalonLogFormatter();
- formatter.setFormat( "%{time} [%7.7{priority}] <<%{category}>> " +
- "(%{context}): %{message}\\n%{throwable}" );
- logTarget.setFormatter( formatter );
-
- LogKit.addLogTarget( m_logFile, logTarget );
- m_logger = LogKit.createLogger( LogKit.createCategory( "Phoenix", Priority.DEBUG ),
- new LogTarget[] { logTarget } );
- m_logger.info( "Loader started" );
-
- ServerKernel kernel = null;
- try
- {
- Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
- kernel = (ServerKernel)Class.forName( DEFAULT_KERNEL_CLASS ).newInstance();
+ final Parameters parameters = new Parameters();
+ parameters.setParameter( "kernel-class", "org.apache.phoenix.engine.PhoenixKernel" );
+ parameters.setParameter( "deployer-class", "org.apache.phoenix.engine.DefaultSarDeployer" );
+ parameters.setParameter( "kernel-configuration-source", null );
+ parameters.setParameter( "log-destination", m_logFile );
+ parameters.setParameter( "applications-directory", m_appsPath );
+
+ final PhoenixEmbeddor embeddor = new PhoenixEmbeddor();
+ embeddor.setParameters( parameters );
+ embeddor.init();
+
+ try
+ {
+ embeddor.execute();
}
- catch( final Exception e )
- {
- m_logger.fatalError( "Failed to create kernel instance", e );
- throw e;
- }
-
- kernel.setLogger( m_logger );
- kernel.init();//ialize();
-
- final File directory = new File( m_appsPath );
- final Deployer deployer = new DefaultSarDeployer();
- setupDeployer( kernel, deployer );
-
- CamelotUtil.deployFromDirectory( deployer, directory, ".sar" );
-
- //run kernel lifecycle
- kernel.start();
- kernel.run();
- kernel.stop();
- kernel.dispose();
-
- System.exit(0);
- }
-
- /**
- * Setup deployer including Logging/componentManager.
- *
- * @param kernel the kernel deploying to
- * @param deployer the deployer
- * @exception Exception if an error occurs
- */
- protected void setupDeployer( final ServerKernel kernel, final Deployer deployer )
- throws Exception
- {
- if( deployer instanceof Loggable )
- {
- ((Loggable)deployer).setLogger( m_logger );
- }
-
- if( deployer instanceof Composer )
+ finally
{
- final DefaultComponentManager componentManager = new DefaultComponentManager();
- componentManager.put( "org.apache.avalon.camelot.Container", kernel );
- ((Composer)deployer).compose( componentManager );
+ embeddor.dispose();
}
}
}
1.1 jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/Embeddor.java
Index: Embeddor.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.phoenix.engine;
import org.apache.avalon.Disposable;
import org.apache.avalon.Initializable;
import org.apache.avalon.configuration.ConfigurationException;
import org.apache.avalon.configuration.Parameters;
/**
* This is the object that is interacted with to create, manage and
* dispose of the kernel and related resources.
*
* Note that this will eventually be moved to atlantis package.
*
* @author <a href="mail@leosimons.com">Leo Simons</a>
* @author <a href="donaldp@apache.org">Peter Donald</a>
*/
public interface Embeddor
extends Initializable, Disposable
{
/**
* Kset parameters for this component.
* This must be called before initialize()
*
* @param parameters the Parameters for embeddor
* @exception ConfigurationException if an error occurs
*/
void setParameters( Parameters parameters )
throws ConfigurationException;
/**
* After the Embeddor is initialized, this method is called to actually
* do the work. It will return when the embeddor is ready to be disposed.
*
* @exception Exception if an error occurs
*/
void execute()
throws Exception;
}
1.1 jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/PhoenixEmbeddor.java
Index: PhoenixEmbeddor.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.phoenix.engine;
import java.io.File;
import java.lang.UnsupportedOperationException;
import org.apache.avalon.AbstractLoggable;
import org.apache.avalon.CascadingException;
import org.apache.avalon.Composer;
import org.apache.avalon.Contextualizable;
import org.apache.avalon.DefaultComponentManager;
import org.apache.avalon.Disposable;
import org.apache.avalon.Initializable;
import org.apache.avalon.atlantis.Kernel;
import org.apache.avalon.camelot.CamelotUtil;
import org.apache.avalon.camelot.Container;
import org.apache.avalon.camelot.Deployer;
import org.apache.avalon.configuration.Configurable;
import org.apache.avalon.configuration.Configuration;
import org.apache.avalon.configuration.ConfigurationException;
import org.apache.avalon.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.configuration.Parameters;
import org.apache.avalon.util.log.AvalonLogFormatter;
import org.apache.log.LogKit;
import org.apache.log.LogTarget;
import org.apache.log.Logger;
import org.apache.log.Priority;
import org.apache.log.output.FileOutputLogTarget;
/**
* This is the object that is interacted with to create, manage and
* dispose of the kernel and related resources.
*
* Note that this will eventually be moved to atlantis package.
*
* @author <a href="mail@leosimons.com">Leo Simons</a>
* @author <a href="donaldp@apache.org">Peter Donald</a>
*/
public class PhoenixEmbeddor
extends AbstractLoggable
implements Embeddor
{
private Parameters m_parameters;
private Kernel m_kernel;
private Deployer m_deployer;
private boolean m_shutdown;
/**
* Set parameters for this component.
* This must be called after contextualize() and before initialize()
*
* @param parameters the Parameters for embeddor
* @exception ConfigurationException if an error occurs
*/
/**
* Make sure to provide all the neccessary information through
* these parameters. All information it needs consists of strings.
* Neccessary are:
* <ul>
* <li><b>kernel-class</b>, the classname of the
* org.apache.phoenix.engine.ServerKernel to be used.</li>
* <li><b>deployer-class</b>, the classname of the
* org.apache.avalon.camelot.Deployer to be used.</li>
* <li><b>kernel-configuration-source</b>, the location
* of the configuration file to be used for configuring the
* kernel. (If kernel is configurable)</li>
* <li><b>log-destination</b>, the file to save log
* messages in. If omitted, no logs are written.</li>
* <li>TODO: <b>facilities-directory</b>, the directory in
* which the facilities you wish to load into the kernel
* are stored (in .far format).<br />
* When ommited, the default facilities are used.</li>
* <li><b>applications-directory</b>, the directory in which
* the defaul applications to be loaded by the kernel are stored
* (in .sar format).<br />
* When ommited, no applications are loaded.</li>
* </ul>
*/
public void setParameters( final Parameters parameters )
throws ConfigurationException
{
m_parameters = parameters;
}
/**
* Creates the core handlers - logger, deployer, Manager and
* Kernel. Note that these are not set up properly until you have
* called the <code>run()</code> method.
*/
public void init()
throws Exception
{
createComponents();
}
/**
* This is the main method of the embeddor. It sets up the core
* components, and then deploys the <code>Facilities</code>. These
* are registered with the Kernel and the Manager. The same
* happens for the <code>Applications</code>.
* Now, the Kernel is taken through its lifecycle. When it is
* finished, as well as all the applications running in it, it
* is shut down, after which the PhoenixEmbeddor is as well.
*/
public void execute()
throws Exception
{
try
{
// setup core handler components
setupComponents();
deployDefaultApplications();
m_kernel.start();
// loop until <code>Shutdown</code> is created.
while( !m_shutdown )
{
// loop
// wait() for shutdown() to take action...
try { synchronized( this ) { wait(); } }
catch (InterruptedException e) {}
}
}
catch ( Exception e )
{
// whoops!
getLogger().fatalError( "There was a fatal error while running phoenix.", e );
System.exit( 1 );
}
}
/**
* Release all the resources associated with kernel.
*/
public void dispose()
throws Exception
{
if( null != m_kernel )
{
m_kernel.stop();
m_kernel.dispose();
}
m_kernel = null;
m_deployer = null;
System.gc(); // make sure resources are released
}
/**
* Shut down the Embeddor together with the
* Logger, Deployer, Manager and Kernel.
*/
public void shutdown()
{
m_shutdown = true;
synchronized( this ) { notifyAll(); }
}
//////////////////////
/// HELPER METHODS ///
//////////////////////
/**
* Create the logger, deployer and kernel components.
* Note that these components are not ready to be used
* until setupComponents() is called.
*/
private void createComponents()
throws Exception
{
final Logger logger = createLogger();
setLogger( logger );
try
{
m_deployer = createDeployer();
}
catch( final Exception e )
{
final String message = "Unable to create deployer!";
getLogger().fatalError( message, e );
throw new CascadingException( message, e );
}
try
{
m_kernel = createKernel();
}
catch( final Exception e )
{
final String message = "Unable to create kernel!";
getLogger().fatalError( message, e );
throw new CascadingException( message, e );
}
}
/**
* Setup the deployer and kernel components.
* Note that after this method these components are ready to be used
*/
private void setupComponents()
throws Exception
{
try
{
setupDeployer();
}
catch( final Exception e )
{
getLogger().fatalError( "Unable to setup deployer!", e );
throw e;
}
try
{
setupKernel();
}
catch( final Exception e )
{
getLogger().fatalError( "Unable to setup kernel!", e );
throw e;
}
}
/**
* Uses <code>org.apache.log.LogKit</code> to create a new
* logger using "Phoenix" as its category, DEBUG as its
* priority and the log-destination from Parameters as its
* destination.
* TODO: allow configurable priorities and multiple
* logtargets.
*/
private Logger createLogger()
throws ConfigurationException
{
try
{
final String logDestination =
m_parameters.getParameter( "log-destination", null );
final FileOutputLogTarget logTarget = new FileOutputLogTarget( logDestination );
final AvalonLogFormatter formatter = new AvalonLogFormatter();
formatter.setFormat( "%{time} [%7.7{priority}] <<%{category}>> " +
"(%{context}): %{message}\\n%{throwable}" );
logTarget.setFormatter( formatter );
LogKit.addLogTarget( logDestination, logTarget );
final Logger logger =
LogKit.createLogger( LogKit.createCategory( "Phoenix", Priority.DEBUG ),
new LogTarget[] { logTarget } );
logger.info( "Logger started" );
return logger;
}
catch( final Exception e )
{
throw new ConfigurationException( "Failed to create Logger", e );
}
}
/**
* Creates a new deployer from the Parameters's deployer-class.
* TODO: fill the Parameters for Deployer properly.
*/
private Deployer createDeployer()
throws ConfigurationException
{
final String className = m_parameters.getParameter( "deployer-class", null );
try
{
Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
return (Deployer)Class.forName( className ).newInstance();
}
catch( final Exception e )
{
throw new ConfigurationException( "Failed to create Deployer of class " +
className, e );
}
}
/**
* Sets up the Deployer. If it is Loggable, it gets a reference
* to the Embeddor's logger. If it is Contextualizable it is
* passed a Context. If it is a Composer it is given a
* ComponentManager which references the Kernel, cast to a
* Container.
* The deployer is now used to load the applications from the
* default-facilities-location specified in Context.
* TODO: load facilities from .fars as well.
*/
private void setupDeployer()
throws Exception
{
setupLogger( m_deployer );
if( m_deployer instanceof Composer )
{
final DefaultComponentManager componentManager = new DefaultComponentManager();
componentManager.put( "org.apache.avalon.camelot.Container", (Container)m_kernel );
((Composer)m_deployer).compose( componentManager );
}
}
/**
* The deployer is used to load the applications from the
* default-apps-location specified in Parameters.
* TODO: load facilities from .fars as well.
*
* @exception Exception if an error occurs
*/
private void deployDefaultApplications()
throws Exception
{
final String defaultAppsLocation =
m_parameters.getParameter( "applications-directory", null );
if( null != defaultAppsLocation )
{
final File directory = new File( defaultAppsLocation );
CamelotUtil.deployFromDirectory( m_deployer, directory, ".sar" );
}
// TODO: load facilities from .fars
// final File directory2 = new File( (String)this.context.get( "default-facilities-location" ) );
// CamelotUtil.deployFromDirectory( deployer, directory2, ".far" );
}
/**
* Creates a new deployer from the Parameters's kernel-class.
* TODO: fill the Parameters for kernel properly.
*/
private Kernel createKernel()
throws ConfigurationException
{
final String className = m_parameters.getParameter( "kernel-class", null );
try
{
Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
return (Kernel)Class.forName( className ).newInstance();
}
catch( final Exception e )
{
throw new ConfigurationException( "Failed to create Kernel of class " +
className, e );
}
}
/**
* Sets up the Kernel. We determine whether it supports Loggable
* and Configurable and supply information based on that.
*/
private void setupKernel()
throws Exception
{
setupLogger( m_kernel );
if( m_kernel instanceof Configurable )
{
final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
final String kernelConfigLocation =
m_parameters.getParameter( "kernel-configuration-source", null );
final Configuration configuration = builder.build( kernelConfigLocation );
((Configurable)m_kernel).configure( configuration );
}
try
{
m_kernel.init();
}
catch( final Exception e )
{
getLogger().fatalError( "There was a fatal error; phoenix could not be started", e );
throw e;
}
}
}
1.1 jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/PhoenixKernel.java
Index: PhoenixKernel.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.phoenix.engine;
import org.apache.avalon.Composer;
import org.apache.avalon.atlantis.Kernel;
import org.apache.avalon.atlantis.AbstractKernel;
import org.apache.avalon.atlantis.Application;
import org.apache.avalon.camelot.Entry;
import org.apache.log.LogKit;
/**
* The ServerKernel is the core of the Phoenix system.
* The kernel is responsible for orchestrating low level services
* such as loading, configuring and destroying blocks. It also
* gives access to basic facilities such as scheduling sub-systems,
* protected execution contexts, naming and directory services etc.
*
* Note that no facilities are available until after the Kernel has been
* configured and initialized.
*
* @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
*/
public class PhoenixKernel
extends AbstractKernel
implements Kernel
{
private final static String BANNER = Constants.SOFTWARE + " " + Constants.VERSION;
public PhoenixKernel()
{
m_entryClass = ServerApplicationEntry.class;
m_applicationClass = ServerApplication.class;
}
public void init()
throws Exception
{
System.out.println();
System.out.println( BANNER );
super.init();
}
protected Application newApplication( final String name, final Entry entry )
throws Exception
{
//It is here where you could return new EASServerApplication()
//if you wanted to host multiple different types of apps
return new DefaultServerApplication();
}
/**
* Prepare an application before it is initialized.
* Overide to provide functionality.
* Usually used to setLogger(), contextualize, compose, configure.
*
* @param name the name of application
* @param entry the application entry
* @param application the application instance
* @exception Exception if an error occurs
*/
protected void prepareApplication( final String name,
final Entry entry,
final Application application )
throws Exception
{
final ServerApplicationEntry saEntry = (ServerApplicationEntry)entry;
final ServerApplication saApplication = (ServerApplication)application;
setupLogger( saApplication, LogKit.getLoggerFor( name ) );
saApplication.contextualize( saEntry.getContext() );
if( saApplication instanceof Composer )
{
((Composer)saApplication).compose( saEntry.getComponentManager() );
}
saApplication.configure( saEntry.getConfiguration() );
}
protected void postAdd( final String name, final Entry entry )
{
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org