mcconnell 2002/12/07 01:47:26 Modified: merlin build.xml merlin/src/java/org/apache/avalon/merlin Main.java merlin/src/java/org/apache/avalon/merlin/block DefaultBlock.java merlin/src/java/org/apache/avalon/merlin/container/builder XMLContainerCreator.java merlin/src/java/org/apache/avalon/merlin/kernel DefaultKernel.java Added: merlin/src/etc kernel.xml merlin/src/java/org/apache/avalon/merlin/block BlockFactory.java DefaultBlockFactory.java DefaultBlockFactory.xinfo Removed: merlin/src/java/org/apache/avalon/merlin/block BlockClassLoader.java merlin/src/java/org/apache/avalon/merlin/container ClasspathDescriptor.java FilesetDescriptor.java IncludeDescriptor.java LibraryDescriptor.java Log: Synchronization of the Merlin Kernel implemetation with the assembly refactoring. Revision Changes Path 1.3 +6 -5 avalon-sandbox/merlin/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/build.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- build.xml 3 Dec 2002 07:08:02 -0000 1.2 +++ build.xml 7 Dec 2002 09:47:26 -0000 1.3 @@ -129,8 +129,12 @@ <filter token="year" value="${year}"/> </filterset> </copy> + <copy todir="${build.conf}" flatten="true"> + <fileset dir="${src.dir}/etc" includes="kernel.xml"/> + </copy> <mkdir dir="${build.lib}"/> + <jar jarfile="${build.lib}/${jar.name}" basedir="${build.classes}" compress="${build.compress}" @@ -140,11 +144,8 @@ <zipfileset dir="${build.conf}" prefix="META-INF/"> <include name="LICENSE.txt"/> </zipfileset> - <zipfileset dir="${lib.dir}" prefix="BLOCK-INFO/lib"> - <include name="*.jar"/> - </zipfileset> - <zipfileset dir="${common.dir}" prefix="BLOCK-INFO/common"> - <include name="*.jar"/> + <zipfileset dir="${build.conf}" prefix="BLOCK-INFO/"> + <include name="kernel.xml"/> </zipfileset> </jar> </target> 1.1 avalon-sandbox/merlin/src/etc/kernel.xml Index: kernel.xml =================================================================== <!-- Merlin default kernel configuration. --> <kernel> <!-- Optional logging catagory creation directive. The logging element declares the application wide default logging priority. A target element enables defintion of a logging file to which log entries will be directed. The target name attribute is the name referenced by category elements defined within the loggers element. The target defaults of "default" which corresponds to a internal default logging target that issue messages to System.out (unless overriden by a target named default). If the target is declared inside a catagory element, it must refer to a named target element. The priority attribute may contain one of the values <code>DEBUG</code> <code>INFO</code>, <code>WARN</code>, or <code>ERROR</code> and declares the system wide default logging priority. The target must contain a single file element with the attribute <code>location</code> the corresponds to the name of the logging file to which log entries shall be written. --> <logging priority="INFO" target="default"> <category name="/sys/logger" priority="WARN"/> <target name="kernel"> <file location="kernel.log" /> </target> </logging> <categories priority="WARN"/> <engine> </engine> </kernel> 1.2 +0 -1 avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/Main.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Main.java 3 Dec 2002 07:08:02 -0000 1.1 +++ Main.java 7 Dec 2002 09:47:26 -0000 1.2 @@ -32,7 +32,6 @@ import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.merlin.block.Block; import org.apache.avalon.merlin.block.DefaultBlock; -import org.apache.avalon.merlin.block.BlockClassLoader; import org.apache.avalon.merlin.kernel.DefaultKernel; import org.apache.avalon.merlin.kernel.KernelException; import org.apache.avalon.assembly.util.ExceptionHelper; 1.2 +1 -1 avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/block/DefaultBlock.java Index: DefaultBlock.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/block/DefaultBlock.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DefaultBlock.java 3 Dec 2002 07:08:02 -0000 1.1 +++ DefaultBlock.java 7 Dec 2002 09:47:26 -0000 1.2 @@ -29,7 +29,7 @@ Attributes attributes = manifest.getAttributes( Block.AVALON_BLOCK_KEY ); if( attributes == null ) { - throw new NullPointerException( "block" ); + throw new NullPointerException( "attributes" ); } if( attributes.containsKey( BLOCK_NAME ) ) 1.1 avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/block/BlockFactory.java Index: BlockFactory.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.avalon.merlin.block; import java.util.Map; import org.apache.avalon.assembly.appliance.ApplianceFactory; /** * An appliance manager implemetation provides support for the * creation and retrival of appliance instances. * * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a> * @version $Revision: 1.1 $ $Date: 2002/12/07 09:47:26 $ */ public interface BlockFactory extends ApplianceFactory { } 1.1 avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/block/DefaultBlockFactory.java Index: DefaultBlockFactory.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.avalon.merlin.block; import java.util.Map; import java.util.Hashtable; import java.util.Iterator; import java.util.ArrayList; import org.apache.avalon.framework.Version; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.configuration.Configuration; 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.service.Serviceable; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.DefaultContext; import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.context.Contextualizable; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.meta.info.DependencyDescriptor; import org.apache.avalon.meta.info.StageDescriptor; import org.apache.avalon.meta.info.ReferenceDescriptor; import org.apache.avalon.meta.model.Profile; import org.apache.avalon.meta.info.InfoDescriptor; import org.apache.avalon.assembly.lifestyle.LifestyleService; import org.apache.avalon.assembly.lifestyle.DefaultLifestyleService; import org.apache.avalon.assembly.logging.DefaultLoggingManager; import org.apache.avalon.assembly.logging.LoggingManager; import org.apache.avalon.assembly.engine.Engine; import org.apache.avalon.assembly.appliance.Appliance; import org.apache.avalon.assembly.appliance.ApplianceException; import org.apache.avalon.assembly.appliance.DefaultApplianceFactory; /** * The default appliance manager provides support for {@link Appliance} * creation, registration and retrival. * * @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a> * @version $Revision: 1.1 $ $Date: 2002/12/07 09:47:26 $ */ public class DefaultBlockFactory extends DefaultApplianceFactory implements BlockFactory { //================================================================== // ApplianceFactory //================================================================== /** * Creation of a new Appliance instance based on a supplied profile, enabled * state and activation policy. * @param profile the component deployment profile * @param enabled the enabled state of the appliance * @param activation the activation policy * @param map a map of context entries to be included in the deployment context * @return the appliance */ public Appliance createAppliance( Engine engine, Profile profile, boolean enabled, boolean activation, Context system, Map map ) throws ApplianceException { if( profile == null ) { throw new NullPointerException( "profile" ); } if( getLogger().isDebugEnabled() ) { getLogger().debug( "create: " + profile.getName() ); } try { DefaultBlock block = new DefaultBlock(); block.enableLogging( getLogger().getChildLogger( profile.getName() ) ); DefaultContext context; if( map == null ) { context = new DefaultContext( system ); } else { context = new DefaultContext( map, system ); } context.put( "urn:assembly:appliance.profile", profile ); context.put( "urn:assembly:appliance.enabled", new Boolean( enabled ) ); context.put( "urn:assembly:appliance.activation", new Boolean( activation ) ); context.makeReadOnly(); block.contextualize( context ); DefaultServiceManager manager = new DefaultServiceManager(); manager.put( "urn:assembly:engine.classloader", engine ); manager.makeReadOnly(); block.service( manager ); block.initialize(); engine.assemble( block ); return block; } catch( Throwable e ) { final String error = "Error while attempting to create standard block" + " from the profile: " + profile; throw new ApplianceException( error, e ); } } } 1.1 avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/block/DefaultBlockFactory.xinfo Index: DefaultBlockFactory.xinfo =================================================================== <?xml version="1.0"?> <!DOCTYPE type PUBLIC "-//AVALON/Component Type DTD Version 1.0//EN" "http://jakarta.apache.org/avalon/dtds/meta/type_1_0.dtd" > <!-- 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. @author Stephen McConnell @version 1.0 12/03/2001 --> <type> <info> <name>factory</name> <version>1.0</version> </info> <context> <entry key="urn:assembly:system-map" type="java.util.Map" optional="true"/> </context> <services> <service> <reference type="org.apache.avalon.assembly.appliance.ApplianceFactory" version="1.0"/> </service> </services> </type> 1.2 +10 -29 avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/builder/XMLContainerCreator.java Index: XMLContainerCreator.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/container/builder/XMLContainerCreator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- XMLContainerCreator.java 3 Dec 2002 07:08:02 -0000 1.1 +++ XMLContainerCreator.java 7 Dec 2002 09:47:26 -0000 1.2 @@ -76,15 +76,16 @@ import org.apache.avalon.meta.model.Mode; import org.apache.avalon.meta.model.Profile; import org.apache.avalon.meta.model.builder.XMLProfileCreator; -import org.apache.avalon.merlin.container.ClasspathDescriptor; -import org.apache.avalon.merlin.container.ContainerDescriptor; -import org.apache.avalon.merlin.container.LibraryDescriptor; -import org.apache.avalon.merlin.container.FilesetDescriptor; -import org.apache.avalon.merlin.container.IncludeDescriptor; +import org.apache.avalon.assembly.engine.model.ClasspathDescriptor; +import org.apache.avalon.assembly.engine.model.LibraryDescriptor; +import org.apache.avalon.assembly.engine.model.FilesetDescriptor; +import org.apache.avalon.assembly.engine.model.IncludeDescriptor; +import org.apache.avalon.assembly.engine.model.EngineConfigurationHelper; import org.apache.avalon.assembly.logging.LoggingDescriptor; import org.apache.avalon.assembly.logging.FileTargetProvider; import org.apache.avalon.assembly.logging.TargetDescriptor; import org.apache.avalon.assembly.logging.TargetProvider; +import org.apache.avalon.merlin.container.ContainerDescriptor; import org.xml.sax.InputSource; /** @@ -261,16 +262,7 @@ public ClasspathDescriptor createClasspathDescriptor( Configuration config ) throws ConfigurationException { - ArrayList list = new ArrayList(); - Configuration[] configs = config.getChildren( "fileset" ); - for( int i = 0; i < configs.length; i++ ) - { - Configuration c = configs[ i ]; - list.add( createFilesetDescriptor( c ) ); - } - FilesetDescriptor[] filesets = - (FilesetDescriptor[])list.toArray( new FilesetDescriptor[ 0 ] ); - return new ClasspathDescriptor( filesets ); + return EngineConfigurationHelper.createClasspathDescriptor( config ); } /** @@ -284,17 +276,7 @@ public FilesetDescriptor createFilesetDescriptor( Configuration config ) throws ConfigurationException { - String base = config.getAttribute( "dir" ); - ArrayList list = new ArrayList(); - Configuration[] includeConfigs = config.getChildren( "include" ); - for( int i = 0; i < includeConfigs.length; i++ ) - { - Configuration includeConfig = includeConfigs[ i ]; - list.add( createIncludeDescriptor( includeConfig ) ); - } - IncludeDescriptor[] includes = - (IncludeDescriptor[])list.toArray( new IncludeDescriptor[ 0 ] ); - return new FilesetDescriptor( base, includes ); + return EngineConfigurationHelper.createFilesetDescriptor( config ); } /** @@ -308,8 +290,7 @@ public IncludeDescriptor createIncludeDescriptor( Configuration config ) throws ConfigurationException { - String filename = config.getAttribute( "name" ); - return new IncludeDescriptor( filename ); + return EngineConfigurationHelper.createIncludeDescriptor( config ); } /** 1.2 +24 -15 avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/kernel/DefaultKernel.java Index: DefaultKernel.java =================================================================== RCS file: /home/cvs/avalon-sandbox/merlin/src/java/org/apache/avalon/merlin/kernel/DefaultKernel.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DefaultKernel.java 3 Dec 2002 07:08:03 -0000 1.1 +++ DefaultKernel.java 7 Dec 2002 09:47:26 -0000 1.2 @@ -80,7 +80,7 @@ import org.apache.avalon.assembly.logging.LoggingManager; import org.apache.avalon.assembly.logging.LoggingDescriptor; import org.apache.avalon.assembly.logging.DefaultLoggingManager; -import org.apache.avalon.assembly.engine.DefaultEngine; +import org.apache.avalon.assembly.engine.EngineClassLoader; import org.apache.avalon.assembly.engine.Engine; import org.apache.avalon.assembly.util.ExceptionHelper; @@ -217,10 +217,9 @@ // Setup the logging system // - final String root = "/"; - try { + final String root = "/"; c_logging = bootstrapLoggingManager( root ); Configuration categoriesConfig = m_config.getChild( "categories" ); LoggingDirective categories = @@ -399,18 +398,28 @@ getLogger().debug( "bootstrap engine" ); } - DefaultEngine engine = new DefaultEngine(); - engine.enableLogging( getLogger().getChildLogger( "engine" ) ); - engine.configure( config ); - DefaultContext context = new DefaultContext(); - context.put( "urn:avalon:home", m_home ); - engine.contextualize( context ); - DefaultServiceManager manager = new DefaultServiceManager(); - manager.put( "urn:assembly:logging.manager", logging ); - manager.makeReadOnly(); - engine.service( manager ); - engine.initialize(); - return engine; + try + { + EngineClassLoader engine = new EngineClassLoader(); + engine.enableLogging( getLogger().getChildLogger( "engine" ) ); + engine.configure( config ); + DefaultContext context = new DefaultContext(); + context.put( "urn:avalon:home", m_home ); + context.put( "urn:assembly:engine.bootstrap", new Boolean( true ) ); + context.makeReadOnly(); + engine.contextualize( context ); + DefaultServiceManager manager = new DefaultServiceManager(); + manager.put( "urn:assembly:logging.manager", logging ); + manager.makeReadOnly(); + engine.service( manager ); + engine.initialize(); + return engine; + } + catch( Throwable e ) + { + final String error = "Engine bootstrap failure."; + throw new CascadingException( error, e ); + } } private Logger getLogger()
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>