mcconnell 2004/01/04 12:19:27
Modified: merlin/composition/api/src/java/org/apache/avalon/composition/model
Tag: Ver_3_4 ComponentContext.java
ContainmentContext.java ContainmentModel.java
Model.java
merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl
Tag: Ver_3_4 DefaultComponentContext.java
DefaultComponentModel.java
DefaultContainmentContext.java
DefaultContainmentModel.java
DefaultContextModel.java DefaultDependent.java
DefaultModel.java
merlin/composition/impl/src/test/org/apache/avalon/composition/model
Tag: Ver_3_4 AbstractTestCase.java
Log:
Refactoring of ComponentContext and ContainmentContext to derive from
DeploymentContext.
Revision Changes Path
No revision
No revision
1.1.2.2 +2 -23
avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/Attic/ComponentContext.java
Index: ComponentContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/Attic/ComponentContext.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- ComponentContext.java 4 Jan 2004 17:23:16 -0000 1.1.2.1
+++ ComponentContext.java 4 Jan 2004 20:19:27 -0000 1.1.2.2
@@ -64,7 +64,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
* @version $Revision$ $Date$
*/
-public interface ComponentContext
+public interface ComponentContext extends DeploymentContext
{
/**
* The standard context entry key for the partition name.
@@ -92,20 +92,6 @@
static final String TEMP_KEY = ContextDescriptor.TEMP_KEY;
/**
- * Return the partition name that the component will execute within.
- *
- * @return the partition name
- */
- String getPartitionName();
-
- /**
- * Return the name that the component will execute under.
- *
- * @return the name
- */
- String getName();
-
- /**
* Return the system context.
*
* @return the system context
@@ -132,13 +118,6 @@
* @return the temporary directory
*/
File getTempDirectory();
-
- /**
- * Return the logging channel assignable to the deployment model.
- *
- * @return the logging channel
- */
- Logger getLogger();
/**
* Return the deployment profile.
1.1.1.1.2.3 +2 -32
avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentContext.java
Index: ContainmentContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentContext.java,v
retrieving revision 1.1.1.1.2.2
retrieving revision 1.1.1.1.2.3
diff -u -r1.1.1.1.2.2 -r1.1.1.1.2.3
--- ContainmentContext.java 3 Jan 2004 22:08:21 -0000 1.1.1.1.2.2
+++ ContainmentContext.java 4 Jan 2004 20:19:27 -0000 1.1.1.1.2.3
@@ -62,16 +62,9 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
* @version $Revision$ $Date$
*/
-public interface ContainmentContext extends Context
+public interface ContainmentContext extends DeploymentContext
{
/**
- * Return the logging channel.
- *
- * @return the logging channel
- */
- Logger getLogger();
-
- /**
* Return the system context.
*
* @return the system context
@@ -107,21 +100,6 @@
ContainmentProfile getContainmentProfile();
/**
- * Return the name that the container has been assigned.
- *
- * @return the container name
- */
- String getName();
-
- /**
- * Return the partition name that the container is
- * established with.
- *
- * @return the partition name
- */
- String getPartitionName();
-
- /**
* Return the containment classloader.
*
* @return the classloader model
@@ -135,12 +113,4 @@
* @return the model repository
*/
ModelRepository getModelRepository();
-
-
- /**
- * Return the model dependency graph.
- *
- * @return the dependency graph
- */
- DependencyGraph getDependencyGraph();
}
1.9.2.4 +1 -3
avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentModel.java
Index: ContainmentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/ContainmentModel.java,v
retrieving revision 1.9.2.3
retrieving revision 1.9.2.4
diff -u -r1.9.2.3 -r1.9.2.4
--- ContainmentModel.java 4 Jan 2004 17:23:16 -0000 1.9.2.3
+++ ContainmentModel.java 4 Jan 2004 20:19:27 -0000 1.9.2.4
@@ -70,8 +70,6 @@
*/
public interface ContainmentModel extends Model
{
- public static String SEPERATOR = "/";
-
/**
* Get the startup sequence for the model.
*/
1.1.1.1.2.2 +2 -4
avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/Model.java
Index: Model.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/api/src/java/org/apache/avalon/composition/model/Model.java,v
retrieving revision 1.1.1.1.2.1
retrieving revision 1.1.1.1.2.2
diff -u -r1.1.1.1.2.1 -r1.1.1.1.2.2
--- Model.java 4 Jan 2004 17:23:16 -0000 1.1.1.1.2.1
+++ Model.java 4 Jan 2004 20:19:27 -0000 1.1.1.1.2.2
@@ -63,9 +63,7 @@
*/
public interface Model
{
- //-----------------------------------------------------------
- // model features
- //-----------------------------------------------------------
+ String SEPERATOR = "/"; // ## fix me
/**
* Return the name of the model.
No revision
No revision
1.1.2.2 +13 -51
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultComponentContext.java
Index: DefaultComponentContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultComponentContext.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- DefaultComponentContext.java 4 Jan 2004 17:23:16 -0000 1.1.2.1
+++ DefaultComponentContext.java 4 Jan 2004 20:19:27 -0000 1.1.2.2
@@ -70,12 +70,14 @@
/**
- * Default implementation of a deployment context.
+ * Default implementation of a deployment context that is used
+ * as the primary constructor argument when creating a new component
+ * model.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
* @version $Revision$ $Date$
*/
-public class DefaultComponentContext extends DefaultContext
+public class DefaultComponentContext extends DefaultDeploymentContext
implements ComponentContext
{
//==============================================================
@@ -89,8 +91,6 @@
// immutable state
//==============================================================
- private final String m_name;
-
private final ContainmentContext m_context;
private final DeploymentProfile m_profile;
@@ -103,10 +103,6 @@
private final File m_temp;
- private final Logger m_logger;
-
- private final String m_partition;
-
/**
* Map containing context entry models
* keyed by entry key.
@@ -136,13 +132,17 @@
DeploymentProfile profile, Type type, Class clazz,
File home, File temp, String partition )
{
- if( context == null )
+ super(
+ logger, partition, name, profile.getMode(),
+ context.getDependencyGraph() );
+
+ if( partition == null )
{
- throw new NullPointerException( "context" );
+ throw new NullPointerException( "partition" );
}
- if( logger == null )
+ if( context == null )
{
- throw new NullPointerException( "logger" );
+ throw new NullPointerException( "context" );
}
if( clazz == null )
{
@@ -156,10 +156,6 @@
{
throw new NullPointerException( "profile" );
}
- if( partition == null )
- {
- throw new NullPointerException( "partition" );
- }
if( home.exists() && !home.isDirectory() )
{
@@ -174,16 +170,12 @@
throw new IllegalArgumentException( error );
}
- m_name = name;
m_home = home;
m_temp = temp;
m_context = context;
m_type = type;
- m_logger = logger;
m_profile = profile;
- m_partition = partition;
m_class = clazz;
-
}
//==============================================================
@@ -191,26 +183,6 @@
//==============================================================
/**
- * Return the partition name that the component will execute within.
- *
- * @return the partition name
- */
- public String getPartitionName()
- {
- return m_partition;
- }
-
- /**
- * Return the name that the component will execute under.
- *
- * @return the name
- */
- public String getName()
- {
- return m_name;
- }
-
- /**
* Return the system context.
*
* @return the system context
@@ -248,16 +220,6 @@
public File getTempDirectory()
{
return m_temp;
- }
-
- /**
- * Return the logging channel.
- *
- * @return the logging channel
- */
- public Logger getLogger()
- {
- return m_logger;
}
/**
1.1.2.2 +2 -7
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultComponentModel.java
Index: DefaultComponentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultComponentModel.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- DefaultComponentModel.java 4 Jan 2004 17:23:16 -0000 1.1.2.1
+++ DefaultComponentModel.java 4 Jan 2004 20:19:27 -0000 1.1.2.2
@@ -149,12 +149,7 @@
public DefaultComponentModel( ComponentContext context )
throws ModelException
{
- super(
- context.getLogger(),
- context.getPartitionName(),
- context.getProfile().getName(),
- context.getProfile().getMode(),
- context.getContainmentContext().getDependencyGraph() );
+ super( context );
m_context = context;
m_activation = m_context.getProfile().getActivationPolicy();
1.2.2.3 +15 -70
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentContext.java
Index: DefaultContainmentContext.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentContext.java,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -r1.2.2.2 -r1.2.2.3
--- DefaultContainmentContext.java 3 Jan 2004 22:08:21 -0000 1.2.2.2
+++ DefaultContainmentContext.java 4 Jan 2004 20:19:27 -0000 1.2.2.3
@@ -65,24 +65,24 @@
/**
- * Implementation of a system context that exposes a system wide set of parameters.
+ * Implementation of a containment supplied to a containment model.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
* @version $Revision$ $Date$
*/
-public class DefaultContainmentContext extends DefaultContext
+public class DefaultContainmentContext extends DefaultDeploymentContext
implements ContainmentContext
{
- //==============================================================
+ //---------------------------------------------------------
// static
- //==============================================================
+ //---------------------------------------------------------
private static final Resources REZ =
ResourceManager.getPackageResources( DefaultContainmentContext.class );
- //==============================================================
+ //---------------------------------------------------------
// immutable state
- //==============================================================
+ //---------------------------------------------------------
private final File m_home;
@@ -90,26 +90,18 @@
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;
- private final String m_name;
-
private final ModelRepository m_repository;
- private final DependencyGraph m_graph;
-
- //==============================================================
+ //---------------------------------------------------------
// constructor
- //==============================================================
+ //---------------------------------------------------------
/**
- * Creation of a new containment context.
+ * Creation of a new root containment context.
*
* @param logger the logging channel to assign
* @param system the system context
@@ -147,10 +139,8 @@
ModelRepository repository, DependencyGraph graph,
File home, File temp, ContainmentProfile profile, String partition, String
name )
{
- if( logger == null )
- {
- throw new NullPointerException( "logger" );
- }
+ super( logger, partition, name, profile.getMode(), graph );
+
if( system == null )
{
throw new NullPointerException( "system" );
@@ -187,53 +177,18 @@
throw new IllegalArgumentException( error );
}
-
- m_graph = new DependencyGraph( graph );
m_repository = new DefaultModelRepository( repository, logger );
- m_logger = logger;
+
m_system = system;
m_model = model;
m_home = home;
m_temp = temp;
m_profile = profile;
- m_partition = partition;
- m_name = name;
}
- //==============================================================
+ //---------------------------------------------------------
// ContainmentContext
- //==============================================================
-
- /**
- * Return the name that the container has been assigned.
- *
- * @return the container name
- */
- public String getName()
- {
- return m_name;
- }
-
- /**
- * 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.
@@ -307,15 +262,5 @@
public ClassLoader getClassLoader()
{
return m_model.getClassLoader();
- }
-
- /**
- * Return the model dependency graph.
- *
- * @return the dependency graph
- */
- public DependencyGraph getDependencyGraph()
- {
- return m_graph;
}
}
1.13.2.8 +55 -30
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
Index: DefaultContainmentModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java,v
retrieving revision 1.13.2.7
retrieving revision 1.13.2.8
diff -u -r1.13.2.7 -r1.13.2.8
--- DefaultContainmentModel.java 4 Jan 2004 17:23:16 -0000 1.13.2.7
+++ DefaultContainmentModel.java 4 Jan 2004 20:19:27 -0000 1.13.2.8
@@ -157,9 +157,6 @@
private final Map m_models = new Hashtable();
- /**
- * The assigned logging categories.
- */
private CategoriesDirective m_categories;
private final LinkedList m_compositionListeners = new LinkedList();
@@ -180,17 +177,19 @@
public DefaultContainmentModel( final ContainmentContext context )
throws ModelException
{
- super( context.getLogger(), getPath( context ), context.getName(),
- context.getContainmentProfile().getMode(), context.getDependencyGraph() );
+ super( context );
m_context = context;
- if( context.getPartitionName() == null )
+
+ if( null == context.getPartitionName() )
{
- m_partition = SEPERATOR;
+ m_partition = Model.SEPERATOR;
}
else
{
- m_partition = getPath() + getName() + SEPERATOR;
+ m_partition = context.getPartitionName()
+ + context.getName()
+ + Model.SEPERATOR;
}
Profile[] profiles = context.getContainmentProfile().getProfiles();
@@ -583,8 +582,10 @@
private ComponentModel createComponentModel( final DeploymentProfile profile )
throws ModelException
{
- if( null == profile )
- throw new NullPointerException( "profile" );
+ if( null == profile )
+ {
+ throw new NullPointerException( "profile" );
+ }
final String name = profile.getName();
final String partition = getPartition();
@@ -707,7 +708,8 @@
DefaultContainmentContext context =
new DefaultContainmentContext(
logger, m_context.getSystemContext(),
- classLoaderModel, modelRepository, graph, home, temp, profile,
partition, name );
+ classLoaderModel, modelRepository, graph,
+ home, temp, profile, partition, name );
//
// TODO: lookup the profile for a factory declaration, then
@@ -820,7 +822,8 @@
* @param directive the block include directive
* @return the containment model established by the include
*/
- private ContainmentModel createContainmentModel( BlockIncludeDirective
directive )
+ private ContainmentModel createContainmentModel(
+ BlockIncludeDirective directive )
throws ModelException
{
final String name = directive.getName();
@@ -830,7 +833,8 @@
{
if( path.indexOf( ":" ) < 0 )
{
- URL anchor =
m_context.getSystemContext().getBaseDirectory().toURL();
+ URL anchor =
+ m_context.getSystemContext().getBaseDirectory().toURL();
URL url = new URL( anchor, path );
return createContainmentModel( name, url );
}
@@ -1070,7 +1074,8 @@
else
{
final String error =
- "Bad path element: " + key + " in path: " + path;
+ "Bad path element: " + key
+ + " in path: " + path;
throw new IllegalArgumentException( error );
}
}
@@ -1118,7 +1123,8 @@
Type[] types = repository.getTypes( dependency );
for( int i=0; i<types.length; i++ )
{
- Profile[] profiles = repository.getProfiles( types[i] );
+ Profile[] profiles =
+ repository.getProfiles( types[i] );
for( int j=0; j<profiles.length; j++ )
{
list.add( profiles[j] );
@@ -1154,8 +1160,10 @@
/**
* Return a model relative to a supplied stage descriptor.
* @param stage the stage descriptor
- * @return model of a an stage handler or null if the stage is unresolvable
- * @exception ModelRuntimeException if an error occurs during model establishment
+ * @return model of a an stage handler or null if the
+ * stage is unresolvable
+ * @exception ModelRuntimeException if an error occurs
+ * during model establishment
*/
public Model getModel( StageDescriptor stage )
throws ModelRuntimeException
@@ -1183,7 +1191,8 @@
Type[] types = repository.getTypes( stage );
for( int i=0; i<types.length; i++ )
{
- Profile[] profiles = repository.getProfiles( types[i] );
+ Profile[] profiles =
+ repository.getProfiles( types[i] );
for( int j=0; j<profiles.length; j++ )
{
list.add( profiles[j] );
@@ -1201,8 +1210,14 @@
Profile[] collection = (Profile[]) list.toArray( new Profile[0] );
ProfileSelector selector = new DefaultProfileSelector();
Profile profile = selector.select( collection, stage );
- if( profile != null ) return addModel( profile );
- return null;
+ if( profile != null )
+ {
+ return addModel( profile );
+ }
+ else
+ {
+ return null;
+ }
}
catch( Throwable e )
{
@@ -1240,9 +1255,10 @@
//==============================================================
/**
- * Conver a classic url to a jar url. TIf the supplied url protocol is not
+ * Conver a classic url to a jar url. If the supplied url protocol is not
* the "jar" protocol, a ne url is created by prepending jar: and adding the
* trailing "!/".
+ *
* @param url the url to convert
* @return the converted url
* @exception MalformedURLException if something goes wrong
@@ -1263,23 +1279,29 @@
}
/**
- * Create a full deployment profile using a supplied named profile reference.
+ * Create a full deployment profile using a supplied named
+ * profile reference.
+ *
* @param profile the named profile reference directive
* @return the deployment profile
- * @exception ModelException if an error occurs during profile creation
+ * @exception ModelException if an error occurs during
+ * profile creation
*/
- private DeploymentProfile createDeploymentProfile( NamedDeploymentProfile
profile )
+ private DeploymentProfile createDeploymentProfile(
+ NamedDeploymentProfile profile )
throws ModelException
{
try
{
- NamedDeploymentProfile holder = (NamedDeploymentProfile) profile;
+ NamedDeploymentProfile holder =
+ (NamedDeploymentProfile) profile;
final String classname = holder.getClassname();
final String key = holder.getKey();
TypeRepository repository =
m_context.getClassLoaderModel().getTypeRepository();
Type type = repository.getType( classname );
- DeploymentProfile template = repository.getProfile( type, key );
+ DeploymentProfile template =
+ repository.getProfile( type, key );
return new DeploymentProfile( profile.getName(), template );
}
catch( Throwable e )
@@ -1327,11 +1349,13 @@
ComponentModel deployment = (ComponentModel) model;
if( target.getConfiguration() != null )
{
- deployment.setConfiguration( target.getConfiguration() );
+ deployment.setConfiguration(
+ target.getConfiguration() );
}
if( target.getCategoriesDirective() != null )
{
- deployment.setCategories( target.getCategoriesDirective() );
+ deployment.setCategories(
+ target.getCategoriesDirective() );
}
}
else if( model instanceof ContainmentModel )
@@ -1339,7 +1363,8 @@
ContainmentModel containment = (ContainmentModel) model;
if( target.getCategoriesDirective() != null )
{
- containment.setCategories( target.getCategoriesDirective()
);
+ containment.setCategories(
+ target.getCategoriesDirective() );
}
}
}
1.3.2.3 +14 -10
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContextModel.java
Index: DefaultContextModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContextModel.java,v
retrieving revision 1.3.2.2
retrieving revision 1.3.2.3
diff -u -r1.3.2.2 -r1.3.2.3
--- DefaultContextModel.java 4 Jan 2004 17:23:16 -0000 1.3.2.2
+++ DefaultContextModel.java 4 Jan 2004 20:19:27 -0000 1.3.2.3
@@ -91,7 +91,8 @@
* The default context implementation class to be used if
* no context class is defined.
*/
- public static final Class DEFAULT_CONTEXT_CLASS = DefaultContext.class;
+ public static final Class DEFAULT_CONTEXT_CLASS =
+ DefaultContext.class;
//==============================================================
// immutable state
@@ -132,13 +133,15 @@
{
super( logger );
- if( null == descriptor )
- throw new NullPointerException( "descriptor" );
+ if( null == descriptor )
+ {
+ throw new NullPointerException( "descriptor" );
+ }
if( null == context )
- throw new NullPointerException( "context" );
-
- enableLogging( logger );
+ {
+ throw new NullPointerException( "context" );
+ }
m_descriptor = descriptor;
m_directive = directive;
@@ -180,7 +183,8 @@
{
try
{
- Object value = m_context.getSystemContext().get( key );
+ Object value =
+ m_context.getSystemContext().get( key );
m_map.put( key, value );
}
catch( ContextException e )
@@ -216,7 +220,6 @@
}
else
{
-
//
// there are only two context entry models - import
// and constructor - identify the model to use then add
@@ -263,7 +266,8 @@
}
}
- m_componentContext = createComponentContext( m_context, descriptor,
directive );
+ m_componentContext =
+ createComponentContext( m_context, descriptor, directive );
if( getLogger().isDebugEnabled() )
{
1.1.2.2 +5 -2
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultDependent.java
Index: DefaultDependent.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/Attic/DefaultDependent.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- DefaultDependent.java 3 Jan 2004 22:08:21 -0000 1.1.2.1
+++ DefaultDependent.java 4 Jan 2004 20:19:27 -0000 1.1.2.2
@@ -85,7 +85,10 @@
*/
public DefaultDependent( final Logger logger )
{
- if( logger == null ) throw new NullPointerException( "logger" );
+ if( logger == null )
+ {
+ throw new NullPointerException( "logger" );
+ }
enableLogging( logger );
}
1.1.1.1.2.2 +30 -35
avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultModel.java
Index: DefaultModel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultModel.java,v
retrieving revision 1.1.1.1.2.1
retrieving revision 1.1.1.1.2.2
diff -u -r1.1.1.1.2.1 -r1.1.1.1.2.2
--- DefaultModel.java 4 Jan 2004 01:19:28 -0000 1.1.1.1.2.1
+++ DefaultModel.java 4 Jan 2004 20:19:27 -0000 1.1.1.1.2.2
@@ -51,6 +51,7 @@
package org.apache.avalon.composition.model.impl;
import org.apache.avalon.composition.model.Model;
+import org.apache.avalon.composition.model.DeploymentContext;
import org.apache.avalon.composition.model.DependencyGraph;
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.excalibur.i18n.ResourceManager;
@@ -67,30 +68,22 @@
public abstract class DefaultModel
implements Model
{
- //==============================================================
+ //--------------------------------------------------------------
// static
- //==============================================================
+ //--------------------------------------------------------------
private static final Resources REZ =
ResourceManager.getPackageResources( DefaultModel.class );
- //==============================================================
+ //--------------------------------------------------------------
// immutable state
- //==============================================================
+ //--------------------------------------------------------------
- private final String m_name;
+ private final DeploymentContext m_context;
- private final String m_path;
-
- private final Logger m_logger;
-
- private final Mode m_mode;
-
- private final DependencyGraph m_graph;
-
- //==============================================================
+ //--------------------------------------------------------------
// constructor
- //==============================================================
+ //--------------------------------------------------------------
/**
* Creation of an abstract model. The model associated a
@@ -99,19 +92,18 @@
* @param path the profile partition
* @param name the profile name
*/
- public DefaultModel(
- final Logger logger, String path, final String name, Mode mode,
DependencyGraph graph )
- {
- m_logger = logger;
- m_name = name;
- m_path = path;
- m_mode = mode;
- m_graph = graph;
+ public DefaultModel( DeploymentContext context )
+ {
+ if( null == context )
+ {
+ throw new NullPointerException( "context" );
+ }
+ m_context = context;
}
- //==============================================================
+ //--------------------------------------------------------------
// Model
- //==============================================================
+ //--------------------------------------------------------------
/**
* Return the profile name.
@@ -119,7 +111,7 @@
*/
public String getName()
{
- return m_name;
+ return m_context.getName();
}
/**
@@ -128,7 +120,11 @@
*/
public String getPath()
{
- return m_path;
+ if( null == m_context.getPartitionName() )
+ {
+ return SEPERATOR;
+ }
+ return m_context.getPartitionName();
}
/**
@@ -146,7 +142,7 @@
*/
public Mode getMode()
{
- return m_mode;
+ return m_context.getMode();
}
/**
@@ -155,7 +151,7 @@
*/
public Model[] getConsumerGraph()
{
- return m_graph.getConsumerGraph( this );
+ return m_context.getDependencyGraph().getConsumerGraph( this );
}
/**
@@ -164,13 +160,12 @@
*/
public Model[] getProviderGraph()
{
- return m_graph.getProviderGraph( this );
+ return m_context.getDependencyGraph().getProviderGraph( this );
}
-
- //==============================================================
+ //--------------------------------------------------------------
// implementation
- //==============================================================
+ //--------------------------------------------------------------
/**
* Return the logging channel.
@@ -178,7 +173,7 @@
*/
protected Logger getLogger()
{
- return m_logger;
+ return m_context.getLogger();
}
public String toString()
No revision
No revision
1.2.2.1 +15 -3
avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/AbstractTestCase.java
Index: AbstractTestCase.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/composition/impl/src/test/org/apache/avalon/composition/model/AbstractTestCase.java,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1
--- AbstractTestCase.java 28 Oct 2003 20:21:01 -0000 1.2
+++ AbstractTestCase.java 4 Jan 2004 20:19:27 -0000 1.2.2.1
@@ -5,9 +5,12 @@
import java.io.File;
import org.apache.avalon.composition.model.impl.DefaultSystemContext;
+
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.ConsoleLogger;
+import org.apache.avalon.util.exception.ExceptionHelper;
+
import junit.framework.TestCase;
public abstract class AbstractTestCase extends TestCase
@@ -58,9 +61,18 @@
File confDir = new File( base, "conf" );
File source = new File( confDir, m_path );
- SystemContext system =
- DefaultSystemContext.createSystemContext( base, repository, PRIORITY
);
- m_model = system.getFactory().createContainmentModel( source.toURL() );
+ try
+ {
+ SystemContext system =
+ DefaultSystemContext.createSystemContext( base, repository,
PRIORITY );
+ m_model = system.getFactory().createContainmentModel(
source.toURL() );
+ }
+ catch( Throwable e )
+ {
+ final String error = ExceptionHelper.packException( e, true );
+ System.err.println( error );
+ fail( error );
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]