You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2002/07/07 06:28:32 UTC
cvs commit: jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier AssemblyVerifier.java MetaDataVerifier.java Resources.properties package.html
mcconnell 2002/07/06 21:28:32
Modified: assembly/src/java/org/apache/excalibur/merlin/kernel
Container.java DefaultContainer.java
DefaultKernel.java Kernel.java Main.java Map.java
Resources.properties Verifiable.java
assembly/src/java/org/apache/excalibur/merlin/registry
DefaultRegistry.java Registry.java
Resources.properties Selector.java
UnresolvedProviderException.java package.html
assembly/src/java/org/apache/excalibur/meta/builder
ConfigurationBuilder.java Resources.properties
package.html
assembly/src/java/org/apache/excalibur/meta/data
DefaultProfile.java Profile.java
assembly/src/java/org/apache/excalibur/meta/info
DefaultType.java Type.java package.html
assembly/src/java/org/apache/excalibur/meta/verifier
AssemblyVerifier.java MetaDataVerifier.java
Resources.properties package.html
Log:
synchronization of sources to excalibur.meta.* packages
Revision Changes Path
1.5 +18 -7 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Container.java
Index: Container.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Container.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Container.java 5 Jul 2002 08:50:23 -0000 1.4
+++ Container.java 7 Jul 2002 04:28:31 -0000 1.5
@@ -8,10 +8,12 @@
package org.apache.excalibur.merlin.kernel;
-import org.apache.excalibur.containerkit.verifier.VerifyException;
-import org.apache.excalibur.containerkit.metainfo.DependencyDescriptor;
-import org.apache.excalibur.merlin.registry.Profile;
+import org.apache.excalibur.meta.verifier.VerifyException;
+import org.apache.excalibur.meta.info.DependencyDescriptor;
import org.apache.excalibur.merlin.registry.UnresolvedProviderException;
+import org.apache.excalibur.meta.data.Profile;
+import org.apache.excalibur.meta.info.Type;
+import org.apache.excalibur.meta.info.ServiceDesignator;
/**
* A service that provides support for the management of a set of component types
@@ -19,16 +21,25 @@
* @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
* @version $Revision$ $Date$
*/
-public interface Container
+public interface Container extends Manageable
{
/**
* Return the profile of an installed component matching a dependency.
+ * @param type a component exposing the depenency
* @param dependency a consumer component dependecy declaration
* @return the supplier profile
* @exception UnresolvedProviderException if no provider available
*/
- Profile getProvider( DependencyDescriptor dependency )
- throws UnresolvedProviderException;
+ //Profile getProvider( Type type, DependencyDescriptor dependency )
+ // throws UnresolvedProviderException;
+
+ /**
+ * Return the set of potential profiles of installed component matching a dependency.
+ * @param dependency a consumer component dependecy declaration
+ * @return the set of potential supplier profile
+ */
+ Profile[] getProviders( ServiceDesignator service );
+
}
1.7 +21 -32 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultContainer.java
Index: DefaultContainer.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/DefaultContainer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DefaultContainer.java 5 Jul 2002 08:50:23 -0000 1.6
+++ DefaultContainer.java 7 Jul 2002 04:28:31 -0000 1.7
@@ -16,7 +16,6 @@
import java.net.URLClassLoader;
import java.util.List;
import java.util.LinkedList;
-import java.util.Map;
import java.util.Hashtable;
import java.util.Properties;
import java.util.Vector;
@@ -57,21 +56,19 @@
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.containerkit.metainfo.ComponentDescriptor;
-import org.apache.excalibur.containerkit.metainfo.ComponentInfo;
-import org.apache.excalibur.containerkit.metainfo.ServiceDescriptor;
-import org.apache.excalibur.containerkit.metainfo.DependencyDescriptor;
-import org.apache.excalibur.containerkit.metainfo.ServiceDesignator;
-import org.apache.excalibur.containerkit.dependency.DependencyMap;
-import org.apache.excalibur.containerkit.metadata.ComponentMetaData;
+import org.apache.excalibur.meta.info.DefaultType;
+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.data.Profile;
+import org.apache.excalibur.meta.verifier.VerifyException;
import org.apache.log.Hierarchy;
import org.apache.log.Priority;
import org.apache.log.output.io.StreamTarget;
import org.apache.excalibur.merlin.registry.DefaultRegistry;
-import org.apache.excalibur.containerkit.verifier.VerifyException;
-import org.apache.excalibur.merlin.registry.Profile;
import org.apache.excalibur.merlin.registry.UnresolvedProviderException;
+import org.apache.excalibur.merlin.kernel.Map;
/**
* Default container implementation that manages a registry of componet providers and
@@ -80,7 +77,7 @@
* @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
* @version $Revision$ $Date$
*/
-public class DefaultContainer extends DefaultRegistry implements Container, Startable
+public class DefaultContainer extends DefaultRegistry implements Container
{
//=======================================================================
// state
@@ -105,7 +102,7 @@
private Logger m_logger;
- private DependencyMap m_map;
+ private Map m_map;
//=======================================================================
// Contextualizable
@@ -119,7 +116,7 @@
{
super.contextualize( context );
m_classloader = (ContainerClassLoader) context.get( CLASSLOADER_KEY );
- m_map = (DependencyMap) context.get( MAP_KEY );
+ m_map = (Map) context.get( MAP_KEY );
try
{
m_parent = (Container) context.get( CONTAINER_KEY );
@@ -200,11 +197,12 @@
// throw new UnresolvedProviderException( "not implemented", dependency );
//}
+
//======================================================================
- // Startable
+ // Manageable
//======================================================================
- public void start() throws Exception
+ public void startup() throws Exception
{
//
@@ -212,20 +210,15 @@
// before starting up any of the nested containers
//
- ComponentMetaData[] startup = m_map.getStartupGraph();
- getLogger().debug("startup");
- for( int i=0; i<startup.length; i++ )
- {
- getLogger().debug("start: " + startup[i].getName() );
- }
+ start();
Iterator iterator = m_containers.iterator();
while( iterator.hasNext() )
{
- ((Startable)iterator.next()).start();
+ ((Manageable)iterator.next()).startup();
}
}
- public void stop() throws Exception
+ public void shutdown()
{
//
@@ -237,13 +230,9 @@
Iterator iterator = m_containers.iterator();
while( iterator.hasNext() )
{
- ((Startable)iterator.next()).stop();
- }
- ComponentMetaData[] shutdown = m_map.getShutdownGraph();
- for( int i=0; i<shutdown.length; i++ )
- {
- getLogger().debug("stop: " + shutdown[i].getName() );
+ ((Manageable)iterator.next()).shutdown();
}
+ stop();
}
//=======================================================================
@@ -252,7 +241,7 @@
private DefaultContainer createContainer( Configuration conf ) throws Exception
{
- Logger logger = getLogger().getChildLogger( conf.getAttribute("name","child") );
+ Logger logger = getLogger().getChildLogger( "container" );
Logger loaderLogger = logger.getChildLogger( "loader" );
final ContainerClassLoader loader = new ContainerClassLoader(
@@ -264,7 +253,7 @@
DefaultContext context = new DefaultContext();
context.put( CLASSLOADER_KEY, loader );
context.put( CONTAINER_KEY, this );
- context.put( MAP_KEY, new DependencyMap( m_map ) );
+ context.put( MAP_KEY, new Map( m_map ) );
DefaultContainer container = new DefaultContainer();
container.enableLogging( logger );
1.6 +55 -14 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DefaultKernel.java 5 Jul 2002 08:50:23 -0000 1.5
+++ DefaultKernel.java 7 Jul 2002 04:28:31 -0000 1.6
@@ -16,7 +16,6 @@
import java.net.URLClassLoader;
import java.util.List;
import java.util.LinkedList;
-import java.util.Map;
import java.util.Hashtable;
import java.util.Properties;
import java.util.Vector;
@@ -58,12 +57,13 @@
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.containerkit.metainfo.ComponentDescriptor;
-import org.apache.excalibur.containerkit.metainfo.ComponentInfo;
-import org.apache.excalibur.containerkit.metainfo.ServiceDescriptor;
-import org.apache.excalibur.containerkit.metainfo.DependencyDescriptor;
-import org.apache.excalibur.containerkit.metainfo.ServiceDesignator;
-import org.apache.excalibur.containerkit.dependency.DependencyMap;
+import org.apache.excalibur.meta.info.DefaultType;
+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.data.Profile;
+import org.apache.excalibur.merlin.kernel.Map;
import org.apache.log.Hierarchy;
import org.apache.log.Priority;
import org.apache.log.output.io.StreamTarget;
@@ -90,6 +90,8 @@
private boolean m_verified = false;
+ private Map m_map = new Map();
+
//=======================================================================
// Configurable
//=======================================================================
@@ -123,7 +125,7 @@
DefaultContext context = new DefaultContext();
context.put( DefaultContainer.CLASSLOADER_KEY, loader );
- context.put( DefaultContainer.MAP_KEY, new DependencyMap() );
+ context.put( DefaultContainer.MAP_KEY, m_map );
m_container.enableLogging( getLogger().getChildLogger("container") );
m_container.contextualize( context );
m_container.configure( m_config.getChild("container" ) );
@@ -137,18 +139,57 @@
public void startup() throws Exception
{
- m_container.start();
+ //listProfiles();
+ m_container.startup();
}
public void shutdown()
{
- try
+ m_container.shutdown();
+ }
+
+ //=======================================================================
+ // Intername stuff
+ //=======================================================================
+
+ private void listProfiles()
+ {
+ getLogger().debug("listing profiles");
+ Profile[] profiles = m_map.getStartupGraph();
+ List reported = new LinkedList();
+ for( int i=0; i<profiles.length; i++ )
+ {
+ //listProfile( profiles[i], m_map, reported );
+ getLogger().info("startup target: " + profiles[i] );
+ }
+ }
+
+ private void listProfile( Profile profile, Map map, List reported )
+ {
+ if( !reported.contains( profile ) )
{
- m_container.stop();
+ getLogger().debug( profile.list() );
+ reported.add( profile );
+ Profile[] consumers = map.getConsumerGraph( profile );
+ for( int j=0; j<consumers.length; j++ )
+ {
+ Profile consumer = consumers[j];
+ getLogger().debug("consumer: " + consumer );
}
- catch( Throwable e )
+ Profile[] providers = map.getProviderGraph( profile );
+ for( int j=0; j<providers.length; j++ )
{
- throw new CascadingRuntimeException("Unexpected error while stopping.", e );
+ Profile provider = providers[j];
+ getLogger().debug("provider: " + provider );
+ }
+
+ //Association[] dependencies = profile.getAssociations();
+ //for( int j=0; j<dependencies.length; j++ )
+ //{
+ // Profile dependent = dependencies[j].getProvider();
+ // listProfile( dependent, map, reported );
+ //}
}
}
+
}
1.5 +2 -11 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Kernel.java
Index: Kernel.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Kernel.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Kernel.java 5 Jul 2002 08:50:23 -0000 1.4
+++ Kernel.java 7 Jul 2002 04:28:31 -0000 1.5
@@ -13,16 +13,7 @@
* @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
* @version $Revision$ $Date$
*/
-public interface Kernel
+public interface Kernel extends Manageable
{
- /**
- * Request the startup of the kernel.
- */
- void startup() throws Exception;
-
- /**
- * Request the shutdown of the kernel.
- */
- void shutdown();
}
1.4 +6 -6 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Main.java
Index: Main.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Main.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Main.java 4 Jul 2002 09:01:35 -0000 1.3
+++ Main.java 7 Jul 2002 04:28:31 -0000 1.4
@@ -56,11 +56,11 @@
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.containerkit.metainfo.ComponentDescriptor;
-import org.apache.excalibur.containerkit.metainfo.ComponentInfo;
-import org.apache.excalibur.containerkit.metainfo.ServiceDescriptor;
-import org.apache.excalibur.containerkit.metainfo.DependencyDescriptor;
-import org.apache.excalibur.containerkit.metainfo.ServiceDesignator;
+import org.apache.excalibur.meta.info.DefaultType;
+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.log.Hierarchy;
import org.apache.log.Priority;
import org.apache.log.output.io.StreamTarget;
1.2 +90 -95 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Map.java
Index: Map.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Map.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Map.java 4 Jul 2002 09:01:35 -0000 1.1
+++ Map.java 7 Jul 2002 04:28:31 -0000 1.2
@@ -8,14 +8,14 @@
package org.apache.excalibur.merlin.kernel;
import java.util.ArrayList;
-import org.apache.excalibur.containerkit.metadata.ComponentMetaData;
-import org.apache.excalibur.containerkit.metadata.DependencyMetaData;
-import org.apache.excalibur.containerkit.metainfo.DependencyDescriptor;
+import org.apache.excalibur.meta.data.Profile;
+import org.apache.excalibur.meta.data.Association;
+import org.apache.excalibur.meta.info.DependencyDescriptor;
/**
* Utility class to help aquire a ordered graph of
* consumers and providers for specific components. This is a locally
- * variant of the containerkit DependencyMap.
+ * variant of the containerkit Map.
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
@@ -26,7 +26,7 @@
/**
* Parent Map. Components in parent
* Map are potential Providers for services
- * if no component in current assembly satisfies dependency.
+ * if no profile in current assembly satisfies dependency.
*/
private final Map m_parent;
@@ -79,82 +79,98 @@
}
/**
- * Add a component to current dependency graph.
+ * Add a profile to current dependency graph.
*
- * @param component the component
+ * @param profile the profile
*/
- public void add( final ComponentMetaData component )
+ public void add( final Profile profile )
{
- m_components.add( component );
+ if( !m_components.contains( profile ) )
+ m_components.add( profile );
}
/**
- * Get the serilized graph of {@link ComponentMetaData} objects
+ * 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 ComponentMetaData[] getStartupGraph()
+ public Profile[] getStartupGraph()
{
return walkGraph( true );
}
/**
- * Get the serilized graph of {@link ComponentMetaData} objects
+ * 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 ComponentMetaData[] getShutdownGraph()
+ public Profile[] getShutdownGraph()
{
return walkGraph( false );
}
/**
- * Get the serilized graph of {@link ComponentMetaData} objects
- * that use services of specified component.
+ * Get the serilized graph of {@link Profile} objects
+ * that use services of specified profile.
*
- * @param component the component
+ * @param profile the profile
* @return the ordered list of consumers
*/
- public ComponentMetaData[] getConsumerGraph( final ComponentMetaData component )
+ public Profile[] getConsumerGraph( final Profile profile )
{
- return getComponentGraph( component, false );
+ return referencedProfiles( profile, getComponentGraph( profile, false ));
}
/**
- * Get the serilized graph of {@link ComponentMetaData} objects
- * that provide specified component with services.
+ * Get the serilized graph of {@link Profile} objects
+ * that provide specified profile with services.
*
- * @param component the component
+ * @param profile the profile
* @return the ordered list of providers
*/
- public ComponentMetaData[] getProviderGraph( final ComponentMetaData component )
+ public Profile[] getProviderGraph( final Profile profile )
{
- return getComponentGraph( component, true );
+ return referencedProfiles( profile, getComponentGraph( profile, true ));
}
/**
- * Get the graph of a single component.
+ * 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; i<profiles.length; i++ )
+ {
+ if( !profiles[i].equals( profile ) )
+ list.add( profiles[i] );
+ }
+ return (Profile[]) list.toArray( new Profile[0] );
+ }
+
+
+ /**
+ * Get the graph of a single profile.
*
- * @param component the component
+ * @param profile the profile
* @param providers true if traversing providers, false if consumers
* @return the list of components in graph
*/
- private ComponentMetaData[] getComponentGraph( final ComponentMetaData component, final boolean providers )
+ private Profile[] getComponentGraph( final Profile profile, final boolean providers )
{
final ArrayList result = new ArrayList();
- visitcomponent( component,
+ visitcomponent( profile,
providers,
new ArrayList(),
result );
- final ComponentMetaData[] returnValue = new ComponentMetaData[ result.size() ];
- return (ComponentMetaData[])result.toArray( returnValue );
+ final Profile[] returnValue = new Profile[ result.size() ];
+ return (Profile[])result.toArray( returnValue );
}
/**
@@ -165,7 +181,7 @@
* @param providers true if forward dependencys traced, false if dependencies reversed
* @return the ordered node names
*/
- private ComponentMetaData[] walkGraph( final boolean providers )
+ private Profile[] walkGraph( final boolean providers )
{
final ArrayList result = new ArrayList();
final ArrayList done = new ArrayList();
@@ -173,105 +189,112 @@
final int size = m_components.size();
for( int i = 0; i < size; i++ )
{
- final ComponentMetaData component =
- (ComponentMetaData)m_components.get( i );
- visitcomponent( component,
+ final Profile profile =
+ (Profile)m_components.get( i );
+
+ visitcomponent( profile,
providers,
done,
result );
}
- final ComponentMetaData[] returnValue = new ComponentMetaData[ result.size() ];
- return (ComponentMetaData[])result.toArray( returnValue );
+ final Profile[] returnValue = new Profile[ result.size() ];
+ return (Profile[])result.toArray( returnValue );
}
/**
- * Visit a component when traversing dependencies.
+ * Visit a profile when traversing dependencies.
*
- * @param component the component
+ * @param profile the profile
* @param providers true if walking tree looking for providers, else false
* @param done those nodes already traversed
* @param order the order in which nodes have already been
* traversed
*/
- private void visitcomponent( final ComponentMetaData component,
+ private void visitcomponent( final Profile profile,
final boolean providers,
final ArrayList done,
final ArrayList order )
{
- //If already visited this component then bug out early
- if( done.contains( component ) )
+ //If already visited this profile then bug out early
+ if( done.contains( profile ) )
{
return;
}
- done.add( component );
+ done.add( profile );
if( providers )
{
- visitProviders( component, done, order );
+ visitProviders( profile, done, order );
}
else
{
- visitConsumers( component, done, order );
+ visitConsumers( profile, done, order );
}
- order.add( component );
+ order.add( profile );
}
/**
* Traverse graph of components that provide services to
- * the specified component.
+ * the specified profile.
*
- * @param component the ComponentMetaData
+ * @param profile the Profile
*/
- private void visitProviders( final ComponentMetaData component,
+ private void visitProviders( final Profile profile,
final ArrayList done,
final ArrayList order )
{
final DependencyDescriptor[] descriptors =
- component.getComponentInfo().getDependencies();
+ profile.getType().getDependencies();
for( int i = 0; i < descriptors.length; i++ )
{
- final DependencyMetaData dependency =
- component.getDependency( descriptors[ i ].getRole() );
+ final Association assignment =
+ profile.getAssociation( descriptors[ i ].getRole() );
// added != null clause to catch cases where an optional
// dependency exists and the dependecy has not been bound
// to a provider
- if( dependency != null )
+ if( assignment != null )
+ {
+ final Profile provider = assignment.getProvider();
+ visitcomponent( provider, true, done, order );
+ }
+ else
{
- final ComponentMetaData other =
- getComponent( dependency.getProviderName() );
- visitcomponent( other, true, done, order );
+ if( descriptors[i].isRequired() )
+ throw new IllegalStateException(
+ "unresolved dependency for role: " + descriptors[i].getRole()
+ + " in profile: " + profile );
}
}
}
/**
- * Traverse all Consumers of component. ie Anyone that uses
- * service provided by component.
+ * Traverse all Consumers of profile. ie Anyone that uses
+ * service provided by profile.
*
- * @param component the ComponentMetaData
+ * @param profile the Profile
*/
- private void visitConsumers( final ComponentMetaData component,
+ private void visitConsumers( final Profile profile,
final ArrayList done,
final ArrayList order )
{
- final String name = component.getName();
+
+ final String name = profile.getName();
final int size = m_components.size();
for( int i = 0; i < size; i++ )
{
- final ComponentMetaData other =
- (ComponentMetaData)m_components.get( i );
- final DependencyMetaData[] roles = other.getDependencies();
+ final Profile other =
+ (Profile)m_components.get( i );
+ final Association[] providers = other.getAssociations();
- for( int j = 0; j < roles.length; j++ )
+ for( int j = 0; j < providers.length; j++ )
{
- final String depends = roles[ j ].getProviderName();
- if( depends.equals( name ) )
+ if( providers[ j ].getProvider().equals( profile ) )
{
visitcomponent( other, false, done, order );
}
@@ -282,35 +305,7 @@
for( int i = 0; i < childCount; i++ )
{
final Map map = (Map)m_children.get( i );
- map.visitConsumers( component, done, order );
- }
- }
-
- /**
- * Utility method to get component with specified name from specified array.
- *
- * @param name the name of component
- * @return the component
- */
- private ComponentMetaData getComponent( final String name )
- {
- final int size = m_components.size();
- for( int i = 0; i < size; i++ )
- {
- final ComponentMetaData component =
- (ComponentMetaData)m_components.get( i );
- if( component.getName().equals( name ) )
- {
- return component;
- }
+ map.visitConsumers( profile, done, order );
}
-
- if( null != m_parent )
- {
- return m_parent.getComponent( name );
- }
-
- //Should never happen if Verifier passed checks
- throw new IllegalStateException();
}
}
1.4 +4 -4 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Resources.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Resources.properties 4 Jul 2002 09:01:35 -0000 1.3
+++ Resources.properties 7 Jul 2002 04:28:31 -0000 1.4
@@ -1,10 +1,10 @@
-xinfo-load=Creating ComponentInfo from {0}.
+xinfo-load=Creating Type from {0}.
xinfo-missing=XINFO resource unavailable for class "{0}".
xinfo-parse-error=Error occured while parsing xinfo resource "{0}".
-xinfo-nocreate=Failed to create ComponentInfo from resource "{0}" (Reason: {1}).
+xinfo-nocreate=Failed to create Type from resource "{0}" (Reason: {1}).
xinfo-props-error=Unable to construct attributes using key "{0}" (Reason: {1}).
-cinfo-nocreate=Failed to create ComponentDescriptor from resource "{0}" (Reason: {1}).
-cinfo-properties-error=Failed to create ComponentInfo attributes from resource "{0}" (Reason: {1}).
+cinfo-nocreate=Failed to create DefaultType from resource "{0}" (Reason: {1}).
+cinfo-properties-error=Failed to create Type attributes from resource "{0}" (Reason: {1}).
sinfo-noname=Missing name attribute in service declaration from resource "{0}".
sinfo-version=Bad service version in resource "(Reason: {0})".
sinfo-nocreate=Failed to create ServiceInfo from resource "{0}" (Reason: {1}).
1.4 +2 -2 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Verifiable.java
Index: Verifiable.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/kernel/Verifiable.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Verifiable.java 4 Jul 2002 09:01:35 -0000 1.3
+++ Verifiable.java 7 Jul 2002 04:28:31 -0000 1.4
@@ -8,7 +8,7 @@
package org.apache.excalibur.merlin.kernel;
-import org.apache.excalibur.containerkit.verifier.VerifyException;
+import org.apache.excalibur.meta.verifier.VerifyException;
/**
* A interface declaring operations related to type and assembly validation.
1.12 +99 -242 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.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DefaultRegistry.java 5 Jul 2002 09:30:07 -0000 1.11
+++ DefaultRegistry.java 7 Jul 2002 04:28:31 -0000 1.12
@@ -16,11 +16,11 @@
import java.net.URLClassLoader;
import java.util.List;
import java.util.LinkedList;
-import java.util.Map;
import java.util.Hashtable;
import java.util.Properties;
import java.util.Vector;
import java.util.Iterator;
+import java.util.ArrayList;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.Enumeration;
@@ -38,6 +38,7 @@
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.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
@@ -59,26 +60,26 @@
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.containerkit.metainfo.ComponentDescriptor;
-import org.apache.excalibur.containerkit.metainfo.ComponentInfo;
-import org.apache.excalibur.containerkit.metainfo.ServiceDescriptor;
-import org.apache.excalibur.containerkit.metainfo.DependencyDescriptor;
-import org.apache.excalibur.containerkit.metainfo.ServiceDesignator;
-import org.apache.excalibur.containerkit.metadata.ComponentMetaData;
-import org.apache.excalibur.containerkit.metadata.DependencyMetaData;
-import org.apache.excalibur.containerkit.verifier.AssemblyVerifier;
-import org.apache.excalibur.containerkit.verifier.MetaDataVerifier;
-import org.apache.excalibur.containerkit.verifier.VerifyException;
-import org.apache.excalibur.containerkit.dependency.DependencyMap;
+import org.apache.excalibur.meta.info.DefaultType;
+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.data.Profile;
+import org.apache.excalibur.meta.data.DefaultProfile;
+import org.apache.excalibur.meta.data.Association;
+import org.apache.excalibur.meta.verifier.AssemblyVerifier;
+import org.apache.excalibur.meta.verifier.MetaDataVerifier;
+import org.apache.excalibur.meta.verifier.VerifyException;
+import org.apache.excalibur.configuration.ContextFactory;
import org.apache.log.output.io.StreamTarget;
import org.apache.log.Hierarchy;
import org.apache.log.Priority;
-import org.apache.excalibur.merlin.registry.*;
+import org.apache.excalibur.merlin.kernel.Map;
import org.apache.excalibur.merlin.kernel.Container;
import org.apache.excalibur.merlin.kernel.ContainerClassLoader;
import org.apache.excalibur.merlin.kernel.Verifiable;
-import org.apache.excalibur.configuration.ContextFactory;
/**
* Provides support for the maintenance of a registry of
@@ -86,7 +87,7 @@
* @author <a href="mailto:mcconnell@apache.org">Stephen McConnell</a>
* @version $Revision$ $Date$
*/
-public class DefaultRegistry extends AbstractLogEnabled implements Contextualizable, Configurable, Initializable, Executable, Disposable, Registry, Verifiable
+public class DefaultRegistry extends AbstractLogEnabled implements Contextualizable, Configurable, Initializable, Executable, Disposable, Registry, Verifiable, Startable
{
//=======================================================================
// static
@@ -129,7 +130,7 @@
/**
* Internal class that maintains information about registered types.
*/
- private ServiceRegistry m_services;
+ private TypeRegistry m_types;
/**
* The supplied configuration.
@@ -139,12 +140,17 @@
/**
* Hashtable of all installed profiles keyed by profile name.
*/
- private Hashtable m_profiles = new Hashtable();
+ //private Hashtable m_profiles = new Hashtable();
+
+ /**
+ * Internal class that maintains information about profile types.
+ */
+ private ProfileRegistry m_profiles;
/**
* The depenecy map supplied by the parent container.
*/
- private DependencyMap m_map;
+ private Map m_map;
//=======================================================================
// Contextualizable
@@ -157,7 +163,7 @@
public void contextualize( Context context ) throws ContextException
{
m_classloader = (ContainerClassLoader) context.get( CLASSLOADER_KEY );
- m_map = (DependencyMap) context.get( MAP_KEY );
+ m_map = (Map) context.get( MAP_KEY );
try
{
m_parent = (Container) context.get( CONTAINER_KEY );
@@ -195,105 +201,66 @@
public void initialize() throws Exception
{
getLogger().debug("registry initialization");
- m_services = new ServiceRegistry( this, m_classloader, m_map, m_config );
- m_services.enableLogging( getLogger().getChildLogger("services") );
+ m_types = new TypeRegistry( this, m_classloader );
+ m_types.enableLogging( getLogger().getChildLogger("types") );
String[] blocks = m_classloader.getComponentClassnames();
- try
+ for( int i=0; i<blocks.length; i++ )
{
//
// register all of the the component providers implied by the classpath
// manifest declarations as potential component type without resolution
- // of dependencies
+ // of dependencies or other other constraints
//
- for( int i=0; i<blocks.length; i++ )
+ final String classname = blocks[i].replace('/','.');
+ try
{
// initialize the component type defintions
- final String classname = blocks[i].replace('/','.');
- m_services.register( classname );
+ m_types.register( classname );
}
-
- }
- catch( Throwable e )
- {
- final String error = "Internal registry candidate registation failure.";
- throw new RegistryException( error, e );
- }
-
- Configuration[] entries = m_config.getChildren( "component" );
- try
- {
- //
- // for all of the components declared in the application profiles,
- // register each one in the service repository
- //
-
- for( int i=0; i<entries.length; i++ )
+ catch( Throwable e )
{
- final Configuration entry = entries[i];
- final String classname = entry.getAttribute("class");
- getLogger().debug("component configuration");
- getLogger().debug( ConfigurationUtil.list( entry ) );
- ComponentType type = m_services.register( classname );
+ final String error = "Ignoring component due to registration error.";
+ getLogger().warn( error, e );
}
+ }
- //
- // for all of the component profiles declared in the container,
- // install each of them
- //
-
- for( int i=0; i<entries.length; i++ )
- {
- final Configuration entry = entries[i];
- final String classname = entry.getAttribute("class");
- ComponentType type = m_services.getComponentType( classname );
- Profile profile = buildProfile( type, entry );
- install( profile );
-
- //listProfile( profile );
- }
+ //
+ // we now have the complete set of components registered and we can proceed
+ // with the establishment of candidate profiles
+ //
+ Type[] types = m_types.getTypes();
+ try
+ {
+ Configuration[] explicit = m_config.getChildren( "component" );
+ m_profiles = new ProfileRegistry( explicit, m_types, m_classloader, m_parent, m_map );
+ m_profiles.enableLogging( getLogger().getChildLogger( "profiles") );
+ int n = m_profiles.prepareProfiles();
+ getLogger().info("Profile count: " + n );
}
catch( Throwable e )
{
- final String error = "Internal registry initialization failure.";
- throw new RegistryException( error, e );
+ final String error = "Ignoring candidate due to profile error.";
+ getLogger().warn( error, e );
}
- }
- Profile buildProfile( ComponentType type, Configuration criteria )
- throws ConfigurationException, UnresolvedProviderException
- {
- String name = criteria.getAttribute("name",null);
- DependencyMetaData[] dependencies = resolveDependencies( type );
- Parameters params = Parameters.fromConfiguration( criteria.getChild("parameters") );
- Configuration config = criteria.getChild("configuration");
- Context context = ContextFactory.createContextFromConfiguration(
- null, criteria.getChild("context") );
- return new Profile( name, dependencies, params, config, type, context );
- }
+ //
+ // Every available type has been expanded to a profile based on .profile
+ // declarations, or a default profile (*where no defaults are specified)
+ // We can now proceed with assembly.
+ //
- private DependencyMetaData[] resolveDependencies( ComponentType type )
- throws UnresolvedProviderException
- {
- Vector vector = new Vector();
- DependencyDescriptor[] deps = type.getComponentInfo().getDependencies();
- for( int i=0; i<deps.length; i++ )
+ try
{
- if( !deps[i].isOptional() )
- {
- final String role = deps[i].getRole();
- final Profile provider = getProvider( deps[i] );
- DependencyMetaData data = new DependencyMetaData(
- role,
- provider.getName()
- );
- vector.add( data );
- }
+ m_profiles.assembleProfiles();
+ }
+ catch( Throwable e )
+ {
+ final String error = "Ignoring candidate due to profile error.";
+ getLogger().warn( error, e );
}
- return (DependencyMetaData[])
- vector.toArray( new DependencyMetaData[0] );
}
//=======================================================================
@@ -311,6 +278,21 @@
{
}
+ //======================================================================
+ // Startable
+ //======================================================================
+
+ public void start() throws Exception
+ {
+ m_profiles.start();
+ }
+
+ public void stop()
+ {
+ m_profiles.stop();
+ }
+
+
//=======================================================================
// Verifiable
//=======================================================================
@@ -323,166 +305,41 @@
*/
public void verify() throws VerifyException
{
- getLogger().debug("DependencyMap listing");
- ComponentMetaData[] startup = m_map.getStartupGraph();
+ getLogger().debug("Map listing");
+ Profile[] startup = m_map.getStartupGraph();
doVerify( startup );
}
//=======================================================================
- // Registry
+ // Container
//=======================================================================
- /**
- * Return the privider for a dependency.
- * @param dependency a consumer component dependecy declaration
- * @return the installed supplier profile
- */
- public Profile getProvider( DependencyDescriptor dependency )
- throws UnresolvedProviderException
- {
- Profile profile = getCandidateProfile( dependency );
- install( profile );
- return profile;
- }
-
- /**
- * Return the preferred profile for a depedency.
- * @param dependency a consumer component dependecy declaration
- * @return the preferred candidate supplier profile
- */
- public Profile getCandidateProfile( DependencyDescriptor dependency )
- throws UnresolvedProviderException
- {
- //try
- //{
- return m_services.getCandidateProfile( dependency );
- //}
- //catch( UnresolvedProviderException upe )
- //{
- // in this case, we can try to locate a service provider
- // in the parent container
-
- // if( m_parent != null )
- // return m_parent.getProvider( dependency );
- // throw upe;
- //}
- }
-
- /**
- * Returns an array of component profiles representing candidate component types
- * capable of acting as a service supplier relative to the supplied dependecy descriptor.
- * @param dependency the dependency descriptor to evaluate
- * @return the set of profiles
- */
- public Profile[] getCandidateProfiles( DependencyDescriptor dependency )
- {
- return m_services.getProfiles( dependency.getService() );
- }
-
- /**
- * Method invoked by a DefaultProfile to declare itself within the application scope.
- * @param profile the Profile to include in application scope
- */
- void install( Profile profile )
+ public Profile[] getProviders( ServiceDesignator designator )
{
- m_profiles.put( profile.getName(), profile );
- m_map.add( profile );
+ Profile[] local = m_profiles.getProviders( designator );
+ if( m_parent != null )
+ {
+ Profile[] facilities = m_parent.getProviders( designator );
+ ArrayList list = new ArrayList();
+ for( int i=0; i<local.length; i++ )
+ {
+ list.add( local[i] );
+ }
+ for( int i=0; i<facilities.length; i++ )
+ {
+ list.add( facilities[i] );
+ }
+ return (Profile[]) list.toArray( new Profile[0] );
+ }
+ return local;
}
//=======================================================================
// implementation
//=======================================================================
- /**
- * Test if the registry can resolve a request for a component with the supplied classname
- * @param classname a component or service class name
- * @return TRUE if the registry can service the request
- */
- private boolean hasComponentDefinition( String classname )
- {
- return m_services.getComponentType( classname ) != null;
- }
-
- /**
- * Returns an component defintion either through referdnce to an exiting defintion
- * or through defintion coreation if no exiting defintion is available relative to
- * the request classname key.
- * @param classname the class name of the component defintion to locate or create
- * @return the corresponding component defintion
- * @exception RegistryRuntimeException if an error occurs during the
- * construction of a new component defintion
- */
- private ComponentType getComponentDefinition( String classname )
- {
- return m_services.getComponentType( classname );
- }
-
- /**
- * Returns the component type implementation class.
- * @param type the component type descriptor
- * @return the class implementing the component type
- */
- private Class getComponentClass( ComponentType type ) throws RegistryException
- {
- if( null == type )
- throw new NullPointerException("Illegal null component type argument.");
-
- final String classname = type.getComponentInfo().getComponentDescriptor().getImplementationKey();
- try
- {
- return m_classloader.loadClass( classname );
- }
- catch( Throwable e )
- {
- final String error = "Could not load implementation class for component type: "
- + classname;
- throw new RegistryException( error, e );
- }
- }
-
-
- /**
- * Returns the service type implementation class.
- * @param service the service type descriptor
- * @return the class implementing the service type
- */
- private Class getServiceClass( ServiceDescriptor service ) throws RegistryException
- {
- final String classname = service.getServiceDesignator().getClassname();
- try
- {
- return m_classloader.loadClass( classname );
- }
- catch( Throwable e )
- {
- final String error = "Could not load implementation class for service type: "
- + classname;
- throw new RegistryException( error, e );
- }
- }
-
- private void listProfile( Profile profile )
- {
- List reported = new LinkedList();
- listProfile( profile, reported );
- }
-
- private void listProfile( Profile profile, List reported )
- {
- if( !reported.contains( profile ) )
- {
- getLogger().debug( profile.report() );
- reported.add( profile );
- }
- DependencyMetaData[] dependencies = profile.getDependencies();
- for( int j=0; j<dependencies.length; j++ )
- {
- Profile dependent = (Profile) m_profiles.get( dependencies[j].getProviderName() );
- listProfile( dependent, reported );
- }
- }
- private void doVerify( ComponentMetaData[] assembly ) throws VerifyException
+ private void doVerify( Profile[] assembly ) throws VerifyException
{
MetaDataVerifier mdv = new MetaDataVerifier();
for( int i=0; i<assembly.length; i++ )
1.6 +10 -10 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Registry.java 4 Jul 2002 09:01:36 -0000 1.5
+++ Registry.java 7 Jul 2002 04:28:31 -0000 1.6
@@ -8,10 +8,10 @@
package org.apache.excalibur.merlin.registry;
-import org.apache.excalibur.containerkit.metainfo.DependencyDescriptor;
-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.meta.info.DependencyDescriptor;
+import org.apache.excalibur.meta.info.ServiceDescriptor;
+import org.apache.excalibur.meta.info.Type;
+import org.apache.excalibur.meta.data.Profile;
import org.apache.excalibur.merlin.kernel.Container;
/**
@@ -32,15 +32,15 @@
* @param dependency the dependency descriptor to evaluate
* @return the set of profiles
*/
- Profile[] getCandidateProfiles( DependencyDescriptor dependency );
+ //Profile[] getCandidateProfiles( DependencyDescriptor dependency );
/**
* Return a single preferred profile capable of supporting the supplied dependency.
* @param dependency a consumer component dependecy declaration
* @return the preferred candidate supplier profile or null if not candidates found
*/
- Profile getCandidateProfile( DependencyDescriptor dependency )
- throws UnresolvedProviderException;
+ //Profile getCandidateProfile( DependencyDescriptor dependency )
+ // throws UnresolvedProviderException;
/**
* Test if the registry can resolve a request for a component with the supplied classname
@@ -56,7 +56,7 @@
* @exception AssemblyException if an error occurs during the construction of a
* new component defintion
*/
- //ComponentType getComponentDefinition( String classname ) throws RegistryException;
+ //Type getComponentDefinition( String classname ) throws RegistryException;
/**
* Returns an array of component definitions capable of acting as a service supplier
@@ -64,5 +64,5 @@
* @param dependency the dependency descriptor to evaluate
* @return the set of matching service descriptors capable of supporting the dependency
*/
- //public ComponentType[] getCandidateProviders( DependencyDescriptor dependency );
+ //public Type[] getCandidateProviders( DependencyDescriptor dependency );
}
1.4 +4 -4 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/Resources.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Resources.properties 4 Jul 2002 09:01:36 -0000 1.3
+++ Resources.properties 7 Jul 2002 04:28:31 -0000 1.4
@@ -1,10 +1,10 @@
-xinfo-load=Creating ComponentInfo from {0}.
+xinfo-load=Creating Type from {0}.
xinfo-missing=XINFO resource unavailable for class "{0}".
xinfo-parse-error=Error occured while parsing xinfo resource "{0}".
-xinfo-nocreate=Failed to create ComponentInfo from resource "{0}" (Reason: {1}).
+xinfo-nocreate=Failed to create Type from resource "{0}" (Reason: {1}).
xinfo-props-error=Unable to construct attributes using key "{0}" (Reason: {1}).
-cinfo-nocreate=Failed to create ComponentDescriptor from resource "{0}" (Reason: {1}).
-cinfo-properties-error=Failed to create ComponentInfo attributes from resource "{0}" (Reason: {1}).
+cinfo-nocreate=Failed to create DefaultType from resource "{0}" (Reason: {1}).
+cinfo-properties-error=Failed to create Type attributes from resource "{0}" (Reason: {1}).
sinfo-noname=Missing name attribute in service declaration from resource "{0}".
sinfo-version=Bad service version in resource "(Reason: {0})".
sinfo-nocreate=Failed to create ServiceInfo from resource "{0}" (Reason: {1}).
1.4 +3 -3 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/Selector.java
Index: Selector.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/Selector.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Selector.java 4 Jul 2002 09:01:36 -0000 1.3
+++ Selector.java 7 Jul 2002 04:28:31 -0000 1.4
@@ -8,7 +8,7 @@
package org.apache.excalibur.merlin.registry;
-import org.apache.excalibur.merlin.registry.Profile;
+import org.apache.excalibur.meta.data.Profile;
/**
@@ -26,5 +26,5 @@
* @return the preferred provider or null if no satisfactory provider can be established
* from the supplied profiles.
*/
- Profile select( Profile[] profiles ) throws UnresolvedProviderException;
+ Profile select( Profile[] facilities, Profile[] profiles );
}
1.4 +2 -2 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/UnresolvedProviderException.java
Index: UnresolvedProviderException.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/merlin/registry/UnresolvedProviderException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- UnresolvedProviderException.java 4 Jul 2002 09:01:36 -0000 1.3
+++ UnresolvedProviderException.java 7 Jul 2002 04:28:31 -0000 1.4
@@ -8,7 +8,7 @@
package org.apache.excalibur.merlin.registry;
-import org.apache.excalibur.containerkit.metainfo.DependencyDescriptor;
+import org.apache.excalibur.meta.info.DependencyDescriptor;
import org.apache.avalon.framework.CascadingException;
1.5 +1 -1 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- package.html 4 Jul 2002 09:01:36 -0000 1.4
+++ package.html 7 Jul 2002 04:28:31 -0000 1.5
@@ -18,7 +18,7 @@
</ul>
<h3>Object Model</h3>
-<p>The registry object model provides a simplified view of the <code>containerkit</code> framework. The principal entry point is the {@link org.apache.excalibur.merlin.registry.Registry} and the associated default implementation {@link org.apache.excalibur.merlin.registry.DefaultRegistry}. The registry acts as a component type repository. Component types are exposed as instances of the {@link 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 {@link 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.
+<p>The registry object model provides a simplified view of the <code>containerkit</code> framework. The principal entry point is the {@link org.apache.excalibur.merlin.registry.Registry} and the associated default implementation {@link org.apache.excalibur.merlin.registry.DefaultRegistry}. The registry acts as a component type repository. Component types are exposed as instances of the {@link org.apache.excalibur.meta.info.Type} interface. Each component type represents a concrete component implementation class. For each component type, the container associates at least one instantiation {@link org.apache.excalibur.meta.data.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 +2 -2 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/builder/ConfigurationBuilder.java
Index: ConfigurationBuilder.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/builder/ConfigurationBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ConfigurationBuilder.java 5 Jul 2002 10:38:59 -0000 1.1
+++ ConfigurationBuilder.java 7 Jul 2002 04:28:31 -0000 1.2
@@ -30,7 +30,7 @@
{
new DTDInfo( "-//AVALON/Component Info DTD Version 1.0//EN",
"http://jakarta.apache.org/avalon/componentinfo_1_0.dtd",
- "org/apache/excalibur/containerkit/infobuilder/componentinfo.dtd" ),
+ "org/apache/excalibur/meta/builder/componentinfo.dtd" ),
};
private static final DTDResolver c_resolver =
1.2 +3 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/builder/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/builder/Resources.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Resources.properties 5 Jul 2002 10:38:59 -0000 1.1
+++ Resources.properties 7 Jul 2002 04:28:31 -0000 1.2
@@ -3,4 +3,6 @@
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 XMLInfoCreator, usually due to not having XML classes on Classpath. Thus unable to lookup XML descriptor for component type "{0}".
\ No newline at end of file
+builder.missing-xml-creator.error=Unable to create XMLInfoCreator, 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}".
1.2 +2 -2 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/builder/package.html
Index: package.html
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/builder/package.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- package.html 5 Jul 2002 10:38:59 -0000 1.1
+++ package.html 7 Jul 2002 04:28:31 -0000 1.2
@@ -2,7 +2,7 @@
<p>Component information builder that handels internalization of an component type description supplied as a configuration instance.</P>
<h3>Package Structure (UML)</h3>
-<!--<p><img src=doc-files/TypeBuilder.gif border=0></p>-->
+<p><img src=doc-files/TypeBuilder.gif border=0></p>
<a name="external"><h3>External Form (XML)</h3></a>
<p>Configuration instances supplied to the builder shall correspond to the <a href="http://home.osm.net/componentinfo.dtd">component-info DTD</a>.
@@ -13,7 +13,7 @@
<font color="gray"><i><!--
Example of a component meta info external XML form.
The element contains the information required to construct an instance of
-org.apache.excalibur.containerkit.metainfo.ComponentInfo. It includes
+org.apache.excalibur.meta.info.Type. It includes
information about the component type, the service it provides, and the
services it is dependent on.
--></i></font>
1.2 +104 -12 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/data/DefaultProfile.java
Index: DefaultProfile.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/data/DefaultProfile.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultProfile.java 5 Jul 2002 10:39:00 -0000 1.1
+++ DefaultProfile.java 7 Jul 2002 04:28:31 -0000 1.2
@@ -7,13 +7,15 @@
*/
package org.apache.excalibur.meta.data;
+import java.io.Serializable;
import java.util.Hashtable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.context.Context;
import org.apache.excalibur.meta.info.Type;
import org.apache.excalibur.meta.data.Profile;
-import org.apache.excalibur.meta.data.Assignment;
+import org.apache.excalibur.meta.data.Association;
+import org.apache.excalibur.configuration.ConfigurationUtil;
/**
* Each component declared in the application is represented by
@@ -28,7 +30,7 @@
* @version $Revision$ $Date$
*/
public class DefaultProfile
- implements Profile
+ implements Profile, Serializable
{
/**
* The name of the component metadata instance. This is an
@@ -62,6 +64,12 @@
private final Context m_context;
/**
+ * The creation mode.
+ */
+ private final int m_mode;
+
+
+ /**
* Create a Profile instance.
*
* @param name the abstract name of component meta data instance
@@ -72,22 +80,28 @@
final Parameters parameters,
final Configuration configuration,
final Context context,
- final Type componentInfo )
+ final Type componentInfo,
+ final int mode )
{
if( null == name )
{
- throw new NullPointerException( "name" );
+ m_name = "" + System.identityHashCode( this );
+ }
+ else
+ {
+ m_name = name;
}
+
if( null == componentInfo )
{
throw new NullPointerException( "componentInfo" );
}
- m_name = name;
m_parameters = parameters;
m_configuration = configuration;
m_componentInfo = componentInfo;
m_context = context;
+ m_mode = mode;
}
/**
@@ -105,7 +119,7 @@
*
* @return the info for component type.
*/
- public Type getInfo()
+ public Type getType()
{
return m_componentInfo;
}
@@ -115,9 +129,9 @@
*
* @return the set of service provider assignments.
*/
- public Assignment[] getAssignments()
+ public Association[] getAssociations()
{
- return (Assignment[])m_dependencies.values().toArray( new Assignment[0] );
+ return (Association[])m_dependencies.values().toArray( new Association[0] );
}
/**
@@ -155,9 +169,18 @@
*
* @return the dependency metadata for component with specified role.
*/
- public Assignment getAssignment( final String role )
+ public Association getAssociation( final String role )
{
- return (Assignment) m_dependencies.get( role );
+ return (Association) m_dependencies.get( role );
+ }
+
+ /**
+ * Returns the creation mode for this profile.
+ * @return a value of EXPLICIT, PACKAGED or IMPLICIT
+ */
+ public int getMode()
+ {
+ return m_mode;
}
/**
@@ -167,7 +190,76 @@
*/
public void addProvider( Profile provider, String role )
{
- m_dependencies.put( role, new Assignment( role, provider ) );
+ m_dependencies.put( role, new Association( role, provider ) );
+ }
+
+ public String toString()
+ {
+ return "Profile name: " + getName()
+ + ", type: " + getType().getInfo().getName()
+ + ", mode: " + modeToString( getMode() );
+ }
+
+ private String modeToString( int mode )
+ {
+ if( mode == IMPLICIT )
+ {
+ return "IMPLICIT";
+ }
+ else if( mode == PACKAGED )
+ {
+ return "PACKAGED";
+ }
+ else if( mode == EXPLICIT )
+ {
+ return "EXPLICIT";
+ }
+ else
+ {
+ return "?";
+ }
+ }
+
+ /**
+ * Provide a textual report on the profile.
+ * @return the formatted profile report
+ */
+ public String list()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "PROFILE REPORT\n" );
+ buffer.append( "\n name: " + getName() );
+ buffer.append( "\n base: " + getType().getInfo().getName() );
+ buffer.append( "\n key: " + getType().getInfo().getImplementationKey() );
+ buffer.append( "\n context: " + getContext( ) );
+ buffer.append( "\n configuration:" );
+ if( getConfiguration() != null )
+ {
+ buffer.append( ConfigurationUtil.list( getConfiguration() ) );
+ }
+ else
+ {
+ buffer.append( " null" );
+ }
+ buffer.append( "\n parameters: " + getParameters() );
+ buffer.append( "\n dependecies" );
+
+ Association[] dependencies = getAssociations();
+ if( dependencies.length == 0 )
+ {
+ buffer.append( " (none)\n\n" );
+ return buffer.toString();
+ }
+
+ for( int i=0; i<dependencies.length; i++ )
+ {
+ buffer.append( "\n dependency " + i );
+ buffer.append( "\n role: " + dependencies[i].getRole() );
+ buffer.append( "\n provider: " + dependencies[i].getProvider() );
+ }
+
+ buffer.append( "\n\n" );
+ return buffer.toString();
}
}
1.2 +40 -16 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/data/Profile.java
Index: Profile.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/data/Profile.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Profile.java 5 Jul 2002 10:39:00 -0000 1.1
+++ Profile.java 7 Jul 2002 04:28:31 -0000 1.2
@@ -27,52 +27,76 @@
public interface Profile
{
+ static final int IMPLICIT = 0;
+ static final int PACKAGED = 1;
+ static final int EXPLICIT = 2;
+
/**
* Return the name of component metadata instance.
*
* @return the name of the component.
*/
- public String getName();
+ String getName();
/**
* Return the info for component.
*
* @return the info for component type.
*/
- public Type getInfo();
-
- /**
- * Return the assigned service providers.
- *
- * @return the dependency metadata for component.
- */
- public Assignment[] getAssignments();
+ Type getType();
/**
* Return the Parameters for component (if any).
*
* @return the Parameters for Component (if any).
*/
- public Parameters getParameters();
+ Parameters getParameters();
/**
* Return the Configuration for component(if any).
*
* @return the Configuration for component
*/
- public Configuration getConfiguration();
+ Configuration getConfiguration();
/**
* Return the Context for component (if any).
*
* @return the Context for component
*/
- public Context getContext();
+ Context getContext();
/**
- * Return the Assignment for specified role.
+ * Return the assigned service providers.
*
- * @return the Assignment for specified role.
+ * @return the dependency metadata for component.
*/
- public Assignment getAssignment( final String role );
+ Association[] getAssociations();
+
+ /**
+ * Return the Association for specified role.
+ *
+ * @return the Association for specified role.
+ */
+ Association getAssociation( final String role );
+
+ /**
+ * Returns the creation mode for this profile.
+ * @return a value of EXPLICIT, PACKAGED or IMPLICIT
+ */
+ int getMode();
+
+ /**
+ * Add a provider for a service dependency role.
+ * @param provider the compenont provider profile
+ * @param role the dependent role
+ */
+ void addProvider( Profile provider, String role );
+
+ /**
+ * Provide a textual report on the profile.
+ * @return the formatted profile report
+ */
+ String list();
+
}
1.2 +9 -3 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/DefaultType.java
Index: DefaultType.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/DefaultType.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultType.java 5 Jul 2002 10:39:00 -0000 1.1
+++ DefaultType.java 7 Jul 2002 04:28:31 -0000 1.2
@@ -15,6 +15,8 @@
import org.apache.excalibur.meta.info.LoggerDescriptor;
import org.apache.excalibur.meta.info.ServiceDescriptor;
import org.apache.excalibur.meta.info.ServiceDesignator;
+import org.apache.excalibur.meta.data.Profile;
+import org.apache.excalibur.meta.data.DefaultProfile;
/**
* This class contains the meta information about a particular
@@ -68,7 +70,7 @@
}
if( null == dependencies )
{
- throw new NullPointerException( "dependencies" );
+ throw new NullPointerException( "profiles" );
}
m_descriptor = descriptor;
m_loggers = loggers;
@@ -82,7 +84,7 @@
*
* @return the Component descriptor.
*/
- public ComponentDescriptor getDescription()
+ public ComponentDescriptor getInfo()
{
return m_descriptor;
}
@@ -147,4 +149,8 @@
return null;
}
+ public String toString()
+ {
+ return "Type name: " + getInfo().getName() + " key: " + getInfo().getImplementationKey();
+ }
}
1.2 +2 -2 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/Type.java
Index: Type.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/Type.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Type.java 5 Jul 2002 10:39:00 -0000 1.1
+++ Type.java 7 Jul 2002 04:28:31 -0000 1.2
@@ -32,7 +32,7 @@
*
* @return the Component descriptor.
*/
- public ComponentDescriptor getDescription();
+ public ComponentDescriptor getInfo();
/**
* Return the set of Logger that this Component will use.
1.2 +3 -0 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/package.html
Index: package.html
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/info/package.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- package.html 5 Jul 2002 10:39:00 -0000 1.1
+++ package.html 7 Jul 2002 04:28:31 -0000 1.2
@@ -7,4 +7,7 @@
and Context establishment criteria, in addition to human-readable
information about the component type.
</p>
+
+<h3>Package Structure (UML)</h3>
+<p><img src=doc-files/Type.gif border=0></p>
</body>
1.2 +14 -13 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier/AssemblyVerifier.java
Index: AssemblyVerifier.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier/AssemblyVerifier.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AssemblyVerifier.java 5 Jul 2002 10:39:00 -0000 1.1
+++ AssemblyVerifier.java 7 Jul 2002 04:28:31 -0000 1.2
@@ -13,7 +13,7 @@
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.excalibur.meta.data.Profile;
-import org.apache.excalibur.meta.data.Assignment;
+import org.apache.excalibur.meta.data.Association;
import org.apache.excalibur.meta.info.Type;
import org.apache.excalibur.meta.info.DependencyDescriptor;
import org.apache.excalibur.meta.info.ServiceDescriptor;
@@ -205,7 +205,7 @@
final Profile[] components )
{
final ArrayList dependencies = new ArrayList();
- final Assignment[] deps = component.getAssignments();
+ final Association[] deps = component.getAssociations();
for( int i = 0; i < deps.length; i++ )
{
@@ -243,8 +243,8 @@
final Profile[] others )
throws VerifyException
{
- final Type info = component.getInfo();
- final Assignment[] roles = component.getAssignments();
+ final Type info = component.getType();
+ final Association[] roles = component.getAssociations();
for( int i = 0; i < roles.length; i++ )
{
@@ -267,14 +267,15 @@
//make sure that the component offers service
//that user expects it to be providing
- final ServiceDescriptor[] services = provider.getInfo().getServices();
+ final ServiceDescriptor[] services = provider.getType().getServices();
if( !hasMatchingService( service, services ) )
{
final String message =
REZ.getString( "assembly.dependency-missing-service.error",
+ component.getName(),
providerName,
- service,
- component.getName() );
+ roleName,
+ service );
throw new VerifyException( message );
}
}
@@ -388,7 +389,7 @@
}
/**
- * Retrieve a list of Assignment objects for Profile
+ * Retrieve a list of Association objects for Profile
* and verify that there is a 1 to 1 map with dependencies specified
* in Type.
*
@@ -399,12 +400,12 @@
throws VerifyException
{
//Make sure all role entries specified in config file are valid
- final Assignment[] dependencySet = component.getAssignments();
+ final Association[] dependencySet = component.getAssociations();
for( int i = 0; i < dependencySet.length; i++ )
{
final String roleName = dependencySet[ i ].getRole();
- final DependencyDescriptor descriptor = component.getInfo().getDependency( roleName );
+ final DependencyDescriptor descriptor = component.getType().getDependency( roleName );
//If there is no dependency descriptor in Type then
//user has specified an uneeded dependency.
@@ -420,11 +421,11 @@
}
//Make sure all dependencies in Type file are satisfied
- final DependencyDescriptor[] dependencies = component.getInfo().getDependencies();
+ final DependencyDescriptor[] dependencies = component.getType().getDependencies();
for( int i = 0; i < dependencies.length; i++ )
{
final DependencyDescriptor dependency = dependencies[ i ];
- final Assignment role = component.getAssignment( dependency.getRole() );
+ final Association role = component.getAssociation( dependency.getRole() );
//If there is no Role then the user has failed
//to specify a needed dependency.
1.2 +5 -5 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier/MetaDataVerifier.java
Index: MetaDataVerifier.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier/MetaDataVerifier.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MetaDataVerifier.java 5 Jul 2002 10:39:00 -0000 1.1
+++ MetaDataVerifier.java 7 Jul 2002 04:28:31 -0000 1.2
@@ -107,7 +107,7 @@
final String name = component.getName();
final Class[] interfaces =
getServiceClasses( name,
- component.getInfo().getServices(),
+ component.getType().getServices(),
clazz.getClassLoader() );
m_verifier.verifyComponent( name, clazz, interfaces );
@@ -128,7 +128,7 @@
final Class clazz )
throws VerifyException
{
- final Type info = component.getInfo();
+ final Type info = component.getType();
final ContextDescriptor context = info.getContextDescriptor();
final int count = context.getEntrys().length;
@@ -160,7 +160,7 @@
final Class clazz )
throws VerifyException
{
- final int count = component.getAssignments().length;
+ final int count = component.getAssociations().length;
final boolean aquiresServices =
Composable.class.isAssignableFrom( clazz ) ||
Serviceable.class.isAssignableFrom( clazz );
@@ -253,6 +253,6 @@
*/
private String getClassname( final Profile component )
{
- return component.getInfo().getDescription().getImplementationKey();
+ return component.getType().getInfo().getImplementationKey();
}
}
1.2 +2 -1 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier/Resources.properties
Index: Resources.properties
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier/Resources.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Resources.properties 5 Jul 2002 10:39:00 -0000 1.1
+++ Resources.properties 7 Jul 2002 04:28:31 -0000 1.2
@@ -21,7 +21,8 @@
assembly.component-type.notice=Verifying that the specified Components have valid types.
assembly.circular-dependency.error=Component named "{0}" has a circular dependency via path: {1}.
assembly.missing-dependency.error=Component "{1}" that satisfies the dependency with role "{0}" of Component "{2}" does not exist.
-assembly.dependency-missing-service.error=Dependency "{0}" of Block "{2}" does not offer the required service "{1}".
+assembly.dependency-missing-service.error=Profile {0}" is associated to profile "{1}" under the role "{2}" however, the provider does not supply the required service "{3}".
+
assembly.bad-class.error=Unable to load class "{1}" for Component named "{0}". (Reason: {2}).
assembly.bad-name.error=The Component name "{0}" is invalid. Valid names contain only letters, digits and the '-' character.
assembly.duplicate-name.error=The name "{0}" is used by multiple Components in assembly.
1.2 +2 -2 jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier/package.html
Index: package.html
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/assembly/src/java/org/apache/excalibur/meta/verifier/package.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- package.html 5 Jul 2002 10:39:00 -0000 1.1
+++ package.html 7 Jul 2002 04:28:31 -0000 1.2
@@ -7,11 +7,11 @@
<p>This package includes a set of classes supporting the verification of the
integrity of a component class and the verification of the integrity of a
relationships and inter-dependecies based on supplied meta-data. The
-{@link org.apache.excalibur.containerkit.verifier.ComponentVerifier} provides
+{@link org.apache.excalibur.meta.verifier.ComponentVerifier} provides
support for the validation of a component class. It includes validation
functions that check for structural and best-practice integrity related to
the class, lifecycle patterns and service. The
-{@link org.apache.excalibur.containerkit.verifier.AssemblyVerifier} performs
+{@link org.apache.excalibur.meta.verifier.AssemblyVerifier} performs
validation of the structural integrity of a set component assembly based on
assembly meta-data.
</body>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>