Return-Path: Delivered-To: apmail-jakarta-avalon-cvs-archive@apache.org Received: (qmail 26318 invoked from network); 2 Aug 2002 06:36:17 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 2 Aug 2002 06:36:17 -0000 Received: (qmail 5931 invoked by uid 97); 2 Aug 2002 06:36:47 -0000 Delivered-To: qmlist-jakarta-archive-avalon-cvs@jakarta.apache.org Received: (qmail 5865 invoked by uid 97); 2 Aug 2002 06:36:46 -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 5853 invoked by uid 97); 2 Aug 2002 06:36:45 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 2 Aug 2002 06:36:10 -0000 Message-ID: <20020802063610.78070.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/merlin/kernel/doc-files DefaultKernel.gif 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/01 23:36:10 Modified: assembly build.xml assembly/demo/src/etc demo.mf assembly/src/etc kernel.xml merlin.html sevak.xml assembly/src/java/org/apache/excalibur/merlin DefaultController.java DefaultController.xinfo Main.java assembly/src/java/org/apache/excalibur/merlin/assembly DefaultLoggerManager.java DependencyGraph.java ProfileRegistry.java TypeManager.java TypeRegistry.java assembly/src/java/org/apache/excalibur/merlin/assembly/resource AbstractExtension.java DefaultManager.java LifecycleHelper.java ProfileDesignator.java ResourceProvider.java assembly/src/java/org/apache/excalibur/merlin/container DefaultContainer.java DefaultContainer.xinfo assembly/src/java/org/apache/excalibur/merlin/doc-files DefaultController.gif assembly/src/java/org/apache/excalibur/merlin/kernel DefaultKernel.java DefaultKernel.xinfo assembly/src/java/org/apache/excalibur/merlin/kernel/doc-files DefaultKernel.gif Added: assembly/src/java/org/apache/excalibur/merlin/assembly/resource ResourceRuntimeException.java Log: general enhancements to support simplified coding when embedding a kernel Revision Changes Path 1.35 +2 -2 jakarta-avalon-excalibur/assembly/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/build.xml,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- build.xml 30 Jul 2002 13:49:06 -0000 1.34 +++ build.xml 2 Aug 2002 06:36:09 -0000 1.35 @@ -299,8 +299,8 @@ + token="org.apache.excalibur.merlin.builder" + value="org.apache.excalibur.merlin.model.builder" > 1.8 +3 -0 jakarta-avalon-excalibur/assembly/demo/src/etc/demo.mf Index: demo.mf =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/etc/demo.mf,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- demo.mf 30 Jul 2002 13:49:07 -0000 1.7 +++ demo.mf 2 Aug 2002 06:36:09 -0000 1.8 @@ -24,3 +24,6 @@ Name: org/apache/excalibur/playground/DemoManager.class Avalon-Facility: true + +Name: org/apache/excalibur/playground/EmbeddedDemo.class +Avalon-Block: true 1.20 +18 -7 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.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- kernel.xml 30 Jul 2002 07:05:54 -0000 1.19 +++ kernel.xml 2 Aug 2002 06:36:09 -0000 1.20 @@ -21,19 +21,19 @@ the corresponds to the name of the logging file. --> - + + - + 1.10 +86 -45 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.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- DefaultController.java 30 Jul 2002 13:49:07 -0000 1.9 +++ DefaultController.java 2 Aug 2002 06:36:09 -0000 1.10 @@ -24,16 +24,19 @@ import org.apache.avalon.framework.context.Contextualizable; import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.logger.Logger; -import org.apache.excalibur.merlin.assembly.ProfileManager; -import org.apache.excalibur.merlin.container.model.ContainerDescriptor; +import org.apache.excalibur.merlin.assembly.TypeManager; +import org.apache.excalibur.merlin.assembly.ContainerManager; +import org.apache.excalibur.merlin.model.ContainerDescriptor; +import org.apache.excalibur.merlin.kernel.Kernel; +import org.apache.excalibur.merlin.assembly.ContainerManager; import org.apache.excalibur.merlin.kernel.DefaultKernel; import org.apache.excalibur.merlin.kernel.KernelException; -import org.apache.excalibur.merlin.kernel.model.KernelDescriptor; -import org.apache.excalibur.merlin.kernel.builder.XMLKernelCreator; +import org.apache.excalibur.merlin.model.builder.XMLContainerUtil; import org.apache.excalibur.merlin.model.Resource; -import org.apache.excalibur.merlin.container.model.ClasspathDescriptor; -import org.apache.excalibur.merlin.container.model.ExtensionsDescriptor; -import org.apache.excalibur.merlin.kernel.model.LoggingDescriptor; +import org.apache.excalibur.merlin.model.CategoriesDescriptor; +import org.apache.excalibur.merlin.model.ClasspathDescriptor; +import org.apache.excalibur.merlin.model.ExtensionsDescriptor; +import org.apache.excalibur.merlin.model.LoggingDescriptor; /** @@ -54,13 +57,15 @@ * // create the execution context * // * - * File file = new File( "src/etc/kernel.xml" ); + * File base = new File( "." ); + * String filename = "src/etc/kernel.xml" ); * DefaultContext context = new DefaultContext(); - * context.put( DefaultController.CONTROLLER_PATH_KEY, file ); + * context.put( DefaultController.APPLICATION_DIR_KEY, base ); + * context.put( DefaultController.CONTROLLER_PATH_KEY, filename ); * context.makeReadOnly(); * * // - * // deploy the kernel + * // deploy the controller * // * * DefaultController controller = new DefaultController(); @@ -89,15 +94,18 @@ private static final int STOPPED = 3; private static final int DISPOSED = 4; - public static final String CONTROLLER_PATH_KEY = "path"; + public static final String CONTROLLER_PATH_KEY = "merlin:path"; + public static final String APPLICATION_DIR_KEY = "avalon:home"; //======================================================================= // state //======================================================================= - private File m_path; + private File m_home; - private final DefaultKernel m_kernel = new DefaultKernel(); + private String m_path; + + private DefaultKernel m_kernel; private int m_status = NOT_READY; @@ -107,12 +115,29 @@ /** * Invoked by the bootstrap process to supply the path to the kernel configuration. - * @param context the context object containing the inital path + * @param context the context object containing the working directory under the + * context key {@link #APPLICATION_DIR_KEY} as a {@link File}, and the path to + * the kernel configuration as a string, supplied under the key {@link #CONTROLLER_PATH_KEY} * @exception ContextException if the supplied does not contain a CONTROLLER_PATH_KEY value */ public void contextualize( Context context ) throws ContextException { - m_path = (File) context.get( CONTROLLER_PATH_KEY ); + try + { + m_path = (String) context.get( CONTROLLER_PATH_KEY ); + } + catch( ContextException e ) + { + m_path = "kernel.xml"; + } + try + { + m_home = (File) context.get( APPLICATION_DIR_KEY ); + } + catch( ContextException e ) + { + m_home = new File( System.getProperty("user.dir") ); + } m_status = CONTEXTUALIZED; } @@ -120,55 +145,72 @@ // Initializable //======================================================================= + /** + * Initialization of the controller resulting in the establishment of a new Kernel. + * The initialization action undertakes the following: + *
    + *
  • validation of the application home directory + *
  • validation that the configuration path is resolvable relative to the home directory + *
  • marchalls the XML kernel description into a kernel meta-data model + *
  • establishes a kernel instance + *
  • establishes and applies the application context to the kernel + *
  • initilializes the kernel + *
