mcconnell 2002/07/12 03:16:19
Added: assembly/src/java/org/apache/excalibur/merlin
Verifiable.java package.html Manageable.java
Main.java Kernel.java Container.java
Log:
all main interface moved from kernel and registry package to top-level
Revision Changes Path
1.1
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Verifiable.java
Index: Verifiable.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.txt file.
*/
package org.apache.excalibur.merlin;
import org.apache.excalibur.meta.verifier.VerifyException;
/**
* A interface declaring operations related to type and assembly validation.
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version $Revision: 1.1 $ $Date: 2002/07/12 10:16:19 $
*/
public interface Verifiable
{
/**
* Method invoked by a parent container to request type level validation of
* the container.
*
* @exception ValidationException if a validation failure occurs
*/
void verify() throws VerifyException;
}
1.1
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/package.html
Index: package.html
===================================================================
<body>
<p>Merlin is a component container that provides support for automatics assembly and
deployment of services based on the explicit assembly information together with
implicit and packaged information associated with compoent types.
</body>
1.1
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Manageable.java
Index: Manageable.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.txt file.
*/
package org.apache.excalibur.merlin;
/**
* A service that provides support managable startup and shutdown.
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version $Revision: 1.1 $ $Date: 2002/07/12 10:16:19 $
*/
public interface Manageable
{
/**
* Request the startup of the managable unit.
*/
void startup() throws Exception;
/**
* Request the shutdown of the managable unit.
*/
void shutdown();
}
1.1
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Main.java
Index: Main.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.txt file.
*/
package org.apache.excalibur.merlin;
import java.io.InputStream;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.JarURLConnection;
import java.net.URLClassLoader;
import java.util.List;
import java.util.LinkedList;
import java.util.Map;
import java.util.Hashtable;
import java.util.Properties;
import java.util.Vector;
import java.util.Iterator;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.security.Policy;
import java.io.FileInputStream;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.excalibur.configuration.ConfigurationUtil;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.AvalonFormatter;
import org.apache.avalon.framework.logger.LogKitLogger;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Executable;
import org.apache.avalon.framework.CascadingRuntimeException;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.DefaultServiceManager;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.Version;
import org.apache.avalon.framework.ExceptionUtil;
import org.apache.avalon.excalibur.extension.PackageRepository;
import org.apache.avalon.excalibur.extension.Extension;
import org.apache.avalon.excalibur.extension.OptionalPackage;
import org.apache.avalon.excalibur.extension.DefaultPackageRepository;
import org.apache.excalibur.meta.info.DefaultType;
import org.apache.excalibur.meta.info.Type;
import org.apache.excalibur.meta.info.ServiceDescriptor;
import org.apache.excalibur.meta.info.DependencyDescriptor;
import org.apache.excalibur.meta.info.ServiceDesignator;
import org.apache.excalibur.merlin.meta.data.builder.XMLKernelCreator;
import org.apache.excalibur.merlin.meta.data.KernelDescriptor;
import org.apache.excalibur.merlin.meta.data.ClasspathDescriptor;
import org.apache.excalibur.merlin.meta.data.ExtensionsDescriptor;
import org.apache.excalibur.merlin.meta.data.LoggingDescriptor;
import org.apache.excalibur.merlin.meta.data.ContainerDescriptor;
import org.apache.excalibur.merlin.kernel.DefaultKernel;
import org.apache.excalibur.merlin.kernel.DefaultLoggerManager;
import org.apache.excalibur.merlin.kernel.ContainerClassLoader;
import org.apache.excalibur.merlin.kernel.KernelException;
import org.apache.log.Hierarchy;
import org.apache.log.Priority;
import org.apache.log.output.io.StreamTarget;
/**
* Application bootstrap.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version $Revision: 1.1 $ $Date: 2002/07/12 10:16:19 $
*/
public class Main
{
//=======================================================================
// static
//=======================================================================
/**
* Creation of a root type registry.
*/
public static void main( String[] args )
{
// get a configuration object containing the kernel profile
// from which we can establish the logger and extensions directory
String path = null;
Configuration config = null;
if( args.length > 0 )
{
path = args[0];
config = getProfile( new File( path ) );
}
else
{
throw new RuntimeException("Missing kernel configuration path
argument.");
}
XMLKernelCreator creator = new XMLKernelCreator();
ClasspathDescriptor classpath = null;
ExtensionsDescriptor extensions = null;
LoggingDescriptor loggingDescriptor = null;
try
{
classpath = creator.createClasspathDescriptor(
config.getChild("classpath") );
extensions = creator.createExtensionsDescriptor(
config.getChild("extensions") );
loggingDescriptor = creator.createLoggingDescriptor(
config.getChild("logging"), "kernel" );
}
catch( Throwable e )
{
e.printStackTrace();
System.exit(0);
}
final DefaultKernel kernel = new DefaultKernel();
//
// add a shutdown hook so we can stop services and target and invoke shutdown
//
Runtime.getRuntime().addShutdownHook(
new Thread()
{
public void run()
{
if( kernel != null )
kernel.shutdown();
}
}
);
//
// log manager
//
DefaultLoggerManager logging = null;
Logger logger = null;
try
{
logging = new DefaultLoggerManager( loggingDescriptor );
logger = logging.getLoggerForCategory( "kernel" );
logger.info("commencing type installation");
}
catch( Throwable e )
{
System.out.println("Unexpected error while preparing log manager.");
e.printStackTrace();
System.exit(0);
}
//
// root classloader
//
final ContainerClassLoader loader = new ContainerClassLoader();
try
{
loader.enableLogging( logger.getChildLogger( "loader" ) );
DefaultContext context = new DefaultContext();
context.put(
ContainerClassLoader.EXTENSIONS_DESCRIPTOR_KEY,
extensions );
context.put(
ContainerClassLoader.CLASSPATH_DESCRIPTOR_KEY,
classpath );
context.makeReadOnly();
loader.contextualize( context );
loader.initialize();
}
catch( Throwable e )
{
System.out.println("Unexpected error while preparing classloader.");
e.printStackTrace();
System.exit(0);
}
//
// installer classloader
//
final ContainerClassLoader installer = new ContainerClassLoader( loader );
try
{
installer.enableLogging( logger.getChildLogger( "installer" ) );
DefaultContext context = new DefaultContext();
installer.contextualize( context );
installer.initialize();
}
catch( Throwable e )
{
System.out.println("Unexpected error while preparing classloader.");
e.printStackTrace();
System.exit(0);
}
ContainerDescriptor container = null;
try
{
container = creator.createContainerDescriptor(
config.getChild("container"), installer );
}
catch( Throwable e )
{
System.out.println("Unexpected error while preparing metamodel.");
e.printStackTrace();
System.exit(0);
}
// run it up
logger.info("commencing kernel deployment");
DefaultContext context = new DefaultContext();
context.put( DefaultKernel.ROOT_CONTAINER_DESCRIPTOR_KEY, container );
context.put( DefaultKernel.CLASSLOADER_KEY, loader );
context.put( DefaultKernel.LOG_MANAGER_KEY, logging );
context.makeReadOnly();
try
{
kernel.enableLogging( logger );
kernel.contextualize( context );
kernel.initialize( );
}
catch( KernelException e )
{
System.exit(0);
}
catch( Throwable e )
{
System.out.println("Unexpected error while initilizing kernel.");
e.printStackTrace();
System.exit(0);
}
// invoke the registry demo
try
{
kernel.startup();
}
catch( Throwable e )
{
System.exit(0);
}
}
private static Configuration getProfile( final File file )
{
try
{
DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
InputStream is = new FileInputStream( file );
if( is == null )
{
throw new RuntimeException(
"Could not load the configuration resource \"" + file + "\"" );
}
return builder.build( is );
}
catch( Throwable e )
{
final String error = "Unable to create configuration from file: " + file;
throw new CascadingRuntimeException( error, e );
}
}
}
1.1
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Kernel.java
Index: Kernel.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.txt file.
*/
package org.apache.excalibur.merlin;
/**
* A service that provides support for the hosting of multiple containers.
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version $Revision: 1.1 $ $Date: 2002/07/12 10:16:19 $
*/
public interface Kernel extends Manageable
{
}
1.1
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Container.java
Index: Container.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.txt file.
*/
package org.apache.excalibur.merlin;
import org.apache.excalibur.merlin.meta.data.Profile;
import org.apache.excalibur.meta.info.ServiceDesignator;
/**
* A service that provides support for the management of a set of component types
* and factories.
* <p><b>UML</b></p>
* <p><image src="doc-files/Container.gif" border="0"/></p>
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version $Revision: 1.1 $ $Date: 2002/07/12 10:16:19 $
*/
public interface Container extends Manageable, Verifiable
{
/**
* Return the set of potential profiles of installed component matching a
dependency.
* @param dependency a consumer component dependecy declaration
* @return the set of potential supplier profile
*/
Profile[] getProviders( ServiceDesignator service );
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>