mcconnell 2003/07/08 22:02:06
Modified: merlin maven.xml
merlin/composition/src/java/org/apache/avalon/composition/model/impl
DefaultClassLoaderModel.java
DefaultContainmentContext.java
DefaultContainmentModel.java
DefaultDeploymentContext.java
DefaultDeploymentModel.java DefaultModel.java
DefaultModelFactory.java
merlin/composition-spi/src/java/org/apache/avalon/composition/model
ClassLoaderModel.java ContainmentContext.java
ContainmentModel.java DeploymentContext.java
ModelFactory.java package.html
merlin/merlin-platform project.xml
Log:
Composition package updates supporting modeel navigation.
Revision Changes Path
1.23 +3 -2 avalon-sandbox/merlin/maven.xml
Index: maven.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/maven.xml,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- maven.xml 8 Jul 2003 15:01:21 -0000 1.22
+++ maven.xml 9 Jul 2003 05:02:05 -0000 1.23
@@ -31,7 +31,7 @@
<maven:reactor
basedir="${basedir}"
includes="*/project.xml,merlin-extensions/merlin-jmx/project.xml,merlin-extensions/merlin-jndi/project.xml,merlin-extensions/merlin-servlet/project.xml"
- excludes="merlin-platform/*,merlin-plugin/*,activation*/*"
+ excludes="merlin-platform/*,merlin-plugin/*"
goals="merlin-propergate"
banner="Installing:"
ignoreFailures="false" />
@@ -236,6 +236,8 @@
<sourcepath path="${basedir}/../meta/src/java"/>
<sourcepath path="${basedir}/../extension-spi/src/java"/>
<sourcepath path="${basedir}/../extension/src/java"/>
+ <sourcepath path="${basedir}/../activation-spi/src/java"/>
+ <sourcepath path="${basedir}/../activation/src/java"/>
<sourcepath path="${basedir}/../composition-spi/src/java"/>
<sourcepath path="${basedir}/../composition/src/java"/>
<sourcepath path="${basedir}/../assembly-spi/src/java"/>
@@ -284,7 +286,6 @@
<maven:reactor
basedir="${basedir}"
includes="*/project.xml,merlin-extensions/*/project.xml"
- excludes="activation*/*"
goals="clean"
banner="Cleaning subproject:"
ignoreFailures="false"/>
1.11 +120 -164
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultClassLoaderModel.java
Index: DefaultClassLoaderModel.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultClassLoaderModel.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DefaultClassLoaderModel.java 8 Jul 2003 17:48:53 -0000 1.10
+++ DefaultClassLoaderModel.java 9 Jul 2003 05:02:05 -0000 1.11
@@ -61,6 +61,7 @@
import java.net.URL;
import java.net.URLClassLoader;
+import org.apache.avalon.composition.model.ClassLoaderContext;
import org.apache.avalon.composition.model.ClassLoaderModel;
import org.apache.avalon.composition.model.SystemContext;
import org.apache.avalon.composition.model.TypeRepository;
@@ -78,11 +79,13 @@
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.meta.data.ContainmentProfile;
import org.apache.avalon.meta.data.ClassLoaderDirective;
import org.apache.avalon.meta.data.ClasspathDirective;
import org.apache.avalon.meta.data.RepositoryDirective;
import org.apache.avalon.meta.data.ResourceDirective;
+import org.apache.avalon.meta.data.Profile;
import org.apache.avalon.meta.info.DependencyDescriptor;
import org.apache.avalon.meta.info.ReferenceDescriptor;
import org.apache.avalon.meta.info.StageDescriptor;
@@ -117,7 +120,8 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
* @version $Revision$ $Date$
*/
-public class DefaultClassLoaderModel implements ClassLoaderModel
+public class DefaultClassLoaderModel extends AbstractLogEnabled
+ implements ClassLoaderModel
{
//==============================================================
// static
@@ -126,21 +130,24 @@
private static final Resources REZ =
ResourceManager.getPackageResources( DefaultClassLoaderModel.class );
+ public static ClassLoaderModel createClassLoaderModel(
+ ClassLoaderContext context ) throws ModelException
+ {
+ return new DefaultClassLoaderModel( context );
+ }
+
+
//==============================================================
// state
//==============================================================
- private final SystemContext m_system;
-
- private final ClassLoaderModel m_parent;
-
- private final String[] m_classpath;
+ private final ClassLoaderContext m_context;
private final ExtensionManager m_extension;
private final PackageManager m_manager;
- private final Logger m_logger;
+ private final String[] m_classpath;
private final OptionalPackage[] m_packages;
@@ -157,165 +164,100 @@
//==============================================================
/**
- * Creation of a root classloader model. The model associated a
- * repository, a base directory and a classloader directive
- * enabling the creation of a fully populated classpath.
- *
- * @param logger the assigned logging channel
- * @param system the system context
- * @param classloader the parent classloader
- * @param directive the classloader directive containing the
- * primative classpath entries and resource directives
- */
- protected DefaultClassLoaderModel(
- final Logger logger, final SystemContext system,
- ClassLoader classLoader, final ClassLoaderDirective directive )
- throws Exception
- {
- this( logger, system, classLoader, null, directive );
- }
-
- /**
* Creation of a new classloader model. The model associated a
* repository, a base directory and a classloader directive
* enabling the creation of a fully populated classpath.
*
- * @param logger the assigned logging channel
- * @param system the system context
- * @param classloader the parent classloader
- * @param parent the parent classloader model
- * @param directive the classloader directive containing the
- * primative classpath entries and resource directives
+ * @param context the classloader context
*/
- private DefaultClassLoaderModel(
- final Logger logger, final SystemContext system,
- ClassLoader classLoader, ClassLoaderModel parent, ClassLoaderDirective
directive )
- throws Exception
- {
- if( logger == null )
- {
- throw new NullPointerException( "logger" );
- }
- if( system == null )
- {
- throw new NullPointerException( "system" );
- }
- if( classLoader == null )
- {
- throw new NullPointerException( "classLoader" );
- }
- if( directive == null )
- {
- throw new NullPointerException( "directive" );
- }
+ public DefaultClassLoaderModel( ClassLoaderContext context )
+ throws ModelException
+ {
+ if( context == null )
+ {
+ throw new NullPointerException( "context" );
+ }
+
+ m_context = context;
+ enableLogging( context.getLogger() );
+ getLogger().debug( "base: " + context.getBaseDirectory() );
+
+ File base =
+ context.getBaseDirectory();
+ Repository repository =
+ context.getRepository();
+ ClassLoaderDirective directive =
+ context.getClassLoaderDirective();
+ ExtensionManager manager =
+ context.getExtensionManager();
- m_logger = logger;
- m_parent = parent;
- m_system = system;
-
- getLogger().debug( "base: " + system.getBaseDirectory() );
- getLogger().debug( "home: " + system.getHomeDirectory() );
- getLogger().debug( "temp: " + system.getTempDirectory() );
-
- if( parent != null )
- {
- DefaultExtensionManager local =
- new DefaultExtensionManager(
- directive.getLibrary().getOptionalExtensionDirectories(
- system.getBaseDirectory() ) );
- m_extension = new DelegatingExtensionManager(
- new ExtensionManager[]{ parent.getExtensionManager(), local } );
- }
- else
- {
- m_extension = new DefaultExtensionManager(
- directive.getLibrary().getOptionalExtensionDirectories(
- system.getBaseDirectory() ) );
- }
-
- m_manager = new PackageManager( m_extension );
-
- //
- // generate the primitive classpath
- //
-
- m_classpath = createClassPath( system, directive );
-
- StringBuffer buffer = new StringBuffer( "classpath: " );
- for( int i=0; i<m_classpath.length; i++ )
+ try
{
- if( i==0 )
+ if( manager != null )
{
- buffer.append( m_classpath[i] );
+ DefaultExtensionManager local =
+ new DefaultExtensionManager(
+ directive.getLibrary().getOptionalExtensionDirectories( base )
);
+ m_extension = new DelegatingExtensionManager(
+ new ExtensionManager[]{ manager, local } );
}
else
{
- buffer.append( ";" + m_classpath[i] );
+ m_extension = new DefaultExtensionManager(
+ directive.getLibrary().getOptionalExtensionDirectories( base ) );
}
- }
- getLogger().debug( buffer.toString() );
+ m_manager = new PackageManager( m_extension );
+ m_classpath = createClassPath( base, repository, directive );
+
+ if( getLogger().isDebugEnabled() )
+ {
+ StringBuffer buffer = new StringBuffer( "classpath: " );
+ for( int i=0; i<m_classpath.length; i++ )
+ {
+ if( i==0 )
+ {
+ buffer.append( m_classpath[i] );
+ }
+ else
+ {
+ buffer.append( ";" + m_classpath[i] );
+ }
+ }
+ getLogger().debug( buffer.toString() );
+ }
- if( parent != null )
- {
m_packages = buildOptionalPackages(
- m_classpath, parent.getOptionalPackages( true ) );
- }
- else
- {
- m_packages = buildOptionalPackages( m_classpath );
- }
+ m_classpath, context.getOptionalPackages() );
+ m_urls = buildQualifiedClassPath();
+ m_classLoader =
+ new URLClassLoader( m_urls, context.getClassLoader() );
+
+ //
+ // scan the classpath for component type and service
+ // definitions
+ //
+
+ ArrayList types = new ArrayList();
+ ArrayList services = new ArrayList();
+ Scanner scanner = new Scanner( m_classLoader );
+ scanner.enableLogging( getLogger().getChildLogger( "scanner" ) );
+ scanner.scan( m_urls, types, services );
+
+ //
+ // create the repository supporting type and service lookup
+ //
- m_urls = buildQualifiedClassPath();
- m_classLoader = new URLClassLoader( m_urls, classLoader );
-
-
- //
- // create a type repository
- //
-
- ArrayList types = new ArrayList();
- ArrayList services = new ArrayList();
- Scanner scanner = new Scanner( m_classLoader );
- scanner.enableLogging( logger.getChildLogger( "scanner" ) );
- scanner.scan( m_urls, types, services );
- Logger typeLogger = logger.getChildLogger( "types" );
- Logger serviceLogger = logger.getChildLogger( "services" );
- if( parent != null )
- {
+ Logger typeLogger = getLogger().getChildLogger( "types" );
m_types = new DefaultTypeRepository(
- typeLogger, m_classLoader, parent.getTypeRepository(), types );
+ typeLogger, m_classLoader, context.getTypeRepository(), types );
+ Logger serviceLogger = getLogger().getChildLogger( "services" );
m_services = new DefaultServiceRepository(
- serviceLogger, parent.getServiceRepository(), services );
- }
- else
- {
- m_types = new DefaultTypeRepository(
- typeLogger, m_classLoader, types );
- m_services = new DefaultServiceRepository(
- serviceLogger, services );
- }
- }
-
- /**
- * Create of a new classloader model as subsididary of this model
- * relative to a supplied containment profile.
- *
- * @param profile the containment profile
- * @return a new class loader model
- */
- public ClassLoaderModel createChild( ContainmentProfile profile ) throws
ModelException
- {
- try
- {
- final Logger logger = getLogger().getChildLogger( profile.getName() );
- ClassLoaderDirective directive = profile.getClassLoaderDirective();
- return new DefaultClassLoaderModel( logger, m_system, getClassLoader(),
this, directive );
+ serviceLogger, context.getServiceRepository(), services );
}
catch( Throwable e )
{
- final String error =
- REZ.getString( "classloader.child.creation.error", profile.getName()
);
+ final String error = "Could not create classloader.";
throw new ModelException( error, e );
}
}
@@ -325,6 +267,27 @@
//==============================================================
/**
+ * Creation of a classloader context using this model as the
+ * relative parent.
+ *
+ * @param profile the profile directive
+ * @return a new classloader context
+ */
+ public ClassLoaderContext createChildContext( ContainmentProfile profile )
+ {
+ Logger logger = getLogger().getChildLogger( profile.getName() );
+ Repository repository = m_context.getRepository();
+ File base = m_context.getBaseDirectory();
+ OptionalPackage[] packages = getOptionalPackages();
+ ClassLoaderDirective directive =
+ profile.getClassLoaderDirective();
+
+ return new DefaultClassLoaderContext(
+ logger, repository, base, m_classLoader, packages,
+ m_extension, m_types, m_services, directive );
+ }
+
+ /**
* Return the type repository managed by this containment
* context.
*
@@ -380,13 +343,10 @@
}
final ArrayList list = new ArrayList();
- if( m_parent != null )
+ OptionalPackage[] available = m_context.getOptionalPackages();
+ for( int i=0; i<available.length; i++ )
{
- OptionalPackage[] available = m_parent.getOptionalPackages( true );
- for( int i=0; i<available.length; i++ )
- {
- list.add( available[i] );
- }
+ list.add( available[i] );
}
for( int i=0; i<m_packages.length; i++ )
{
@@ -421,9 +381,9 @@
// private implementation
//==============================================================
- private Logger getLogger()
+ private String[] getClassPath()
{
- return m_logger;
+ return m_classpath;
}
/**
@@ -449,19 +409,14 @@
return (URL[]) list.toArray( new URL[0] );
}
- private String[] getClassPath()
- {
- return m_classpath;
- }
-
- private String[] createClassPath( SystemContext system, ClassLoaderDirective
directive )
+ private String[] createClassPath(
+ File base, Repository repository, ClassLoaderDirective directive )
throws Exception
{
ArrayList classpath = new ArrayList();
addToClassPath(
classpath,
- directive.getClasspathDirective().expandFileSetDirectives(
- system.getBaseDirectory() ) );
+ directive.getClasspathDirective().expandFileSetDirectives( base ) );
RepositoryDirective[] repositories =
directive.getClasspathDirective().getRepositoryDirectives();
@@ -473,7 +428,7 @@
ResourceDirective resource = resources[j];
String id = resource.getId();
String version = resource.getVersion();
- URL url = system.getRepository().getArtifact( id, version, "jar" );
+ URL url = repository.getArtifact( id, version, "jar" );
classpath.add( url.toString() );
}
}
@@ -490,7 +445,7 @@
* @exception Exception if a extension error occurs
*/
private OptionalPackage[] buildOptionalPackages( final String[] classPath )
- throws Exception
+ throws Exception
{
return buildOptionalPackages( classPath, new OptionalPackage[0] );
}
@@ -540,7 +495,8 @@
extension.getImplementationVersion(),
extension.getImplementationURL()
};
- final String entry = REZ.format(
"classloader.missing.extension.error", params );
+ final String entry = REZ.format(
+ "classloader.missing.extension.error", params );
buffer.append( "\n" + entry );
}
throw new ModelException( buffer.toString() );
1.2 +105 -28
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentContext.java
Index: DefaultContainmentContext.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultContainmentContext.java 8 Jul 2003 13:47:05 -0000 1.1
+++ DefaultContainmentContext.java 9 Jul 2003 05:02:05 -0000 1.2
@@ -55,10 +55,13 @@
import org.apache.avalon.composition.model.SystemContext;
import org.apache.avalon.composition.model.ContainmentContext;
+import org.apache.avalon.composition.model.ClassLoaderModel;
+import org.apache.avalon.composition.model.TypeRepository;
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
+import org.apache.avalon.meta.data.ContainmentProfile;
/**
@@ -81,16 +84,20 @@
// immutable state
//==============================================================
- private final SystemContext m_system;
-
private final File m_home;
private final File m_temp;
- private final ClassLoader m_classLoader;
+ private final ClassLoaderModel m_model;
private final Logger m_logger;
+ private final ContainmentProfile m_profile;
+
+ private final String m_partition;
+
+ private final SystemContext m_system;
+
//==============================================================
// constructor
//==============================================================
@@ -98,51 +105,89 @@
/**
* Creation of a new containment context.
*
- * @param system the system context
- * @param classLoader the containment classloader
+ * @param logger the logging channel to assign
+ * @param parent the parent containment model (null if this is
+ * a root containment context)
+ * @param model the classloader model
+ * @param home the directory for the container
+ * @param temp a temporary directory for the container
+ * @param profile the containment profile
+ * @param partition the partition that this containment
+ * context is established within
+ */
+ public DefaultContainmentContext(
+ Logger logger, SystemContext system, ClassLoaderModel model,
+ ContainmentProfile profile )
+ {
+ this( logger, system, model,
+ system.getHomeDirectory(), system.getTempDirectory(),
+ profile, null );
+ }
+
+ /**
+ * Creation of a new containment context.
+ *
+ * @param logger the logging channel to assign
+ * @param parent the parent containment model (null if this is
+ * a root containment context)
+ * @param model the classloader model
* @param home the directory for the container
* @param temp a temporary directory for the container
- * @param repository a resource repository to be used when resolving
- * resource directives
+ * @param profile the containment profile
+ * @param partition the partition that this containment
+ * context is established within
*/
public DefaultContainmentContext(
- Logger logger, SystemContext system, ClassLoader classLoader, File home, File
temp )
+ Logger logger, SystemContext system, ClassLoaderModel model,
+ File home, File temp, ContainmentProfile profile, String partition )
{
+ if( logger == null )
+ {
+ throw new NullPointerException( "logger" );
+ }
if( system == null )
{
throw new NullPointerException( "system" );
}
- if( classLoader == null )
+ if( model == null )
{
- throw new NullPointerException( "classLoader" );
+ throw new NullPointerException( "model" );
}
- if( logger == null )
+ if( home == null )
{
- throw new NullPointerException( "logger" );
+ throw new NullPointerException( "home" );
+ }
+ if( temp == null )
+ {
+ throw new NullPointerException( "temp" );
+ }
+ if( profile == null )
+ {
+ throw new NullPointerException( "profile" );
}
- /*
- if( !home.isDirectory() )
+ if( home.exists() && !home.isDirectory() )
{
final String error =
REZ.getString(
"containment.context.home.not-a-directory.error", home.toString() );
throw new IllegalArgumentException( error );
}
- if( !temp.isDirectory() )
+ if( temp.exists() && !temp.isDirectory() )
{
final String error =
REZ.getString(
"containment.context.temp.not-a-directory.error", temp.toString() );
throw new IllegalArgumentException( error );
}
- */
+ m_logger = logger;
+ m_system = system;
+ m_model = model;
m_home = home;
m_temp = temp;
- m_system = system;
- m_classLoader = classLoader;
- m_logger = logger;
+ m_profile = profile;
+ m_partition = partition;
}
//==============================================================
@@ -150,6 +195,27 @@
//==============================================================
/**
+ * Return the partition name that the container is
+ * established with.
+ *
+ * @return the partition name
+ */
+ public String getPartitionName()
+ {
+ return m_partition;
+ }
+
+ /**
+ * Return the logging channel.
+ *
+ * @return the containment models logging channel
+ */
+ public Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ /**
* Return the system context.
*
* @return the system context
@@ -182,22 +248,33 @@
}
/**
- * Return the containment classloader.
+ * Return the containment profile.
*
- * @return the classloader
+ * @return the containment profile
*/
- public ClassLoader getClassLoader()
+ public ContainmentProfile getContainmentProfile()
{
- return m_classLoader;
+ return m_profile;
}
/**
- * Return the system logging channel.
+ * Return the containment classloader model.
*
- * @return the system logging channel
+ * @return the classloader model
*/
- public Logger getLogger()
+ public ClassLoaderModel getClassLoaderModel()
{
- return m_logger;
+ return m_model;
+ }
+
+ /**
+ * Return the containment classloader. This method is a
+ * convinience operation equivalent to getClassLoaderModel().getClassLoader();
+ *
+ * @return the classloader
+ */
+ public ClassLoader getClassLoader()
+ {
+ return m_model.getClassLoader();
}
}
1.10 +101 -96
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
Index: DefaultContainmentModel.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DefaultContainmentModel.java 8 Jul 2003 13:47:05 -0000 1.9
+++ DefaultContainmentModel.java 9 Jul 2003 05:02:05 -0000 1.10
@@ -57,6 +57,7 @@
import java.util.List;
import java.util.ArrayList;
+import org.apache.avalon.composition.model.ClassLoaderContext;
import org.apache.avalon.composition.model.ClassLoaderModel;
import org.apache.avalon.composition.model.ContainmentModel;
import org.apache.avalon.composition.model.ContainmentContext;
@@ -72,8 +73,8 @@
import org.apache.avalon.meta.data.DeploymentProfile;
import org.apache.avalon.meta.data.Profile;
import org.apache.avalon.meta.data.ServiceDirective;
-import org.apache.avalon.meta.info.ServiceDescriptor;
import org.apache.avalon.meta.info.DependencyDescriptor;
+import org.apache.avalon.meta.info.ServiceDescriptor;
import org.apache.avalon.meta.info.StageDescriptor;
import org.apache.avalon.meta.info.Type;
@@ -95,6 +96,30 @@
private static final Resources REZ =
ResourceManager.getPackageResources( DefaultContainmentModel.class );
+ private static String getName( ContainmentContext context )
+ {
+ if( context.getPartitionName() == null )
+ {
+ return "";
+ }
+ else
+ {
+ return context.getContainmentProfile().getName();
+ }
+ }
+
+ private static String getPath( ContainmentContext context )
+ {
+ if( context.getPartitionName() == null )
+ {
+ return SEPERATOR;
+ }
+ else
+ {
+ return context.getPartitionName();
+ }
+ }
+
//==============================================================
// state
//==============================================================
@@ -103,10 +128,6 @@
private String m_partition;
- private final ContainmentProfile m_profile;
-
- private final ClassLoaderModel m_classLoaderModel;
-
private final List m_models = new ArrayList();
//==============================================================
@@ -114,63 +135,29 @@
//==============================================================
/**
- * Creation of a new root containment model. The model associated a
- * repository, a base directory and a containment directive
- * enabling the creation of a fully populated containment
- * scenario.
+ * Creation of a new containment model.
*
- * @param base the base directory from which relative references
- * shall be resolved
- * @param repository a local cache of jar files addressable
- * relative to group/name/version identifiers
- * @param profile the composition profile
- */
- public DefaultContainmentModel(
- final ContainmentContext context, ClassLoaderModel classLoaderModel,
- ContainmentProfile profile )
- throws Exception
- {
- super( context.getLogger(), SEPERATOR, "", profile.getMode() );
- m_partition = SEPERATOR;
- m_profile = profile;
- m_context = context;
- m_classLoaderModel = classLoaderModel;
- expandContainmentModel();
- }
-
- /**
- * Creation of a new containment model. The model associated a
- * repository, a base directory and a containment directive
- * enabling the creation of a fully populated containment
- * scenario.
- *
- * @param base the base directory from which relative references
- * shall be resolved
- * @param repository a local cache of jar files addressable
- * relative to group/name/version identifiers
- * @param directive the containment profile
- */
- public DefaultContainmentModel(
- final ContainmentContext context, ContainmentModel parent,
- ClassLoaderModel classLoaderModel, ContainmentProfile profile )
- throws Exception
- {
- super(
- context.getLogger(), parent.getPartition(),
- profile.getName(), profile.getMode() );
+ * @param context the containment context that establishes
+ * the structural association of this containment model
+ * within a parent scope
+ */
+ public DefaultContainmentModel( final ContainmentContext context )
+ throws ModelException
+ {
+ super( context.getLogger(), getPath( context ), getName( context ),
+ context.getContainmentProfile().getMode() );
- m_profile = profile;
m_context = context;
- m_classLoaderModel = classLoaderModel;
-
- m_partition = getPath() + getName() + SEPERATOR;
- expandContainmentModel();
- }
+ if( context.getPartitionName() == null )
+ {
+ m_partition = SEPERATOR;
+ }
+ else
+ {
+ m_partition = getPath() + getName() + SEPERATOR;
+ }
- private void expandContainmentModel()
- throws ModelException
- {
- Profile[] profiles = m_profile.getProfiles();
+ Profile[] profiles = context.getContainmentProfile().getProfiles();
for( int i=0; i<profiles.length; i++ )
{
Profile profile = profiles[i];
@@ -186,6 +173,11 @@
}
else
{
+ //
+ // TODO: establish the mechanisms for the declaration
+ // of a custom profile handler.
+ //
+
final String error =
REZ.getString(
"containment.unknown-profile-class.error",
@@ -201,6 +193,16 @@
//==============================================================
/**
+ * Return the classloader model.
+ *
+ * @return the classloader model
+ */
+ public ClassLoaderModel getClassLoaderModel()
+ {
+ return m_context.getClassLoaderModel();
+ }
+
+ /**
* Return the set of services produced by the model.
* @return the services
*/
@@ -216,7 +218,12 @@
*/
public boolean isaCandidate( DependencyDescriptor dependency )
{
- return false;
+ //
+ // TODO: implementation - needs to check the request
+ // egainst the set of exported services.
+ //
+
+ return false;
}
/**
@@ -226,6 +233,11 @@
*/
public boolean isaCandidate( StageDescriptor stage )
{
+ //
+ // TODO-LATER: requires declaration of extension handling
+ // export within the container meta-data
+ //
+
return false;
}
@@ -235,7 +247,7 @@
*/
public DependencyDescriptor[] getDependencies()
{
- return m_profile.getDependencies();
+ return m_context.getContainmentProfile().getDependencies();
}
//==============================================================
@@ -258,20 +270,25 @@
try
{
-
- ClassLoader classLoader = m_classLoaderModel.getClassLoader();
+ ClassLoader classLoader = m_context.getClassLoader();
Class base = classLoader.loadClass( profile.getClassname() );
- Type type = m_classLoaderModel.getTypeRepository().getType( base );
-
+ Type type =
+ m_context.getClassLoaderModel().getTypeRepository().getType( base );
+ final File home = new File( m_context.getHomeDirectory(), name );
+ final File temp = new File( m_context.getTempDirectory(), name );
DefaultDeploymentContext context =
new DefaultDeploymentContext(
- logger, m_context, profile, type, base,
- new File( m_context.getHomeDirectory(), name ),
- new File( m_context.getTempDirectory(), name ),
- partition );
+ logger, m_context, profile, type, base, home, temp, partition );
+
+ //
+ // TODO: lookup the profile for a factory declaration, then
+ // use the factory to create the model using the context as
+ // the argument.
+ //
final DeploymentModel model = new DefaultDeploymentModel( context );
m_models.add( model );
+
return model;
}
catch( Throwable e )
@@ -297,26 +314,32 @@
{
final String name = profile.getName();
final String partition = getPartition();
- final Logger logger = getLogger().getChildLogger( profile.getName() );
+ final Logger logger = getLogger().getChildLogger( name );
try
{
+ ClassLoaderContext cntx =
+ m_context.getClassLoaderModel().createChildContext( profile );
final ClassLoaderModel classLoaderModel =
- m_classLoaderModel.createChild( profile );
- final ClassLoader classLoader = classLoaderModel.getClassLoader();
- final SystemContext system = m_context.getSystemContext();
+ DefaultClassLoaderModel.createClassLoaderModel( cntx );
final File home = new File( m_context.getHomeDirectory(), name );
final File temp = new File( m_context.getTempDirectory(), name );
DefaultContainmentContext context =
new DefaultContainmentContext(
- logger, system, classLoader, home, temp );
+ logger, m_context.getSystemContext(),
+ classLoaderModel, home, temp, profile, getPartition() );
- final ContainmentModel model =
- new DefaultContainmentModel(
- context, this, classLoaderModel, profile );
+ //
+ // TODO: lookup the profile for a factory declaration, then
+ // use the factory to create the model using the context as
+ // the argument.
+ //
+ final ContainmentModel model =
+ new DefaultContainmentModel( context );
m_models.add( model );
+
return model;
}
catch( Throwable e )
@@ -340,24 +363,6 @@
}
/**
- * Return the classloader model.
- * @return the classloader model
- */
- public ContainmentContext getContainmentContext()
- {
- return m_context;
- }
-
- /**
- * Return the classloader model.
- * @return the classloader model
- */
- public ClassLoaderModel getClassLoaderModel()
- {
- return m_classLoaderModel;
- }
-
- /**
* Return the set of models nested within this model.
* @return the nested model
*/
@@ -376,7 +381,7 @@
*/
private ServiceDirective[] getServiceDirectives()
{
- return m_profile.getServiceDirectives();
+ return m_context.getContainmentProfile().getServiceDirectives();
}
public String toString()
1.2 +8 -9
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentContext.java
Index: DefaultDeploymentContext.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultDeploymentContext.java 8 Jul 2003 13:47:06 -0000 1.1
+++ DefaultDeploymentContext.java 9 Jul 2003 05:02:05 -0000 1.2
@@ -53,6 +53,7 @@
import java.io.File;
import java.util.Map;
+import org.apache.avalon.composition.model.SystemContext;
import org.apache.avalon.composition.model.ContainmentContext;
import org.apache.avalon.composition.model.DeploymentContext;
import org.apache.avalon.framework.context.DefaultContext;
@@ -140,20 +141,18 @@
throw new NullPointerException( "partition" );
}
- /*
- if( !home.isDirectory() )
+ if( home.exists() && !home.isDirectory() )
{
final String error =
REZ.getString( "deployment.context.home.not-a-directory.error", home
);
throw new IllegalArgumentException( error );
}
- if( !temp.isDirectory() )
+ if( temp.exists() && !temp.isDirectory() )
{
final String error =
REZ.getString( "deployment.context.temp.not-a-directory.error", temp
);
throw new IllegalArgumentException( error );
}
- */
m_home = home;
m_temp = temp;
@@ -180,13 +179,13 @@
}
/**
- * Return the containment context.
+ * Return the system context.
*
- * @return the containment context
+ * @return the system context
*/
- public ContainmentContext getContainmentContext()
+ public SystemContext getSystemContext()
{
- return m_context;
+ return m_context.getSystemContext();
}
/**
1.10 +4 -3
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java
Index: DefaultDeploymentModel.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DefaultDeploymentModel.java 8 Jul 2003 13:47:06 -0000 1.9
+++ DefaultDeploymentModel.java 9 Jul 2003 05:02:05 -0000 1.10
@@ -61,6 +61,7 @@
import org.apache.avalon.composition.model.DeploymentModel;
import org.apache.avalon.composition.model.DeploymentContext;
import org.apache.avalon.composition.model.ClassLoaderModel;
+import org.apache.avalon.composition.model.ModelException;
import org.apache.avalon.composition.model.SystemContext;
import org.apache.avalon.composition.repository.Repository;
import org.apache.avalon.excalibur.i18n.ResourceManager;
@@ -133,7 +134,7 @@
* @param path the partition name
*/
public DefaultDeploymentModel( DeploymentContext context )
- throws Exception
+ throws ModelException
{
super(
context.getLogger(),
@@ -183,7 +184,7 @@
m_context.getProfile().getContext();
final Logger log = getLogger().getChildLogger( "context" );
final SystemContext system =
- m_context.getContainmentContext().getSystemContext();
+ m_context.getSystemContext();
m_contextModel = new DefaultContextModel(
log, contextDescriptor, contextDirective,
1.5 +1 -2
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultModel.java
Index: DefaultModel.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultModel.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultModel.java 7 Jul 2003 08:31:18 -0000 1.4
+++ DefaultModel.java 9 Jul 2003 05:02:05 -0000 1.5
@@ -97,7 +97,6 @@
*/
public DefaultModel(
final Logger logger, String path, final String name, Mode mode )
- throws Exception
{
m_logger = logger;
m_name = name;
1.2 +35 -44
avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultModelFactory.java
Index: DefaultModelFactory.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition/src/java/org/apache/avalon/composition/model/impl/DefaultModelFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultModelFactory.java 8 Jul 2003 13:47:06 -0000 1.1
+++ DefaultModelFactory.java 9 Jul 2003 05:02:05 -0000 1.2
@@ -53,14 +53,18 @@
import java.io.File;
import org.apache.avalon.composition.model.ClassLoaderModel;
+import org.apache.avalon.composition.model.ClassLoaderContext;
import org.apache.avalon.composition.model.ContainmentModel;
import org.apache.avalon.composition.model.ContainmentContext;
+import org.apache.avalon.composition.model.DeploymentContext;
+import org.apache.avalon.composition.model.DeploymentModel;
import org.apache.avalon.composition.model.ModelFactory;
import org.apache.avalon.composition.model.ModelException;
import org.apache.avalon.composition.model.SystemContext;
import org.apache.avalon.composition.repository.Repository;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
+import org.apache.avalon.extension.manager.OptionalPackage;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.meta.data.ContainmentProfile;
@@ -139,23 +143,25 @@
try
{
+ Repository repository = m_system.getRepository();
+ File base = m_system.getBaseDirectory();
ClassLoader root = ClassLoader.getSystemClassLoader();
-
ClassLoaderDirective classLoaderDirective =
profile.getClassLoaderDirective();
+
+ ClassLoaderContext classLoaderContext =
+ new DefaultClassLoaderContext(
+ logger, repository, base, root,
+ classLoaderDirective );
+
ClassLoaderModel classLoaderModel =
- new DefaultClassLoaderModel(
- logger, m_system, root, classLoaderDirective );
+ new DefaultClassLoaderModel( classLoaderContext );
DefaultContainmentContext context =
new DefaultContainmentContext(
- logger, m_system,
- classLoaderModel.getClassLoader(),
- m_system.getHomeDirectory(),
- m_system.getTempDirectory() );
+ logger, m_system, classLoaderModel, profile );
- return new DefaultContainmentModel(
- context, classLoaderModel, profile );
+ return createContainmentModel( context );
}
catch( Throwable e )
{
@@ -166,46 +172,31 @@
}
/**
- * Creation of a new nested containment model.
+ * Creation of a new nested containment model. This method is called
+ * by a container implementation when constructing model instances. The
+ * factory is identified by its implementation classname.
*
- * @param parent the containment model into which the new
- * containment model is to be added
- * @param profile the containment profile
+ * @param context a potentially foreign containment context
* @return the containment model
*/
- public ContainmentModel createContainmentModel(
- final ContainmentModel parent, ContainmentProfile profile )
+ public ContainmentModel createContainmentModel( ContainmentContext context )
throws ModelException
{
- throw new IllegalStateException( "I'm not implmented" );
-
- /*
- Logger logger = getLogger().getChildLogger( profile.getName() );
- final String name = profile.getName();
-
- try
- {
- ClassLoaderModel classLoaderModel =
- parent.getClassLoaderModel().createChild( profile );
- ClassLoader classLoader = classLoaderModel.getClassLoader();
- ContainmentContext parentContext = parent.getContainmentContext();
- SystemContext system = parentContext.getSystemContext();
- final File home = new File( parentContext.getHomeDirectory(), name );
- final File temp = new File( parentContext.getTempDirectory(), name );
+ return new DefaultContainmentModel( context );
+ }
- DefaultContainmentContext context =
- new DefaultContainmentContext(
- logger, system, classLoader, home, temp );
- return new DefaultContainmentModel(
- context, parent, classLoaderModel, profile );
- }
- catch( Throwable e )
- {
- final String error =
- REZ.getString( "factory.containment.create.error", profile.getName()
);
- throw new ModelException( error, e );
- }
- */
+ /**
+ * Creation of a new nested deployment model. This method is called
+ * by a container implementation when constructing model instances. The
+ * factory is identified by its implementation classname.
+ *
+ * @param context a potentially foreign deployment context
+ * @return the deployment model
+ */
+ public DeploymentModel createDeploymentModel( DeploymentContext context )
+ throws ModelException
+ {
+ return new DefaultDeploymentModel( context );
}
}
1.6 +6 -8
avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ClassLoaderModel.java
Index: ClassLoaderModel.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ClassLoaderModel.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ClassLoaderModel.java 7 Jul 2003 18:45:35 -0000 1.5
+++ ClassLoaderModel.java 9 Jul 2003 05:02:06 -0000 1.6
@@ -66,6 +66,7 @@
*/
public interface ClassLoaderModel
{
+
/**
* Return the classloader model type repository.
*
@@ -125,14 +126,11 @@
ClassLoader getClassLoader();
/**
- * Create of a new classloader model as subsididary of this model
- * relative to a supplied containment profile.
+ * Creation of a classloader context using this model as the
+ * relative parent.
*
* @param profile the containment profile
- * @return a new class loader model
- * @exception ModelException if an error occurs during model establishment
+ * @return a new classloader context
*/
- ClassLoaderModel createChild( ContainmentProfile profile )
- throws ModelException;
-
+ ClassLoaderContext createChildContext( ContainmentProfile profile );
}
1.2 +31 -7
avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ContainmentContext.java
Index: ContainmentContext.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ContainmentContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ContainmentContext.java 8 Jul 2003 13:45:10 -0000 1.1
+++ ContainmentContext.java 9 Jul 2003 05:02:06 -0000 1.2
@@ -54,6 +54,7 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.meta.data.ContainmentProfile;
/**
* Defintion of a working context.
@@ -64,6 +65,13 @@
public interface ContainmentContext extends Context
{
/**
+ * Return the logging channel.
+ *
+ * @return the logging channel
+ */
+ Logger getLogger();
+
+ /**
* Return the system context.
*
* @return the system context
@@ -71,6 +79,13 @@
SystemContext getSystemContext();
/**
+ * Return the classloader model.
+ *
+ * @return the type manager assigned to the containment model.
+ */
+ ClassLoaderModel getClassLoaderModel();
+
+ /**
* Return the working directory for a container.
*
* @return the working directory
@@ -85,17 +100,26 @@
File getTempDirectory();
/**
- * Return the containment classloader.
+ * Return the containment profile.
*
- * @return the classloader
+ * @return the containment profile
*/
- ClassLoader getClassLoader();
+ ContainmentProfile getContainmentProfile();
/**
- * Return the logging channel.
+ * Return the partition name that the container is
+ * established with.
*
- * @return the logging channel
+ * @return the partition name
*/
- Logger getLogger();
+ String getPartitionName();
+
+ /**
+ * Return the containment classloader.
+ *
+ * @return the classloader model
+ */
+ ClassLoader getClassLoader();
+
}
1.8 +10 -3
avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ContainmentModel.java
Index: ContainmentModel.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ContainmentModel.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ContainmentModel.java 8 Jul 2003 13:45:10 -0000 1.7
+++ ContainmentModel.java 9 Jul 2003 05:02:06 -0000 1.8
@@ -75,8 +75,7 @@
String getPartition();
/**
- * Return the classloader model assigned to this
- * containment model.
+ * Return the classloader model.
*
* @return the classloader model
*/
@@ -99,6 +98,10 @@
DeploymentModel addDeploymentProfile( DeploymentProfile profile )
throws ModelException;
+ // TODO: replaceDeploymentProfile
+
+ // TODO: removeDeploymentProfile
+
/**
* Addition of a new instance of a containment model within
* this containment context.
@@ -109,4 +112,8 @@
*/
ContainmentModel addContainmentProfile( ContainmentProfile profile )
throws ModelException;
+
+ // TODO: replaceContainmentProfile
+
+ // TODO: removeContainmentProfile
}
1.2 +2 -2
avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/DeploymentContext.java
Index: DeploymentContext.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/DeploymentContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeploymentContext.java 8 Jul 2003 13:45:10 -0000 1.1
+++ DeploymentContext.java 9 Jul 2003 05:02:06 -0000 1.2
@@ -77,7 +77,7 @@
*
* @return the system context
*/
- ContainmentContext getContainmentContext();
+ SystemContext getSystemContext();
/**
* Return the working directory for the component.
1.2 +18 -8
avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ModelFactory.java
Index: ModelFactory.java
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/ModelFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ModelFactory.java 8 Jul 2003 13:45:10 -0000 1.1
+++ ModelFactory.java 9 Jul 2003 05:02:06 -0000 1.2
@@ -74,15 +74,25 @@
throws ModelException;
/**
- * Creation of a new nested containment model.
+ * Creation of a new nested containment model. This method is called
+ * by a container implementation when constructing model instances. The
+ * factory is identified by its implementation classname.
*
- * @param parent the containment model into which the new
- * containment model is to be added
- * @param profile the containment profile
+ * @param context a potentially foreign containment context
* @return the containment model
- * @exception ModelException if an error occurs during model establishment
*/
- public ContainmentModel createContainmentModel(
- final ContainmentModel parent, ContainmentProfile profile )
+ ContainmentModel createContainmentModel( ContainmentContext context )
throws ModelException;
+
+ /**
+ * Creation of a new nested deployment model. This method is called
+ * by a container implementation when constructing model instances. The
+ * factory is identified by its implementation classname.
+ *
+ * @param context a potentially foreign deployment context
+ * @return the deployment model
+ */
+ DeploymentModel createDeploymentModel( DeploymentContext context )
+ throws ModelException;
+
}
1.2 +3 -6
avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/package.html
Index: package.html
===================================================================
RCS file:
/home/cvs/avalon-sandbox/merlin/composition-spi/src/java/org/apache/avalon/composition/model/package.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- package.html 4 Jul 2003 07:28:20 -0000 1.1
+++ package.html 9 Jul 2003 05:02:06 -0000 1.2
@@ -1,9 +1,6 @@
<body>
<p>
-The <code>repository</code> package contains the
[EMAIL PROTECTED] org.apache.avalon.composition.repository.Repository} interface
which
-defines the contract for a resource repository where resources
-references can be established based on group, name, type and version
-attributes.
-</p>
+The <code>model</code> package is resonsible for the population of the containment
information model taking into account criteria expressed under meta-info and
directives expressed under meta-data in conjunction with the runtime environment.</p>
+</source>
+
</body>
1.8 +15 -0 avalon-sandbox/merlin/merlin-platform/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/avalon-sandbox/merlin/merlin-platform/project.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- project.xml 4 Jul 2003 07:36:22 -0000 1.7
+++ project.xml 9 Jul 2003 05:02:06 -0000 1.8
@@ -27,6 +27,17 @@
<dependency>
<groupId>avalon</groupId>
+ <artifactId>avalon-activation-spi</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>avalon</groupId>
+ <artifactId>avalon-activation</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>avalon</groupId>
<artifactId>avalon-composition-spi</artifactId>
<version>1.0</version>
</dependency>
@@ -127,6 +138,10 @@
<packageGroup>
<title>Avalon Assembly Framework</title>
<packages>org.apache.avalon.assembly.*</packages>
+ </packageGroup>
+ <packageGroup>
+ <title>Avalon Activation Framework</title>
+ <packages>org.apache.avalon.activation.*</packages>
</packageGroup>
<packageGroup>
<title>Avalon Composition Framework</title>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]