+ * + * @exception Exception if a validation or establishment error occurs + */ public void initialize() throws Exception { if( m_status < CONTEXTUALIZED ) throw new ControllerException( "Controller has not been contextualized." ); - Configuration config = null; - XMLKernelCreator creator = new XMLKernelCreator(); - KernelDescriptor descriptor = null; - try + final File file = new File( m_home, m_path ); + if( !file.exists() ) { - - // - // build the kernel descriptor - // - - config = getProfile( m_path ); - descriptor = creator.createKernelDescriptor( - config, Thread.currentThread().getContextClassLoader() ); - descriptor.getLogger().info("kernel descriptor created"); - + final String error = "Supplied filename does not exist. (" + file + ")"; + throw new ControllerException( error ); } - catch( Throwable e ) + if( file.isDirectory() ) { - final String error = "Controller bootstrap failure."; - throw new ControllerException( error, e ); + final String error = "Supplied filename is not a file. (" + file + ")"; + throw new ControllerException( error ); + } + if( !file.canRead() ) + { + final String error = "Cannot read the file. (" + file + ")"; + throw new ControllerException( error ); } - // run it up + // + // create the application context + // (in the future this should include a more general framework where + // application context can be defined in the kernel configuration) + // DefaultContext context = new DefaultContext(); - context.put( DefaultKernel.KERNEL_DESCRIPTOR_KEY, descriptor ); + context.put( DefaultKernel.APPLICATION_DIR_KEY, m_home ); context.makeReadOnly(); + + Configuration config = null; + config = getProfile( file ); + try { - m_kernel.enableLogging( descriptor.getLogger() ); + // + // create the kernel + // + + m_kernel = new DefaultKernel(); m_kernel.contextualize( context ); - m_kernel.initialize( ); - } - catch( KernelException e ) - { - final String error = "Kernel initialization failure."; - throw new ControllerException( error, e ); + m_kernel.configure( config ); + m_kernel.initialize(); } catch( Throwable e ) { - final String error = "Unexpected initialization failure."; + final String error = "Kernel establishment failure."; throw new ControllerException( error, e ); } - + m_status = INITIALIZED; } @@ -219,7 +261,6 @@ // ignore } } - m_kernel.dispose(); m_status = DISPOSED; } 1.3 +2 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/DefaultController.xinfo Index: DefaultController.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/DefaultController.xinfo,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefaultController.xinfo 29 Jul 2002 06:14:29 -0000 1.2 +++ DefaultController.xinfo 2 Aug 2002 06:36:09 -0000 1.3 @@ -18,7 +18,8 @@ - + + 1.11 +13 -31 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Main.java Index: Main.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/Main.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Main.java 30 Jul 2002 07:05:55 -0000 1.10 +++ Main.java 2 Aug 2002 06:36:09 -0000 1.11 @@ -56,13 +56,11 @@ import org.apache.excalibur.meta.info.ServiceDescriptor; import org.apache.excalibur.meta.info.DependencyDescriptor; import org.apache.excalibur.meta.info.ReferenceDescriptor; -import org.apache.excalibur.merlin.assembly.ProfileManager; -import org.apache.excalibur.merlin.container.model.ContainerDescriptor; -import org.apache.excalibur.merlin.kernel.builder.XMLKernelCreator; -import org.apache.excalibur.merlin.kernel.model.KernelDescriptor; -import org.apache.excalibur.merlin.container.model.ClasspathDescriptor; -import org.apache.excalibur.merlin.container.model.ExtensionsDescriptor; -import org.apache.excalibur.merlin.kernel.model.LoggingDescriptor; +import org.apache.excalibur.merlin.assembly.ContainerManager; +import org.apache.excalibur.merlin.model.ContainerDescriptor; +import org.apache.excalibur.merlin.model.ClasspathDescriptor; +import org.apache.excalibur.merlin.model.ExtensionsDescriptor; +import org.apache.excalibur.merlin.model.LoggingDescriptor; import org.apache.excalibur.merlin.kernel.DefaultKernel; import org.apache.excalibur.merlin.kernel.KernelException; @@ -136,33 +134,16 @@ */ public static void main( String[] args ) { + // - // get the filename from the command line arguments and check it - // for existance and general integrity + // get the filename from the command line argument // - File path = null; + String filename = null; + final File base = new File( System.getProperty("user.dir") ); if( args.length > 0 ) { - String filename = args[0]; - path = new File( filename ); - if( !path.exists() ) - { - final String error = "Supplied filename does not exist. (" + filename + ")"; - throw new ControllerRuntimeException( error ); - } - - if( path.isDirectory() ) - { - final String error = "Supplied filename is not a file. (" + filename + ")"; - throw new ControllerRuntimeException( error ); - } - - if( !path.canRead() ) - { - final String error = "Cannot read the file. (" + filename + ")"; - throw new ControllerRuntimeException( error ); - } + filename = args[0]; } else { @@ -176,7 +157,8 @@ final DefaultController controller = new DefaultController(); DefaultContext context = new DefaultContext(); - context.put( DefaultController.CONTROLLER_PATH_KEY, path ); + context.put( DefaultController.APPLICATION_DIR_KEY, base ); + context.put( DefaultController.CONTROLLER_PATH_KEY, filename ); context.makeReadOnly(); Runtime.getRuntime().addShutdownHook( new Thread() 1.2 +20 -33 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DefaultLoggerManager.java Index: DefaultLoggerManager.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DefaultLoggerManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DefaultLoggerManager.java 29 Jul 2002 06:14:29 -0000 1.1 +++ DefaultLoggerManager.java 2 Aug 2002 06:36:09 -0000 1.2 @@ -28,11 +28,11 @@ import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.logger.AvalonFormatter; import org.apache.avalon.framework.logger.LogKitLogger; -import org.apache.excalibur.merlin.container.model.Parent; -import org.apache.excalibur.merlin.kernel.model.TargetDescriptor; -import org.apache.excalibur.merlin.kernel.model.LoggingDescriptor; -import org.apache.excalibur.merlin.kernel.model.TargetProvider; -import org.apache.excalibur.merlin.kernel.model.FileTargetProvider; +//import org.apache.excalibur.merlin.model.Parent; +import org.apache.excalibur.merlin.model.TargetDescriptor; +import org.apache.excalibur.merlin.model.LoggingDescriptor; +import org.apache.excalibur.merlin.model.TargetProvider; +import org.apache.excalibur.merlin.model.FileTargetProvider; import org.apache.excalibur.merlin.model.Category; import org.apache.excalibur.merlin.model.CategoriesDescriptor; @@ -90,6 +90,15 @@ /** * Creation of a new LoggerManager. + * @exception Exception is an error occurs + */ + public DefaultLoggerManager() throws Exception + { + this( new LoggingDescriptor( "", null, null, new TargetDescriptor[0] ) ); + } + + /** + * Creation of a new LoggerManager. * @param descriptor the logging system description * @exception Exception is an error occurs */ @@ -107,14 +116,12 @@ m_targets.put( DEFAULT_TARGET, m_stream ); if( descriptor.getPriority() != null ) { - getLogger().debug("supplied system priority: " + descriptor.getPriority() ); getHierarchy().setDefaultPriority( Priority.getPriorityForName( descriptor.getPriority( ) ) ); } else { - getLogger().debug("internal system priority: " + DEFAULT_PRIORITY ); getHierarchy().setDefaultPriority( Priority.getPriorityForName( DEFAULT_PRIORITY ) ); @@ -165,29 +172,9 @@ * @param path the category header * @param descriptor a set of category descriptors to be added under the path */ - public void addCategories( Parent parent, CategoriesDescriptor descriptor ) - { - String path = null; - final String name = descriptor.getName(); - if( parent != null ) - { - path = parent.getPath().replace('/','.').substring(1) + "." + name; - } - else - { - path = name; - } - addCategories( path, descriptor ); - } - - /** - * Add a set of category entries using the system wide defaults. - * @param path the category header - * @param descriptor a set of category descriptors to be added under the path - */ public void addCategories( String path, CategoriesDescriptor descriptor ) { - addSingleCategory( path, descriptor.getPriority(), descriptor.getTarget( ) ); + addCategory( path, descriptor.getPriority(), descriptor.getTarget( ) ); Category[] categories = descriptor.getCategories(); for( int i=0; iUtility class to help aquire a ordered graph of @@ -240,6 +241,27 @@ final ArrayList done, final ArrayList order ) { + // + // get all of the extensions the provide extension + // support to the subject profile + // + + final PhaseDescriptor[] phases = profile.getType().getPhases(); + for( int i=(phases.length-1); i>-1; i-- ) + { + PhaseDescriptor phase = phases[i]; + Profile extension = profile.getExtensionProfile( phase ); + if( extension != null ) + { + visitcomponent( extension, true, done, order ); + } + } + + // + // get all of the profiles that are service providers + // towards the target profile + // + final DependencyDescriptor[] descriptors = profile.getType().getDependencies(); @@ -285,8 +307,28 @@ { final Profile other = (Profile)m_components.get( i ); - final Association[] providers = other.getAssociations(); + // + // check if the 'other' profile is used by this 'profile' + // as an extension provider + // + + final PhaseDescriptor[] phases = other.getType().getPhases(); + for( int j = 0; j < phases.length; j++ ) + { + Profile extension = other.getExtensionProfile( phases[j] ); + if( extension.equals( profile ) ) + { + visitcomponent( other, false, done, order ); + } + } + + // + // check if the 'other' profile is used by this 'profile' + // as a service provider + // + + final Association[] providers = other.getAssociations(); for( int j = 0; j < providers.length; j++ ) { if( providers[ j ].getProvider().equals( profile ) ) 1.4 +4 -4 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ProfileRegistry.java Index: ProfileRegistry.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/ProfileRegistry.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ProfileRegistry.java 30 Jul 2002 13:49:07 -0000 1.3 +++ ProfileRegistry.java 2 Aug 2002 06:36:09 -0000 1.4 @@ -54,7 +54,7 @@ /** * Classloader used to load a service profile selector. */ - private ProfileManager m_classloader; + private ContainerManager m_classloader; /** * The dependency map that is populated during the assembly process. @@ -70,7 +70,7 @@ * @param loader the registry class loader * @param map the dependency map */ - public ProfileRegistry( ProfileManager loader, DependencyGraph map ) + public ProfileRegistry( ContainerManager loader, DependencyGraph map ) { m_classloader = loader; m_map = map; @@ -98,7 +98,7 @@ assembleProfile( profile, visited, "" ); final String name = - m_classloader.getPath() + ProfileManager.DELIMITER + profile.getName(); + m_classloader.getPath() + ContainerManager.DELIMITER + profile.getName(); final Resource resource = m_classloader.getResource( profile, true ); getLogger().debug( "created explicit resource for: " + name ); m_map.add( profile ); 1.3 +38 -27 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java Index: TypeManager.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TypeManager.java 30 Jul 2002 07:05:55 -0000 1.2 +++ TypeManager.java 2 Aug 2002 06:36:09 -0000 1.3 @@ -45,14 +45,14 @@ import org.apache.excalibur.meta.info.Facility; import org.apache.excalibur.meta.info.ReferenceDescriptor; import org.apache.excalibur.meta.info.PhaseDescriptor; -import org.apache.excalibur.merlin.container.model.IncludeDescriptor; -import org.apache.excalibur.merlin.container.model.ExtensionsDescriptor; -import org.apache.excalibur.merlin.container.model.DirsetDescriptor; -import org.apache.excalibur.merlin.container.model.ClasspathDescriptor; -import org.apache.excalibur.merlin.container.model.FilesetDescriptor; -import org.apache.excalibur.merlin.container.model.IncludeDescriptor; -import org.apache.excalibur.merlin.container.model.ExtensionsDescriptor; -import org.apache.excalibur.merlin.container.model.DirsetDescriptor; +import org.apache.excalibur.merlin.model.IncludeDescriptor; +import org.apache.excalibur.merlin.model.ExtensionsDescriptor; +import org.apache.excalibur.merlin.model.DirsetDescriptor; +import org.apache.excalibur.merlin.model.ClasspathDescriptor; +import org.apache.excalibur.merlin.model.FilesetDescriptor; +import org.apache.excalibur.merlin.model.IncludeDescriptor; +import org.apache.excalibur.merlin.model.ExtensionsDescriptor; +import org.apache.excalibur.merlin.model.DirsetDescriptor; /** * Abstract type manager. @@ -93,6 +93,11 @@ private Logger m_logger; /** + * Logging channel for the type manager. + */ + private Logger m_localLogger; + + /** * Description of the extension directories. */ private ExtensionsDescriptor m_extensions; @@ -140,6 +145,7 @@ public void enableLogging( Logger logger ) { m_logger = logger; + m_localLogger = logger.getChildLogger("loader"); } protected Logger getLogger() @@ -147,6 +153,12 @@ return m_logger; } + protected Logger getLocalLogger() + { + return m_localLogger; + } + + //======================================================================= // Contextualizable //======================================================================= @@ -158,7 +170,6 @@ */ public void contextualize( Context context ) throws ContextException { - getLogger().debug( "contextualize" ); try { m_extensions = (ExtensionsDescriptor) context.get( EXTENSIONS_DESCRIPTOR_KEY ); @@ -188,8 +199,8 @@ // initialize the type registries and install the classpath // - getLogger().debug("initialize"); - m_types = new TypeRegistry( this, getLogger().getChildLogger( "types" ) ); + getLocalLogger().debug("initialize"); + m_types = new TypeRegistry( this, getLocalLogger().getChildLogger( "types" ) ); // // setup the extension directories @@ -197,7 +208,7 @@ if( m_extensions != null ) { - getLogger().debug( "initializing extensions libraries" ); + getLocalLogger().debug( "initializing extensions libraries" ); ArrayList list = new ArrayList(); File dir = new File( System.getProperty("user.dir") ); DirsetDescriptor[] dirs = m_extensions.getDirsetDescriptors(); @@ -232,7 +243,7 @@ if( m_classpath != null ) { - getLogger().debug("installing classpath"); + getLocalLogger().debug("installing classpath"); addClasspath( m_classpath ); } } @@ -279,7 +290,7 @@ catch( Throwable e ) { final String warning = "Bypassing type: " + path ; - getLogger().warn( warning, e ); + getLocalLogger().warn( warning, e ); } } } @@ -295,7 +306,7 @@ catch( Throwable e ) { final String warning = "Bypassing extension: " + path ; - getLogger().warn( warning, e ); + getLocalLogger().warn( warning, e ); } } } @@ -325,7 +336,7 @@ */ void addClasspath( ClasspathDescriptor classpath ) throws Exception { - getLogger().debug( "adding classpath" ); + getLocalLogger().debug( "adding classpath" ); List list = new ArrayList(); Vector stack = new Vector(); File dir = new File( System.getProperty("user.dir") ); @@ -349,16 +360,16 @@ for( int i = 0; i < extensions.length; i++ ) { URL url = extensions[ i ].toURL(); - getLogger().info("extension: " + url ); + getLocalLogger().info("extension: " + url ); super.addURL( url ); } load( stack ); for( int i = 0; i < urls.length; i++ ) { - getLogger().info("adding: " + urls[i] ); + getLocalLogger().info("adding: " + urls[i] ); scan( urls[i] ); } - getLogger().debug( "classpath addition complete" ); + getLocalLogger().debug( "classpath addition complete" ); } @@ -377,13 +388,13 @@ private void load( Vector stack ) { int size = stack.size(); - getLogger().debug( "Stack size: " + stack.size() ); + getLocalLogger().debug( "Stack size: " + stack.size() ); Hashtable errors = new Hashtable(); Enumeration enum = stack.elements(); while( enum.hasMoreElements() ) { File file = (File)enum.nextElement(); - getLogger().debug( "Loading resource: " + file ); + getLocalLogger().debug( "Loading resource: " + file ); try { super.addURL( file.toURL() ); @@ -391,7 +402,7 @@ } catch( Throwable error ) { - getLogger().warn( + getLocalLogger().warn( "Encountered error while loading resource: " + file, error ); errors.put( file, error ); } @@ -407,11 +418,11 @@ else { Enumeration keys = errors.keys(); - getLogger().error( "Load error count = " + errors.size() ); + getLocalLogger().error( "Load error count = " + errors.size() ); while( keys.hasMoreElements() ) { File key = (File)keys.nextElement(); - getLogger().error( + getLocalLogger().error( "Error while loading file." + "\n\tfile: " + key.toString(), (Throwable)errors.get( key ) ); } @@ -437,7 +448,7 @@ */ public Type loadType( String classname ) throws Exception { - getLogger().debug("LOOKUP: " + classname ); + getLocalLogger().debug("LOOKUP: " + classname ); Type type = m_types.loadType( classname ); if( type != null ) { @@ -564,7 +575,7 @@ extension.getImplementationURL() }; final String message = REZ.format( "missing.extension", params ); - getLogger().warn( message ); + getLocalLogger().warn( message ); } final String message = 1.3 +2 -2 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeRegistry.java Index: TypeRegistry.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeRegistry.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TypeRegistry.java 30 Jul 2002 07:05:55 -0000 1.2 +++ TypeRegistry.java 2 Aug 2002 06:36:09 -0000 1.3 @@ -82,7 +82,7 @@ super.enableLogging( logger ); m_typeBuilder.enableLogging( logger.getChildLogger("component") ); m_facilityBuilder.enableLogging( logger.getChildLogger("facility") ); - getLogger().info("type registry established"); + getLogger().debug("type registry established"); } //======================================================================= 1.2 +37 -25 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/AbstractExtension.java Index: AbstractExtension.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/AbstractExtension.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AbstractExtension.java 30 Jul 2002 13:52:57 -0000 1.1 +++ AbstractExtension.java 2 Aug 2002 06:36:09 -0000 1.2 @@ -30,30 +30,42 @@ */ public void extend( int stage, Object object, Context context ) throws Exception - { - if( stage == CREATE ) - { - if( getLogger().isDebugEnabled() ) - getLogger().debug("extend CREATE" ); - } - else if( stage == ACCESS ) - { - if( getLogger().isDebugEnabled() ) - getLogger().debug("extend ACCESS" ); - } - else if( stage == RELEASE ) - { - if( getLogger().isDebugEnabled() ) - getLogger().debug("extend RELEASE" ); - } - else if( stage == DESTROY ) - { - if( getLogger().isDebugEnabled() ) - getLogger().debug("extend DESTROY" ); - } - else - { - throw new IllegalArgumentException("stage"); - } + { + if( getLogger().isDebugEnabled() ) + getLogger().debug( + "extending " + object.getClass().getName() + + "#" + System.identityHashCode( object ) + + " for stage " + stageToString( stage ) ); } + + /** + * Utility method to return a string representation of the lifecycle stage. + * @param stage the lifecycle stage + * @return the string representation of the stage + */ + public static String stageToString( int stage ) + { + if( stage == CREATE ) + { + return "CREATE"; + } + else if( stage == ACCESS ) + { + return "ACCESS"; + } + else if( stage == RELEASE ) + { + return "RELEASE"; + } + else if( stage == DESTROY ) + { + return "DESTROY"; + } + else + { + throw new IllegalArgumentException( "stage: " + stage ); + } + } + + } 1.4 +13 -3 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/DefaultManager.java Index: DefaultManager.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/DefaultManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DefaultManager.java 30 Jul 2002 14:34:04 -0000 1.3 +++ DefaultManager.java 2 Aug 2002 06:36:09 -0000 1.4 @@ -12,6 +12,7 @@ import java.util.Map; import java.util.Hashtable; import org.apache.avalon.framework.service.ServiceException; +import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.excalibur.merlin.model.Resource; @@ -84,12 +85,21 @@ /** * Release a pooled object. * @param object a pooled object + * @exception ResourceRuntimeException is an error occurs during release */ - public void put( Object object ) + public void put( Object object ) throws ResourceRuntimeException { final Resource resource = (Resource) m_mapping.get( object ); - resource.release( object ); - m_mapping.remove( object ); + try + { + resource.release( object ); + m_mapping.remove( object ); + } + catch( Throwable e ) + { + final String error = "Unexpected error while attempting to release resource: " + resource; + throw new ResourceRuntimeException( error, e ); + } } } 1.4 +2 -4 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/LifecycleHelper.java Index: LifecycleHelper.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/LifecycleHelper.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- LifecycleHelper.java 30 Jul 2002 13:49:07 -0000 1.3 +++ LifecycleHelper.java 2 Aug 2002 06:36:09 -0000 1.4 @@ -245,9 +245,7 @@ // // apply disposal extensions - // ### what about context ? ### - // ## what about extension exceptions - it should containue - // to subsequent extensions - needs testing ## + // ### TO-DO context ### // stage = STAGE_EXTENSION_POST; @@ -332,7 +330,6 @@ final int stage, final Throwable t ) { - //final String reason = t.getMessage(); final String reason = t.toString(); final String message = REZ.getString( "lifecycle.fail.error", @@ -366,4 +363,5 @@ getLogger().error( message ); throw new LifecycleException( message, t ); } + } 1.5 +24 -11 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/ProfileDesignator.java Index: ProfileDesignator.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/ProfileDesignator.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ProfileDesignator.java 30 Jul 2002 14:34:04 -0000 1.4 +++ ProfileDesignator.java 2 Aug 2002 06:36:09 -0000 1.5 @@ -150,25 +150,38 @@ { create(); } - handleExtensions( ExtensionDescriptor.ACCESS, m_service ); + + // + // handle the extension phases + // + + DefaultContext context = new DefaultContext(); + PhaseDescriptor[] phases = m_profile.getType().getPhases(); + for( int i=0; iStephen McConnell * @version $Revision: 1.1 $ $Date: 2002/08/02 06:36:09 $ */ public final class ResourceRuntimeException extends CascadingRuntimeException { /** * Construct a new ResourceRuntimeException instance. * * @param message The detail message for this exception. */ public ResourceRuntimeException( final String message ) { this( message, null ); } /** * Construct a new ResourceRuntimeException instance. * * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public ResourceRuntimeException( final String message, final Throwable throwable ) { super( message, throwable ); } } 1.19 +145 -60 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.java Index: DefaultContainer.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/DefaultContainer.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- DefaultContainer.java 30 Jul 2002 13:49:07 -0000 1.18 +++ DefaultContainer.java 2 Aug 2002 06:36:10 -0000 1.19 @@ -65,13 +65,16 @@ import org.apache.excalibur.meta.info.ReferenceDescriptor; import org.apache.excalibur.meta.verifier.VerifyException; import org.apache.excalibur.merlin.assembly.TypeManager; -import org.apache.excalibur.merlin.assembly.ProfileManager; +import org.apache.excalibur.merlin.assembly.ContainerManager; import org.apache.excalibur.merlin.assembly.DefaultLoggerManager; -import org.apache.excalibur.merlin.container.model.ContainerDescriptor; +import org.apache.excalibur.merlin.model.ContainerDescriptor; +import org.apache.excalibur.merlin.model.ClasspathDescriptor; import org.apache.excalibur.merlin.model.Profile; import org.apache.excalibur.merlin.model.Resource; +import org.apache.excalibur.merlin.model.CategoriesDescriptor; import org.apache.excalibur.merlin.model.verifier.AssemblyVerifier; import org.apache.excalibur.merlin.model.verifier.MetaDataVerifier; +import org.apache.excalibur.merlin.model.builder.XMLContainerUtil; import org.apache.excalibur.merlin.Verifiable; import org.apache.excalibur.merlin.Controller; @@ -84,16 +87,16 @@ * @author Stephen McConnell * @version $Revision$ $Date$ */ -public class DefaultContainer extends AbstractLogEnabled implements Container, Contextualizable, Initializable, Disposable, Startable +public class DefaultContainer extends AbstractLogEnabled implements Container, Contextualizable, Configurable, Initializable, Disposable, Startable { //======================================================================= // static //======================================================================= /** - * Context key used to locate the container meta data model. + * Context key used to locate the container manager. */ - public static final String CONTAINER_DESCRIPTOR_KEY = "descriptor"; + public static final String MANAGER_KEY = "manager"; private static final Resources REZ = ResourceManager.getPackageResources( DefaultContainer.class ); @@ -110,7 +113,7 @@ /** * The classloader resolved from the meta model. */ - private ProfileManager m_classloader; + private ContainerManager m_manager; /** * The meta data model of this container. @@ -122,6 +125,10 @@ */ private boolean m_initialized = false; + private Configuration m_configuration; + + private XMLContainerUtil m_creator = new XMLContainerUtil(); + //======================================================================= // Contextualizable //======================================================================= @@ -129,15 +136,24 @@ /** *

Service context from which the container meta data model is provided.

*
    - *
  • {@link #CONTAINER_DESCRIPTOR_KEY} the container meta model as - * a {@link ContainerDescriptor} (REQUIRED}
  • + *
  • {@link #MANAGER_KEY} the container manager + * a {@link ContainerManager} (REQUIRED}
  • *
* @param context the service context value */ public void contextualize( Context context ) throws ContextException { - m_descriptor = (ContainerDescriptor) context.get( CONTAINER_DESCRIPTOR_KEY ); - m_classloader = m_descriptor.getProfileManager(); + m_manager = (ContainerManager) context.get( MANAGER_KEY ); + m_descriptor = m_manager.getContainerDescriptor(); + } + + //======================================================================= + // Configurable + //======================================================================= + + public void configure( Configuration config ) + { + m_configuration = config; } //======================================================================= @@ -154,26 +170,28 @@ */ public void initialize() throws Exception { - getLogger().debug("initialization"); - getLogger().debug( "container creation using classloader: " + m_classloader ); + getLogger().debug( "initialization" ); + + Configuration[] components = m_configuration.getChildren("component"); + 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 - + - + 1.3 +16 -19 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/doc-files/DefaultController.gif <> 1.25 +138 -62 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.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- DefaultKernel.java 30 Jul 2002 13:49:08 -0000 1.24 +++ DefaultKernel.java 2 Aug 2002 06:36:10 -0000 1.25 @@ -64,14 +64,19 @@ import org.apache.excalibur.meta.info.DependencyDescriptor; import org.apache.excalibur.meta.info.ReferenceDescriptor; import org.apache.excalibur.meta.info.EntryDescriptor; -import org.apache.excalibur.merlin.kernel.model.KernelDescriptor; -import org.apache.excalibur.merlin.container.model.DirsetDescriptor; +import org.apache.excalibur.merlin.model.builder.XMLContainerUtil; +import org.apache.excalibur.merlin.model.DirsetDescriptor; +import org.apache.excalibur.merlin.model.ExtensionsDescriptor; +import org.apache.excalibur.merlin.model.ClasspathDescriptor; import org.apache.excalibur.merlin.model.Profile; -import org.apache.excalibur.merlin.container.model.ContainerDescriptor; +import org.apache.excalibur.merlin.model.CategoriesDescriptor; +import org.apache.excalibur.merlin.model.ContainerDescriptor; import org.apache.excalibur.merlin.model.Resource; import org.apache.excalibur.merlin.assembly.TypeManager; -import org.apache.excalibur.merlin.assembly.ProfileManager; -import org.apache.excalibur.merlin.kernel.builder.XMLKernelCreator; +import org.apache.excalibur.merlin.assembly.ContainerManager; +import org.apache.excalibur.merlin.model.builder.XMLContainerUtil; +import org.apache.excalibur.merlin.model.LoggingDescriptor; +import org.apache.excalibur.merlin.container.Container; import org.apache.excalibur.merlin.container.DefaultContainer; /** @@ -84,34 +89,32 @@ *
      
           //
  +        // create the execution context
  +        //
  +  
  +        File base = new File( "." );
  +        DefaultContext context = new DefaultContext();
  +        context.put( DefaultKernel.APPLICATION_DIR_KEY, base );
  +        context.makeReadOnly();
  +       
  +        //
           // Read in the configuration.
           //
   
  -        File file = new File("kernel.xml");
  +        File file = new File("base, "kernel.xml");
           {@link DefaultConfigurationBuilder} builder = new DefaultConfigurationBuilder();
           InputStream input = new FileInputStream( file );
           {@link Configuration} configuration = builder.build( input );
   
           //
  -        // Create the kernel meta model using the configuration and a root classloder.
  -        //
  -
  -        ClassLoader classloader = Thread.currentThread().getContextClassLoader();
  -        {@link XMLKernelCreator} creator = new XMLKernelCreator();
  -        {@link KernelDescriptor} descriptor = creator.createKernelDescriptor(
  -           configuration, classloader );
  -
  -        //
  -        // Create a kernel implementation.
  +        // Create the kernel.
           //
   
  -        {@link DefaultContext} context = new DefaultContext();
  -        context.put( DefaultKernel.{@link #KERNEL_DESCRIPTOR_KEY}, descriptor );
  -        context.makeReadOnly();
           DefaultKernel kernel = new DefaultKernel();
           Logger logger = descriptor.getLogger();
           kernel.enableLogging( logger );
           kernel.contextualize( context );
  +        kernel.configure( configuration );
           kernel.initialize();
   
           //
  @@ -126,24 +129,19 @@
   
    * 
* - * @see XMLKernelCreator - * @see KernelDescriptor * @see Kernel * * @author Stephen McConnell * @version $Revision$ $Date$ */ -public class DefaultKernel extends AbstractLogEnabled - implements Kernel, Contextualizable, Initializable, Startable, Disposable +public class DefaultKernel extends AbstractLogEnabled + implements Kernel, Contextualizable, Configurable, Initializable, Startable, Disposable { //======================================================================= // static //======================================================================= - /** - * Context key used by the kernel to access the kernel meta-data descriptor. - */ - public static final String KERNEL_DESCRIPTOR_KEY = "descriptor"; + public static final String APPLICATION_DIR_KEY = "avalon:home"; //======================================================================= // state @@ -153,8 +151,6 @@ private boolean m_verified = false; - private KernelDescriptor m_descriptor; - private boolean m_initialized = false; /** @@ -167,69 +163,145 @@ */ private ArrayList m_services = new ArrayList(); + private ContainerManager m_manager; + + private Logger m_logger; + + private Configuration m_config; + + private Context m_context; + + private XMLContainerUtil m_creator = new XMLContainerUtil(); + //======================================================================= // Contextualizable //======================================================================= /** - * Invoked by the bootstrap process to supply to kernel defintion. + * Invoked by the bootstrap process to supply the root directory. * @param context the context object containing the inital parameters * @exception ContextException if the supplied does not contain a - * KERNEL_CONTAINER_DESCRIPTOR_KEY value. + * APPLICATION_DIR_KEY value. */ public void contextualize( Context context ) throws ContextException { - m_descriptor = (KernelDescriptor) context.get( KERNEL_DESCRIPTOR_KEY ); + m_context = context; + context.get( APPLICATION_DIR_KEY ); } //======================================================================= - // Initializable + // Configurable //======================================================================= - public void initialize() throws Exception + public void configure( Configuration config ) { - getLogger().debug( "creating root container descriptor" ); - ContainerDescriptor descriptor = m_descriptor.getContainer(); + m_config = config; + } - // - // root container context creation - // - - getLogger().debug( "root container context creation" ); - DefaultContext context = new DefaultContext(); - context.put( DefaultContainer.CONTAINER_DESCRIPTOR_KEY, descriptor ); - context.makeReadOnly(); - - // - // container instantiation - // + //======================================================================= + // Initializable + //======================================================================= - getLogger().debug( "root container instantiation" ); + public void initialize() throws Exception + { try { - m_container = new DefaultContainer(); - m_container.enableLogging( descriptor.getLogger() ); - m_container.contextualize( context ); - m_container.initialize( ); - m_container.verify(); + DefaultContext ctx = new DefaultContext( m_context ); + + String name = m_config.getName(); + + ExtensionsDescriptor extensions = + m_creator.createExtensionsDescriptor( m_config.getChild("extensions") ); + ClasspathDescriptor classpath = + m_creator.createClasspathDescriptor( m_config.getChild("classpath") ); + LoggingDescriptor loggingDescriptor = + m_creator.createLoggingDescriptor( m_config.getChild("logging"), name ); + CategoriesDescriptor categories = + m_creator.createCategoriesDescriptor( name, m_config.getChild("categories") ); + + m_manager = new ContainerManager( name ); + ctx.put( ContainerManager.LOGGING_DESCRIPTOR_KEY, loggingDescriptor ); + ctx.put( ContainerManager.CATEGORIES_DESCRIPTOR_KEY, categories ); + ctx.put( ContainerManager.EXTENSIONS_DESCRIPTOR_KEY, extensions ); + ctx.put( ContainerManager.CLASSPATH_DESCRIPTOR_KEY, classpath ); + m_manager.contextualize( ctx ); + m_manager.initialize(); + + if( getLogger() == null ) + { + enableLogging( m_manager.getLoggingManager().getLoggerForCategory( name ) ); + } + getLogger().debug("kernel manager established"); + } catch( Throwable e ) { - final String error = "Kernel initialization failure."; - if( getLogger() != null ) - getLogger().error( error, e ); - throw new KernelException( error, e ); + final String error = "manager establishment failure"; + throw new KernelException( error ); } + final Configuration config = m_config.getChild("container"); + m_container = createContainer( config ); + + /* + getLogger().info( "listing exportable resources" ); Resource[] resources = getResources(); Logger export = getLogger().getChildLogger( "export" ); for( int i=0; i - - - + 1.3 +21 -22 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/doc-files/DefaultKernel.gif <> -- To unsubscribe, e-mail: For additional commands, e-mail: