Return-Path: Delivered-To: apmail-jakarta-avalon-cvs-archive@apache.org Received: (qmail 81901 invoked from network); 29 Jul 2002 06:14:47 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 29 Jul 2002 06:14:47 -0000 Received: (qmail 22284 invoked by uid 97); 29 Jul 2002 06:15:14 -0000 Delivered-To: qmlist-jakarta-archive-avalon-cvs@jakarta.apache.org Received: (qmail 22211 invoked by uid 97); 29 Jul 2002 06:15:13 -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 22198 invoked by uid 97); 29 Jul 2002 06:15:12 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 29 Jul 2002 06:14:35 -0000 Message-ID: <20020729061435.6042.qmail@icarus.apache.org> From: mcconnell@apache.org To: jakarta-avalon-excalibur-cvs@apache.org Subject: cvs commit: jakarta-avalon-excalibur/assembly/src/xdocs assembly.xml 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/07/28 23:14:34 Modified: assembly kernel.bat assembly/demo/src/etc demo.mf assembly/demo/src/java/org/apache/excalibur/playground BasicComponent.xinfo ComplexComponent.xinfo InvalidComponent.xinfo SimpleComponent.java SimpleComponent.xinfo TerminalComponent.xinfo assembly/lib excalibur-i18n-1.0.jar assembly/src/etc kernel.xml merlin.html meta.mf project.mf assembly/src/java/org/apache/excalibur/merlin DefaultController.java DefaultController.xinfo Main.java assembly/src/java/org/apache/excalibur/merlin/container Container.java DefaultContainer.java DefaultContainer.xinfo package.html assembly/src/java/org/apache/excalibur/merlin/kernel DefaultKernel.java DefaultKernel.xinfo assembly/src/java/org/apache/excalibur/merlin/model Category.java Profile.java ResourceDesignator.java package.html assembly/src/java/org/apache/excalibur/merlin/model/builder ProfileBuilder.java ProfileCreator.java XMLProfileCreator.java assembly/src/java/org/apache/excalibur/merlin/model/verifier AssemblyVerifier.java MetaDataVerifier.java assembly/src/java/org/apache/excalibur/meta componentinfo.dtd assembly/src/java/org/apache/excalibur/meta/info DependencyDescriptor.java PhaseDescriptor.java ServiceDescriptor.java Type.java assembly/src/java/org/apache/excalibur/meta/info/builder Resources.properties XMLTypeCreator.java package.html assembly/src/java/org/apache/excalibur/meta/info/doc-files Type.gif assembly/src/xdocs assembly.xml Added: assembly/demo/src/java/org/apache/excalibur/playground DefaultExploitationManager.java DefaultExploitationManager.xinfo Exploitable.java ExploitationManager.java assembly/src/java/org/apache/excalibur/merlin/assembly AssemblyException.java AssemblyRuntimeException.java DefaultLoggerManager.java DefaultSelector.java DependencyGraph.java ProfileManager.java ProfileRegistry.java ProfileTable.java Selector.java TypeException.java TypeManager.java TypeRegistry.java TypeRuntimeException.java TypeTable.java UnresolvedProviderException.java package.html assembly/src/java/org/apache/excalibur/merlin/assembly/doc-files DependencyGraph.gif assembly/src/java/org/apache/excalibur/merlin/assembly/resource AbstractLifecycleExtensionManager.java~ DefaultComponentManager.java DefaultManager.java DefaultServiceManager.java ExtensionManager.java~ LifecycleException.java LifecycleExtensionManager.java~ LifecycleHelper.java PhaseManager.java ProfileDesignator.java ResourceException.java ResourceProvider.java package.html assembly/src/java/org/apache/excalibur/merlin/container/builder ContainerCreator.java Resources.properties XMLContainerCreator.java package.html assembly/src/java/org/apache/excalibur/merlin/container/model ClasspathDescriptor.java ContainerDescriptor.java DirsetDescriptor.java ExtensionsDescriptor.java FilesetDescriptor.java IncludeDescriptor.java Parent.java package.html assembly/src/java/org/apache/excalibur/merlin/kernel/builder KernelCreator.java Resources.properties XMLKernelCreator.java package.html assembly/src/java/org/apache/excalibur/merlin/kernel/model FileTargetProvider.java KernelDescriptor.java LoggingDescriptor.java TargetDescriptor.java TargetProvider.java package.html assembly/src/java/org/apache/excalibur/meta/info ExtensionDescriptor.java Facility.java ReferenceDescriptor.java assembly/src/java/org/apache/excalibur/meta/info/builder FacilityBuilder.java FacilityCreator.java SerializedFacilityCreator.java XMLFacilityCreator.java assembly/src/java/org/apache/excalibur/meta/info/builder/doc-files FacilityBuilder.gif Removed: assembly/src/java/org/apache/excalibur/merlin/container AssemblyException.java AssemblyRuntimeException.java DefaultComponentManager.java DefaultManager.java DefaultSelector.java DefaultServiceManager.java DependencyGraph.java LifecycleException.java LifecycleHelper.java ProfileDesignator.java ProfileRegistry.java ProfileTable.java ResourceProvider.java Selector.java UnresolvedProviderException.java assembly/src/java/org/apache/excalibur/merlin/container/doc-files DependencyGraph.gif assembly/src/java/org/apache/excalibur/merlin/extension PhaseManager.java package.html assembly/src/java/org/apache/excalibur/merlin/model ClasspathDescriptor.java ContainerDescriptor.java DirsetDescriptor.java ExtensionsDescriptor.java FileTargetProvider.java FilesetDescriptor.java IncludeDescriptor.java KernelDescriptor.java LoggingDescriptor.java Parent.java TargetDescriptor.java TargetProvider.java assembly/src/java/org/apache/excalibur/merlin/model/builder ContainerCreator.java DefaultLoggerManager.java KernelCreator.java ProfileManager.java TypeException.java TypeManager.java TypeRegistry.java TypeRuntimeException.java TypeTable.java XMLContainerCreator.java XMLKernelCreator.java assembly/src/java/org/apache/excalibur/meta/info Extension.java ServiceDesignator.java assembly/src/java/org/apache/excalibur/meta/info/builder ExtensionBuilder.java ExtensionCreator.java SerializedExtensionCreator.java XMLExtensionCreator.java assembly/src/java/org/apache/excalibur/meta/info/builder/doc-files ExtensionBuilder.gif Log: general restructuring (better seperation of kernal, container and component abstractions) Revision Changes Path 1.5 +1 -1 jakarta-avalon-excalibur/assembly/kernel.bat Index: kernel.bat =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/kernel.bat,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- kernel.bat 13 Jul 2002 00:09:44 -0000 1.4 +++ kernel.bat 29 Jul 2002 06:14:28 -0000 1.5 @@ -1 +1 @@ -java -jar .\extensions\merlin.jar src\etc\kernel.xml +java -Djava.ext.dirs=.\extensions -jar .\extensions\merlin.jar src\etc\kernel.xml 1.5 +6 -4 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.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- demo.mf 4 Jul 2002 19:46:07 -0000 1.4 +++ demo.mf 29 Jul 2002 06:14:28 -0000 1.5 @@ -1,9 +1,8 @@ Manifest-Version: 1.0 Created-By: OSM SARL -Extension-List: framework -framework-Extension-Name: avalon-framework -framework-Specification-Version: 1.0 -framework-Implementation-Version: 4.1.2 +Extension-List: meta +meta-Extension-Name: avalon-meta +meta-Specification-Version: 1.0 Name: org/apache/excalibur/playground/SimpleComponent.class Avalon-Block: true @@ -19,3 +18,6 @@ Name: org/apache/excalibur/playground/InvalidComponent.class Avalon-Block: true + +Name: org/apache/excalibur/playground/DefaultExploitationManager.class +Avalon-Facility: true 1.7 +1 -1 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/BasicComponent.xinfo Index: BasicComponent.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/BasicComponent.xinfo,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- BasicComponent.xinfo 18 Jul 2002 17:34:32 -0000 1.6 +++ BasicComponent.xinfo 29 Jul 2002 06:14:28 -0000 1.7 @@ -16,7 +16,7 @@ - + 1.7 +2 -2 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ComplexComponent.xinfo Index: ComplexComponent.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ComplexComponent.xinfo,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ComplexComponent.xinfo 12 Jul 2002 15:11:57 -0000 1.6 +++ ComplexComponent.xinfo 29 Jul 2002 06:14:28 -0000 1.7 @@ -16,11 +16,11 @@ basic - + simple - + 1.6 +1 -1 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/InvalidComponent.xinfo Index: InvalidComponent.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/InvalidComponent.xinfo,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- InvalidComponent.xinfo 7 Jul 2002 23:06:39 -0000 1.5 +++ InvalidComponent.xinfo 29 Jul 2002 06:14:28 -0000 1.6 @@ -12,7 +12,7 @@ silly - + 1.7 +21 -10 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/SimpleComponent.java Index: SimpleComponent.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/SimpleComponent.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SimpleComponent.java 20 Jul 2002 01:35:50 -0000 1.6 +++ SimpleComponent.java 29 Jul 2002 06:14:28 -0000 1.7 @@ -19,7 +19,7 @@ */ public class SimpleComponent extends AbstractLogEnabled -implements Configurable, Serviceable, Initializable, Startable, SimpleService +implements Configurable, Serviceable, Initializable, Startable, SimpleService, Exploitable { private String m_message; @@ -28,15 +28,6 @@ private boolean CONTINUE = false; //======================================================================= - // PrimaryService - //======================================================================= - - public void doObjective() - { - getLogger().info( m_message ); - } - - //======================================================================= // Configurable //======================================================================= @@ -57,6 +48,15 @@ } //======================================================================= + // Exploitable + //======================================================================= + + public void exploit() + { + getLogger().debug( "I've been exploited!" ); + } + + //======================================================================= // Initializable //======================================================================= @@ -111,4 +111,15 @@ { } } + + //======================================================================= + // PrimaryService + //======================================================================= + + public void doObjective() + { + getLogger().info( m_message ); + } + + } 1.5 +21 -3 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/SimpleComponent.xinfo Index: SimpleComponent.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/SimpleComponent.xinfo,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- SimpleComponent.xinfo 7 Jul 2002 23:06:39 -0000 1.4 +++ SimpleComponent.xinfo 29 Jul 2002 06:14:28 -0000 1.5 @@ -11,16 +11,34 @@ - + + + - basic - + basic + + + + + + + + + + 1.5 +1 -1 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/TerminalComponent.xinfo Index: TerminalComponent.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/TerminalComponent.xinfo,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- TerminalComponent.xinfo 7 Jul 2002 23:06:39 -0000 1.4 +++ TerminalComponent.xinfo 29 Jul 2002 06:14:28 -0000 1.5 @@ -11,7 +11,7 @@ - + 1.1 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/DefaultExploitationManager.java Index: DefaultExploitationManager.java =================================================================== package org.apache.excalibur.playground; import org.apache.avalon.framework.context.Context; import org.apache.excalibur.merlin.assembly.resource.PhaseManager; /** * Definition of an extension type. * @author Stephen McConnell */ public class DefaultExploitationManager implements PhaseManager { /** * Create, called when the given component is being * instantiated. * * @param component a Component instance * @param context a Context instance * @exception Exception if an error occurs */ public void create( Object component, Context context ) throws Exception { if( component instanceof Exploitable ) { ((Exploitable)component).exploit(); } } /** * Destroy, called when the given component is being * decomissioned. * * @param component a Component instance * @param context a Context instance * @exception Exception if an error occurs */ public void destroy( Object component, Context context ) throws Exception {} /** * Access, called when the given component is being * accessed (ie. via lookup() or select()). * * @param component a Component instance * @param context a Context instance * @exception Exception if an error occurs */ public void access( Object component, Context context ) throws Exception {} /** * Release, called when the given component is being * released (ie. by a CM or CS). * * @param component a Component instance * @param context a Context instance * @exception Exception if an error occurs */ public void release( Object component, Context context ) throws Exception {} } 1.1 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/DefaultExploitationManager.xinfo Index: DefaultExploitationManager.xinfo =================================================================== exploitation exploit 1.1 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/Exploitable.java Index: Exploitable.java =================================================================== package org.apache.excalibur.playground; /** * @author Stephen McConnell */ public interface Exploitable { public void exploit(); } 1.1 jakarta-avalon-excalibur/assembly/demo/src/java/org/apache/excalibur/playground/ExploitationManager.java Index: ExploitationManager.java =================================================================== package org.apache.excalibur.playground; import org.apache.excalibur.merlin.assembly.resource.PhaseManager; /** * Definition of an extension type. * @author Stephen McConnell */ public interface ExploitationManager extends PhaseManager { } 1.4 +73 -69 jakarta-avalon-excalibur/assembly/lib/excalibur-i18n-1.0.jar <> 1.18 +13 -13 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.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- kernel.xml 25 Jul 2002 18:07:15 -0000 1.17 +++ kernel.xml 29 Jul 2002 06:14:29 -0000 1.18 @@ -21,7 +21,7 @@ the corresponds to the name of the logging file. --> - + @@ -29,10 +29,10 @@ + + + - - - - + This is a custom message. 1.8 +1 -1 jakarta-avalon-excalibur/assembly/src/etc/merlin.html Index: merlin.html =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/merlin.html,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- merlin.html 17 Jul 2002 13:48:37 -0000 1.7 +++ merlin.html 29 Jul 2002 06:14:29 -0000 1.8 @@ -16,7 +16,7 @@

Kernel Model

Merlin seperates the notion of a kernel from a container. A kernal manages resources (Objects) whereas a container manages services (Objects that serve as service providers and consumers). The Merlin implementation provides a default kernal that manages a container hierachy. The kernel provides the framework for overall management including startup, shutting down, extensions management, and other system wide facilities. The Melin implementation provides a utility class {@link org.apache.excalibur.merlin.Main} that handles establish of a kernel based on a single command line argument.

-

A merlin kernel is created using a kernel model ({@link org.apache.excalibur.merlin.model.KernelDescriptor}). The model may be defined programatically or through an XML file. A kernel XML file contains the defintion of kernal execution parameters and a root container.

+

A merlin kernel is created using a kernel model ({@link org.apache.excalibur.merlin.kernel.model.KernelDescriptor}). The model may be defined programatically or through an XML file. A kernel XML file contains the defintion of kernal execution parameters and a root container.

Minimilist kernel defintion.

     <kernel>
  
  
  
  1.2       +8 -2      jakarta-avalon-excalibur/assembly/src/etc/meta.mf
  
  Index: meta.mf
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/meta.mf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- meta.mf	7 Jul 2002 05:17:13 -0000	1.1
  +++ meta.mf	29 Jul 2002 06:14:29 -0000	1.2
  @@ -1,8 +1,14 @@
   Manifest-Version: 1.0
   Created-By: OSM SARL
  -Extension-Name: AvalonMetaModel
  +Extension-Name: avalon-meta
   Specification-Vendor: Apache Software Foundation
   Specification-Version: 1.0
   Implementation-Vendor: Apache Software Foundation
   Implementation-Version: 0.1
  -Class-Path: avalon-framework.jar logkit.jar excalibur-i18n-1.0.jar 
  +Extension-List: framework i18n
  +framework-Extension-Name: avalon-framework
  +framework-Specification-Version: 1.0
  +framework-Implementation-Version: 4.1.2
  +i18n-Extension-Name: excalibur-i18n
  +i18n-Specification-Version: 1.0
  +Class-Path: logkit.jar 
  
  
  
  1.11      +17 -4     jakarta-avalon-excalibur/assembly/src/etc/project.mf
  
  Index: project.mf
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/etc/project.mf,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- project.mf	17 Jul 2002 13:48:37 -0000	1.10
  +++ project.mf	29 Jul 2002 06:14:29 -0000	1.11
  @@ -1,13 +1,26 @@
   Manifest-Version: 1.0
   Created-By: OSM SARL
  -Extension-Name: Assembler
  +Extension-Name: org/apache/avalon/merlin
   Specification-Vendor: Apache Software Foundation
   Specification-Version: 1.0
   Implementation-Vendor: Apache Software Foundation
   Implementation-Version: 0.1
  -Class-Path: avalon-framework.jar logkit.jar excalibur-logger-1.0.jar excalibur-i18n-1.0.jar 
  - excalibur-configuration-1.0.jar excalibur-extension-1.0a.jar 
  - avalon-meta.jar xerces-2.0.1.jar xml-apis.jar xalan-2.3.1.jar
  +Extension-List: framework meta configuration i18n logger extension
  +framework-Extension-Name: avalon-framework
  +framework-Specification-Version: 1.0
  +framework-Implementation-Version: 4.1.2
  +meta-Extension-Name: avalon-meta
  +meta-Specification-Version: 1.0
  +meta-Implementation-Version: 0.1
  +configuration-Extension-Name: excalibur-configuration
  +configuration-Specification-Version: 1.0
  +i18n-Extension-Name: excalibur-i18n
  +i18n-Specification-Version: 1.0
  +logger-Extension-Name: excalibur-logger
  +logger-Specification-Version: 1.0
  +extension-Extension-Name: excalibur-extension
  +extension-Specification-Version: 1.0
  +Class-Path: logkit.jar xerces-2.0.1.jar xml-apis.jar xalan-2.3.1.jar
   Main-Class: org.apache.excalibur.merlin.Main
   
   Name: org/apache/excalibur/merlin/container/DefaultContainer.class
  
  
  
  1.8       +8 -9      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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultController.java	26 Jul 2002 06:17:04 -0000	1.7
  +++ DefaultController.java	29 Jul 2002 06:14:29 -0000	1.8
  @@ -24,17 +24,16 @@
   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.kernel.DefaultKernel;
  -//import org.apache.excalibur.merlin.kernel.DefaultLoggerManager;
  -import org.apache.excalibur.merlin.model.builder.DefaultTypeManager;
   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.ResourceDesignator;
  -import org.apache.excalibur.merlin.model.builder.XMLKernelCreator;
  -import org.apache.excalibur.merlin.model.KernelDescriptor;
  -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.model.ContainerDescriptor;
  +import org.apache.excalibur.merlin.container.model.ClasspathDescriptor;
  +import org.apache.excalibur.merlin.container.model.ExtensionsDescriptor;
  +import org.apache.excalibur.merlin.kernel.model.LoggingDescriptor;
   
   
   /**
  
  
  
  1.2       +1 -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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultController.xinfo	13 Jul 2002 00:09:44 -0000	1.1
  +++ DefaultController.xinfo	29 Jul 2002 06:14:29 -0000	1.2
  @@ -23,7 +23,7 @@
   
     
       
  -      
  +      
       
     
   
  
  
  
  1.9       +9 -18     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Main.java	25 Jul 2002 18:07:15 -0000	1.8
  +++ Main.java	29 Jul 2002 06:14:29 -0000	1.9
  @@ -52,28 +52,19 @@
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.Version;
   import org.apache.avalon.framework.ExceptionUtil;
  -import org.apache.avalon.excalibur.extension.PackageRepository;
  -import org.apache.avalon.excalibur.extension.Extension;
  -import org.apache.avalon.excalibur.extension.OptionalPackage;
  -import org.apache.avalon.excalibur.extension.DefaultPackageRepository;
  -import org.apache.excalibur.meta.info.Type;
   import org.apache.excalibur.meta.info.Type;
   import org.apache.excalibur.meta.info.ServiceDescriptor;
   import org.apache.excalibur.meta.info.DependencyDescriptor;
  -import org.apache.excalibur.meta.info.ServiceDesignator;
  -import org.apache.excalibur.merlin.model.builder.XMLKernelCreator;
  -import org.apache.excalibur.merlin.model.KernelDescriptor;
  -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.model.ContainerDescriptor;
  +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.kernel.DefaultKernel;
  -//import org.apache.excalibur.merlin.kernel.DefaultLoggerManager;
  -import org.apache.excalibur.merlin.model.builder.DefaultTypeManager;
   import org.apache.excalibur.merlin.kernel.KernelException;
  -import org.apache.log.Hierarchy;
  -import org.apache.log.Priority;
  -import org.apache.log.output.io.StreamTarget;
   
   /**
    * 

Utility class supporting the establishment of a new Controller 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/AssemblyException.java Index: AssemblyException.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly; import java.util.Enumeration; import java.util.Dictionary; import java.util.Hashtable; import org.apache.avalon.framework.CascadingException; /** * Exception to indicate that there was an error during assembly. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ public final class AssemblyException extends CascadingException { private static final Hashtable EMPTY_TABLE = new Hashtable(); private Dictionary m_errors; /** * Construct a new AssemblyException instance. * * @param message The detail message for this exception. */ public AssemblyException( final String message ) { this( null, message, null ); } /** * Construct a new AssemblyRuntimeException instance. * * @param errors a list of warning messages related to the exception. * @param message The detail message for this exception. */ public AssemblyException( final Dictionary errors, final String message ) { this( errors, message, null ); } /** * Construct a new AssemblyException instance. * * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public AssemblyException( final String message, final Throwable throwable ) { this( null, message, throwable ); } /** * Construct a new AssemblyException instance. * * @param errors a list of warning messages related to the exception. * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public AssemblyException( final Dictionary errors, final String message, final Throwable throwable ) { super( message, throwable ); if( errors != null ) { m_errors = errors; } else { m_errors = EMPTY_TABLE; } } /** * Return the table of supplimentary messages. * @return the messages table */ public Dictionary getDictionary() { return m_errors; } /** * Returns a stringified representation of the exception. * @return the exception as a string. */ public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append( super.toString() ); buffer.append( " Errors: " + m_errors.size() ); Enumeration keys = m_errors.keys(); while( keys.hasMoreElements() ) { Object key = keys.nextElement(); buffer.append( "\n source: " + key.toString() + " cause: " + m_errors.get( key ) ); } return buffer.toString(); } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/AssemblyRuntimeException.java Index: AssemblyRuntimeException.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly; import java.util.Enumeration; import java.util.Dictionary; import java.util.Hashtable; import org.apache.avalon.framework.CascadingRuntimeException; /** * Exception to indicate that there was a runtime error during assembly. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ public final class AssemblyRuntimeException extends CascadingRuntimeException { private static final Hashtable EMPTY_TABLE = new Hashtable(); private Dictionary m_errors; /** * Construct a new AssemblyRuntimeException instance. * * @param message The detail message for this exception. */ public AssemblyRuntimeException( final String message ) { this( null, message, null ); } /** * Construct a new AssemblyRuntimeException instance. * * @param errors a list of warning messages related to the exception. * @param message The detail message for this exception. */ public AssemblyRuntimeException( final Dictionary errors, final String message ) { this( errors, message, null ); } /** * Construct a new AssemblyRuntimeException instance. * * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public AssemblyRuntimeException( final String message, final Throwable throwable ) { this( null, message, throwable ); } /** * Construct a new AssemblyRuntimeException instance. * * @param errors a list of warning messages related to the exception. * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public AssemblyRuntimeException( final Dictionary errors, final String message, final Throwable throwable ) { super( message, throwable ); if( errors != null ) { m_errors = errors; } else { m_errors = EMPTY_TABLE; } } /** * Return the table of supplimentary messages. * @return the messages table */ public Dictionary getDictionary() { return m_errors; } /** * Returns a stringified representation of the exception. * @return the exception as a string. */ public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append( super.toString() ); buffer.append( " Errors: " + m_errors.size() ); Enumeration keys = m_errors.keys(); while( keys.hasMoreElements() ) { Object key = keys.nextElement(); buffer.append( "\n source: " + key.toString() + " cause: " + m_errors.get( key ) ); } return buffer.toString(); } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/DefaultLoggerManager.java Index: DefaultLoggerManager.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly; import java.io.File; import java.io.IOException; import java.util.HashMap; import org.apache.log.Hierarchy; import org.apache.log.LogTarget; import org.apache.log.Logger; import org.apache.log.Priority; import org.apache.log.output.io.FileTarget; import org.apache.log.output.io.StreamTarget; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.excalibur.logger.LoggerManager; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.context.Contextualizable; 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.Category; import org.apache.excalibur.merlin.model.CategoriesDescriptor; /** * A LoggerManager that supports management of a logging hierarchy. * * @author Stephen McConnell * @author Eung-ju Park * @author Peter Donald */ public class DefaultLoggerManager implements LoggerManager { public static final String DEFAULT_PRIORITY = "INFO"; public static final String DEFAULT_TARGET = "default"; public static final String HOME_KEY = "app.home"; private static final Resources REZ = ResourceManager.getPackageResources( DefaultLoggerManager.class ); private static final String DEFAULT_FORMAT = "[%7.7{priority}] (%{category}): %{message}\\n%{throwable}"; /** * Base directory of file targets. */ private File m_baseDirectory; /** * log hierarchy. */ private Hierarchy m_logHierarchy; /** * default logger */ private org.apache.avalon.framework.logger.Logger m_logger; /** * default logger target */ private StreamTarget m_stream; private final HashMap m_targets = new HashMap(); private DefaultLoggerManager m_parent; private String m_category; //=============================================================== // constructor //=============================================================== /** * Creation of a new LoggerManager. * @param descriptor the logging system description * @exception Exception is an error occurs */ public DefaultLoggerManager( final LoggingDescriptor descriptor ) throws Exception { // // setup the hierarchy, default logging target, and default priority // m_stream = new StreamTarget( System.out, new AvalonFormatter( DEFAULT_FORMAT ) ); m_baseDirectory = new File( System.getProperty("user.dir") ); m_logHierarchy = new Hierarchy(); getHierarchy().setDefaultLogTarget( m_stream ); 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 ) ); } // // build targets based on the information contained in the descriptor // TargetDescriptor[] targets = descriptor.getTargetDescriptors(); for( int i=0; iStephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ class DefaultSelector extends AbstractLogEnabled implements Selector { /** * Returns the preferred profile form an available selection of candidate provider profiles. * @param profiles the set of profiles of potential service providers * @return the preferred provider or null if no satisfactory provider can be established * from the supplied profiles. */ public Profile select( Profile[] profiles ) { Profile profile = select( profiles, Profile.EXPLICIT ); if( profile == null ) profile = select( profiles, Profile.PACKAGED ); if( profile == null ) profile = select( profiles, Profile.IMPLICIT ); return profile; } /** * Returns the preferred profile form an available selection of candidate provider profiles. * @param facilities the set of profiles of potential service providers available in the * container hierachy * @param profiles the set of profiles of potential service providers contained with the * local container * @return the preferred provider or null if no satisfactory provider can be established * from the supplied profiles. */ public Profile select( Profile[] facilities, Profile[] profiles ) { // // apply default selection policy // Profile profile = select( profiles, Profile.EXPLICIT ); if( profile == null ) { profile = select( facilities ); } else { getLogger().debug("local selection: " + profile ); } if( profile == null ) { profile = select( profiles ); } else { getLogger().debug("facility selection: " + profile ); } return profile; } private Profile select( Profile[] profiles, int mode ) { for( int i=0; iUtility class to help aquire a ordered graph of * consumers and providers for specific components.

*

UML

*

* * @author Peter Donald * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ public class DependencyGraph { /** * Parent Map. Components in parent * Map are potential Providers for services * if no profile in current assembly satisfies dependency. */ private final DependencyGraph m_parent; /** * The set of components declared by the container as available., * Used when searching for providers/consumers. */ private final ArrayList m_components = new ArrayList(); /** * The child {@link DependencyGraph} objects. * Possible consumers of services in this assembly. */ private final ArrayList m_children = new ArrayList(); public DependencyGraph() { this( null ); } public DependencyGraph( final DependencyGraph parent ) { m_parent = parent; } /** * Add child dependency graph. * * @param child the child map */ public void addChild( final DependencyGraph child ) { m_children.add( child ); } /** * Remove child dependency graph. * * @param child the child map */ public void removeChild( final DependencyGraph child ) { m_children.remove( child ); } /** * Add a profile to current dependency graph. * * @param profile the profile */ public void add( final Profile profile ) { if( !m_components.contains( profile ) ) m_components.add( profile ); } /** * Get the serilized graph of {@link Profile} objects * required when starting up all the components. This makes sure * that all providers occur before their coresponding * consumers in graph. * * @return the ordered list of components */ public Profile[] getStartupGraph() { return walkGraph( true ); } /** * Get the serilized graph of {@link Profile} objects * required when shutting down all the components. This makes * sure that all consumers occur before their coresponding * providers in graph. * * @return the ordered list of components */ public Profile[] getShutdownGraph() { return walkGraph( false ); } /** * Get the serilized graph of {@link Profile} objects * that use services of specified profile. * * @param profile the profile * @return the ordered list of consumers */ public Profile[] getConsumerGraph( final Profile profile ) { return referencedProfiles( profile, getComponentGraph( profile, false )); } /** * Get the serilized graph of {@link Profile} objects * that provide specified profile with services. * * @param profile the profile * @return the ordered list of providers */ public Profile[] getProviderGraph( final Profile profile ) { return referencedProfiles( profile, getComponentGraph( profile, true )); } /** * Return a profile array that does not include the provided profile. */ private Profile[] referencedProfiles( final Profile profile, Profile[] profiles ) { ArrayList list = new ArrayList(); for( int i=0; iStephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ public class ProfileManager extends TypeManager implements Startable { //=================================================================== // static //=================================================================== private static final Resources REZ = ResourceManager.getPackageResources( ProfileManager.class ); public static final String DELIMITER = "/"; /** * Context key used to locate the logging manager. */ public static final String LOGGING_MANAGER_KEY = "logging"; //=================================================================== // state //=================================================================== /** * The default selector. */ private LifecycleHelper m_helper = new LifecycleHelper(); /** * The default selector. */ private DefaultSelector m_selector = new DefaultSelector(); /** * Profiles keyed by name. */ private Hashtable m_profiles = new Hashtable(); /** * List of ServiceTable instances. */ private List m_services = new LinkedList(); /** * Utility class used to create type meta info for components not explicity declared * in the meta data model. */ private ProfileBuilder m_builder = new ProfileBuilder(); /** * The logging manager - one instance in a root manager. * @see #getLoggingManager() */ private DefaultLoggerManager m_logging; /** * Utility class that manages supply of context, config, services, etc. during * startup of a profile. */ private ResourceProvider m_provider; /** * The manager name from which the manager path is resolved. */ private String m_name; /** * The manager's path. */ private String m_path; /** * The parent manager. */ private ProfileManager m_parent; /** * Mapping of established resource designators keyed by profile. */ private Hashtable m_resources = new Hashtable(); /** * The dependency map. */ private DependencyGraph m_map; /** * Utility class to handle assembly. */ private ProfileRegistry m_registry; //=================================================================== // constructor //=================================================================== public ProfileManager( ClassLoader parent, String name ) { super( parent ); m_name = name; if( parent instanceof ProfileManager ) { m_parent = (ProfileManager) parent; m_path = m_parent.getPath() + DELIMITER + name; m_map = new DependencyGraph( m_parent.getDependencyMap() ); } else { m_path = DELIMITER + name; m_map = new DependencyGraph(); } } //======================================================================= // Contextualizable //======================================================================= /** * Declaration of the logging manager. * @param context the context object containing the inital parameters */ public void contextualize( Context context ) throws ContextException { super.contextualize( context ); if( getLoggingManager() == null ) m_logging = (DefaultLoggerManager) context.get( LOGGING_MANAGER_KEY ); } //======================================================================= // Initializable //======================================================================= public void initialize() throws Exception { super.initialize(); getLogger().info("profile manager"); m_selector.enableLogging( getLogger().getChildLogger("selector") ); m_helper.enableLogging( getLogger().getChildLogger("lifecycle") ); // // setup the resource provider // DefaultContext context = new DefaultContext(); context.put("avalon:work", new File( System.getProperty("user.dir") ) ); m_provider = new ResourceProvider( this, context, getLoggingManager() ); m_provider.enableLogging( getLogger().getChildLogger("provider") ); // // setup the assembly sub-system // m_registry = new ProfileRegistry( this, m_map ); m_registry.enableLogging( getLogger().getChildLogger( "assembly") ); // // build the profiles // getLogger().debug("packaged and implicit profile registration"); Type[] types = getTypes(); getLogger().info("type count: " + types.length ); for( int i=0; iStephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ final class ProfileRegistry extends AbstractLogEnabled { //======================================================================= // state //======================================================================= /** * Classloader used to load a service profile selector. */ private ProfileManager m_classloader; /** * The dependency map that is populated during the assembly process. */ private DependencyGraph m_map; //======================================================================= // constructor //======================================================================= /** * Creation of a new service registry. * @param loader the registry class loader * @param map the dependency map */ public ProfileRegistry( ProfileManager loader, DependencyGraph map ) { m_classloader = loader; m_map = map; } //======================================================================= // ProfileRegistry //======================================================================= /** * For all of the explicity declared profiles, initiate dependency correlation. */ public void assemble( Profile[] profiles ) throws Exception { for( int i=0; iStephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ final class ProfileTable { //======================================================================= // state //======================================================================= /** * Component type lists keyed by service designator. */ private List m_providers = new LinkedList(); /** * Identification of the service type that this table is supporting. */ private ReferenceDescriptor m_designator; public ProfileTable( ReferenceDescriptor designator ) { m_designator = designator; } //======================================================================= // ServiceTable //======================================================================= /** * Add a service provider to the set of provider managed by this table. * * @param classname the component class name * @return the component type */ public void add( Profile profile ) { m_providers.add( profile ); } /** * Returns the set of providers currently registered in the table. * @return the set of component types capable of acting as a provider for the * service managed by the table */ public Profile[] getProfiles() { return (Profile[]) m_providers.toArray( new Profile[0] ); } /** * Return the service type for the table. * @return the service designator */ public ReferenceDescriptor getService() { return m_designator; } /** * Return the number of entries in the table. * @return the number of providers */ public int getSize() { return m_providers.size(); } /** * Returns true if the table service designator matches the supplied designator. * @param service a service type designator * @return TRUE if the supplied service type matches the the service type for * this table. */ public boolean matches( ReferenceDescriptor service ) { return m_designator.matches( service ); } public String toString() { return "ProfileTable:" + System.identityHashCode( this ) + ", " + m_designator; } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/Selector.java Index: Selector.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly; import org.apache.excalibur.merlin.model.Profile; /** * Interface implemented by a service selection implementation mechanism. Classes * implementing the selector interface may be activated during the selection of * candidate service providers in an autom assembly process. A selector my be * declared via inclusion a implemetation class nameed <service-type>Selector. * Alternatively, a component author may declare a selection class explicitly via a * service dependecy attribute with the attribute name of avalon.service.selector. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ public interface Selector { /** * Returns the preferred profile form an available selection of candidate provider profiles. * @param profiles the set of profiles of potential service providers * @return the preferred provider or null if no satisfactory provider can be established * from the supplied profiles. */ Profile select( Profile[] profiles ); /** * Returns the preferred profile form an available selection of candidate provider profiles. * @param facilities the set of profiles of potential service providers available in the * container hierachy * @param profiles the set of profiles of potential service providers contained with the * local container * @return the preferred provider or null if no satisfactory provider can be established * from the supplied profiles. */ Profile select( Profile[] facilities, Profile[] profiles ); } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeException.java Index: TypeException.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly; import org.apache.avalon.framework.CascadingException; /** * Exception to indicate that there was a model related error. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ public final class TypeException extends CascadingException { /** * Construct a new TypeException instance. * * @param message The detail message for this exception. */ public TypeException( final String message ) { this( message, null ); } /** * Construct a new TypeException instance. * * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public TypeException( final String message, final Throwable throwable ) { super( message, throwable ); } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeManager.java Index: TypeManager.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly; import java.io.File; import java.io.IOException; import java.util.jar.Attributes; import java.util.jar.Manifest; import java.util.Dictionary; import java.util.Hashtable; import java.util.Enumeration; import java.util.Vector; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.Map; import java.util.List; import java.util.LinkedList; import java.net.URLClassLoader; import java.net.URL; import java.net.JarURLConnection; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.LogEnabled; import org.apache.avalon.framework.CascadingRuntimeException; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.Contextualizable; import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.excalibur.extension.Extension; import org.apache.avalon.excalibur.extension.PackageManager; import org.apache.avalon.excalibur.extension.PackageRepository; import org.apache.avalon.excalibur.extension.OptionalPackage; import org.apache.avalon.excalibur.extension.DefaultPackageRepository; import org.apache.excalibur.meta.info.Type; import org.apache.excalibur.meta.info.Facility; import org.apache.excalibur.meta.info.ReferenceDescriptor; 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; /** * Abstract type manager. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ public abstract class TypeManager extends URLClassLoader implements LogEnabled, Contextualizable, Initializable { //=================================================================== // static //=================================================================== private static final Resources REZ = ResourceManager.getPackageResources( TypeManager.class ); /** * Optional context key referencing an instance of {@link ExtensionsDescriptor} * that defines the set of extension directories to use. */ public static final String EXTENSIONS_DESCRIPTOR_KEY = "extensions"; /** * Optional classpath key referencing an instance of {@link ClasspathDescriptor} * that defines the set of jar files to install. */ public static final String CLASSPATH_DESCRIPTOR_KEY = "classpath"; //=================================================================== // state //=================================================================== /** * Logging channel. */ private Logger m_logger; /** * Description of the extension directories. */ private ExtensionsDescriptor m_extensions; /** * Utility class to manage extension jar files. */ private PackageManager m_manager; /** * The classpath descriptor. */ private ClasspathDescriptor m_classpath; /** * The registry of installed component types. */ private TypeRegistry m_types; //=================================================================== // constructor //=================================================================== /** * Creation of a new type manager. */ public TypeManager( ) { super( new URL[ 0 ], Thread.currentThread().getContextClassLoader() ); } /** * Creation of a new type manager using the supplied parent class loader. * @param parent the parent class loader */ public TypeManager( ClassLoader parent ) { super( new URL[ 0 ], parent ); } //======================================================================= // LogEnabled //======================================================================= public void enableLogging( Logger logger ) { m_logger = logger; } protected Logger getLogger() { return m_logger; } //======================================================================= // Contextualizable //======================================================================= /** * Declaration of the extensions and classpath descriptors. * @param context the context object containing the inital parameters * @exception ContextException if the supplied does not contain a DESCRIPTOR_KEY value */ public void contextualize( Context context ) throws ContextException { getLogger().debug( "contextualize" ); try { m_extensions = (ExtensionsDescriptor) context.get( EXTENSIONS_DESCRIPTOR_KEY ); } catch( ContextException e ) { // ignore - optional context element } try { m_classpath = (ClasspathDescriptor) context.get( CLASSPATH_DESCRIPTOR_KEY ); } catch( ContextException e ) { // ignore - optional context element } } //======================================================================= // Initializable //======================================================================= public void initialize() throws Exception { // // initialize the type registries and install the classpath // getLogger().debug("initialize"); m_types = new TypeRegistry( this, getLogger().getChildLogger( "types" ) ); // // setup the extension directories // if( m_extensions != null ) { getLogger().debug( "initializing extensions libraries" ); ArrayList list = new ArrayList(); File dir = new File( System.getProperty("user.dir") ); DirsetDescriptor[] dirs = m_extensions.getDirsetDescriptors(); for( int i=0; iVector containing a sequence of jar files * to be added to the classloader. */ private void load( Vector stack ) { int size = stack.size(); getLogger().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 ); try { super.addURL( file.toURL() ); stack.remove( file ); } catch( Throwable error ) { getLogger().warn( "Encountered error while loading resource: " + file, error ); errors.put( file, error ); } } if( stack.size() == 0 ) { return; } if( stack.size() < size ) { load( stack ); } else { Enumeration keys = errors.keys(); getLogger().error( "Load error count = " + errors.size() ); while( keys.hasMoreElements() ) { File key = (File)keys.nextElement(); getLogger().error( "Error while loading file." + "\n\tfile: " + key.toString(), (Throwable)errors.get( key ) ); } throw new RuntimeException( "Unable to load file stack - see trace for details." ); } } private String[] urlsToStrings( URL[] urls ) { Vector vector = new Vector(); for( int i=0; iStephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ class TypeRegistry extends AbstractLogEnabled { //======================================================================= // state //======================================================================= private TypeBuilder m_typeBuilder = new TypeBuilder(); private FacilityBuilder m_facilityBuilder = new FacilityBuilder(); private ClassLoader m_classloader; /** * Component types keyed by classname. */ private Hashtable m_types = new Hashtable(); /** * List of TypeTable instances. */ private List m_services = new LinkedList(); //======================================================================= // constructor //======================================================================= /** * Creation of a new service registry. * @param registry the registry that will be supplied to new component defintions * @param loader the registry class loader * @param profiles the configuration fragment containing explicit component profiles */ public TypeRegistry( ClassLoader loader, Logger logger ) { m_classloader = loader; super.enableLogging( logger ); m_typeBuilder.enableLogging( logger.getChildLogger("component") ); m_facilityBuilder.enableLogging( logger.getChildLogger("facility") ); getLogger().info("type registry established"); } //======================================================================= // implemetation (TypeManager handler) //======================================================================= /** * Test is a type is know. */ public boolean isLocal( String classname ) { Type type = getType( classname ); if( type != null ) return true; return false; } /** * Resolve a {@link Type} from a classname. * * @param classname the component type * @return the component type or null if unknown */ public Type loadType( String classname ) throws Exception { return getType( classname ); } /** * Register a potential supplier component type. The implementation will * create a component type instance for the entry if not already known and * return the existing or new instance to the invoking client. * * @param classname the component class name * @return the component type */ public Type addType( String path ) throws Exception { final String classname = path.replace('/','.'); getLogger().info("type: " + classname ); Type type = getType( classname ); if( type == null ) { type = m_typeBuilder.build( classname, m_classloader ); verify( type ); register( type ); } return type; } /** * Register a potential supplier component type. The implementation will * create a component type instance for the entry if not already known and * return the existing or new instance to the invoking client. * * @param classname the component class name * @return the component type */ public Type addFacility( String path ) throws Exception { final String classname = path.replace('/','.'); getLogger().info("facility: " + classname ); Type type = getType( classname ); if( type == null ) { type = m_facilityBuilder.build( classname, m_classloader ); verify( type ); register( type ); } return type; } private void verify( Type type ) throws Exception { String name = type.getInfo().getName(); Class clazz = getComponentClass( type ); Class[] classes = getServiceClasses( type ); ComponentVerifier verifier = new ComponentVerifier(); verifier.enableLogging( getLogger().getChildLogger( "verifier" )); verifier.verifyComponent( name, clazz, classes ); } //======================================================================= // TypeRegistry (private and protected) //======================================================================= protected Class[] getServiceClasses( Type type ) { Vector vector = new Vector(); ServiceDescriptor[] services = type.getServices(); for( int i=0; iStephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ public final class TypeRuntimeException extends CascadingRuntimeException { /** * Construct a new TypeRuntimeException instance. * * @param message The detail message for this exception. */ public TypeRuntimeException( final String message ) { this( message, null ); } /** * Construct a new TypeRuntimeException instance. * * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public TypeRuntimeException( final String message, final Throwable throwable ) { super( message, throwable ); } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/TypeTable.java Index: TypeTable.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly; import java.util.List; import java.util.LinkedList; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.excalibur.meta.info.ReferenceDescriptor; import org.apache.excalibur.meta.info.Type; /** * Internal table that holds references to the available component types * that represent candidate providers for a single service type. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ final class TypeTable extends AbstractLogEnabled { //======================================================================= // state //======================================================================= /** * Component type lists keyed by service designator. */ private List m_providers = new LinkedList(); /** * Identification of the service type that this table is supporting. */ private ReferenceDescriptor m_designator; public TypeTable( ReferenceDescriptor designator, Logger logger ) { m_designator = designator; super.enableLogging( logger ); } //======================================================================= // ServiceTable //======================================================================= /** * Add a service provider to the set of provider managed by this table. * * @param classname the component class name * @return the component type */ public void add( Type type ) { m_providers.add( type ); } /** * Returns the set of providers currently registered in the table. * @return the set of component types capable of acting as a provider for the * service managed by the table */ public Type[] getTypes() { return (Type[]) m_providers.toArray( new Type[0] ); } /** * Return the service type for the table. * @return the service designator */ public ReferenceDescriptor getService() { return m_designator; } /** * Return the number of entries in the table. * @return the number of providers */ public int getSize() { return m_providers.size(); } /** * Returns true if the table service designator matches the supplied designator. * @param service a service type designator * @return TRUE if the supplied service type matches the the service type for * this table. */ public boolean matches( ReferenceDescriptor service ) { return m_designator.matches( service ); } public String toString() { return "TypeTable:" + System.identityHashCode( this ) + ", " + m_designator; } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/UnresolvedProviderException.java Index: UnresolvedProviderException.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly; import org.apache.excalibur.meta.info.DependencyDescriptor; import org.apache.avalon.framework.CascadingException; /** * Exception to indicate that a service provider could not be found. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:29 $ */ public final class UnresolvedProviderException extends CascadingException { private DependencyDescriptor m_dependency; /** * Construct a new UnresolvedProviderException instance. * * @param dependency the unresolved dependency */ public UnresolvedProviderException( DependencyDescriptor dependency ) { this( dependency, null ); } /** * Construct a new UnresolvedProviderException instance. * * @param dependency the unresolved dependency * @param cause the causal exception */ public UnresolvedProviderException( DependencyDescriptor dependency, Throwable cause ) { super( getStandardMessage( dependency ), cause ); m_dependency = dependency; } /** * Return the dependency description. * @return the unresolved dependency. */ public DependencyDescriptor getDependency() { return m_dependency; } private static String getStandardMessage( DependencyDescriptor dependency ) { return "Unable to resolve a provider for the dependency '" + dependency.getService() + "' for the role: " + dependency.getRole(); } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/package.html Index: package.html ===================================================================

The assembly package contains the main type, profile, and assembly manegment.

1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/doc-files/DependencyGraph.gif <> 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/AbstractLifecycleExtensionManager.java~ Index: AbstractLifecycleExtensionManager.java~ =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.extension; import java.lang.reflect.Method; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.logger.AbstractLogEnabled; /** * AbstractLifecycleExtensionManager class. * * @author Marcus Crafter * @version CVS $Revision: 1.1 $ $Date: 2002/07/29 06:14:30 $ */ public abstract class AbstractLifecycleExtensionManager extends AbstractLogEnabled { // Lifecycle method constants, these are passed to executeExtensions() protected final Method ACCESS; protected final Method RELEASE; protected final Method CREATION; protected final Method DESTRUCTION; /** * Constructor, creates a lifecycle manager, and caches all lifecycle * Method objects for later use. */ public AbstractLifecycleExtensionManager() { final Class[] params = { Object.class, Context.class }; final Class clazz = LifecycleExtension.class; try { ACCESS = clazz.getDeclaredMethod( "access", params ); RELEASE = clazz.getDeclaredMethod( "release", params ); CREATION = clazz.getDeclaredMethod( "create", params ); DESTRUCTION = clazz.getDeclaredMethod( "destroy", params ); } catch ( NoSuchMethodException e ) { throw new IllegalStateException( "Bad environment, cannot reference LifecycleExtension class: " + e.getMessage() ); } } /** * executeExtensions method, executes a given array of lifecycle interfaces * on a given component. * * @param component a Component instance * @param context a Context instance * @param type a Method instance, referencing which phase the * extensions array adheres to * @exception Exception if an error occurs */ protected void executeExtensions( Object[] extensions, Object component, Context context, Method type ) throws Exception { final Object[] params = { component, context }; for ( int i = 0; i < extensions.length; ++i ) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Executing extension " + extensions[i] + " on component " + component + " (" + type.getName() + " phase)" ); } type.invoke( ( LifecycleExtension ) extensions[i], params ); } } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/DefaultComponentManager.java Index: DefaultComponentManager.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.TXT file. * * Original contribution by OSM SARL, http://www.osm.net */ package org.apache.excalibur.merlin.assembly.resource; import java.util.Map; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; /** * Internal helper class the implements the ComponentLocator interface and * is supplied to dynamically created componets during lifecycle pipeline processing. * @author Stephen McConnell */ class DefaultComponentManager extends DefaultManager implements ComponentManager { public DefaultComponentManager( Map providers ) { super( providers ); } public boolean hasComponent( String role ) { return super.has( role ); } public Component lookup( String role ) throws ComponentException { Object object = null; try { object = super.resolve( role ); if( object instanceof Component ) { return (Component)object; } throw new ComponentException( role, "Service provider returned a non-Component." ); } catch( ResourceException e ) { final String error = "Provider related error during service resolution."; throw new ComponentException( role, error, e ); } } /** * Release a pooled object. * * @param component a pooled object */ public void release( Component component ) { super.disgard( component ); } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/DefaultManager.java Index: DefaultManager.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.TXT file. * * Original contribution by OSM SARL, http://www.osm.net */ package org.apache.excalibur.merlin.assembly.resource; import java.util.Map; import org.apache.avalon.framework.service.ServiceException; import org.apache.excalibur.merlin.model.ResourceDesignator; /** * Internal helper class the handles the functional requirements of * both ComponetManager and ComponentLocator. * @author Stephen McConnell */ class DefaultManager { /** * A map of resources keyed by lookup role. */ private Map m_providers; /** * Creation of a new manager. * @param providers the resource map */ public DefaultManager( Map providers ) { m_providers = providers; } /** * Return TRUE is the manager has a resoruce for the role. * @param role the role name to look for in the resource map * @return TRUE is a resource exists for the role */ public boolean has( String role ) { return ( m_providers.get( role ) != null ); } /** * Returns the service object. * @return the service instance */ public Object resolve( String role ) throws ResourceException { ResourceDesignator resource = (ResourceDesignator) m_providers.get( role ); if( resource == null ) { throw new ResourceException( "Could not locate a provider for the role: " + role ); } else { try { return resource.getInstance(); } catch( Throwable e ) { final String error = "Unexpected exception while resolving the service from " + resource.getPath() + " for the role: " + role; throw new ResourceException( error, e ); } } } /** * Release a pooled object. * @param object a pooled object */ public void disgard( Object object ) { // } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/DefaultServiceManager.java Index: DefaultServiceManager.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.TXT file. * * Original contribution by OSM SARL, http://www.osm.net */ package org.apache.excalibur.merlin.assembly.resource; import java.util.Map; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; /** * Internal helper class the implements the ServiceManager interface and * is supplied to dynamically created componets during lifecyle pipeline processing. * @author Stephen McConnell */ class DefaultServiceManager extends DefaultManager implements ServiceManager { /** * Construct a new ServiceManager. */ public DefaultServiceManager( Map providers ) { super( providers ); } /** * Returns true if a provider exists for the supplied role. * @param role the service identifier * @return boolean TRUE if the service is available else FALSE */ public boolean hasService( String role ) { return super.has( role ); } /** * Retrieve Object by role from ComponentLocator. * @param role the role * @return the Object * @throws ServiceException if an error occurs */ public Object lookup( String role ) throws ServiceException { try { return super.resolve( role ); } catch( ResourceException e ) { final String error = "Service resolution failure for role: " + role; throw new ServiceException( error, e ); } } /** * Release a pooled object. * @param object a pooled object */ public void release( Object object ) { super.disgard( object ); } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/ExtensionManager.java~ Index: ExtensionManager.java~ =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.extension; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.context.Context; /** * ExtensionManager interface. This interface shall be implemented by * classes providing support for lifecycle extension. * * @author Marcus Crafter * @author Stephen McConnell * @version CVS $Revision: 1.1 $ $Date: 2002/07/29 06:14:30 $ */ public interface ExtensionManager { /** * The executeAccess method, executes all access level * extensions on the given component. * * @param component a component instance * @param context a Context instance * @exception Exception if an error occurs */ void executeAccess( Object component, Context context ) throws Exception; /** * The executeRelease method, executes all release level * extensions on the given component. * * @param component a component instance * @param context a Context instance * @exception Exception if an error occurs */ void executeRelease( Object component, Context context ) throws Exception; /** * The executeCreation method, executes all creation level * extensions on the given component. * * @param component a component instance * @param context a Context instance * @exception Exception if an error occurs */ void executeCreation( Object component, Context context ) throws Exception; /** * The executeDestruction method, executes all destruction * level extensions on the given component. * * @param component a component instance * @param context a Context instance * @exception Exception if an error occurs */ void executeDestruction( Object component, Context context ) throws Exception; } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/LifecycleException.java Index: LifecycleException.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly.resource; import org.apache.avalon.framework.CascadingException; import org.apache.excalibur.meta.verifier.VerifyException; /** * Exception to indicate error processing a component through its lifecycle. * * @author Peter Donald * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:30 $ */ public final class LifecycleException extends CascadingException { /** * Construct a new VerifyException instance. * * @param message The detail message for this exception. */ public LifecycleException( final String message ) { this( message, null ); } /** * Construct a new VerifyException instance. * * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public LifecycleException( final String message, final Throwable throwable ) { super( message, throwable ); } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/LifecycleExtensionManager.java~ Index: LifecycleExtensionManager.java~ =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.extension; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.context.Context; /** * LifecycleExtensionManager class. This class manages a list * of extensions objects that are executed on components during the various * stages of their lifecycles. * *

* It provides methods for adding extension objects to the system, * and a method for executing them on a particular component object. The * current context is also passed in to the extension objects to facilitate * the communication of any global values. *

* *

* Extensions are stored internally in a list. This guarentees that the * order in which they are executed matches the order in which they are * inserted. *

* * @author Marcus Crafter * @version CVS $Revision: 1.1 $ $Date: 2002/07/29 06:14:30 $ */ public class LifecycleExtensionManager extends AbstractLifecycleExtensionManager { // extensions objects private final CachedArrayList m_extensions = new CachedArrayList(); /** * executeAccessExtensions method, executes all access level * extensions on the given component. * * @param component a Component instance * @param context a Context instance * @exception Exception if an error occurs */ public void executeAccessExtensions( Object component, Context context ) throws Exception { executeExtensions( m_extensions.toArray(), component, context, ACCESS ); } /** * executeReleaseExtensions method, executes all release level * extensions on the given component. * * @param component a Component instance * @param context a Context instance * @exception Exception if an error occurs */ public void executeReleaseExtensions( Object component, Context context ) throws Exception { executeExtensions( m_extensions.toArray(), component, context, RELEASE ); } /** * executeCreationExtensions method, executes all creation level * extensions on the given component. * * @param component a Component instance * @param context a Context instance * @exception Exception if an error occurs */ public void executeCreationExtensions( Object component, Context context ) throws Exception { executeExtensions( m_extensions.toArray(), component, context, CREATION ); } /** * executeDestructionExtensions method, executes all destruction * level extensions on the given component. * * @param component a Component instance * @param context a Context instance * @exception Exception if an error occurs */ public void executeDestructionExtensions( Object component, Context context ) throws Exception { executeExtensions( m_extensions.toArray(), component, context, DESTRUCTION ); } // The following methods define operations that modify the internal list // of extensions. I've refrained from returning the List directly, via a // getExtensions() method for the following reasons: // // 1. Returning List breaks encapsulation, implicitly exposing all of List's // current and future operations to the client // 2. List operates with type Object, not LifecycleExtension which means we need // more error handling code if we make it possible for the user to add instances // of any type to the extension lists. // 3. Wrapping add/remove methods allow us to add optimizations to improve performance // (eg. to convert the List to an array upon each add/remove, and not upon each // execute operation) // 4. The book 'Refactoring' says we shouldn't do it :-) // // I'm open to suggestions though if there's any better ideas ? /** * Adds an extension to the manager * * @param extension a LifecycleExtension instance */ public void addExtension( LifecycleExtension extension ) { m_extensions.add( extension ); } /** * Inserts an extension at a given index in the manager * * @param position an int index value * @param extension a LifecycleExtension instance */ public void insertExtension( int position, LifecycleExtension extension ) { m_extensions.insert( position, extension ); } /** * Removes a particular extension from the manager * * @param position an int index value * @return a LifecycleExtension instance */ public LifecycleExtension removeExtension( int position ) { return (LifecycleExtension) m_extensions.remove( position ); } /** * Obtain an iterator. * * @return an Iterator instance */ public Iterator extensionsIterator() { return m_extensions.iterator(); } /** * Find out the total number of extensions registered with this manager * * @return an int value */ public int extensionsCount() { return m_extensions.size(); } /** * Obtain the particular extension at the given index * * @param index an int index value * @return a LifecycleExtension instance */ public LifecycleExtension getExtension( int index ) { return (LifecycleExtension) m_extensions.get( index ); } /** * Check whether the given extension is already registered * with this manager * * @param extension a LifecycleExtension instance * @return index of given extension, -1 if non-existing. */ public int indexOfExtension( LifecycleExtension extension ) { return m_extensions.indexOf( extension ); } /** * Clears all extensions registered with this manager */ public void clearExtensions() { m_extensions.clear(); } /** * CachedArrayList class. * *

* This class wraps a synchronized ArrayList to provide an optimized * toArray() method that returns an internally cached array, rather * than a new array generated per toArray() invocation. *

* *

* Use of the class by the Manager results in toArray() being invoked * far more often than any other method. Caching the value toArray * normally returns is intended to be a performance optimization. *

* *

* The cached array value is updated upon each write operation to the List. *

* *

* REVISIT(MC): investigate using FastArrayList from collections ? *

*/ private final class CachedArrayList { // Empty array constant private final Object[] EMPTY_ARRAY = new Object[0]; // Actual list for storing elements private final List m_proxy = Collections.synchronizedList( new ArrayList() ); // Proxy cache, saves unnecessary conversions from List to Array private Object[] m_cache = EMPTY_ARRAY; /** * Add an object to the list * * @param object an Object value */ public void add( final Object object ) { m_proxy.add( object ); m_cache = m_proxy.toArray(); } /** * Insert an object into a particular position in the list * * @param position an int value * @param object an Object value */ public void insert( final int position, final Object object ) { m_proxy.add( position, object ); m_cache = m_proxy.toArray(); } /** * Remove an object from the list * * @param position an int value * @return a Object value */ public Object remove( final int position ) { final Object object = m_proxy.remove( position ); m_cache = m_proxy.toArray(); return object; } /** * Obtain an iterator * * @return an Iterator value */ public Iterator iterator() { return m_proxy.iterator(); } /** * Obtain the size of the list * * @return an int value */ public int size() { return m_proxy.size(); } /** * Access an object that is in the list * * @param index an int value * @return a Object value */ public Object get( final int index ) { return m_proxy.get( index ); } /** * Find out the index of an object in the list * * @param object an Object value * @return an int value */ public int indexOf( final Object object ) { return m_proxy.indexOf( object ); } /** * Clear the list */ public void clear() { m_proxy.clear(); m_cache = EMPTY_ARRAY; } /** * Obtain the list as an array. Subsequents calls to this method * will return the same array object, until a write operation is * performed on the list. * * @return an Object[] value */ public Object[] toArray() { return m_cache; } } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/LifecycleHelper.java Index: LifecycleHelper.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly.resource; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.activity.Startable; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.Composable; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.container.ContainerUtil; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.Contextualizable; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.logger.LogEnabled; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.parameters.Parameterizable; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.Serviceable; import org.apache.excalibur.merlin.model.Profile; /** * This is a class to help an Application manage the lifecycle of a component. * The implementation provides support for the processing of a component through * each lifecycle stage, and manage errors in a consistent way. * * @author Peter Donald * @author Stephen McConnell */ public class LifecycleHelper extends AbstractLogEnabled { private static final Resources REZ = ResourceManager.getPackageResources( LifecycleHelper.class ); //Constants to designate stages private static final int STAGE_CREATE = 0; private static final int STAGE_LOGGER = 1; private static final int STAGE_CONTEXT = 2; private static final int STAGE_COMPOSE = 3; private static final int STAGE_CONFIG = 4; private static final int STAGE_PARAMETER = 5; private static final int STAGE_INIT = 6; private static final int STAGE_START = 7; private static final int STAGE_STOP = 8; private static final int STAGE_DISPOSE = 9; private static final int STAGE_DESTROY = 10; /** * Method to run a component through it's startup phase. * Errors that occur during startup will be logged appropriately and * cause exceptions with useful messages to be raised. * * @param name the name of the component * @param profile representing the instance criteria * @param provider the resource provider * @throws LifecycleException if an error occurs when the component passes * through a specific lifecycle stage */ public Object startup( final String name, final Profile profile, final ResourceProvider provider ) throws LifecycleException { getLogger().info("startup initiated for '" + name + "'." ); int stage = 0; try { //Creation stage stage = STAGE_CREATE; notice( name, stage ); final Object object = provider.createObject( profile ); //LogEnabled stage stage = STAGE_LOGGER; if( object instanceof LogEnabled ) { notice( name, stage ); final Logger logger = provider.createLogger( profile ); ContainerUtil.enableLogging( object, logger ); } //Contextualize stage stage = STAGE_CONTEXT; if( object instanceof Contextualizable ) { notice( name, stage ); final Context context = provider.createContext( profile ); ContainerUtil.contextualize( object, context ); } //Composition stage stage = STAGE_COMPOSE; if( object instanceof Serviceable ) { notice( name, stage ); final ServiceManager manager = provider.createServiceManager( profile ); ContainerUtil.service( object, manager ); } else if( object instanceof Composable ) { notice( name, stage ); final ComponentManager componentManager = provider.createComponentManager( profile ); ContainerUtil.compose( object, componentManager ); } //Configuring stage stage = STAGE_CONFIG; if( object instanceof Configurable ) { notice( name, stage ); final Configuration configuration = provider.createConfiguration( profile ); ContainerUtil.configure( object, configuration ); } //Parameterizing stage stage = STAGE_PARAMETER; if( object instanceof Parameterizable ) { notice( name, stage ); final Parameters parameters = provider.createParameters( profile ); ContainerUtil.parameterize( object, parameters ); } //Initialize stage stage = STAGE_INIT; if( object instanceof Initializable ) { notice( name, stage ); ContainerUtil.initialize( object ); } //Start stage stage = STAGE_START; if( object instanceof Startable ) { notice( name, stage ); ContainerUtil.start( object ); } return object; } catch( final Throwable t ) { fail( name, stage, t ); //fail() throws an exception so next //line will never be executed return null; } } /** * Method to run a component through it's shutdown phase. * Errors that occur during shutdown will be logged appropraitely. * * @param name the name of the component * @param object the component to shutdown */ public void shutdown( final String name, final Object object ) throws LifecycleException { getLogger().info("shutdown initiated for '" + name + "'." ); //Stage at which failure occured int stage = 0; //Failure exception Throwable failure = null; //Stoppable stage if( object instanceof Startable ) { notice( name, STAGE_STOP ); try { ContainerUtil.stop( object ); } catch( final Throwable t ) { safeFail( name, STAGE_STOP, t ); failure = t; stage = STAGE_STOP; } } //Disposable stage if( object instanceof Disposable ) { notice( name, STAGE_DISPOSE ); try { ContainerUtil.dispose( object ); } catch( final Throwable t ) { safeFail( name, STAGE_DISPOSE, t ); failure = t; stage = STAGE_DISPOSE; } } notice( name, STAGE_DESTROY ); if( null != failure ) { fail( name, stage, failure ); } } /** * Utility method to report that a lifecycle stage is about to be processed. * * @param name the name of component that is the subject of the notice * @param stage the lifecycle processing stage */ private void notice( final String name, final int stage ) { if( getLogger().isDebugEnabled() ) { final String message = REZ.getString( "lifecycle.stage.notice", name, new Integer( stage ) ); getLogger().debug( message ); } } /** * Utility method to report that there was an error processing * specified lifecycle stage. * * @param name the name of component that caused failure * @param stage the lefecycle stage * @param t the exception thrown */ private void safeFail( final String name, final int stage, final Throwable t ) { //final String reason = t.getMessage(); final String reason = t.toString(); final String message = REZ.getString( "lifecycle.fail.error", name, new Integer( stage ), reason ); getLogger().error( message ); } /** * Utility method to report that there was an error processing * specified lifecycle stage. It will also re-throw an exception * with a better error message. * * @param name the name of block that caused failure * @param stage the stage * @param t the exception thrown * @throws LifecycleException containing error */ private void fail( final String name, final int stage, final Throwable t ) throws LifecycleException { //final String reason = t.getMessage(); final String reason = t.toString(); final String message = REZ.getString( "lifecycle.fail.error", name, new Integer( stage ), reason ); getLogger().error( message ); throw new LifecycleException( message, t ); } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/PhaseManager.java Index: PhaseManager.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly.resource; import org.apache.avalon.framework.context.Context; /** * PhaseExtension interface. This interface defines the methods that * a container can invoke on a phase handler. * * @author Stephen McConnell * @author Marcus Crafter * @version CVS $Revision: 1.1 $ $Date: 2002/07/29 06:14:30 $ */ public interface PhaseManager { /** * Create, called when the given component is being * instantiated. * * @param component a Component instance * @param context a Context instance * @exception Exception if an error occurs */ void create( Object component, Context context ) throws Exception; /** * Destroy, called when the given component is being * decomissioned. * * @param component a Component instance * @param context a Context instance * @exception Exception if an error occurs */ void destroy( Object component, Context context ) throws Exception; /** * Access, called when the given component is being * accessed (ie. via lookup() or select()). * * @param component a Component instance * @param context a Context instance * @exception Exception if an error occurs */ void access( Object component, Context context ) throws Exception; /** * Release, called when the given component is being * released (ie. by a CM or CS). * * @param component a Component instance * @param context a Context instance * @exception Exception if an error occurs */ void release( Object component, Context context ) throws Exception; } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/ProfileDesignator.java Index: ProfileDesignator.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly.resource; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.excalibur.merlin.assembly.resource.LifecycleHelper; import org.apache.excalibur.merlin.model.Profile; import org.apache.excalibur.merlin.model.ResourceDesignator; import org.apache.excalibur.meta.info.ServiceDescriptor; /** * Opaque type that maps a path to a profile. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:30 $ */ public class ProfileDesignator implements ResourceDesignator { public static final String HEADER = "service:"; /** * The path of the profile designator. */ private final String m_path; /** * The profile that disignator refers to. */ private final Profile m_profile; /** * A singleton reference to the instantiated service. */ private Object m_service; /** * The lifecycle helper. */ private final LifecycleHelper m_helper; /** * The resource provider. */ private final ResourceProvider m_provider; /** * The current state */ private int m_state = NOT_STARTED; /** * Create a profile designator instance. * * @param path the path of the profile designator * @param profile the profile * @param helper the lifecycle helper * @param provider the resource provider */ public ProfileDesignator( final String path, final Profile profile, final LifecycleHelper helper, final ResourceProvider provider ) { if( null == path ) { throw new NullPointerException( "path" ); } if( null == profile ) { throw new NullPointerException( "profile" ); } if( null == helper ) { throw new NullPointerException( "helper" ); } if( null == provider ) { throw new NullPointerException( "provider" ); } m_path = path; m_profile = profile; m_helper = helper; m_provider = provider; } /** * Returns the path of the resource. * * @return the simbolic path of the resource */ public String getPath() { return HEADER + m_path; } /** * Returns the service descriptor. * * @return the service descriptor */ public ServiceDescriptor[] getServices() { return m_profile.getType().getServices(); } /** * Get the resource instance. * * @return the service instance. * @exception LifecycleException if an error occurs while establishing the object */ public Object getInstance() throws LifecycleException { if( m_service == null ) m_service = m_helper.startup( m_path, m_profile, m_provider ); setState( STARTED ); return m_service; } /** * Release the service instance. * * @exception LifecycleException if an error occurs while releasing the object */ public void release() throws LifecycleException { if( m_service != null ) m_helper.shutdown( m_path, m_service ); setState( STOPPED ); } /** * Returns the active state of the resoruce. * @return one of the values NOT_STARTED, STARTED, or STOPPED */ public int getState() { return m_state; } private synchronized void setState( int state ) { m_state = state; } /** * Return the profile. * * @return the profile */ public Profile getProfile() { return m_profile; } public String toString() { return "ProfileResource: " + getPath(); } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/ResourceException.java Index: ResourceException.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly.resource; import java.util.Enumeration; import java.util.Dictionary; import java.util.Hashtable; import org.apache.avalon.framework.CascadingException; /** * Exception to indicate that there was an error relating to resource management. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:30 $ */ public final class ResourceException extends CascadingException { /** * Construct a new ResourceException instance. * * @param message The detail message for this exception. */ public ResourceException( final String message ) { this( message, null ); } /** * Construct a new ResourceException instance. * * @param message The detail message for this exception. * @param throwable the root cause of the exception */ public ResourceException( final String message, final Throwable throwable ) { super( message, throwable ); } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/assembly/resource/ResourceProvider.java Index: ResourceProvider.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.assembly.resource; import java.io.InputStream; import java.io.File; import java.io.IOException; import java.net.URL; import java.net.JarURLConnection; import java.net.URLClassLoader; import java.util.Map; import java.util.List; import java.util.LinkedList; import java.util.Hashtable; import java.util.Properties; import java.util.Vector; import java.util.Iterator; import java.util.jar.Attributes; import java.util.jar.Manifest; import java.security.Policy; import java.io.FileInputStream; import java.util.HashMap; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.framework.Version; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.logger.AvalonFormatter; import org.apache.avalon.framework.logger.LogKitLogger; import org.apache.avalon.framework.activity.Initializable; import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.activity.Executable; import org.apache.avalon.framework.activity.Startable; import org.apache.avalon.framework.CascadingRuntimeException; import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.DefaultConfiguration; import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.Contextualizable; import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.context.DefaultContext; import org.apache.avalon.framework.service.Serviceable; import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.ServiceException; import org.apache.excalibur.configuration.ConfigurationUtil; import org.apache.excalibur.meta.verifier.VerifyException; import org.apache.excalibur.meta.info.Type; import org.apache.excalibur.meta.info.ServiceDescriptor; import org.apache.excalibur.meta.info.DependencyDescriptor; import org.apache.excalibur.meta.info.ReferenceDescriptor; import org.apache.excalibur.merlin.assembly.ProfileManager; import org.apache.excalibur.merlin.assembly.DefaultLoggerManager; import org.apache.excalibur.merlin.container.model.ContainerDescriptor; import org.apache.excalibur.merlin.model.Profile; import org.apache.excalibur.merlin.model.Association; import org.apache.excalibur.merlin.model.ResourceDesignator; import org.apache.excalibur.merlin.model.Import; /** * Internal class that handles the establishment of component instances based on a supplied * type profile. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:30 $ */ public class ResourceProvider extends AbstractLogEnabled { //======================================================================= // state //======================================================================= private final static Resources REZ = ResourceManager.getPackageResources( ResourceProvider.class ); //======================================================================= // state //======================================================================= /** * The log manager. */ private DefaultLoggerManager m_logging; /** * The classloader to use when servicing object creation requests. */ private ProfileManager m_classloader; /** * A hashtable of service implemenentation object references keyed by profile. */ private final Hashtable m_singletons = new Hashtable(); private DefaultContext m_dictionary; //======================================================================= // constructor //======================================================================= /** * Creation of a new resource provider. * * @param logger the parent logger to use when creating loggers for services. * @param loader the class loader * @param dictionary the parent dictionary */ public ResourceProvider( ProfileManager loader, Context dictionary, DefaultLoggerManager logging ) { m_classloader = loader; m_logging = logging; // ##### WARNING ########## // The following is a hack to add the avalon:work context key - this needs to // constructed using context creation directives at the level of the kernel // defintion //######################### m_dictionary = new DefaultContext( dictionary ); m_dictionary.put( "classloader", loader ); m_dictionary.put( "home", new File( System.getProperty("user.dir") ) ); m_dictionary.makeReadOnly(); } //======================================================================= // ResourceProvider //======================================================================= /** * Create an object specified by profile. * * @param profile the profile * @return the new object * @throws Exception if unable to resolve resource */ public Object createObject( Profile profile ) throws Exception { Object object = getSingletonInstance( profile ); if( object == null ) { Class clazz = null; String classname = null; try { classname = profile.getType().getInfo().getImplementationKey(); clazz = m_classloader.loadClass( classname ); } catch( Throwable e ) { final String error = "Unexpected exception while attempting to load class '" + classname + "' for the profile: " + profile; throw new ResourceException( error, e ); } try { object = clazz.newInstance(); putSingletonInstance( profile, object ); } catch( Throwable e ) { final String error = "Unexpected exception while attempting to instantiate an instance from profile: " + profile; throw new ResourceException( error, e ); } } return object; } /** * Create a new Logger for component. * * @param profile the profile * @return a new Logger for service * @throws Exception if unable to create the logger */ public Logger createLogger( Profile profile ) throws Exception { final String path = m_classloader.getPath(); final String root = path.replace('/','.').substring(1) + "." + profile.getName(); m_logging.addCategories( root, profile.getCategories() ); return m_logging.getLoggerForCategory( root ); } /** * Create a new Context for component. * * @param profile the profile * @return a new Context for service * @throws Exception if unable to create context */ public Context createContext( Profile profile ) throws Exception { DefaultContext parent = new DefaultContext(); Import[] imports = profile.getContext().getImports(); for( int i=0; i Interfaces and classes supporting component lifecycle management. 1.6 +2 -54 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/Container.java Index: Container.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/Container.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Container.java 19 Jul 2002 14:08:06 -0000 1.5 +++ Container.java 29 Jul 2002 06:14:30 -0000 1.6 @@ -10,7 +10,7 @@ import org.apache.excalibur.merlin.model.Profile; import org.apache.excalibur.merlin.model.ResourceDesignator; -import org.apache.excalibur.meta.info.ServiceDesignator; +import org.apache.excalibur.meta.info.ReferenceDescriptor; import org.apache.excalibur.merlin.Verifiable; import org.apache.excalibur.merlin.Controller; @@ -31,30 +31,6 @@ */ public interface Container extends Controller, Verifiable { - /** - * Assembly function that return an establish candidate resource from a parent or local - * container matching a supplied profile. - * - * @param profile a supplier profile - * @return the corresponding candidate resource or null if no matching resource - */ - ResourceDesignator getCandidateResource( Profile profile ); - - /** - * Assembly function that returns the set of potential profiles - * matching a dependency that may be applied as candidates to an assembly - * process. - * - * @param dependency a consumer component dependency declaration - * @return the set of available potential supplier profiles - */ - Profile[] getProviders( ServiceDesignator service ); - - /** - * Returns the path name of this container. - * @return the container's path - */ - String getPath(); /** * Post-assembly function that returns the set of resources @@ -63,33 +39,5 @@ * @return the set of available resources */ ResourceDesignator[] getResources(); - - /** - * Post-assembly function that return the set of resources available in the - * container that matches the supplied service type. - * - * @param service the service type - * @return the set of available resources matching the service type - */ - ResourceDesignator[] getResources( ServiceDesignator service ); - - /** - *

Post-assembly function that returns a resource by name. The path - * argument shall be in the form:

- * - *
  -    *    <path> == <resource-type> + ":" + <container-path> + "/" + <profile-name>
  -    *    <container-path> == <parent-path> + "/" + <container-name>
  -    *    <parent-path> == <root> | <container-path>
  -    * 
- *

Example

- *

  -    *   service:/facilities/security/vault
  -    * 
- * - * @param path the resource identifier - * @return the named resource or null if the resource does not exist - */ - ResourceDesignator getResource( String path ); } 1.17 +40 -375 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.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- DefaultContainer.java 26 Jul 2002 06:17:04 -0000 1.16 +++ DefaultContainer.java 29 Jul 2002 06:14:30 -0000 1.17 @@ -62,25 +62,18 @@ import org.apache.excalibur.meta.info.Type; import org.apache.excalibur.meta.info.ServiceDescriptor; import org.apache.excalibur.meta.info.DependencyDescriptor; -import org.apache.excalibur.meta.info.ServiceDesignator; +import org.apache.excalibur.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.DefaultLoggerManager; +import org.apache.excalibur.merlin.container.model.ContainerDescriptor; import org.apache.excalibur.merlin.model.Profile; -import org.apache.excalibur.merlin.model.Profile; -import org.apache.excalibur.merlin.model.ContainerDescriptor; +import org.apache.excalibur.merlin.model.ResourceDesignator; import org.apache.excalibur.merlin.model.verifier.AssemblyVerifier; import org.apache.excalibur.merlin.model.verifier.MetaDataVerifier; -import org.apache.excalibur.merlin.model.builder.ProfileBuilder; -import org.apache.excalibur.merlin.model.builder.TypeManager; -import org.apache.excalibur.merlin.model.ResourceDesignator; -import org.apache.excalibur.merlin.model.builder.DefaultTypeManager; -import org.apache.excalibur.merlin.model.builder.DefaultLoggerManager; import org.apache.excalibur.merlin.Verifiable; import org.apache.excalibur.merlin.Controller; -import org.apache.log.Hierarchy; -import org.apache.log.Priority; -import org.apache.log.output.io.StreamTarget; - -import org.apache.excalibur.merlin.container.UnresolvedProviderException; /** * Default container implementation that manages a registry of componet providers and @@ -132,26 +125,9 @@ private List m_containers = new LinkedList(); /** - * Parent container. - */ - private Container m_parent; - - /** * The classloader resolved from the meta model. */ - private TypeManager m_classloader; - - /** - * Dependecy graph shared across all containers within the container hierachy. - */ - private DependencyGraph m_map; - - /** - * Utility class providing support for establishments of objects that get - * supplied to components (cofiguration, context, etc.). Interacts between - * the meta model, container implementation, resources and service managers. - */ - private ResourceProvider m_provider; + private ProfileManager m_classloader; /** * The meta data model of this container. @@ -159,37 +135,10 @@ private ContainerDescriptor m_descriptor; /** - * The lifecycle helper to use to process startup and shutdown of services. - */ - private LifecycleHelper m_helper = new LifecycleHelper(); - - /** - * Internal class that maintains information about profile types managed - * by this container. - */ - private ProfileRegistry m_profiles; - - /** - * Table of resources that have been created - keyed by the associated profile. - */ - private Hashtable m_mapping = new Hashtable(); - - /** - * Utility class used to create type meta info for compoents not explicity declared - * in the meta data model. - */ - private ProfileBuilder m_builder = new ProfileBuilder(); - - /** * Flag showing initialization status. */ private boolean m_initialized = false; - /** - * The context object against which resoruce requests will be evaluated. - */ - private Context m_dictionary; - //======================================================================= // Contextualizable //======================================================================= @@ -199,32 +148,13 @@ *
    *
  • {@link #CONTAINER_DESCRIPTOR_KEY} the container meta model as * a {@link ContainerDescriptor} (REQUIRED}
  • - *
  • {@link #DICTIONARY_KEY} the kernel context import dictionary as - * a {@link Context} object from which import directives may be resolved - * (REQUIRED)
  • - *
  • {@link #CONTAINER_KEY} the parent {@link Container} (OPTIONAL) - if null, - * this is a root container
  • - *
  • {@link #MAP_KEY} the shared dependecy map {@link DependencyGraph} (OPTIONAL) - * - if null, this is a root container
  • *
* @param context the service context value */ public void contextualize( Context context ) throws ContextException { m_descriptor = (ContainerDescriptor) context.get( CONTAINER_DESCRIPTOR_KEY ); - m_dictionary = (Context) context.get( DICTIONARY_KEY ); - m_classloader = m_descriptor.getTypeManager(); - - try - { - m_parent = (Container) context.get( CONTAINER_KEY ); - m_map = (DependencyGraph) context.get( MAP_KEY ); - } - catch( ContextException e ) - { - // root container - m_map = new DependencyGraph(); - } + m_classloader = m_descriptor.getProfileManager(); } //======================================================================= @@ -242,27 +172,7 @@ public void initialize() throws Exception { getLogger().debug("initialization"); - getLogger().debug( "container creation using clasloader: " + m_classloader ); - - m_helper.enableLogging( getLogger().getChildLogger("lifecycle") ); - m_provider = new ResourceProvider( m_classloader, this, m_dictionary ); - m_provider.enableLogging( getLogger().getChildLogger("provider") ); - - // - // initiate profile creation - // - - m_profiles = new ProfileRegistry( - m_descriptor, - m_classloader, - getPath(), - m_parent, - m_map, - m_helper, - m_provider, - m_mapping ); - - m_profiles.enableLogging( getLogger().getChildLogger( "assembly") ); + getLogger().debug( "container creation using classloader: " + m_classloader ); // // explicit component profile registration @@ -272,35 +182,20 @@ Profile[] children = m_descriptor.getComponents( Profile.EXPLICIT, true ); for( int i=0; i - - - - - + + + + + - + 1.4 +1 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/package.html Index: package.html =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/package.html,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- package.html 12 Jul 2002 19:09:26 -0000 1.3 +++ package.html 29 Jul 2002 06:14:30 -0000 1.4 @@ -1,7 +1,7 @@

-A geneneric component type management service supporting automated component assembly, service deployment and service decommissioning . The service acts as a repository for component types and profiles. The repository enables resolution of component types based on a classloader, extension directory set defintion (managemed by the host kernel), a supplied classpath, and component deployment directives. Components are established based on the publication of components across a set jar file manifest together with explicit component profile directives included within the registry configuration. Given a manifest declaration of a component implementation class, a component type definition will be resolvable providing the registry can resolve all type constraints (specifically the validation of the dependecies of candidate supplier components). +A component type management service supporting automated component assembly, service deployment and service decommissioning. The service acts as a repository for component types and profiles. The repository enables resolution of component types based on a classloader, extension directory set defintion (managemed by the host kernel), a supplied classpath, and component deployment directives. Components are established based on the publication of components across a set jar file manifest together with explicit component profile directives included within the registry configuration. Given a manifest declaration of a component implementation class, a component type definition will be resolvable providing the registry can resolve all type constraints (specifically the validation of the dependecies of candidate supplier components).

Funtional Summary

    1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/builder/ContainerCreator.java Index: ContainerCreator.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.container.builder; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.logger.Logger; import org.apache.excalibur.merlin.assembly.TypeManager; import org.apache.excalibur.merlin.assembly.DefaultLoggerManager; import org.apache.excalibur.merlin.container.model.ContainerDescriptor; import org.apache.excalibur.merlin.container.model.Parent; /** * Simple interface used to create {@link ContainerDescriptor} * from a Configuration sorce. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:31 $ */ public interface ContainerCreator { /** * Create a {@link org.apache.excalibur.merlin.model.Profile} from configuration * * @param config the confiugration source * @return the newly created {@link ContainerDescriptor} * @throws Exception */ ContainerDescriptor createContainerDescriptor( Parent parent, Configuration config, TypeManager manager, DefaultLoggerManager logging ) throws Exception; } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/builder/Resources.properties Index: Resources.properties =================================================================== builder.redundent-role.notice=Warning: Type for class {0} redundently specifies role name "{1}" in dependency when it is identical to the name of service. It is recomended that the section be elided. builder.creating-info.notice=Creating a Type for class "{0}". builder.created-info.notice=Constructed Type object for class {0}. ComponentInfo contains {1} services, {2} dependencies, {3} context entrys and {4} loggers. builder.bad-toplevel-element.error=Error the component implemented by "{0}" has an invalid element at top level of component info descriptor. Expected: "component-info". Actual: "{1}" builder.missing-info.error=Unable to locate resource from which to load info for component implemented by class "{0}". builder.missing-xml-creator.error=Unable to create XMLTypeCreator, usually due to not having XML classes on Classpath. Thus unable to lookup XML descriptor for component type "{0}". builder.creating-profile.notice=Creating Profiles for class "{0}". target.nocreate=Error creating LogTarget named "{0}" for file {0}. (Reason: {2}). unknown-priority=Unknown priority "{0}" for Logger named "{1}". category-create=Creating a log category named "{0}" that writes to "{1}" target at priority "{2}". missing.extension=Unable to locate an extension that is required by application.\n Extension Name: {0}\n Specification Vendor: {1}\n Specification Version: {2}\n Implementation Vendor: {3}\n Implementation Vendor-Id: {4}\n Implementation Version: {5}\n Implementation URL: {6} unsatisfied.extensions=Missing {0} extensions and thus can not build ClassLoader for application. bad-classpath-entry=There is a bad entry ("{0}") on classpath that made it impossible to load a manifest. available-extensions=Available extensions: {0} required-extensions=The list of required extensions for application includes: {0} optional-packages-added=The list of "Optional Packages" added to the application include: {0} classpath-entries=The list of classpath entrys for the application include: {0} 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/builder/XMLContainerCreator.java Index: XMLContainerCreator.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.container.builder; import java.io.InputStream; import java.util.ArrayList; import java.util.Properties; import java.util.Vector; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.framework.Version; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.context.DefaultContext; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.excalibur.configuration.ContextFactory; import org.apache.excalibur.merlin.model.Profile; import org.apache.excalibur.merlin.model.CategoriesDescriptor; import org.apache.excalibur.merlin.model.Category; import org.apache.excalibur.merlin.container.model.ContainerDescriptor; import org.apache.excalibur.merlin.container.model.IncludeDescriptor; import org.apache.excalibur.merlin.container.model.FilesetDescriptor; import org.apache.excalibur.merlin.container.model.ClasspathDescriptor; import org.apache.excalibur.merlin.container.model.Parent; import org.apache.excalibur.merlin.model.ModelException; import org.apache.excalibur.merlin.model.builder.XMLProfileCreator; import org.apache.excalibur.merlin.assembly.TypeManager; import org.apache.excalibur.merlin.assembly.ProfileManager; import org.apache.excalibur.merlin.assembly.DefaultLoggerManager; import org.apache.excalibur.meta.info.Type; /** * Handles internalization of an XML based description of a {@link ContainerDescriptor} * from a Configuration object. The format for Configuration object * is specified in the package summary. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:31 $ */ public class XMLContainerCreator extends XMLProfileCreator implements ContainerCreator { private static final Resources REZ = ResourceManager.getPackageResources( XMLContainerCreator.class ); /** * Create a new container descriptor. * @param config the container configuration * @param manager the parent type manager * @param logger the parent logger * @exception Exception is a error occurs during container descriptor creation */ public ContainerDescriptor createContainerDescriptor( Parent parent, Configuration config, TypeManager manager, DefaultLoggerManager logging ) throws Exception { // // create the logging categories for this container // final String name = config.getAttribute("name"); CategoriesDescriptor categories = super.createCategoriesDescriptor( name, config.getChild("categories") ); Logger logger; if( parent instanceof ContainerDescriptor ) { final String root = parent.getPath().replace('/','.').substring(1) + "." + name; logging.addCategories( root, categories ); logger = logging.getLoggerForCategory( root ); } else { logging.addCategories( name, categories ); logger = logging.getLoggerForCategory( name ); } // // create a new classloader for this container // logger.info("preparing type manager"); ClasspathDescriptor classpath = createClasspathDescriptor( config.getChild("classpath") ); final ProfileManager loader = new ProfileManager( manager, name ); try { loader.enableLogging( logger.getChildLogger( "loader" ) ); DefaultContext context = new DefaultContext(); context.put( TypeManager.CLASSPATH_DESCRIPTOR_KEY, classpath ); context.makeReadOnly(); loader.contextualize( context ); loader.initialize(); } catch( Throwable e ) { final String error = "Classloader establishment failure."; throw new ModelException( error, e ); } // // create an empty container // logger.info("container descriptor creation"); ContainerDescriptor container = new ContainerDescriptor( parent, name, logger, loader ); // // add all of the profiles declared within the container using the container's // type manager // logger.info("component creation"); Configuration[] children = config.getChildren("component"); for( int i=0; i Utilities supporting the creation of a container from an XML description. 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/model/ClasspathDescriptor.java Index: ClasspathDescriptor.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.container.model; import java.io.Serializable; /** *

    A classpath descriptor that describes a scoped set of jar files. Classpath * descriptors are contained with {@link org.apache.excalibur.merlin.kernel.model.KernelDescriptor} and * {@link org.apache.excalibur.merlin.container.model.ContainerDescriptor} declarations. * A classpath contains 0-n {@link FilesetDescriptor} instances.

    * *

    XML

    *

    The XML form for a classpath description is shown below. The classpath element contains * no attributes. The element may contain multiple fileset elements that collectively define * the scope of the classpath. *

    *
       *    <classpath>
       *
       *      <!-- 
       *      Declaration of multiple filesets.
       *      -->
       *
       *      <fileset dir="dist">
       *        <include name="demo.jar"/>
       *        <include name="new-application-1.0.jar"/>
       *      </fileset>
       *
       *      <fileset dir="lib">
       *        <include name="avalon-framework.jar"/>
       *      </fileset>
       *
       *    </classpath>
       * 
    * * @see FilesetDescriptor * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:31 $ */ public class ClasspathDescriptor implements Serializable { /** * The collection of filesets. */ private final FilesetDescriptor[] m_filesets; /** * Create a ClasspathDescriptor instance. * * @param filesets the set of filesets to include in the classpath */ public ClasspathDescriptor( final FilesetDescriptor[] filesets ) { m_filesets = filesets; } /** * Return the filesets held within the classpath descriptor. * * @return the filesets */ public FilesetDescriptor[] getFilesetDescriptors() { return m_filesets; } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/model/ContainerDescriptor.java Index: ContainerDescriptor.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.container.model; import java.util.ArrayList; import org.apache.avalon.framework.logger.Logger; import org.apache.excalibur.merlin.assembly.ProfileManager; import org.apache.excalibur.merlin.model.Profile; /** *

    A container descriptor is a description of the crieria supporting the * construction of a container. It may may include multiple * component profile declarations, and multiple nested container declarations.

    * *

    XML

    * A single container element is required within a kernel defintion. Multiple * container declarations may appear within an enclosing container. *

       *    <!-- 
       *    Definition of a container.  The name attribute declares bother the container
       *    name and the base logging category that will be supplied to the container
       *    by its parent.  Logging category defintions declared within the container
       *    declaration are relative to the container name.
       *    -->
       *
       *    <container name="root">
       *
       *      <!-- 
       *      Classpath declaration.  Classes accessible to a component are constrained
       *      to the classes available in the jar files declared within the immediate 
       *      classpath, together with and resources declared in any parent container.
       *      -->
       * 
       *      <classpath>
       *        <fileset dir="dist">
       *          <include name="demo.jar"/>
       *          <include name="new-application-1.0.jar"/>
       *        </fileset>
       *      </classpath>
       *
       *      <!-- 
       *      Logging categories declaration.  Logging categories are relative to the name of the 
       *      enaclosing container. Logging priorities and targets will default to the parent
       *      containtains values if undefined.
       *      -->
       * 
       *      <categories priority="INFO">
       *        <category name="profiles" />
       *        <category name="lifecycle" />
       *        <category name="verifier" />
       *      </categories>
       *
       *      <!-- 
       *      Multiple component profile declarations.  If a component declares dependecies, 
       *      the container will attempt to resolve the dependency locally relative to any 
       *      other declared components, otherwise, the container will attempt to resolve
       *      the dependecy using services established (explicitly or implicitly) in the 
       *      parent containers before attempting a local implicit solution.
       *      -->
       * 
       *      <component name="my-component" 
       *         class="org.apache.excalibur.playground.SimpleComponent" />
       *
       *      <!-- 
       *      Multiple subsidiary container declarations.
       *      -->
       * 
       *      <container name="child">
       *        <component name="demo-component" class="org.apache.excalibur.playground.BasicComponent" />
       *      <container>
       *      
       *    </container>
       * 
    * * @see Profile * @see ClasspathDescriptor * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:31 $ */ public class ContainerDescriptor extends Parent { /** * The component described within the scope of the container. */ private final ArrayList m_components = new ArrayList(); /** * The component described within the scope of the container. */ private final ArrayList m_containers = new ArrayList(); /** * Create a ContainerDescriptor instance. * @param parent the parent container * @param name the container name * @param logger the logging channel the the container * @param manager the containers type manager * @param components the set of components to be included in the container * @param containers the set of subsidiary containers to include in the container */ public ContainerDescriptor( final Parent parent, final String name, final Logger logger, final ProfileManager manager ) { super( parent, manager, name, logger ); } /** * Returns the path name of this container descriptor. * @return the container's path */ public String getPath() { if( getParent() instanceof ContainerDescriptor ) { return getParent().getPath() + DELIMITER + getName(); } else { return DELIMITER + getName(); } } /** * Add a component profile to this container. * * @param component the component profile to add to the container */ public void addComponent( Profile component ) { if( !m_components.contains( component ) ) { m_components.add( component ); } } /** * Return the set of component descriptors contained within this container. * * @return the target descriptors */ public Profile[] getComponents() { return (Profile[]) m_components.toArray( new Profile[0] ); } /** * Return the set of enabled or disable components based on the supplied criteria. * * @param enabled TRUE to select enabled components, FALSE returns disabled components * @return the descriptors matching the supplied enabled status */ public Profile[] getComponents( boolean enabled ) { ArrayList list = new ArrayList(); Profile[] components = getComponents(); for( int i=0; iA description of a directory set. A directory set is a declaration of a * a set of directories scoped relative to a parent directory.

    * *

    XML

    *
       *   <dirset dir="../system">
       *     <include name="extensions"/>
       *     <include name="lib"/>
       *   </dirset>
       * 
    * * @see IncludeDescriptor * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:31 $ */ public class DirsetDescriptor implements Serializable { /** * The base directory */ private final String m_base; /** * The set of include directives. */ private final IncludeDescriptor[] m_includes; /** * Create a DirsetDescriptor instance using a base directory and a set of * include statements that should reference directories relative to the base. * * @param base the base directory from which include directory name will be resolved * @param includes the set of include directives */ public DirsetDescriptor( final String base, final IncludeDescriptor[] includes ) { m_base = base; m_includes = includes; } /** * Return the base directory. * * @return the directory */ public String getBaseDirectory() { return m_base; } /** * Return the set of include deirectives. * * @return the include directives */ public IncludeDescriptor[] getIncludeDescriptors() { return m_includes; } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/model/ExtensionsDescriptor.java Index: ExtensionsDescriptor.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.container.model; import java.io.Serializable; /** *

    An extensions descriptor that declares a set of directories to be used * referenced as the installed extension directories. An extensions descriptor * may contain multiple {@link DirsetDescriptor} instances.

    * *

    XML

    *
       *   <extensions>
       *     <dirset dir=".">
       *       <include name="extensions"/>
       *       <include name="lib"/>
       *     </dirset>
       *   </extensions>
       * 
    * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:31 $ */ public class ExtensionsDescriptor implements Serializable { /** * The base directory */ private final DirsetDescriptor[] m_dirs; /** * Create a ExtensionsDescriptor instance. * * @param dirs the set of dirsets to include in the classpath */ public ExtensionsDescriptor( final DirsetDescriptor[] dirs ) { m_dirs = dirs; } /** * Return the dirsets held within the extensions descriptor. * * @return the set of directory set instances */ public DirsetDescriptor[] getDirsetDescriptors() { return m_dirs; } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/model/FilesetDescriptor.java Index: FilesetDescriptor.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.container.model; import java.io.Serializable; /** *

    A fileset descriptor is a scoped defintion of a set of files. A fileset * a structurally defined as a base directory and a set of relative filenames * represented as include directives.

    * *

    XML

    *
       *   <fileset dir="lib">
       *     <include name="avalon-framework.jar"/>
       *     <include name="logkit.jar"/>
       *   </dirset>
       * 
    * * @see IncludeDescriptor * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:31 $ */ public class FilesetDescriptor implements Serializable { /** * The base directory from which include directives will be resolved. */ private final String m_base; /** * The set of include directives. */ private final IncludeDescriptor[] m_includes; /** * Create a FilesetDescriptor instance. * * @param includes the set of includes to include in the fileset */ public FilesetDescriptor( final String base, final IncludeDescriptor[] includes ) { m_base = base; m_includes = includes; } /** * Return the base directory. * * @return the directory */ public String getBaseDirectory() { return m_base; } /** * Return the filesets held within the classpath descriptor. * * @return the filesets */ public IncludeDescriptor[] getIncludeDescriptors() { return m_includes; } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/model/IncludeDescriptor.java Index: IncludeDescriptor.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.container.model; import java.io.Serializable; /** *

    An file include directive.

    *

    XML

    *

    An include element is normally contained within a scoping structure such as a * fileset or directory set. The include element contains the single attribute name * which is used to refer to the file or directory (depending on the containing * context.

    *
       *    <fileset dir="lib">
       *       <include name="avalon-framework.jar" />
       *    </fileset>
       * 
    * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:31 $ */ public class IncludeDescriptor implements Serializable { /** * The base directory */ private final String m_file; /** * Create a FilesetDescriptor instance. * * @param file the filename */ public IncludeDescriptor( final String file ) { m_file = file; } /** * Return the included filename. * * @return the file */ public String getFile() { return m_file; } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/model/Parent.java Index: Parent.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.container.model; import java.io.Serializable; import org.apache.avalon.framework.logger.Logger; import org.apache.excalibur.merlin.assembly.DefaultLoggerManager; import org.apache.excalibur.merlin.assembly.ProfileManager; import org.apache.excalibur.merlin.kernel.model.KernelDescriptor; /** * Abstract class for types that can act as logical parents in the mera-date hierachy. * * @see KernelDescriptor * @see ContainerDescriptor * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:31 $ */ public abstract class Parent implements Serializable { /** * The container classpath descriptor. */ private final ProfileManager m_manager; /** * Container path delimiter. */ public static final String DELIMITER = "/"; /** * The kernel name */ private final String m_name; /** * The logging channel. */ private Logger m_logger; /** * The parent of this parent. */ private Parent m_parent; /** * Abstract constructor that handles name and logging category assignment. The logging * category supplied under this constructor will be used as the parent to subsidary * objects (enabling the creation of logging category chains. * * @param name the name of the instance * @param categories the logging categories descriptor */ public Parent( final Parent parent, ProfileManager manager, final String name, final Logger logger ) { if( name == null ) throw new NullPointerException("name"); if( logger == null ) throw new NullPointerException("logger"); if( manager == null ) throw new NullPointerException("manager"); m_manager = manager; m_name = name; m_logger = logger; m_parent = parent; } /** * Return the type manager assigned to the abstract container. * * @return the {@link ProfileManager} for the container. */ public ProfileManager getProfileManager() { return m_manager; } /** * Return the instance name. * * @return the name of the container */ public String getName() { return m_name; } /** * Returns the path name of this container descriptor. * @return the container's path */ public String getPath() { if( getParent() == null ) { return DELIMITER + getName(); } else { return getParent().getPath() + DELIMITER + getName(); } } /** * Set the parent container. * * @param the container containing this container. * @exception IllegalStateException if the parent is already set */ public void setParent( Parent parent ) throws IllegalStateException { if( m_parent != null ) throw new IllegalStateException("parent"); m_parent = parent; } /** * Return the parent container. * * @return the container containing this container. */ public Parent getParent() { return m_parent; } /** * Return the default logger. * * @return the {@link Logger}. */ public Logger getLogger() { return m_logger; } /** * Add a set of categories to the logging system as direct sub-categrories * of the category representing this container. * * @param categories {@link CategoriesDescriptor} set */ //public void addCategories( CategoriesDescriptor categories ) //{ // m_logging.addCategories( this, categories ); //} } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/container/model/package.html Index: package.html ===================================================================

    The model package contains the formal meta data model describing a container including stuctures for the representation of extension directories, classpath descriptors and subsidiary containers.

    1.23 +13 -22 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.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- DefaultKernel.java 26 Jul 2002 06:17:04 -0000 1.22 +++ DefaultKernel.java 29 Jul 2002 06:14:32 -0000 1.23 @@ -62,15 +62,16 @@ import org.apache.excalibur.meta.info.Type; import org.apache.excalibur.meta.info.ServiceDescriptor; import org.apache.excalibur.meta.info.DependencyDescriptor; -import org.apache.excalibur.meta.info.ServiceDesignator; +import org.apache.excalibur.meta.info.ReferenceDescriptor; import org.apache.excalibur.meta.info.EntryDescriptor; -import org.apache.excalibur.merlin.model.KernelDescriptor; -import org.apache.excalibur.merlin.model.DirsetDescriptor; +import org.apache.excalibur.merlin.kernel.model.KernelDescriptor; +import org.apache.excalibur.merlin.container.model.DirsetDescriptor; import org.apache.excalibur.merlin.model.Profile; -import org.apache.excalibur.merlin.model.ContainerDescriptor; -import org.apache.excalibur.merlin.model.builder.TypeManager; +import org.apache.excalibur.merlin.container.model.ContainerDescriptor; import org.apache.excalibur.merlin.model.ResourceDesignator; -import org.apache.excalibur.merlin.model.builder.XMLKernelCreator; +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.container.DefaultContainer; /** @@ -116,7 +117,7 @@ // // Following initialization the assembly of components has been completed and // resource descriptiors have been assigned. Service exported by the kernel may - // may be access via {@link ResourceDescriptor} references exposed by the + // may be access via {@link ResourceDesignator} references exposed by the // {link #getResources()} method. The following method start all resources // declared as activatable on startup. // @@ -139,7 +140,9 @@ // static //======================================================================= - public static final String WORKING_DIRECTORY_KEY = "avalon:work"; + /** + * Context key used by the kernel to access the kernel meta-data descriptor. + */ public static final String KERNEL_DESCRIPTOR_KEY = "descriptor"; //======================================================================= @@ -185,28 +188,16 @@ public void initialize() throws Exception { - getLogger().debug( - "creating root container descriptor using classloader: " - + m_descriptor.getTypeManager() ); + getLogger().debug( "creating root container descriptor" ); ContainerDescriptor descriptor = m_descriptor.getContainer(); // - // dictionary creation - // - - getLogger().debug("container dictionary" ); - DefaultContext dictionary = new DefaultContext(); - dictionary.put( WORKING_DIRECTORY_KEY, new File( System.getProperty("user.dir") ) ); - dictionary.makeReadOnly(); - - // // root container context creation // getLogger().debug( "root container context creation" ); DefaultContext context = new DefaultContext(); context.put( DefaultContainer.CONTAINER_DESCRIPTOR_KEY, descriptor ); - context.put( DefaultContainer.DICTIONARY_KEY, dictionary ); context.makeReadOnly(); // 1.7 +4 -4 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.xinfo Index: DefaultKernel.xinfo =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultKernel.xinfo,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DefaultKernel.xinfo 25 Jul 2002 18:07:15 -0000 1.6 +++ DefaultKernel.xinfo 29 Jul 2002 06:14:32 -0000 1.7 @@ -18,14 +18,14 @@ - - - + + + - + 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/builder/KernelCreator.java Index: KernelCreator.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.kernel.builder; import org.apache.avalon.framework.configuration.Configuration; import org.apache.excalibur.merlin.kernel.model.KernelDescriptor; /** * Simple interface used to create {@link KernelDescriptor} * from a Configuration sorce. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:32 $ */ public interface KernelCreator { /** * Create a {@link KernelDescriptor} from configuration * * @param config the configration source * @return the newly created {@link KernelDescriptor} * @throws Exception */ KernelDescriptor createKernelDescriptor( Configuration config, ClassLoader loader ) throws Exception; } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/builder/Resources.properties Index: Resources.properties =================================================================== builder.redundent-role.notice=Warning: Type for class {0} redundently specifies role name "{1}" in dependency when it is identical to the name of service. It is recomended that the section be elided. builder.creating-info.notice=Creating a Type for class "{0}". builder.created-info.notice=Constructed Type object for class {0}. ComponentInfo contains {1} services, {2} dependencies, {3} context entrys and {4} loggers. builder.bad-toplevel-element.error=Error the component implemented by "{0}" has an invalid element at top level of component info descriptor. Expected: "component-info". Actual: "{1}" builder.missing-info.error=Unable to locate resource from which to load info for component implemented by class "{0}". builder.missing-xml-creator.error=Unable to create XMLTypeCreator, usually due to not having XML classes on Classpath. Thus unable to lookup XML descriptor for component type "{0}". builder.creating-profile.notice=Creating Profiles for class "{0}". target.nocreate=Error creating LogTarget named "{0}" for file {0}. (Reason: {2}). unknown-priority=Unknown priority "{0}" for Logger named "{1}". category-create=Creating a log category named "{0}" that writes to "{1}" target at priority "{2}". missing.extension=Unable to locate an extension that is required by application.\n Extension Name: {0}\n Specification Vendor: {1}\n Specification Version: {2}\n Implementation Vendor: {3}\n Implementation Vendor-Id: {4}\n Implementation Version: {5}\n Implementation URL: {6} unsatisfied.extensions=Missing {0} extensions and thus can not build ClassLoader for application. bad-classpath-entry=There is a bad entry ("{0}") on classpath that made it impossible to load a manifest. available-extensions=Available extensions: {0} required-extensions=The list of required extensions for application includes: {0} optional-packages-added=The list of "Optional Packages" added to the application include: {0} classpath-entries=The list of classpath entrys for the application include: {0} 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/builder/XMLKernelCreator.java Index: XMLKernelCreator.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.kernel.builder; import java.io.InputStream; import java.util.ArrayList; import java.util.Properties; import java.util.Vector; import org.apache.avalon.excalibur.i18n.ResourceManager; import org.apache.avalon.excalibur.i18n.Resources; import org.apache.avalon.framework.Version; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.context.DefaultContext; import org.apache.excalibur.meta.info.Type; import org.apache.excalibur.merlin.assembly.TypeManager; import org.apache.excalibur.merlin.assembly.ProfileManager; import org.apache.excalibur.merlin.assembly.DefaultLoggerManager; import org.apache.excalibur.merlin.container.model.ContainerDescriptor; import org.apache.excalibur.merlin.container.builder.XMLContainerCreator; import org.apache.excalibur.merlin.kernel.model.KernelDescriptor; import org.apache.excalibur.merlin.model.Profile; import org.apache.excalibur.merlin.model.Category; import org.apache.excalibur.merlin.model.CategoriesDescriptor; import org.apache.excalibur.merlin.container.model.IncludeDescriptor ; import org.apache.excalibur.merlin.container.model.FilesetDescriptor; import org.apache.excalibur.merlin.container.model.ClasspathDescriptor; import org.apache.excalibur.merlin.container.model.DirsetDescriptor; import org.apache.excalibur.merlin.container.model.ExtensionsDescriptor; import org.apache.excalibur.merlin.kernel.model.TargetDescriptor; import org.apache.excalibur.merlin.kernel.model.FileTargetProvider; import org.apache.excalibur.merlin.kernel.model.TargetProvider; import org.apache.excalibur.merlin.kernel.model.LoggingDescriptor; import org.apache.excalibur.merlin.model.ModelException; /** * Handles internalization of an XML based description of a {@link KernelDescriptor} * from a Configuration object. The format for Configuration object * is specified in the package summary. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:32 $ */ public final class XMLKernelCreator extends XMLContainerCreator implements KernelCreator { private static final Resources REZ = ResourceManager.getPackageResources( XMLKernelCreator.class ); /** * Create a {@link KernelDescriptor} from configuration * * @param config the configration source * @param loader the parent classloader * @return the newly created {@link ContainerDescriptor} * @throws Exception */ public KernelDescriptor createKernelDescriptor( Configuration config, ClassLoader loader ) throws Exception { final String name = config.getName(); LoggingDescriptor loggingDescriptor = createLoggingDescriptor( config.getChild("logging"), name ); DefaultLoggerManager logging = new DefaultLoggerManager( loggingDescriptor ); CategoriesDescriptor categories = super.createCategoriesDescriptor( name, config.getChild("categories") ); logging.addCategories( name, categories ); Logger logger = logging.getLoggerForCategory( name ); logger.info("preparing kernel type manager"); ExtensionsDescriptor extensions = createExtensionsDescriptor( config.getChild("extensions") ); ClasspathDescriptor classpath = createClasspathDescriptor( config.getChild("classpath") ); final ProfileManager manager = new ProfileManager( loader, name ); try { manager.enableLogging( logger.getChildLogger( "loader" ) ); DefaultContext context = new DefaultContext(); context.put( TypeManager.EXTENSIONS_DESCRIPTOR_KEY, extensions ); context.put( TypeManager.CLASSPATH_DESCRIPTOR_KEY, classpath ); context.put( ProfileManager.LOGGING_MANAGER_KEY, logging ); context.makeReadOnly(); manager.contextualize( context ); manager.initialize(); } catch( Throwable e ) { final String error = "Classloader establishment failure."; throw new ModelException( error, e ); } logger.info("preparing kernel descriptor"); KernelDescriptor kernel = new KernelDescriptor( name, logger, manager ); ContainerDescriptor container = createContainerDescriptor( kernel, config.getChild("container"), manager, logging ); kernel.setContainer( container ); return kernel; } public LoggingDescriptor createLoggingDescriptor( Configuration config, String name ) throws ConfigurationException { final String target = config.getAttribute( "target", Category.DEFAULT_LOGGING_TARGET ); final String priority = config.getAttribute( "priority", null ); ArrayList list = new ArrayList(); Configuration[] configs = config.getChildren("target"); for( int i=0; i Utilities supporting the creation of a kernel from an XML description. 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/model/FileTargetProvider.java Index: FileTargetProvider.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.kernel.model; /** * File target provider descriptor declares the criteria for the creation of * an file based logging target provider. * *

    XML

    *

    A file target element may be contained within a target element to declare * the target as a file based logging sink.

    *
       *    <target name="kernel">
       *       <file location="kernel.log" />
       *    </target>
       * 
    * * @see TargetDescriptor * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:32 $ */ public class FileTargetProvider extends TargetProvider { private final String m_location; /** * Creation of a new file target. * @param location the filename of the logging destination */ public FileTargetProvider( final String location ) { m_location = location; } /** * Return the filename of the logging target. * @return the filename */ public String getLocation() { return m_location; } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/model/KernelDescriptor.java Index: KernelDescriptor.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.kernel.model; 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.container.model.ClasspathDescriptor; import org.apache.excalibur.merlin.container.model.ExtensionsDescriptor; import org.apache.excalibur.merlin.container.model.Parent; import org.apache.excalibur.merlin.kernel.model.LoggingDescriptor; /** * Kernel creation directive that includes a root container, an extensions directive, * common application level classpath directive and logigng category descriptors. * *

    XML

    * A kernel element may contain a logging defintion, extensions element, and classpath * element. A kernel element must contain a single root container element.

    *
       *    <!-- 
       *    Definition of a kernel.
       *    -->
       *
       *    <kernel>
       *
       *      <!--
       *      Logging targets and defaults. 
       *      -->
       * 
       *      <logging priority="INFO" target="kernel">
       *        <target name="kernel">
       *          <file location="kernel.log" />
       *        </target>
       *      </logging>
       *
       *      <!--
       *      Declaration of loggin categories within the scope of the kernel. 
       *      -->
       * 
       *      <categories priority="WARN">
       *        <category name="logging"/>
       *        <category name="loader"/>
       *        <category name="installer"/>
       *      </categories>
       *
       *      <!-- 
       *      Declaration of the extensions directories.
       *      -->
       *
       *      <extensions>
       *        <dirset dir=".">
       *          <include name="extensions"/>
       *          <include name="lib"/>
       *        </dirset>
       *      </extensions>
       *
       *      <!-- 
       *      Common application classpath declaration.
       *      -->
       * 
       *      <classpath>
       *        <fileset dir="dist">
       *          <include name="new-application-1.0.jar"/>
       *        </fileset>
       *      </classpath>
       *
       *      <!-- 
       *      Single root container declaration.
       *      -->
       * 
       *      <container name="child">
       *        <classpath>
       *          <fileset dir="dist">
       *            <include name="demo.jar"/>
       *          </fileset>
       *        </classpath>
       *        <component name="demo-component" class="org.apache.excalibur.playground.BasicComponent">
       *          <categories priority="WARN">
       *            <category name="cache"/>
       *            <category name="store"/>
       *          </categories>
       *          <context>
       *            <entry name="location" value="Paris"/>
       *          </context>
       *        </component>
       *        <container>
       *          <!-- Etc., etc. -->
       *        </container>
       *      </container>
       *      
       *    </kernel>
       * 
    * * @see ClasspathDescriptor * @see ExtensionsDescriptor * @see LoggingDescriptor * @see ContainerDescriptor * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:32 $ */ public class KernelDescriptor extends Parent { /** * The root container. */ private ContainerDescriptor m_container; /** * Create a KernelDescriptor instance. * * @param name the kernel name * @param logging the logging manager * @param manager the type manager * @param container the root container */ public KernelDescriptor( final String name, final Logger logger, final ProfileManager manager ) { super( null, manager, name, logger ); } /** * Return the root container. * * @return the root {@link ContainerDescriptor}. */ public ContainerDescriptor getContainer() { return m_container; } /** * Set the root container. * * @param container {@link ContainerDescriptor}. */ public void setContainer( ContainerDescriptor container ) { m_container = container; } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/model/LoggingDescriptor.java Index: LoggingDescriptor.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.kernel.model; import java.io.Serializable; import org.apache.excalibur.merlin.model.Category; /** * Description of a top level logging environment. * *

    XML

    *

    A logging element declares the top level defaults for priority and target name, a set of * targets to which logging events shall be directed. * 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 priority attribute may container one of the values * DEBUG, INFO, WARN or ERROR. * The target must contain a single file element with the attribute location * the corresponds to the name of the logging file.

    * *
       *    <!-- 
       *    Definition of a logging system.
       *    -->
       *
       *    <logging name="" priority="INFO" target="kernel">
       *      <target name="kernel">
       *        <file location="kernel.log" />
       *      </target>
       *    </logging>
       * 
    * * @see TargetDescriptor * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:32 $ */ public final class LoggingDescriptor extends Category implements Serializable { /** * The dependencies keyed by role name. */ private final TargetDescriptor[] m_targets; /** * Create a LoggingDescriptor instance. * * @param root the root logger category name * @param priority the default logging priority * @param target the default logging target * @param targets the set of logging targets */ public LoggingDescriptor( final String root, final String priority, final String target, final TargetDescriptor[] targets ) { super( root, priority, target ); m_targets = targets; } /** * Return the set of logging target descriptors. * * @return the target descriptors */ public TargetDescriptor[] getTargetDescriptors() { return m_targets; } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/model/TargetDescriptor.java Index: TargetDescriptor.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.kernel.model; import java.io.Serializable; /** * A logging target descriptor. * *

    XML

    * A logging target declares target name and a mechanism.

    * *
       *     <target name="kernel">
       *       <file location="kernel.log" />
       *     </target>
       * 
    * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:32 $ */ public final class TargetDescriptor implements Serializable { /** * The target name. */ private final String m_name; /** * The target provider descriptor. */ private final TargetProvider m_provider; /** * Create a LoggingDescriptor instance. * * @param name the target name * @param provider the target provider description */ public TargetDescriptor( final String name, final TargetProvider provider ) { m_name = name; m_provider = provider; } /** * Return the target name. * * @return the target name. */ public String getName() { return m_name; } /** * Return the target provider descriptor * * @return the provider descriptor */ public TargetProvider getProvider() { return m_provider; } } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/model/TargetProvider.java Index: TargetProvider.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.excalibur.merlin.kernel.model; import java.io.Serializable; /** * Abstract logging target provider type. This is an emty abstract class from * all logging providers must inherit. * * @author Stephen McConnell * @version $Revision: 1.1 $ $Date: 2002/07/29 06:14:32 $ */ public abstract class TargetProvider implements Serializable { } 1.1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/model/package.html Index: package.html ===================================================================

    The model package contains the formal meta data model extensions supporting the declaration of a kernel, its logging infrasturcture, and root container.

    1.3 +1 -2 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Category.java Index: Category.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/Category.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Category.java 26 Jul 2002 06:17:04 -0000 1.2 +++ Category.java 29 Jul 2002 06:14:32 -0000 1.3 @@ -66,7 +66,6 @@ * @param priority the category priority - DEBUG, INFO, WARN, or ERROR * @param target the name of a logging category target * - * @see TargetDescriptor */ public Category( final String name, final String priority, final String target ) 1.11 +10 -10 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.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Profile.java 26 Jul 2002 06:17:04 -0000 1.10 +++ Profile.java 29 Jul 2002 06:14:32 -0000 1.11 @@ -114,9 +114,9 @@ private final String m_name; /** - * The profile assigned logger. + * The assigned logging categories. */ - private final Logger m_logger; + private final CategoriesDescriptor m_categories; /** * The dependencies keyed by role name. @@ -176,7 +176,7 @@ final Parameters parameters, final Configuration configuration, final ContextDirective context, - final Logger logger, + final CategoriesDescriptor categories, final Type type, final boolean enabled, final boolean activation, @@ -193,12 +193,12 @@ if( null == type ) throw new NullPointerException( "type" ); - if( null == logger ) - throw new NullPointerException( "logger" ); + if( null == categories ) + throw new NullPointerException( "categories" ); m_parameters = parameters; m_configuration = configuration; - m_logger = logger; + m_categories = categories; m_type = type; m_context = context; m_enabled = enabled; @@ -238,13 +238,13 @@ } /** - * Return the logger for the profile. + * Return the logging categories for the profile. * * @return the logger */ - public Logger getLogger() + public CategoriesDescriptor getCategories() { - return m_logger; + return m_categories; } /** 1.2 +12 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/ResourceDesignator.java Index: ResourceDesignator.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/ResourceDesignator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ResourceDesignator.java 18 Jul 2002 03:38:12 -0000 1.1 +++ ResourceDesignator.java 29 Jul 2002 06:14:32 -0000 1.2 @@ -18,6 +18,11 @@ public interface ResourceDesignator { + static final int NOT_STARTED = 0; + static final int STARTED = 1; + static final int STOPPED = 2; + + /** * Returns the designated resource path. * @@ -52,5 +57,11 @@ * @return the profile */ Profile getProfile(); + + /** + * Returns the active state of the resoruce. + * @return one of the values NOT_STARTED, STARTED, or STOPPED + */ + int getState(); } 1.3 +1 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/package.html Index: package.html =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/package.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- package.html 12 Jul 2002 19:09:27 -0000 1.2 +++ package.html 29 Jul 2002 06:14:32 -0000 1.3 @@ -1,7 +1,7 @@

    -The model package contains the formal meta data model for the Merlin kernel, container and profile abstractions. These classes define the criteria for creation of new containers, component and factory profiles, classloaders, extensions, and the kernel itself. +The model package contains the formal profile meta data model. These classes define the criteria used to populate a Profile, including context management, confuration management, logging category management and extension and lifecycle phase management.

    Object Model (UML)

    1.4 +7 -9 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ProfileBuilder.java Index: ProfileBuilder.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ProfileBuilder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ProfileBuilder.java 25 Jul 2002 18:07:16 -0000 1.3 +++ ProfileBuilder.java 29 Jul 2002 06:14:33 -0000 1.4 @@ -18,8 +18,6 @@ import org.apache.excalibur.meta.info.Type; import org.apache.excalibur.meta.info.builder.TypeBuilder; import org.apache.excalibur.merlin.model.Profile; -import org.apache.excalibur.merlin.model.ContainerDescriptor; -import org.xml.sax.InputSource; /** * A ProfileBuilder is responsible for building {@link Profile} @@ -38,21 +36,21 @@ /** * Build Profile from the XML descriptor format. * - * @param classname The classname of Component - * @param classLoader the ClassLoader to load info from - * @return the created Type + * @param loader the ClassLoader to load info from + * @param type the Type on which the profile is based + * @return the created Profile * @throws Exception if an error occurs */ - public Profile[] build( ContainerDescriptor container, Type type ) + public Profile[] build( ClassLoader loader, Type type ) throws Exception { final String xprofile = type.getInfo().getImplementationKey().replace( '.', '/' ) + ".xprofile"; final InputStream inputStream = - container.getTypeManager().getResourceAsStream( xprofile ); + loader.getResourceAsStream( xprofile ); final ProfileCreator creator = getXMLProfileCreator( xprofile ); - return creator.createProfiles( container, type, inputStream ); + return creator.createProfiles( loader, type, inputStream ); } 1.4 +3 -4 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ProfileCreator.java Index: ProfileCreator.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/ProfileCreator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ProfileCreator.java 25 Jul 2002 18:07:16 -0000 1.3 +++ ProfileCreator.java 29 Jul 2002 06:14:33 -0000 1.4 @@ -11,7 +11,6 @@ import org.apache.avalon.framework.configuration.Configuration; import org.apache.excalibur.meta.info.Type; import org.apache.excalibur.merlin.model.Profile; -import org.apache.excalibur.merlin.model.ContainerDescriptor; /** * Simple interface used to create {@link Profile} @@ -30,7 +29,7 @@ * @return the newly created {@link Type} * @throws Exception */ - Profile[] createProfiles( ContainerDescriptor container, Type type, InputStream inputStream ) + Profile[] createProfiles( ClassLoader loader, Type type, InputStream inputStream ) throws Exception; /** @@ -40,7 +39,7 @@ * @return the profile * @exception Exception if an error occurs during profile creation */ - Profile createProfile( ContainerDescriptor container, Type type, Configuration config ) + Profile createProfile( ClassLoader loader, Type type, Configuration config ) throws Exception; } 1.11 +27 -21 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLProfileCreator.java Index: XMLProfileCreator.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/model/builder/XMLProfileCreator.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- XMLProfileCreator.java 25 Jul 2002 18:07:16 -0000 1.10 +++ XMLProfileCreator.java 29 Jul 2002 06:14:33 -0000 1.11 @@ -24,7 +24,6 @@ import org.apache.excalibur.meta.info.builder.XMLTypeCreator; import org.apache.excalibur.meta.ConfigurationBuilder; import org.apache.excalibur.merlin.model.Profile; -import org.apache.excalibur.merlin.model.ContainerDescriptor; import org.apache.excalibur.merlin.model.Category; import org.apache.excalibur.merlin.model.CategoriesDescriptor; import org.apache.excalibur.merlin.model.ContextDirective; @@ -60,18 +59,18 @@ * @throws ConfigurationException if an error occurs */ public Profile[] createProfiles( - ContainerDescriptor container, Type type, InputStream inputStream ) + ClassLoader loader, Type type, InputStream inputStream ) throws Exception { if( inputStream != null ) { final InputSource input = new InputSource( inputStream ); final Configuration configuration = ConfigurationBuilder.build( input ); - return createPackagedProfiles( container, type, configuration ); + return createPackagedProfiles( loader, type, configuration ); } else { - Profile profile = createImplicitProfile( container, type ); + Profile profile = createImplicitProfile( loader, type ); return new Profile[]{ profile }; } } @@ -84,10 +83,10 @@ * @exception Exception if an error occurs during profile creation */ public Profile createProfile( - ContainerDescriptor container, Type type, Configuration config ) + ClassLoader loader, Type type, Configuration config ) throws Exception { - return buildProfile( container, type, config, Profile.EXPLICIT ); + return buildProfile( loader, type, config, Profile.EXPLICIT ); } /** @@ -100,25 +99,25 @@ * @throws ConfigurationException if an error occurs */ private Profile[] createPackagedProfiles( - ContainerDescriptor container, Type type, final Configuration info ) + ClassLoader loader, Type type, final Configuration info ) throws Exception { Vector vector = new Vector(); Configuration[] profiles = info.getChildren("component"); if( profiles.length == 0 ) { - Profile profile = createImplicitProfile( container, type ); + Profile profile = createImplicitProfile( loader, type ); return new Profile[]{ profile }; } for( int i=0; i + + - + - + + - - - + + + + + + - - + + + + + + + + +