mcconnell 2002/07/03 12:08:36
Modified: assembly/src/java/org/apache/excalibur/merlin/registry
DefaultRegistry.java DefaultRegistry.xinfo
Profile.java Registry.java ServiceRegistry.java
ServiceTable.java package.html
assembly/src/java/org/apache/excalibur/merlin/registry/doc-files
registry.gif
Removed: assembly/src/java/org/apache/excalibur/merlin/registry
DefaultClassLoader.java Fileset.java Main.java
Log:
Seperation of Kernel/Container/Registry
Revision Changes Path
1.6 +85 -165
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/DefaultRegistry.java
Index: DefaultRegistry.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/DefaultRegistry.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultRegistry.java 3 Jul 2002 02:09:13 -0000 1.5
+++ DefaultRegistry.java 3 Jul 2002 19:08:35 -0000 1.6
@@ -74,7 +74,9 @@
import org.apache.log.output.io.StreamTarget;
import org.apache.excalibur.merlin.registry.*;
-import org.apache.excalibur.merlin.registry.Profile;
+import org.apache.excalibur.merlin.kernel.Container;
+import org.apache.excalibur.merlin.kernel.ContainerClassLoader;
+import org.apache.excalibur.merlin.kernel.Verifiable;
/**
* Provides support for the maintenance of a registry of
@@ -82,7 +84,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version $Revision$ $Date$
*/
-public class DefaultRegistry extends AbstractLogEnabled implements
Contextualizable, Serviceable, Configurable, Initializable, Executable,
Disposable, Registry
+public class DefaultRegistry extends AbstractLogEnabled implements
Contextualizable, Configurable, Initializable, Executable, Disposable,
Registry, Verifiable
{
//=======================================================================
// static
@@ -100,9 +102,9 @@
public static final String CLASSLOADER_KEY = "classloader";
/**
- * Context key value used to locate the extension repository.
+ * Context key used to locate the application classloader.
*/
- public static final String EXTENSIONS_KEY = "extensions";
+ public static final String CONTAINER_KEY = "container";
private static final ComponentType[] EMPTY_DEFS = new ComponentType[0];
private static final Profile[] EMPTY_PROFILES = new Profile[0];
@@ -118,7 +120,7 @@
* (not currently in use - will come into effect as registry hierachies
as
* dealt with).
*/
- private Registry m_parent;
+ private Container m_parent;
/**
* The context argument supplied by the container.
@@ -135,20 +137,13 @@
*/
private ServiceRegistry m_services;
- private ClassLoader m_classloaderParent;
-
- private DefaultClassLoader m_classloader;
+ private ContainerClassLoader m_classloader;
/**
* List of the component classname recorded in the jar file manifests.
*/
private List m_classnames = new LinkedList();
- /**
- * The extensions repository (supplied by service manager).
- */
- private PackageRepository m_repository;
-
private Configuration m_config;
private MetaDataVerifier m_verifier;
@@ -159,7 +154,7 @@
private Hashtable m_profiles = new Hashtable();
- private ComponentMetaData[] m_appContext;
+ private DependencyMap m_map = new DependencyMap();
//=======================================================================
// LogEnabled
@@ -181,38 +176,8 @@
public void contextualize( Context context ) throws ContextException
{
m_context = context;
-
- //
- // use the supplied classloader or none supplied get the context
- // classloader
- //
-
- try
- {
- m_classloaderParent = (ClassLoader) context.get( CLASSLOADER_KEY
);
- getLogger().debug("classloader supplied");
- }
- catch( ContextException ce )
- {
- m_classloaderParent =
Thread.currentThread().getContextClassLoader();
- getLogger().debug("using context classloader", ce );
- }
-
- //
- // use the supplied extension manager or none supplied create an
empty
- // manager
- //
-
- try
- {
- m_repository = (PackageRepository) context.get( EXTENSIONS_KEY );
- getLogger().debug("extension manager supplied");
- }
- catch( ContextException ce )
- {
- m_repository = new DefaultPackageRepository( new File[0] );
- getLogger().debug("extension manager created");
- }
+ m_classloader = (ContainerClassLoader) context.get( CLASSLOADER_KEY
);
+ m_parent = (Container) context.get( CONTAINER_KEY );
}
//=======================================================================
@@ -229,29 +194,6 @@
}
//=======================================================================
- // Service
- //=======================================================================
-
- /**
- * Invoked by the container to establish services that this component
- * is dependent on. The implementation will attempt to locate a parent
- * registry (optional dependency).
- *
- * @param manager a service manager
- */
- public void service( ServiceManager manager )
- {
- try
- {
- m_parent = (Registry) manager.lookup( REGISTRY_KEY );
- }
- catch( ServiceException se )
- {
- m_parent = null;
- }
- }
-
- //=======================================================================
// Initializable
//=======================================================================
@@ -262,21 +204,8 @@
*/
public void initialize() throws Exception
{
- getLogger().debug("local classloader creation");
- m_classloader = new DefaultClassLoader(
- m_repository,
- m_classloaderParent,
- m_config.getChild("classpath"),
- getLogger().getChildLogger( "loader" )
- );
-
- //
- // for all of the compoents declared under manifest jar block
entries,
- // register these as potential service providers with the service
repository
- //
-
- getLogger().debug("repository creation");
- m_services = new ServiceRegistry( this, m_classloader,
m_config.getChild("factories") );
+ getLogger().debug("initialize");
+ m_services = new ServiceRegistry( this, m_classloader, m_config );
m_services.enableLogging( getLogger().getChildLogger("services") );
String[] blocks = m_classloader.getComponentClassnames();
@@ -291,8 +220,6 @@
{
// initialize the component type defintions
final String classname = blocks[i].replace('/','.');
- getLogger().debug("");
- getLogger().debug("register classname: " + classname );
m_services.register( classname );
}
@@ -303,36 +230,43 @@
// construct the application context
//
- Configuration factories = m_config.getChild("factories");
- Configuration[] entries = factories.getChildren();
+ Configuration[] entries = m_config.getChildren( "component" );
for( int i=0; i<entries.length; i++ )
{
final Configuration factory = entries[i];
final String name = factory.getAttribute("name");
final String classname = factory.getAttribute("class");
final String mode = factory.getName();
+
if( mode.equals("component") )
{
- getLogger().debug("install: \n" +
ConfigurationUtil.list( factory ));
+ getLogger().debug("container: \n" +
ConfigurationUtil.list( factory ));
Profile profile = m_services.install( classname, name );
-
- listProfile( profile );
-
- //
- // create a dependency graph for this component
- //
-
- DependencyMap map = buildDependencyMap( profile );
- list( map );
+ populate( m_map, profile );
+ //listProfile( profile );
}
else
{
// unrecognized declaration
getLogger().debug(
- "bypassing unrecognized element "
- + ConfigurationUtil.list( factory ) );
+ "bypassing unrecognized element\n"
+ + ConfigurationUtil.list( factory )
+ );
}
}
+
+ //
+ // if its a container we need to instantiate it and verify it.
+ //
+
+ if( m_config.getName().equals("containers"))
+ {
+ getLogger().debug(
+ "nested containers ("
+ + entries.length
+ + ") pending validation."
+ );
+ }
}
catch( Throwable e )
{
@@ -341,30 +275,6 @@
}
}
- private DependencyMap buildDependencyMap( Profile profile )
- {
- DependencyMap map = new DependencyMap();
- map.add( profile );
- DependencyMetaData[] dependencies = profile.getDependencies();
- for( int j=0; j<dependencies.length; j++ )
- {
- populate( map, dependencies[j] );
- }
- return map;
- }
-
- private void populate( DependencyMap map, DependencyMetaData dependency )
- {
- Profile profile = m_services.getInstalledProfile(
dependency.getProviderName() );
- map.add( profile );
- DependencyMetaData[] dependencies = profile.getDependencies();
- for( int j=0; j<dependencies.length; j++ )
- {
- populate( map, dependencies[j] );
- }
- }
-
-
//=======================================================================
// Executable
//=======================================================================
@@ -378,7 +288,34 @@
*/
public void execute() throws Exception
{
- // nothing to do yet - need to sort out the DependecyMap issue
+ }
+
+ //=======================================================================
+ // Verifiable
+ //=======================================================================
+
+ /**
+ * Method invoked by a parent container to request type level validation
of
+ * the container.
+ *
+ * @exception ValidationException if a validation failure occurs
+ */
+ public void verify() throws VerifyException
+ {
+ getLogger().debug("DependencyMap listing");
+ getLogger().debug("startup sequence");
+ ComponentMetaData[] startup = m_map.getStartupGraph();
+ doVerify( startup );
+ for( int i=0; i<startup.length; i++ )
+ {
+ getLogger().debug(" start: " + startup[i] );
+ }
+ getLogger().debug("shutdown sequence");
+ ComponentMetaData[] shutdown = m_map.getShutdownGraph();
+ for( int i=0; i<shutdown.length; i++ )
+ {
+ getLogger().debug(" stop: " + shutdown[i] );
+ }
}
//=======================================================================
@@ -420,6 +357,27 @@
// implementation
//=======================================================================
+ private void populate( DependencyMap map, Profile profile )
+ {
+ map.add( profile );
+ DependencyMetaData[] dependencies = profile.getDependencies();
+ for( int j=0; j<dependencies.length; j++ )
+ {
+ populate( map, dependencies[j] );
+ }
+ }
+
+ private void populate( DependencyMap map, DependencyMetaData dependency )
+ {
+ Profile profile = m_services.getInstalledProfile(
dependency.getProviderName() );
+ map.add( profile );
+ DependencyMetaData[] dependencies = profile.getDependencies();
+ for( int j=0; j<dependencies.length; j++ )
+ {
+ populate( map, dependencies[j] );
+ }
+ }
+
/**
* Test if the registry can resolve a request for a component with the
supplied classname
* @param classname a component or service class name
@@ -509,45 +467,7 @@
}
}
- private void list( DependencyMap map )
- {
- try
- {
- getLogger().debug("DependencyMap listing");
- getLogger().debug("startup sequence");
- ComponentMetaData[] startup = map.getStartupGraph();
- verify( startup );
- for( int i=0; i<startup.length; i++ )
- {
- getLogger().debug(" start: " + startup[i] );
- //getLogger().debug(" consumers");
- //ComponentMetaData[] consumers = map.getConsumerGraph(
startup[i] );
- //for( int j=0; j<consumers.length; j++ )
- //{
- // getLogger().debug(" consumer: " +
consumers[j].getName() );
- //}
- //getLogger().debug(" providers");
- //ComponentMetaData[] providers = map.getConsumerGraph(
startup[i] );
- //for( int j=0; j<providers.length; j++ )
- //{
- // getLogger().debug(" provider: " +
providers[j].getName() );
- //}
-
- }
- getLogger().debug("shutdown sequence");
- ComponentMetaData[] shutdown = map.getShutdownGraph();
- for( int i=0; i<shutdown.length; i++ )
- {
- getLogger().debug(" stop: " + shutdown[i] );
- }
- }
- catch( Throwable e )
- {
- getLogger().error("map error", e );
- }
- }
-
- private void verify( ComponentMetaData[] assembly ) throws
VerifyException
+ private void doVerify( ComponentMetaData[] assembly ) throws
VerifyException
{
MetaDataVerifier mdv = new MetaDataVerifier();
for( int i=0; i<assembly.length; i++ )
1.4 +5 -3
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/DefaultRegistry.xinfo
Index: DefaultRegistry.xinfo
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/DefaultRegistry.xinfo,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultRegistry.xinfo 3 Jul 2002 02:09:58 -0000 1.3
+++ DefaultRegistry.xinfo 3 Jul 2002 19:08:35 -0000 1.4
@@ -28,11 +28,13 @@
</service>
</services>
+ <!--
<dependencies>
- <dependency>
- <role>registry</role>
- <service-ref type="org.apache.excalibur.merlin.registry.Registry"
optional="true"/>
+ <dependency optional="true">
+ <role>parent</role>
+ <service-ref type="org.apache.excalibur.merlin.kernel.Container" />
</dependency>
</dependencies>
+ -->
</component-info>
1.3 +11 -9
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/Profile.java
Index: Profile.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/Profile.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Profile.java 3 Jul 2002 00:52:23 -0000 1.2
+++ Profile.java 3 Jul 2002 19:08:35 -0000 1.3
@@ -81,17 +81,19 @@
DependencyDescriptor[] deps =
type.getComponentInfo().getDependencies();
for( int i=0; i<deps.length; i++ )
{
- final String role = deps[i].getRole();
- final Profile provider = registry.getCandidateProfile( deps[i] );
- DependencyMetaData data = new DependencyMetaData(
- role,
- provider.getName()
- );
- vector.add( data );
+ if( !deps[i].isOptional() )
+ {
+ final String role = deps[i].getRole();
+ final Profile provider = registry.getCandidateProfile(
deps[i] );
+ DependencyMetaData data = new DependencyMetaData(
+ role,
+ provider.getName()
+ );
+ vector.add( data );
+ }
}
return (DependencyMetaData[]) vector.toArray( new
DependencyMetaData[0] );
}
-
private final ComponentType m_type;
1.3 +3 -2
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/Registry.java
Index: Registry.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/Registry.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Registry.java 3 Jul 2002 01:19:09 -0000 1.2
+++ Registry.java 3 Jul 2002 19:08:35 -0000 1.3
@@ -12,13 +12,14 @@
import org.apache.excalibur.containerkit.metainfo.ServiceDescriptor;
import org.apache.excalibur.merlin.registry.ComponentType;
import org.apache.excalibur.merlin.registry.Profile;
+import org.apache.excalibur.merlin.kernel.Container;
/**
* A service that provides support for location of components types.
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version $Revision$ $Date$
*/
-public interface Registry
+public interface Registry
{
/**
* Default role.
1.3 +6 -7
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/ServiceRegistry.java
Index: ServiceRegistry.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/ServiceRegistry.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServiceRegistry.java 3 Jul 2002 00:54:43 -0000 1.2
+++ ServiceRegistry.java 3 Jul 2002 19:08:35 -0000 1.3
@@ -189,7 +189,6 @@
return (ComponentType) m_types.get( classname );
}
-
public Profile[] getProfiles( ServiceDesignator service )
{
//
@@ -221,18 +220,18 @@
getLogger().debug("getting profiles for service: " + service );
Vector vector = new Vector();
ComponentType[] components = table.getTypes();
- getLogger().debug("located table: = "
- + table + ", size: " + ", " + components.length );
+ //getLogger().debug("located table: = "
+ // + table + ", size: " + ", " + components.length );
for( int i=0; i<components.length; i++ )
{
try
{
Profile[] profiles = components[i].getProfiles();
- getLogger().debug(" located provider: " + components[i] +
", profile: " + profiles.length);
+ //getLogger().debug(" located provider: " + components[i] +
", profile: " + profiles.length);
for( int j=0; j<profiles.length; j++ )
{
vector.add( profiles[j] );
- getLogger().debug(" profile: " +
profiles[j].getComponentType() );
+ //getLogger().debug(" profile: " +
profiles[j].getComponentType() );
}
}
catch( Throwable e )
@@ -267,7 +266,7 @@
private void register( ComponentType type )
{
- getLogger().debug("registering provider type: " +
getImplementationKey( type ) );
+ //getLogger().debug("registering provider type: " +
getImplementationKey( type ) );
m_types.put( getImplementationKey( type ), type );
ServiceDescriptor[] services = type.getComponentInfo().getServices();
for( int i=0; i<services.length; i++ )
1.2 +6 -6
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/ServiceTable.java
Index: ServiceTable.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/ServiceTable.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServiceTable.java 3 Jul 2002 00:51:23 -0000 1.1
+++ ServiceTable.java 3 Jul 2002 19:08:35 -0000 1.2
@@ -55,7 +55,7 @@
*/
public void add( ComponentType type )
{
- getLogger().debug("addition\n\ttype:" + type + "\n\ttable: " + this
);
+ //getLogger().debug("addition\n\ttype:" + type + "\n\ttable: " +
this );
m_providers.add( type );
}
@@ -87,8 +87,6 @@
return m_providers.size();
}
-
-
/**
* Returns true if the table service designator matches the supplied
designator.
* @param service a service type designator
@@ -100,10 +98,12 @@
return m_designator.matches( service );
}
-
public String toString()
{
- return "ServiceTable:" + System.identityHashCode( this ) + ", " +
m_designator;
+ return "ServiceTable:"
+ + System.identityHashCode( this )
+ + ", "
+ + m_designator;
}
}
1.2 +5 -8
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/package.html
Index: package.html
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/package.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- package.html 1 Jul 2002 04:27:15 -0000 1.1
+++ package.html 3 Jul 2002 19:08:35 -0000 1.2
@@ -1,27 +1,24 @@
<body>
<p>
-A geneneric container supporting component lifecycle management. The
container serves as a repository for component types and provides support for a
type hierarchy based on an formal component type and profile model. The
repository enables resolution of component types based on a classloader,
extension directory set defintion, supplied classpath, and application
directives. Components are established based on the publication of components
within a jar file manifest together with explicit component profile directives
included within the repository 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 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).
</p>
<h3>Funtional Summary</h3>
<ul>
-<li>Geneneric container supporting component lifecycle management.
-<li>Hierachical container composition.
+<li>Portable component type mangement.
+<li>Automated service assembly.
</ul>
<h3>Key Features</h3>
-<p>A primary objective of this container is to provide simple deployment of
components with minimal administration overhead. In many cases, no component
assembly directives are required as the container will apply assembly logic
based on the meta-information association with component types that are either
explicity declared, or implicly located via a classpath and extension
directories.</p>
+<p>A primary objective of this service is to provide simple deployment of
components with minimal administration overhead. In many cases, no component
assembly directives are required as the container will apply assembly logic
based on the meta-information association with component types that are either
explicity declared, or implicly located via a classpath and extension
directories.</p>
<ul>
-<li>Stand-alone and embeddable deployment.
<li>Automatic component profile generation.
<li>Automatic assembly of components based on dependency and service
production declarations.
<li>Service provider selection plug-in architecture.
<li>Customization of application content.
-<li>Support for multiple extension directories.
-<li>Protected classloading.
</ul>
<h3>Object Model</h3>
-<p>The container object model provides a simplified view of the
<code>containerkit</code> framework. The princincipal entry point is the
[EMAIL PROTECTED] org.apache.excalibur.merlin.registry.Registry} and the
associated default component based implementation [EMAIL PROTECTED]
org.apache.excalibur.merlin.registry.DefaultRegistry}. The registry acts as a
component type repository. Component types are exposed as instances of the
[EMAIL PROTECTED] org.apache.excalibur.merlin.registry.ComponentType}
interface. Each component type represents a concrete component implementation
class. For each component type, the container associates at least one
instantiation [EMAIL PROTECTED] org.apache.excalibur.merlin.registry.Profile}.
A profile is either a default profile generated by the container based on
meta-information derived from the type, or, an explicit profile declared by the
component user under the registry configuration. Multiple profile for a
particular component type can coexist in the same container.
+<p>The registry object model provides a simplified view of the
<code>containerkit</code> framework. The principal entry point is the [EMAIL
PROTECTED] org.apache.excalibur.merlin.registry.Registry} and the associated
default implementation [EMAIL PROTECTED]
org.apache.excalibur.merlin.registry.DefaultRegistry}. The registry acts as a
component type repository. Component types are exposed as instances of the
[EMAIL PROTECTED] org.apache.excalibur.merlin.registry.ComponentType}
interface. Each component type represents a concrete component implementation
class. For each component type, the container associates at least one
instantiation [EMAIL PROTECTED] org.apache.excalibur.merlin.registry.Profile}.
A profile is either a default profile generated by the registry based on
meta-information derived from the type, or, an explicit profile declared by the
component assembler via the registry configuration. Multiple profiles for a
particular component type can coexist in the same registry.
<h3>Package Structure (UML)</h3>
<p><img src=doc-files/registry.gif border=0></p>
1.2 +27 -33
jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/doc-files/registry.gif
<<Binary file>>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>