Return-Path: Delivered-To: apmail-jakarta-avalon-cvs-archive@apache.org Received: (qmail 27614 invoked from network); 12 Aug 2002 02:00:21 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 12 Aug 2002 02:00:21 -0000 Received: (qmail 22536 invoked by uid 97); 12 Aug 2002 02:00:49 -0000 Delivered-To: qmlist-jakarta-archive-avalon-cvs@jakarta.apache.org Received: (qmail 22460 invoked by uid 97); 12 Aug 2002 02:00:49 -0000 Mailing-List: contact avalon-cvs-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon CVS List" Reply-To: "Avalon Developers List" Delivered-To: mailing list avalon-cvs@jakarta.apache.org Received: (qmail 22444 invoked by uid 97); 12 Aug 2002 02:00:48 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 12 Aug 2002 02:00:11 -0000 Message-ID: <20020812020011.64380.qmail@icarus.apache.org> From: mcconnell@apache.org To: jakarta-avalon-excalibur-cvs@apache.org Subject: cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/builder XMLFacilityCreator.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mcconnell 2002/08/11 19:00:11 Modified: assembly/demo/src/java/org/apache/excalibur/playground BasicComponent.xprofile CustomContainer.xinfo DemoManager.xinfo EmbeddedDemo.java ExploitationManager.xinfo assembly/src/etc kernel.xml assembly/src/java/org/apache/excalibur/merlin DefaultController.java assembly/src/java/org/apache/excalibur/merlin/assembly AssemblyException.java ContainerManager.java DefaultLoggerManager.java KernelManager.java ProfileRegistry.java TypeManager.java UnresolvedManagerException.java UnresolvedProviderException.java assembly/src/java/org/apache/excalibur/merlin/assembly/resource LifecycleHelper.java ProfileDesignator.java ResourceProvider.java assembly/src/java/org/apache/excalibur/merlin/container Container.java DefaultContainer.java DefaultContainer.xinfo assembly/src/java/org/apache/excalibur/merlin/kernel DefaultKernel.java assembly/src/java/org/apache/excalibur/merlin/model ContainerDescriptor.java ContextDirective.java Import.java Parameter.java Profile.java Resource.java assembly/src/java/org/apache/excalibur/merlin/model/builder ContainerBuilder.java XMLContainerCreator.java XMLContainerUtil.java XMLProfileCreator.java assembly/src/java/org/apache/excalibur/meta/info ExtensionDescriptor.java assembly/src/java/org/apache/excalibur/meta/info/builder XMLFacilityCreator.java Added: assembly/demo/src/java/org/apache/excalibur/playground CustomContainer.xprofile EmbeddedDemo.xconfig Log: General updates enabling management of a container as a pure component (i.e. containers implementations may have thier own dependecies, extensions, etc. and other components may declare dependencies on containers). Revision Changes Path 1.7 +0 -1 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/BasicComponent.xprofile Index: BasicComponent.xprofile =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/BasicComponent.xprofile,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- BasicComponent.xprofile 4 Aug 2002 14:58:30 -0000 1.6 +++ BasicComponent.xprofile 12 Aug 2002 02:00:08 -0000 1.7 @@ -13,7 +13,6 @@ Paris - ../assembly 1.2 +26 -5 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/CustomContainer.xinfo Index: CustomContainer.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/CustomContainer.xinfo,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- CustomContainer.xinfo 5 Aug 2002 11:37:18 -0000 1.1 +++ CustomContainer.xinfo 12 Aug 2002 02:00:08 -0000 1.2 @@ -3,17 +3,38 @@ PUBLIC "-//AVALON/Component Info DTD Version 1.0//EN" "http://jakarta.apache.org/avalon/componentinfo_1_0.dtd" > - + custom + + + + + + + + - - - + + + - + + + + + + + 1.4 +2 -2 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/DemoManager.xinfo Index: DemoManager.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/DemoManager.xinfo,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DemoManager.xinfo 4 Aug 2002 11:49:35 -0000 1.3 +++ DemoManager.xinfo 12 Aug 2002 02:00:08 -0000 1.4 @@ -4,7 +4,7 @@ Definition of the extension type phase support. --> - + demonstratable @@ -29,5 +29,5 @@ - + 1.10 +24 -6 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/EmbeddedDemo.java Index: EmbeddedDemo.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/EmbeddedDemo.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- EmbeddedDemo.java 9 Aug 2002 15:28:04 -0000 1.9 +++ EmbeddedDemo.java 12 Aug 2002 02:00:08 -0000 1.10 @@ -9,6 +9,8 @@ import org.apache.avalon.framework.context.DefaultContext; import org.apache.avalon.framework.context.Contextualizable; import org.apache.avalon.framework.context.ContextException; +import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.DefaultConfiguration; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.activity.Initializable; @@ -22,6 +24,7 @@ import org.apache.excalibur.merlin.model.ClasspathDescriptor; import org.apache.excalibur.merlin.model.Profile; import org.apache.excalibur.merlin.assembly.ContainerManager; +import org.apache.excalibur.merlin.container.ContainerFactory; import org.apache.excalibur.meta.info.Type; import org.apache.excalibur.meta.info.DependencyDescriptor; import org.apache.excalibur.meta.info.ReferenceDescriptor; @@ -33,20 +36,35 @@ * @author Stephen McConnell */ public class EmbeddedDemo extends AbstractLogEnabled -implements Contextualizable, Initializable, Startable, Disposable +implements Contextualizable, Configurable, Initializable, Startable, Disposable { private DefaultKernel m_kernel; private File m_home; private Context m_context; + private Configuration m_configuration; + private Container m_container; + //======================================================================= + // Contextualizable + //======================================================================= + public void contextualize( Context context ) throws ContextException { m_context = context; } //======================================================================= + // Configurable + //======================================================================= + + public void configure( Configuration config ) + { + m_configuration = config; + } + + //======================================================================= // Initializable //======================================================================= @@ -78,7 +96,7 @@ DefaultContext context = new DefaultContext( m_context ); context.put( DefaultKernel.PATH_KEY, "work" ); m_kernel.contextualize( context ); - m_kernel.configure( new DefaultConfiguration( "", null ) ); + m_kernel.configure( m_configuration.getChild("kernel") ); m_kernel.initialize(); // @@ -95,7 +113,7 @@ // getLogger().debug("adding subcontainer: admin"); - Container container = root.createSubContainer( "admin" ); + Container container = root.addContainer( "admin" ); // // Add a component to the container programatically. @@ -105,8 +123,8 @@ // container. // - Profile profile = manager.getProfile( - new ReferenceDescriptor( "org.apache.excalibur.playground.SimpleService" ) ); + Profile profile = new Profile("simple2", manager.getProfile( + new ReferenceDescriptor( "org.apache.excalibur.playground.SimpleService" ) ) ); // // install the profile into the container triggering profile assembly @@ -143,7 +161,7 @@ public void dispose() { getLogger().debug( "dispose" ); - m_kernel.dispose(); + //m_kernel.dispose(); } } 1.5 +2 -2 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ExploitationManager.xinfo Index: ExploitationManager.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ExploitationManager.xinfo,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ExploitationManager.xinfo 4 Aug 2002 11:49:35 -0000 1.4 +++ ExploitationManager.xinfo 12 Aug 2002 02:00:08 -0000 1.5 @@ -4,7 +4,7 @@ Definition of the extension type phase support. --> - + exploit @@ -29,5 +29,5 @@ - + 1.1 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/CustomContainer.xprofile Index: CustomContainer.xprofile =================================================================== 1.1 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/EmbeddedDemo.xconfig Index: EmbeddedDemo.xconfig =================================================================== 1.29 +10 -5 jakarta-avalon-excalibur/assembly/src/etc/kernel.xml Index: kernel.xml =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/kernel.xml,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- kernel.xml 9 Aug 2002 15:28:04 -0000 1.28 +++ kernel.xml 12 Aug 2002 02:00:08 -0000 1.29 @@ -39,6 +39,12 @@ + + + + + + @@ -54,7 +60,6 @@ - @@ -118,7 +123,7 @@ child container instances. --> - + @@ -136,8 +141,8 @@ from either TerminalComponent or BasicComponent implicitly created in the parent container path (due to a depenency declared by ComplexComponent). In addition, this profile demonstrates the use of a cascading configuration. The configuration passed - to the instantiated component is based primarily on this configuration declared here, - and defaults derived from SimpleComponent.xconfig. + to the instantiated component is based primarily on this configuration declared here + with defaults derived from SimpleComponent.xconfig. --> + class="org.apache.excalibur.playground.EmbeddedDemo" enabled="true" activation="true"> 1.15 +3 -3 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/DefaultController.java Index: DefaultController.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/DefaultController.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- DefaultController.java 8 Aug 2002 21:29:24 -0000 1.14 +++ DefaultController.java 12 Aug 2002 02:00:08 -0000 1.15 @@ -220,7 +220,7 @@ /** * Invoked by a contrainer to request startup of the controller. Thie implementation - * simply invokes the {@link #startup} operation. + * simply invokes the {@link #start} operation. */ public void start() throws Exception { @@ -241,7 +241,7 @@ /** * Invoked by a contrainer to request shutdown of the controller. Thie implementation - * simply invokes the {@link #startup} operation. + * simply invokes the {@link #stop} operation. */ public void stop() throws Exception { 1.2 +2 -2 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/AssemblyException.java Index: AssemblyException.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/AssemblyException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AssemblyException.java 29 Jul 2002 06:14:29 -0000 1.1 +++ AssemblyException.java 12 Aug 2002 02:00:08 -0000 1.2 @@ -19,7 +19,7 @@ * @author Stephen McConnell * @version $Revision$ $Date$ */ -public final class AssemblyException +public class AssemblyException extends CascadingException { 1.10 +170 -65 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ContainerManager.java Index: ContainerManager.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ContainerManager.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ContainerManager.java 9 Aug 2002 15:28:04 -0000 1.9 +++ ContainerManager.java 12 Aug 2002 02:00:08 -0000 1.10 @@ -36,6 +36,7 @@ import org.apache.excalibur.configuration.ConfigurationUtil; import org.apache.excalibur.merlin.assembly.resource.LifecycleHelper; import org.apache.excalibur.merlin.assembly.resource.ResourceProvider; +import org.apache.excalibur.merlin.assembly.resource.ResourceException; import org.apache.excalibur.merlin.assembly.resource.ProfileDesignator; import org.apache.excalibur.merlin.model.ContainerDescriptor; import org.apache.excalibur.merlin.model.ClasspathDescriptor; @@ -68,7 +69,7 @@ * @version $Revision$ $Date$ */ -public class ContainerManager extends TypeManager implements Startable +public class ContainerManager extends TypeManager { //=================================================================== @@ -149,6 +150,10 @@ private ContainerManager m_parent; /** + * Mapping of subsidiary managers keyed by container descriptor. + */ + + /** * Mapping of established resource designators keyed by profile. */ private Hashtable m_resources = new Hashtable(); @@ -249,20 +254,15 @@ public void initialize() throws Exception { - XMLContainerUtil creator = new XMLContainerUtil(); + super.initialize(); - // - // start internal initialization - // + XMLContainerUtil creator = new XMLContainerUtil(); getLogger().debug( "creating manager '" + m_name + "' " + System.identityHashCode( this ) + " with parent: " + System.identityHashCode( getParent() ) ); - super.initialize(); - - getLocalLogger().debug("manager initialization"); m_selector.enableLogging( getLocalLogger().getChildLogger("selector") ); m_helper.enableLogging( getLocalLogger().getChildLogger("lifecycle") ); @@ -277,7 +277,7 @@ // setup the assembly sub-system // - m_registry = new ProfileRegistry( this, m_map ); + m_registry = new ProfileRegistry( this, m_map, m_helper, m_provider ); m_registry.enableLogging( getLocalLogger().getChildLogger( "assembly") ); // @@ -321,9 +321,8 @@ * * @exception Exception if a start related error occurs */ - public void start() throws Exception + public void start( Profile[] profiles ) throws Exception { - Profile[] profiles = m_map.getStartupGraph(); if( profiles.length == 0 ) { getLocalLogger().debug("nothing to start"); @@ -349,9 +348,8 @@ } } - public void stop() + public void stop( Profile[] shutdown ) { - Profile[] shutdown = m_map.getShutdownGraph(); if( shutdown.length == 0 ) { getLogger().info( "shutdown" ); @@ -426,7 +424,7 @@ public void dispose() { // need to complete this ... - // if stop has ben invoked then dispose has already been invoked on + // if stop has been invoked then dispose has already been invoked on // all of the component we are managing (see LifecycleHelper) - but // aside from that, we should be going though and cleaning up state // locally @@ -437,9 +435,24 @@ //=================================================================== public ContainerManager createContainerManager( - String name, + ContainerDescriptor descriptor, ClasspathDescriptor classpath ) { + + String path; + final String name = descriptor.getName(); + if( this instanceof KernelManager ) + { + path = getPath().replace('/','.').substring(1); + } + else + { + path = getPath().replace('/','.').substring(1) + "." + name; + } + + CategoriesDescriptor categories = descriptor.getCategories(); + getLoggingManager().addCategories( path, categories ); + try { ContainerManager loader = new ContainerManager( this, name ); @@ -457,6 +470,8 @@ } loader.contextualize( context ); loader.initialize(); + + addProfile( descriptor ); return loader; } catch( Throwable e ) @@ -511,7 +526,7 @@ + existing.getType() ); } - m_profiles.put( profile.getName(), profile ); + m_profiles.put( name, profile ); ServiceDescriptor[] services = profile.getType().getServices(); for( int i=0; i 0 ) - { - StringBuffer buffer = new StringBuffer(); - for( int i=0; i 0 ) + { + StringBuffer buffer = new StringBuffer(); + for( int i=0; i 0 ) - notice( name, stage ); + notice( path, stage ); for( int i=0; iStephen McConnell * @version $Revision$ $Date$ */ -public class DefaultContainer extends AbstractLogEnabled implements Container, Contextualizable, Configurable, Initializable, Startable, Suspendable, Disposable, Runnable, StateListener +public class DefaultContainer extends AbstractLogEnabled implements Container, Contextualizable, Configurable, Structural, Initializable, Startable, Suspendable, Disposable, Runnable, StateListener { //======================================================================= // static //======================================================================= - /** - * Context key used to locate the container manager. - */ - public static final String MANAGER_KEY = "manager"; - - /** - * Context key used to locate the container descriptor. - */ - public static final String DESCRIPTOR_KEY = "descriptor"; - - /** - * Context key used to locate a state listener. - */ - public static final String STATE_LISTENER_KEY = "state-listener"; - - /** - * Context key used to locate a content listener. - */ - public static final String CONTAINER_LISTENER_KEY = "container-listener"; - - /** - * Context key used to locate subsidiary container configurations. - */ - public static final String CONFIGURATIONS_KEY = "configurations"; - - /** - * Context key used to locate the logging manager. - */ - public static final String LOGGING_KEY = "logging"; - private static final Resources REZ = ResourceManager.getPackageResources( DefaultContainer.class ); @@ -135,7 +109,7 @@ * Utility class that provides support for marshalling an XML configuration * into meta-data and meta-info instances. */ - private XMLContainerUtil m_creator = new XMLContainerUtil(); + private XMLContainerCreator m_creator = new XMLContainerCreator(); /** * The list of initialized embedded containers wrapped in Container instances. @@ -189,12 +163,16 @@ */ private Thread m_thread; - private Configuration[] m_configs; + private ContainerFactory m_factory; private DefaultLoggerManager m_logging; private Throwable m_error; + private DependencyGraph m_map; + + private Map m_services; + //======================================================================= // Contextualizable //======================================================================= @@ -208,10 +186,10 @@ * a {@link ContainerManager} (REQUIRED} *
  • {@link #DESCRIPTOR_KEY} the container meta data * {@link ContainerDescriptor} (REQUIRED}
  • + *
  • {@link #SERVICES_KEY} the container services + * {@link Map} (REQUIRED}
  • *
  • {@link #LOGGING_KEY} the logging manager {@link DefaultLoggerManager} (REQUIRED}
  • - *
  • {@link #CONFIGURATIONS_KEY} the set of subsidiary container - * configurations {@link Configuration}[] (OPTIONAL}
  • *
  • {@link #STATE_LISTENER_KEY} a container state listener {@link StateListener} (OPTIONAL}
  • *
  • {@link #CONTAINER_LISTENER_KEY} a container container listener @@ -224,15 +202,7 @@ m_manager = (ContainerManager) context.get( MANAGER_KEY ); m_descriptor = (ContainerDescriptor) context.get( DESCRIPTOR_KEY ); m_logging = (DefaultLoggerManager) context.get( LOGGING_KEY ); - - try - { - m_configs = (Configuration[]) context.get( CONFIGURATIONS_KEY ); - } - catch( ContextException e ) - { - m_configs = new Configuration[0]; - } + m_services = (Map) context.get( SERVICES_KEY ); try { @@ -253,6 +223,8 @@ { // optional } + + m_factory = new ContainerFactory( m_manager, m_logging ); } //======================================================================= @@ -275,6 +247,45 @@ } //======================================================================= + // Structural + //======================================================================= + + /** + * Lifecycle extension stage during which an array of configuration instances + * is supplied. Each contiguration instance represents the configuration of + * a subsidiary container to be hosted within this container. + * + * @param assembly the subsidiary container configurations + */ + public void assemble( ) throws AssemblyException + { + // + // initiate assembly of the immediate child components contained within + // this container + // + + getLogger().debug("assembly"); + Profile[] profiles = m_descriptor.getComponents( Profile.EXPLICIT, true ); + if( profiles.length > 0 ) + { + try + { + getLogger().debug("profile assembly (" + profiles.length + ")"); + m_map = m_manager.assemble( profiles ); + } + catch( Throwable e ) + { + final String error = "Assembly failure."; + throw new AssemblyException( error, e ); + } + } + else + { + m_map = new DependencyGraph(); + } + } + + //======================================================================= // Initializable //======================================================================= @@ -376,39 +387,26 @@ if( m_state >= INITIALIZED ) return; - // - // initiate component assembly - // - - getLogger().debug("assembly"); - Profile[] profiles = m_descriptor.getComponents( Profile.EXPLICIT, true ); - if( profiles.length > 0 ) - { - try - { - getLogger().debug("profile assembly (" + profiles.length + ")"); - m_manager.assemble( profiles ); - } - catch( Throwable e ) - { - final String error = "Assembly failure."; - throw new ContainerException( error, e ); - } - } - // // creation of the subsidiary containers // getLogger().debug("subsidiary container creation" ); - if( m_configs == null ) - m_configs = new Configuration[0]; - - for( int i=0; i - - + container @@ -18,7 +18,19 @@ - + + + + + + @@ -27,4 +39,10 @@ - + + + + + + + 1.34 +81 -181 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.java Index: DefaultKernel.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- DefaultKernel.java 9 Aug 2002 15:28:04 -0000 1.33 +++ DefaultKernel.java 12 Aug 2002 02:00:10 -0000 1.34 @@ -46,9 +46,9 @@ import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.context.Context; +import org.apache.avalon.framework.context.DefaultContext; 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; @@ -85,8 +85,10 @@ import org.apache.excalibur.merlin.model.LoggingDescriptor; import org.apache.excalibur.merlin.container.Container; import org.apache.excalibur.merlin.container.DefaultContainer; +import org.apache.excalibur.merlin.container.ContainerService; import org.apache.excalibur.merlin.container.StateListener; import org.apache.excalibur.merlin.container.StateEvent; +import org.apache.excalibur.merlin.container.ContainerFactory; import org.apache.excalibur.configuration.ConfigurationUtil; /** @@ -159,7 +161,7 @@ // state //======================================================================= - private DefaultContainer m_container; + private Container m_container; private boolean m_verified = false; @@ -247,24 +249,6 @@ { m_context = context; context.get( DIR_KEY ); - - try - { - m_path = (String) context.get( PATH_KEY ); - } - catch( Throwable e ) - { - m_path = "root"; - } - - if( m_path.indexOf("/") > -1 ) - { - m_name = m_path.substring( m_path.lastIndexOf("/") + 1 ); - } - else - { - m_name = m_path; - } } //======================================================================= @@ -282,26 +266,46 @@ public void initialize() throws Exception { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); final Configuration config = m_config.getChild("container"); - + String name = config.getAttribute("name"); + + // + // If this kernel has been created inside container scope then + // all we need to do is to setup a root container that the client + // can access. + // + + if( classloader instanceof ContainerManager ) + { + ContainerManager manager = (ContainerManager) classloader; + + m_base = manager.getPath().replace('/','.').substring(1) + "." + name; + m_logger = getLoggingManager().getLoggerForCategory( m_base ); + m_localLogger = m_logger.getChildLogger("kernel"); + + ContainerFactory factory = new ContainerFactory( manager, getLoggingManager() ); + factory.enableLogging( m_logger ); + + ContainerService service = factory.build( config ); + Resource resource = service.getResource(); + + m_container = (Container) resource.create(); + m_initialized = true; + return; + } + + // + // Otherwise this is a full root kernel under which we need to establish + // the singleton logging system, extension, etc. + // + try { - String name = m_name; - if( Thread.currentThread().getContextClassLoader() instanceof ContainerManager ) - { - m_root = false; - m_parent = - (ContainerManager)Thread.currentThread().getContextClassLoader(); - m_base = m_parent.getPath().replace('/','.').substring(1) + "." + name; - } - else - { - m_root = true; - LoggingDescriptor logging = - m_creator.createLoggingDescriptor( m_config.getChild("logging"), name ); - m_logging = new DefaultLoggerManager( logging ); - m_base = name; - } + LoggingDescriptor logging = + m_creator.createLoggingDescriptor( m_config.getChild("logging"), name ); + m_logging = new DefaultLoggerManager( logging ); + m_base = name; // // Setup the logging categories @@ -309,8 +313,10 @@ Configuration categoriesConfig = config.getChild("categories" ); CategoriesDescriptor categories = - m_creator.createCategoriesDescriptor( name, categoriesConfig ); + m_creator.createCategoriesDescriptor( m_base, categoriesConfig ); getLoggingManager().addCategories( m_base, categories ); + m_logger = getLoggingManager().getLoggerForCategory( m_base ); + m_localLogger = m_logger.getChildLogger("kernel"); // // Create the kernel type manager. @@ -324,10 +330,7 @@ ClasspathDescriptor classpath = m_creator.createClasspathDescriptor( m_config.getChild("classpath") ); - m_logger = getLoggingManager().getLoggerForCategory( m_base ); - m_localLogger = m_logger.getChildLogger("kernel"); - - m_manager = new KernelManager( m_path ); + m_manager = new KernelManager( m_base ); m_manager.enableLogging( m_logger ); DefaultContext ctx = new DefaultContext( m_context ); ctx.put( KernelManager.LOGGING_KEY, m_logging ); @@ -339,12 +342,19 @@ Thread.currentThread().setContextClassLoader( m_manager ); getLogger().info("kernel established: " + name ); + // + // setup the root container + // - m_container = createContainer( config ); - m_initialized = true; + ContainerFactory factory = new ContainerFactory( m_manager, getLoggingManager() ); + factory.enableLogging( m_logger ); - getLogger().info("kernel initialization complete"); + ContainerService service = factory.build( config ); + Resource resource = service.getResource(); + m_container = (Container) resource.create(); + getLogger().info("kernel initialization complete"); + m_initialized = true; } catch( Throwable e ) { @@ -378,122 +388,6 @@ return m_localLogger; } - /** - * Internal utility to create the root container. - * - * @param descriptor the subsidiary container descriptor - * @exception Exception is an error occurs - */ - private DefaultContainer createContainer( Configuration config ) throws Exception - { - try - { - // - // collect the information defining the root container - // descriptor - // - - final String name = config.getAttribute( "name", "root" ); - final String classname = config.getAttribute( "class", DefaultContainer.class.getName() ); - final Type type = m_manager.getType( classname ); - final CategoriesDescriptor categories = - m_creator.createCategoriesDescriptor( name, config.getChild("categories") ); - final boolean enabled = - config.getAttributeAsBoolean( "enabled", true ); - final boolean activation = - config.getAttributeAsBoolean( "activation", false ); - final Parameters params = - Parameters.fromConfiguration( config.getChild("parameters") ); - final ContextDirective contextDirective = - m_creator.createContextDirective( config.getChild("context") ); - final Configuration conf = config.getChild("configuration"); - - // - // create the descriptor - // - - final ContainerDescriptor descriptor = - new ContainerDescriptor( - name, params, conf, contextDirective, categories, type, enabled, - activation, ContainerDescriptor.EXPLICIT - ); - - // - // create the container manager - // - - final ClasspathDescriptor classpath = - m_creator.createClasspathDescriptor( config.getChild("classpath") ); - final ContainerManager manager = - m_manager.createContainerManager( name, classpath ); - - // - // populate the container descriptor with the components it contains - // - - final Configuration[] components = config.getChildren("component"); - for( int i=0; iParameter represents a single constructor typed argument value. A parameter @@ -187,7 +187,7 @@ * Return the derived parameter value. * @return the value */ - public Object getValue( ClassLoader loader, Context context ) throws ModelException + public Object getValue( ClassLoader loader, Map map ) throws ModelException { // // if the parameter value has already been established - return it now @@ -200,7 +200,7 @@ // // if the parameter contains a text argument then check if its a reference - // to a context entry (in the form"${}" ), otherwise its a simple constructor + // to a map entry (in the form"${}" ), otherwise its a simple constructor // case with a single string paremeter // @@ -211,12 +211,12 @@ if( m_argument.endsWith("}") ) { final String key = m_argument.substring( 2, m_argument.length() -1 ); - try + m_value = map.get( key ); + if( m_value != null ) { - m_value = context.get( key ); return m_value; } - catch( Throwable e ) + else { final String error = "Missing context value: '" + key + "'."; throw new IllegalArgumentException( error ); @@ -315,7 +315,7 @@ try { - values[i] = m_parameters[i].getValue( loader, context ); + values[i] = m_parameters[i].getValue( loader, map ); } catch( Throwable e ) { 1.20 +23 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Profile.java Index: Profile.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Profile.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- Profile.java 8 Aug 2002 10:02:35 -0000 1.19 +++ Profile.java 12 Aug 2002 02:00:10 -0000 1.20 @@ -225,6 +225,28 @@ } /** + * Create a Profile instance without parameters. + * + * @param name the abstract name of profile + * @param profile the profile to use as a template + */ + public Profile( final String name, + final Profile template ) + { + this( + name, + template.getParameters(), + template.getConfiguration(), + template.getContext(), + template.getCategories(), + template.getType(), + template.isEnabled(), + template.getActivationPolicy(), + template.getMode() ); + } + + + /** * Create a Profile instance. * * @param name the abstract name of component meta data instance 1.4 +11 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Resource.java Index: Resource.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Resource.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Resource.java 2 Aug 2002 06:34:51 -0000 1.3 +++ Resource.java 12 Aug 2002 02:00:10 -0000 1.4 @@ -8,6 +8,7 @@ package org.apache.excalibur.merlin.model; import org.apache.excalibur.meta.info.ServiceDescriptor; +import org.apache.avalon.framework.context.Context; /** * Interface implemented by object capable of supply a resources. @@ -56,6 +57,15 @@ * @return an instance of the type constrained to the profile */ Object create() throws Exception; + + /** + * Return the resource instance using a supplied context. + * + * @param context a supplimentary context for inport resolution + * @return an instance of the type constrained to the profile + */ + Object create( String name ) throws Exception; + /** * Return the resource instance. 1.4 +2 -2 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ContainerBuilder.java Index: ContainerBuilder.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ContainerBuilder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ContainerBuilder.java 9 Aug 2002 15:28:04 -0000 1.3 +++ ContainerBuilder.java 12 Aug 2002 02:00:10 -0000 1.4 @@ -50,8 +50,8 @@ final ContainerCreator creator = getXMLContainerCreator( xprofile ); return creator.createPackagedContainerDescriptors( loader, type, inputStream ); - } + /** * Utility to get xml info builder, else throw 1.9 +114 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLContainerCreator.java Index: XMLContainerCreator.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLContainerCreator.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- XMLContainerCreator.java 8 Aug 2002 10:00:50 -0000 1.8 +++ XMLContainerCreator.java 12 Aug 2002 02:00:10 -0000 1.9 @@ -159,4 +159,117 @@ return new ContainerDescriptor( name, params, config, context, categories, type, enabled, activation, mode ); } + + public ClasspathDescriptor createClasspathDescriptor( Configuration config ) + throws ConfigurationException + { + ArrayList list = new ArrayList(); + Configuration[] configs = config.getChildren("fileset"); + for( int i=0; i For additional commands, e-mail: