Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2119 - in development/main: . metro/composition/api/src/main/net/dpml/composition/data metro/composition/api/src/main/net/dpml/composition/model metro/composition/api/src/test/net/dpml/composition/data/test metro/composition/impl/src/main/net/dpml/composition/data/builder metro/composition/impl/src/main/net/dpml/composition/model/impl metro/composition/spi/src/main/net/dpml/composition/provider

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2119 - in development/main: . metro/composition/api/src/main/net/dpml/composition/data metro/composition/api/src/main/net/dpml/composition/model metro/composition/api/src/test/net/dpml/composition/data/test metro/composition/impl/src/main/net/dpml/composition/data/builder metro/composition/impl/src/main/net/dpml/composition/model/impl metro/composition/spi/src/main/net/dpml/composition/provider
  • Date: Tue, 22 Mar 2005 21:04:47 -0500

Author: mcconnell AT dpml.net
Date: Tue Mar 22 21:04:46 2005
New Revision: 2119

Added:

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/AbstractSerializableTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ClasspathDirectiveTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/CompositionDirectiveTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContainmentProfileTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/DependencyDirectiveTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/FilesetDirectiveTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ModeTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/NamedComponentProfileTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ProfilePackageTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ServiceDirectiveTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/TargetDirectiveTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/TargetsTestCase.java
Modified:
development/main/ (props changed)

development/main/metro/composition/api/src/main/net/dpml/composition/data/ClasspathDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/ComponentProfile.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/CompositionDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/ConstructorDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/ContainmentProfile.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/ContextDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/DependencyDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/DeploymentProfile.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/EntryDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/FilesetDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/ImportDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/Mode.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/NamedComponentProfile.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/Parameter.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/ProfilePackage.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/ServiceDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/TargetDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/Targets.java

development/main/metro/composition/api/src/main/net/dpml/composition/model/ClassLoaderModel.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ComponentProfileTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ConstructorDirectiveTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContextDirectiveTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ImportDirectiveTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ParameterTestCase.java

development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLContainmentProfileCreator.java

development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLTargetsCreator.java

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderContext.java

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderModel.java

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultComponentModel.java

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModelComponentHelper.java

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultDeploymentModel.java

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultModelFactory.java

development/main/metro/composition/spi/src/main/net/dpml/composition/provider/ClassLoaderContext.java
Log:
Complete the implementation of full serialization support for the component
and container directives (which paves the way for the creation of component
and container serialized parts as transit artifacts). Add test cases to all
meta-data directives, identified and closed a couple of bugs, and
completed/updated javadocs. In some cases updated method names to improve
consitency.

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ClasspathDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ClasspathDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ClasspathDirective.java
Tue Mar 22 21:04:46 2005
@@ -19,8 +19,7 @@
package net.dpml.composition.data;

import java.io.Serializable;
-
-import net.dpml.transit.artifact.Artifact;
+import java.net.URI;

/**
* Description of classpath.
@@ -30,10 +29,8 @@
*/
public final class ClasspathDirective implements Serializable
{
- private static final FilesetDirective[] EMPTY_FILESETS =
- new FilesetDirective[0];
- private static final Artifact[] EMPTY_ARTIFACTS =
- new Artifact[0];
+ private static final FilesetDirective[] EMPTY_FILESETS = new
FilesetDirective[0];
+ private static final URI[] EMPTY_URIS = new URI[0];

/**
* The fileset directives
@@ -43,7 +40,7 @@
/**
* The resource references
*/
- private Artifact[] m_artifacts;
+ private URI[] m_uris;

/**
* Create a empty ClasspathDirective.
@@ -57,11 +54,11 @@
* Create a ClasspathDirective instance.
*
* @param filesets the filesets to be included in a classloader
- * @param artifacts the set of artifact directives
+ * @param uris the set of artifact uris
*/
public ClasspathDirective(
final FilesetDirective[] filesets,
- final Artifact[] artifacts )
+ final URI[] uris )
{
if( filesets == null )
{
@@ -72,13 +69,13 @@
m_filesets = filesets;
}

- if( artifacts == null )
+ if( uris == null )
{
- m_artifacts = EMPTY_ARTIFACTS;
+ m_uris = EMPTY_URIS;
}
else
{
- m_artifacts = artifacts;
+ m_uris = uris;
}
}

@@ -88,7 +85,7 @@
*/
public boolean isEmpty()
{
- final int n = m_artifacts.length + m_filesets.length;
+ final int n = m_uris.length + m_filesets.length;
return n == 0;
}

@@ -97,9 +94,9 @@
*
* @return the artifact directive set
*/
- public Artifact[] getArtifacts()
+ public URI[] getURIs()
{
- return m_artifacts;
+ return m_uris;
}

/**
@@ -111,4 +108,79 @@
{
return m_filesets;
}
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof ClasspathDirective )
+ {
+ ClasspathDirective directive = (ClasspathDirective) other;
+ if( getURIs().length != directive.getURIs().length )
+ {
+ return false;
+ }
+ else
+ {
+ URI[] myUris = getURIs();
+ URI[] yourURIs = directive.getURIs();
+ for( int i=0; i<myUris.length; i++ )
+ {
+ URI m = myUris [i];
+ URI n = yourURIs[i];
+ if( false == m.equals( n ) )
+ {
+ return false;
+ }
+ }
+ }
+ if( getFilesets().length != directive.getFilesets().length )
+ {
+ return false;
+ }
+ else
+ {
+ FilesetDirective[] mine = getFilesets();
+ FilesetDirective[] yours = directive.getFilesets();
+ for( int i=0; i<mine.length; i++ )
+ {
+ FilesetDirective d = mine[i];
+ FilesetDirective e = yours[i];
+ if( false == d.equals( e ) )
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = 0;
+ for( int i=0; i<m_filesets.length; i++ )
+ {
+ hash ^= m_filesets[i].hashCode();
+ }
+ for( int i=0; i<m_uris.length; i++ )
+ {
+ hash ^= m_uris[i].hashCode();
+ }
+ return hash;
+ }
+
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ComponentProfile.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ComponentProfile.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ComponentProfile.java
Tue Mar 22 21:04:46 2005
@@ -105,11 +105,6 @@
public class ComponentProfile extends DeploymentProfile
{
/**
- * The assigned logging categories.
- */
- private CategoriesDirective m_categories;
-
- /**
* The collection policy override.
*/
private int m_collection;
@@ -117,27 +112,27 @@
/**
* The component classname.
*/
- private String m_classname;
+ private final String m_classname;

/**
* The parameters for component (if any).
*/
- private Parameters m_parameters;
+ private final Parameters m_parameters;

/**
* The configuration for component (if any).
*/
- private Configuration m_configuration;
+ private final Configuration m_configuration;

/**
- * The configuration for component (if any).
+ * The components context directive.
*/
- private ContextDirective m_context = new ContextDirective( new
EntryDirective[0] );
+ private final ContextDirective m_context;

/**
* The dependency directives.
*/
- private DependencyDirective[] m_dependencies;
+ private final DependencyDirective[] m_dependencies;


//--------------------------------------------------------------------------
// constructor
@@ -168,14 +163,14 @@
{
this(
name,
- template.getActivationDirective(),
+ template.getActivationPolicy(),
template.getCollectionPolicy(),
- template.m_classname,
- template.m_categories,
- template.m_context,
- template.m_dependencies,
- template.m_parameters,
- template.m_configuration,
+ template.getClassname(),
+ template.getCategoriesDirective(),
+ template.getContextDirective(),
+ template.getDependencyDirectives(),
+ template.getParameters(),
+ template.getConfiguration(),
Mode.EXPLICIT );
}

@@ -199,10 +194,17 @@
throw new NullArgumentException( "classname" );
}

+ if( null == context )
+ {
+ m_context = new ContextDirective( new EntryDirective[0] );
+ }
+ else
+ {
+ m_context = context;
+ }
+
m_collection = collection;
m_classname = classname;
- m_categories = categories;
- m_context = context;
m_parameters = parameters;
m_configuration = config;

@@ -246,7 +248,7 @@
*
* @return the ContextDirective for the profile.
*/
- public ContextDirective getContext()
+ public ContextDirective getContextDirective()
{
return m_context;
}
@@ -310,4 +312,100 @@
{
return "[" + getName() + "]";
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ if( false == super.equals( other ) )
+ {
+ return false;
+ }
+ if( false == ( other instanceof ComponentProfile ) )
+ {
+ return false;
+ }
+ ComponentProfile profile = (ComponentProfile) other;
+ if( false == m_classname.equals( profile.getClassname() ) )
+ {
+ return false;
+ }
+ if( false == m_context.equals( profile.getContextDirective() ) )
+ {
+ return false;
+ }
+ if( m_collection != profile.getCollectionPolicy() )
+ {
+ return false;
+ }
+ if( false == equals( m_parameters, profile.getParameters() ) )
+ {
+ return false;
+ }
+ if( false == equals( m_configuration, profile.getConfiguration() ) )
+ {
+ return false;
+ }
+ if( getDependencyDirectives().length !=
profile.getDependencyDirectives().length )
+ {
+ return false;
+ }
+ DependencyDirective[] mine = getDependencyDirectives();
+ DependencyDirective[] yours = profile.getDependencyDirectives();
+ for( int i=0; i<mine.length; i++ )
+ {
+ DependencyDirective a = mine[i];
+ DependencyDirective b = yours[i];
+ if( false == a.equals( b ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private boolean equals( Object a, Object b )
+ {
+ if( null == a )
+ {
+ return ( null == b );
+ }
+ else
+ {
+ return a.equals( b );
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = super.hashCode();
+ hash ^= m_classname.hashCode();
+ hash ^= m_context.hashCode();
+ hash ^= m_collection;
+ if( false == ( null == m_parameters ) )
+ {
+ hash ^= m_parameters.hashCode();
+ }
+ if( false == ( null == m_configuration ) )
+ {
+ hash ^= m_configuration.hashCode();
+ }
+ for( int i=0; i<m_dependencies.length; i++ )
+ {
+ hash ^= m_dependencies[i].hashCode();
+ }
+ return hash;
+ }
+
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/CompositionDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/CompositionDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/CompositionDirective.java
Tue Mar 22 21:04:46 2005
@@ -64,12 +64,12 @@
*/
public CompositionDirective(
final String name, URI uri, TargetDirective[] targets )
- throws NullArgumentException
+ throws NullPointerException
{
super( name, DeploymentProfile.ENABLED, Mode.EXPLICIT, null );
if( uri == null )
{
- throw new NullArgumentException( "uri" );
+ throw new NullPointerException( "uri" );
}
m_uri = uri;
m_targets = targets;
@@ -92,4 +92,61 @@
{
return m_targets;
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ if( false == super.equals( other ) )
+ {
+ return false;
+ }
+ if( false == ( other instanceof CompositionDirective ) )
+ {
+ return false;
+ }
+ CompositionDirective directive = (CompositionDirective) other;
+ if( false == m_uri.equals( directive.getURI() ) )
+ {
+ return false;
+ }
+ if( getTargetDirectives().length !=
directive.getTargetDirectives().length )
+ {
+ return false;
+ }
+ TargetDirective[] mine = getTargetDirectives();
+ TargetDirective[] yours = directive.getTargetDirectives();
+ for( int i=0; i<mine.length; i++ )
+ {
+ TargetDirective a = mine[i];
+ TargetDirective b = yours[i];
+ if( false == a.equals( b ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = super.hashCode();
+ hash ^= m_uri.hashCode();
+ for( int i=0; i<m_targets.length; i++ )
+ {
+ hash ^= m_targets[i].hashCode();
+ }
+ return hash;
+ }
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ConstructorDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ConstructorDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ConstructorDirective.java
Tue Mar 22 21:04:46 2005
@@ -166,7 +166,7 @@
}

/**
- * Return the parameter directive if the mode is PARAM else null.
+ * Return the constructor parameters.
* @return the directive
*/
public Parameter[] getParameters()
@@ -182,4 +182,80 @@
{
return m_argument;
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( super.equals( other ) )
+ {
+ if( other instanceof ConstructorDirective )
+ {
+ ConstructorDirective directive = (ConstructorDirective)
other;
+ if( false == m_classname.equals( directive.getClassname() ) )
+ {
+ return false;
+ }
+ if( getParameters().length !=
directive.getParameters().length )
+ {
+ return false;
+ }
+ else
+ {
+ Parameter[] myParams = getParameters();
+ Parameter[] yourParams = directive.getParameters();
+ for( int i=0; i<myParams.length; i++ )
+ {
+ Parameter p = myParams[i];
+ Parameter q = yourParams[i];
+ if( false == p.equals( q ) )
+ {
+ return false;
+ }
+ }
+ }
+ if( null == m_argument )
+ {
+ return ( null == directive.getArgument() );
+ }
+ else
+ {
+ return m_argument.equals( directive.getArgument() );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = m_classname.hashCode();
+ if( null != m_argument )
+ {
+ hash ^= m_argument.hashCode();
+ }
+ for( int i=0; i<m_params.length; i++ )
+ {
+ hash ^= m_params[i].hashCode();
+ }
+ return hash;
+ }
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ContainmentProfile.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ContainmentProfile.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ContainmentProfile.java
Tue Mar 22 21:04:46 2005
@@ -34,9 +34,9 @@
*/
public class ContainmentProfile extends DeploymentProfile
{
-
//========================================================================
+
//--------------------------------------------------------------------------
// static
-
//========================================================================
+
//--------------------------------------------------------------------------

/**
* Container path delimiter.
@@ -52,9 +52,9 @@
private static final ClasspathDirective EMPTY_CLASSPATH =
new ClasspathDirective();

-
//========================================================================
+
//--------------------------------------------------------------------------
// state
-
//========================================================================
+
//--------------------------------------------------------------------------

/**
* The classpath directive.
@@ -222,4 +222,89 @@
}
return (DeploymentProfile[])list.toArray( new DeploymentProfile[0] );
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ if( false == super.equals( other ) )
+ {
+ return false;
+ }
+ if( false == ( other instanceof ContainmentProfile ) )
+ {
+ return false;
+ }
+ ContainmentProfile profile = (ContainmentProfile) other;
+ if( false == m_classpath.equals( profile.getClasspathDirective() ) )
+ {
+ return false;
+ }
+
+ if( getExportDirectives().length !=
profile.getExportDirectives().length )
+ {
+ return false;
+ }
+ else
+ {
+ ServiceDirective[] mine = getExportDirectives();
+ ServiceDirective[] yours = profile.getExportDirectives();
+ for( int i=0; i<mine.length; i++ )
+ {
+ ServiceDirective a = mine[i];
+ ServiceDirective b = yours[i];
+ if( false == a.equals( b ) )
+ {
+ return false;
+ }
+ }
+ }
+
+ if( getProfiles().length != profile.getProfiles().length )
+ {
+ return false;
+ }
+ else
+ {
+ DeploymentProfile[] mine = getProfiles();
+ DeploymentProfile[] yours = profile.getProfiles();
+ for( int i=0; i<mine.length; i++ )
+ {
+ DeploymentProfile a = mine[i];
+ DeploymentProfile b = yours[i];
+ if( false == a.equals( b ) )
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = super.hashCode();
+ hash ^= m_classpath.hashCode();
+ for( int i=0; i<m_export.length; i++ )
+ {
+ hash ^= m_export[i].hashCode();
+ }
+ for( int i=0; i<m_profiles.length; i++ )
+ {
+ hash ^= m_profiles[i].hashCode();
+ }
+ return hash;
+ }
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ContextDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ContextDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ContextDirective.java
Tue Mar 22 21:04:46 2005
@@ -58,7 +58,15 @@
private final String m_classname;

/**
- * Creation of a new file target.
+ * Creation of a context directive.
+ */
+ public ContextDirective()
+ {
+ this( new EntryDirective[0] );
+ }
+
+ /**
+ * Creation of a context directive
* @param entries the set of entry descriptors
*/
public ContextDirective( final EntryDirective[] entries )
@@ -120,4 +128,76 @@
}
return null;
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof ContextDirective )
+ {
+ ContextDirective context = (ContextDirective) other;
+ if( null == m_classname )
+ {
+ if( null != context.getClassname() )
+ {
+ return false;
+ }
+ }
+ else if( false == m_classname.equals( context.getClassname()
) )
+ {
+ return false;
+ }
+ if( getEntryDirectives().length !=
context.getEntryDirectives().length )
+ {
+ return false;
+ }
+ else
+ {
+ EntryDirective[] mine = getEntryDirectives();
+ EntryDirective[] yours = context.getEntryDirectives();
+ for( int i=0; i<mine.length; i++ )
+ {
+ EntryDirective p = mine[i];
+ EntryDirective q = yours[i];
+ if( false == p.equals( q ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = 9;
+ if( null != m_classname )
+ {
+ hash ^= m_classname.hashCode();
+ }
+ for( int i=0; i<m_entries.length; i++ )
+ {
+ hash ^= m_entries[i].hashCode();
+ }
+ return hash;
+ }
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/DependencyDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/DependencyDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/DependencyDirective.java
Tue Mar 22 21:04:46 2005
@@ -45,9 +45,14 @@
*
* @param key the dependency key
* @param source path to the source provider component
+ * @exception NullPointerException if the supplied key is null
*/
public DependencyDirective( String key, String source )
{
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
m_key = key;
m_source = source;
}
@@ -63,10 +68,61 @@

/**
* Return the dependency source path.
- * @return the path
+ * @return the path (posibly null)
*/
public String getSource()
{
return m_source;
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof DependencyDirective )
+ {
+ DependencyDirective dep = (DependencyDirective) other;
+ if( false == m_key.equals( dep.getKey() ) )
+ {
+ return false;
+ }
+ if( null == m_source )
+ {
+ return ( null == dep.getSource() );
+ }
+ else
+ {
+ return m_source.equals( dep.getSource() );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = m_key.hashCode();
+ if( null != m_source )
+ {
+ hash ^= m_source.hashCode();
+ }
+ return hash;
+ }
+
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/DeploymentProfile.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/DeploymentProfile.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/DeploymentProfile.java
Tue Mar 22 21:04:46 2005
@@ -73,17 +73,35 @@
*/
private final Mode m_mode;

+ /**
+ * Logging category directives.
+ */
private final CategoriesDirective m_categories;


//--------------------------------------------------------------------------
// constructor

//--------------------------------------------------------------------------

+ /**
+ * Creation of a new deployment profile instance.
+ * @param name the profile name
+ * @param activation the activation policy
+ * @param mode the mode of depployment
+ * @param categories logging category directives
+ */
public DeploymentProfile(
final String name, int activation, Mode mode, CategoriesDirective
categories )
{
m_activation = activation;
- m_categories = categories;
+
+ if( null == categories )
+ {
+ m_categories = EMPTY_CATEGORIES;
+ }
+ else
+ {
+ m_categories = categories;
+ }

if( mode == null )
{
@@ -109,7 +127,7 @@

//--------------------------------------------------------------------------

/**
- * Return the name of meta-data instance.
+ * Return the profile name.
*
* @return the name of the component.
*/
@@ -123,21 +141,20 @@
*
* @return the categories
*/
- public CategoriesDirective getCategories()
+ public CategoriesDirective getCategoriesDirective()
{
- if( m_categories == null ) return EMPTY_CATEGORIES;
return m_categories;
}

/**
- * Get the activation directive for the profile.
+ * Get the activation policy for the profile.
*
* @return the declared activation policy
* @see #DEFAULT
* @see #ENABLED
* @see #DISABLED
*/
- public int getActivationDirective()
+ public int getActivationPolicy()
{
return m_activation;
}
@@ -166,4 +183,58 @@
String other = object.toString();
return name.compareTo( other );
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof DeploymentProfile )
+ {
+ DeploymentProfile profile = (DeploymentProfile) other;
+ if( false == m_name.equals( profile.getName() ) )
+ {
+ return false;
+ }
+ if( m_activation != profile.getActivationPolicy() )
+ {
+ return false;
+ }
+ if( false == m_mode.equals( profile.getMode() ) )
+ {
+ return false;
+ }
+ if( false == m_categories.equals(
profile.getCategoriesDirective() ) )
+ {
+ return false;
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = m_name.hashCode();
+ hash ^= m_activation;
+ hash ^= m_mode.hashCode();
+ hash ^= m_categories.hashCode();
+ return hash;
+ }
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/EntryDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/EntryDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/EntryDirective.java
Tue Mar 22 21:04:46 2005
@@ -18,8 +18,6 @@

package net.dpml.composition.data;

-import net.dpml.lang. NullArgumentException;
-
import java.io.Serializable;

import net.dpml.lang.NullArgumentException;
@@ -85,4 +83,38 @@
{
return m_key;
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof EntryDirective )
+ {
+ EntryDirective entry = (EntryDirective) other;
+ return m_key.equals( entry.getKey() );
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ return m_key.hashCode();
+ }
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/FilesetDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/FilesetDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/FilesetDirective.java
Tue Mar 22 21:04:46 2005
@@ -34,8 +34,6 @@
* &lt;/dirset&gt;
* </pre>
*
- * @see IncludeDirective
- * @see ExcludeDirective
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id$
*/
@@ -76,6 +74,10 @@
public FilesetDirective( final String base, final Include[] includes,
final Exclude[] excludes)
{
+ if( null == base )
+ {
+ throw new NullPointerException( "base" );
+ }
m_base = base;
m_includes = includes;
m_excludes = excludes;
@@ -112,6 +114,90 @@
}

/**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof FilesetDirective )
+ {
+ FilesetDirective fileset = (FilesetDirective) other;
+ if( false == m_base.equals( fileset.getBaseDirectory() ) )
+ {
+ return false;
+ }
+ if( getIncludes().length != fileset.getIncludes().length )
+ {
+ return false;
+ }
+ else
+ {
+ Include[] mine = getIncludes();
+ Include[] yours = fileset.getIncludes();
+ for( int i=0; i<mine.length; i++ )
+ {
+ Include p = mine[i];
+ Include q = yours[i];
+ if( false == p.equals( q ) )
+ {
+ return false;
+ }
+ }
+ }
+ if( getExcludes().length != fileset.getExcludes().length )
+ {
+ return false;
+ }
+ else
+ {
+ Exclude[] mine = getExcludes();
+ Exclude[] yours = fileset.getExcludes();
+ for( int i=0; i<mine.length; i++ )
+ {
+ Exclude p = mine[i];
+ Exclude q = yours[i];
+ if( false == p.equals( q ) )
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = m_base.hashCode();
+ for( int i=0; i<m_includes.length; i++ )
+ {
+ hash ^= m_includes[i].hashCode();
+ }
+ for( int i=0; i<m_excludes.length; i++ )
+ {
+ hash ^= m_excludes[i].hashCode();
+ }
+ return hash;
+ }
+
+
+ /**
* <p>A file exclude directive.</p>
* <p><b>XML</b></p>
* <p>An exclude element is normally contained within a scoping structure
such as a
@@ -154,6 +240,40 @@
{
return m_path;
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof Exclude )
+ {
+ Exclude exclude = (Exclude) other;
+ return m_path.equals( exclude.getPath() );
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ return m_path.hashCode();
+ }
}

/**
@@ -199,5 +319,40 @@
{
return m_path;
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof Include )
+ {
+ Include inc = (Include) other;
+ return m_path.equals( inc.getPath() );
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ return m_path.hashCode();
+ }
+
}
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ImportDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ImportDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ImportDirective.java
Tue Mar 22 21:04:46 2005
@@ -81,4 +81,45 @@
{
return m_import;
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( false == super.equals( other ) )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof ImportDirective )
+ {
+ ImportDirective directive = (ImportDirective) other;
+ return m_import.equals( directive.getImportKey() );
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = super.hashCode();
+ hash ^= m_import.hashCode();
+ return hash;
+ }
+
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/Mode.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/Mode.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/Mode.java
Tue Mar 22 21:04:46 2005
@@ -93,7 +93,7 @@
* Creation of a new mode value.
* @param mode the int value of the mode.
*/
- public Mode( int mode )
+ private Mode( int mode )
{
m_mode = mode;
}
@@ -129,4 +129,9 @@
}
return false;
}
+
+ public int hashCode()
+ {
+ return m_mode;
+ }
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/NamedComponentProfile.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/NamedComponentProfile.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/NamedComponentProfile.java
Tue Mar 22 21:04:46 2005
@@ -41,6 +41,16 @@
// constructor

//--------------------------------------------------------------------------

+ /**
+ * Creation of a deployment profile that is defined by a reference to
+ * a packaged deployment profile.
+ *
+ * @param name the name asigned to the profile
+ * @param classname the classname of a component type that will be used
+ * to locate a xprofile package
+ * @param key the name of a profile in the package
+ * @param activation the activation policy to apply
+ */
public NamedComponentProfile(
final String name,
final String classname,
@@ -48,6 +58,16 @@
final int activation )
{
super( name, activation, Mode.EXPLICIT, null );
+
+ if( null == classname )
+ {
+ throw new NullPointerException( "classname" );
+ }
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+
m_classname = classname;
m_key = key;
}
@@ -84,4 +104,47 @@
{
return "[" + getName() + "-" + getKey() + "]";
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ if( false == super.equals( other ) )
+ {
+ return false;
+ }
+ if( false == ( other instanceof NamedComponentProfile ) )
+ {
+ return false;
+ }
+ NamedComponentProfile profile = (NamedComponentProfile) other;
+ if( false == m_key.equals( profile.getKey() ) )
+ {
+ return false;
+ }
+ if( false == m_classname.equals( profile.getClassname() ) )
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = super.hashCode();
+ hash ^= m_classname.hashCode();
+ hash ^= m_key.hashCode();
+ return hash;
+ }
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/Parameter.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/Parameter.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/Parameter.java
Tue Mar 22 21:04:46 2005
@@ -79,11 +79,6 @@
private final Parameter[] m_parameters;

/**
- * The derived value.
- */
- private transient Object m_value;
-
- /**
* Creation of a new parameter using the default
<code>java.lang.String</code>
* type and a supplied value.
*
@@ -169,4 +164,80 @@
{
return m_parameters;
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof Parameter )
+ {
+ Parameter param = (Parameter) other;
+ if( false == m_classname.equals( param.getClassname() ) )
+ {
+ return false;
+ }
+ if( null == m_argument )
+ {
+ if( null != param.getArgument() )
+ {
+ return false;
+ }
+ }
+ else if( false == m_argument.equals( param.getArgument() ) )
+ {
+ return false;
+ }
+ if( getParameters().length != param.getParameters().length )
+ {
+ return false;
+ }
+ else
+ {
+ Parameter[] myParams = getParameters();
+ Parameter[] yourParams = param.getParameters();
+ for( int i=0; i<myParams.length; i++ )
+ {
+ Parameter p = myParams[i];
+ Parameter q = yourParams[i];
+ if( false == p.equals( q ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = m_classname.hashCode();
+ if( null != m_argument )
+ {
+ hash ^= m_argument.hashCode();
+ }
+ for( int i=0; i<m_parameters.length; i++ )
+ {
+ hash ^= m_parameters[i].hashCode();
+ }
+ return hash;
+ }
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ProfilePackage.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ProfilePackage.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ProfilePackage.java
Tue Mar 22 21:04:46 2005
@@ -35,7 +35,7 @@
public static final ProfilePackage EMPTY_PACKAGE = new ProfilePackage();


//--------------------------------------------------------------------------
- // immutable state
+ // state

//--------------------------------------------------------------------------

/**
@@ -59,6 +59,10 @@
*/
public ProfilePackage( final ComponentProfile[] profiles )
{
+ if( null == profiles )
+ {
+ throw new NullPointerException( "profiles" );
+ }
m_profiles = profiles;
}

@@ -75,4 +79,53 @@
{
return m_profiles;
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ if( false == ( other instanceof ProfilePackage ) )
+ {
+ return false;
+ }
+ ProfilePackage profile = (ProfilePackage) other;
+ if( getComponentProfiles().length !=
profile.getComponentProfiles().length )
+ {
+ return false;
+ }
+ ComponentProfile[] mine = getComponentProfiles();
+ ComponentProfile[] yours = profile.getComponentProfiles();
+ for( int i=0; i<mine.length; i++ )
+ {
+ ComponentProfile a = mine[i];
+ ComponentProfile b = yours[i];
+ if( false == a.equals( b ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = 9;
+ for( int i=0; i<m_profiles.length; i++ )
+ {
+ hash ^= m_profiles[i].hashCode();
+ }
+ return hash;
+ }
+
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ServiceDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ServiceDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ServiceDirective.java
Tue Mar 22 21:04:46 2005
@@ -66,4 +66,50 @@
return m_path;
}

+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof ServiceDirective )
+ {
+ ServiceDirective directive = (ServiceDirective) other;
+ if( null == m_path )
+ {
+ return ( null == directive.getPath() );
+ }
+ else
+ {
+ return m_path.equals( directive.getPath() );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = 9;
+ if( null != m_path )
+ {
+ hash ^= m_path.hashCode();
+ }
+ return hash;
+ }
+
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/TargetDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/TargetDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/TargetDirective.java
Tue Mar 22 21:04:46 2005
@@ -59,11 +59,6 @@
*/
private final CategoriesDirective m_categories;

- /**
- * The name of a security profile to assign to a target.
- */
- private final String m_profile;
-

//========================================================================
// constructors

//========================================================================
@@ -73,44 +68,21 @@
*
* @param path target path
* @param configuration the configuration
- * @param categories the logging category directives
- * @param profile a security profile
- */
- public TargetDirective(
- final String path,
- final Configuration configuration,
- final CategoriesDirective categories,
- final String profile )
- {
- this( path, configuration, null, categories, profile );
- }
-
- /**
- * Create a new Target instance.
- *
- * @param path target path
- * @param configuration the configuration
* @param parameters the parameters
* @param categories the logging category directives
- * @param profile a security profile
- *
- * @since 2.1.0
*/
public TargetDirective(
final String path,
final Configuration configuration,
final Parameters parameters,
- final CategoriesDirective categories,
- final String profile )
+ final CategoriesDirective categories ) throws IllegalArgumentException
{
m_path = path;
m_config = configuration;
m_params = parameters;
m_categories = categories;
- m_profile = profile;
}

-

//========================================================================
// implementation

//========================================================================
@@ -146,16 +118,6 @@
}

/**
- * Return the name of the assigned security profile.
- *
- * @return the assigned profile name (possibly null)
- */
- public String getSecurityProfileName()
- {
- return m_profile;
- }
-
- /**
* Return the logging categories directive.
*
* @return the logging categories directive
@@ -175,7 +137,81 @@
+ (getConfiguration() != null ) + ", "
+ (getParameters() != null ) + ", "
+ (getCategoriesDirective() != null ) + ", "
- + (getSecurityProfileName() != null )
+ " ]";
}
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof TargetDirective )
+ {
+ TargetDirective target = (TargetDirective) other;
+ if( false == equals( getPath(), target.getPath() ) )
+ {
+ return false;
+ }
+ if( false == equals( getConfiguration(),
target.getConfiguration() ) )
+ {
+ return false;
+ }
+ if( false == equals( getParameters(), target.getParameters()
) )
+ {
+ return false;
+ }
+ if( false == equals( getCategoriesDirective(),
target.getCategoriesDirective() ) )
+ {
+ return false;
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ private boolean equals( Object mine, Object yours )
+ {
+ if( null == mine )
+ {
+ return ( null == yours );
+ }
+ else
+ {
+ return mine.equals( yours );
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = m_path.hashCode();
+ if( null != m_config )
+ {
+ hash ^= m_config.hashCode();
+ }
+ if( null != m_params )
+ {
+ hash ^= m_params.hashCode();
+ }
+ if( null != m_categories )
+ {
+ hash ^= m_categories.hashCode();
+ }
+ return hash;
+ }
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/Targets.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/Targets.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/Targets.java
Tue Mar 22 21:04:46 2005
@@ -19,6 +19,7 @@
package net.dpml.composition.data;

import java.util.ArrayList;
+import java.io.Serializable;


/**
@@ -29,7 +30,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id$
*/
-public class Targets
+public class Targets implements Serializable
{

//========================================================================
// state
@@ -119,8 +120,8 @@
new TargetDirective(
getKey( name ),
target.getConfiguration(),
- target.getCategoriesDirective(),
- target.getSecurityProfileName() ) );
+ target.getParameters(),
+ target.getCategoriesDirective() ) );
}
}
}
@@ -161,4 +162,57 @@
buffer.append( " ]" );
return buffer.toString();
}
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof Targets )
+ {
+ Targets targets = (Targets) other;
+ if( getTargets().length != targets.getTargets().length )
+ {
+ return false;
+ }
+ else
+ {
+ TargetDirective[] mine = getTargets();
+ TargetDirective[] yours = targets.getTargets();
+ for( int i=0; i<mine.length; i++ )
+ {
+ TargetDirective p = mine[i];
+ TargetDirective q = yours[i];
+ if( false == p.equals( q ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = 0;
+ for( int i=0; i<m_targets.length; i++ )
+ {
+ hash ^= m_targets[i].hashCode();
+ }
+ return hash;
+ }
+
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/model/ClassLoaderModel.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/model/ClassLoaderModel.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/model/ClassLoaderModel.java
Tue Mar 22 21:04:46 2005
@@ -18,7 +18,7 @@

package net.dpml.composition.model;

-import java.net.URL;
+import java.net.URI;
import java.security.CodeSource;

import net.dpml.composition.data.ContainmentProfile;
@@ -50,11 +50,10 @@
ServiceRepository getServiceRepository();

/**
- * Return the fully qualified classpath including extension jar files
- * resolved relative to a classpath directives.
+ * Return the fully qualified classpath.
*
- * @return an array of CodeSource instances representing the qualified
- * classpath
+ * @return an array of CodeSource instances representing
+ * the qualified classpath
*/
CodeSource[] getQualifiedClassPath();

@@ -81,5 +80,5 @@
* @return a new classloader context
*/
ClassLoaderModel createClassLoaderModel(
- Logger logger, ContainmentProfile profile, URL[] implied ) throws
ModelException;
+ Logger logger, ContainmentProfile profile, URI[] implied ) throws
ModelException;
}

Added:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/AbstractSerializableTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/AbstractSerializableTestCase.java
Tue Mar 22 21:04:46 2005
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.data.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import junit.framework.TestCase;
+
+/**
+ * SerializableTestCase validates the serializable integrity of a supplied
object.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: AbstractDescriptorTestCase.java 1556 2005-01-22 12:43:42Z
niclas $
+ */
+public abstract class AbstractSerializableTestCase extends TestCase
+{
+ public AbstractSerializableTestCase()
+ {
+ super();
+ }
+
+ public AbstractSerializableTestCase( String name )
+ {
+ super( name );
+ }
+
+ protected void testSerialization( Serializable instance )
+ throws Exception
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream( baos );
+ oos.writeObject( instance );
+ oos.close();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(
baos.toByteArray() );
+ ObjectInputStream ois = new ObjectInputStream( bais );
+ Object serialized = ois.readObject();
+ ois.close();
+
+ assertTrue( "identity", instance != serialized );
+ assertEquals( "equals", instance, serialized );
+ assertEquals( "hashcode", instance.hashCode(), serialized.hashCode()
);
+ }
+}

Added:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ClasspathDirectiveTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ClasspathDirectiveTestCase.java
Tue Mar 22 21:04:46 2005
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.data.test;
+
+import java.net.URI;
+
+import net.dpml.composition.data.FilesetDirective;
+import net.dpml.composition.data.ClasspathDirective;
+
+/**
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: ParameterTestCase.java 1518 2005-01-17 17:13:05Z niclas $
+ */
+public class ClasspathDirectiveTestCase extends AbstractSerializableTestCase
+{
+ public void testURIs() throws Exception
+ {
+ FilesetDirective[] filesets = new FilesetDirective[0];
+ URI uri1 = new URI( "abc:def" );
+ URI uri2 = new URI( "xyz:def" );
+ URI[] uris = new URI[]{ uri1, uri2 };
+ ClasspathDirective classpath = new ClasspathDirective( filesets,
uris );
+ URI[] result = classpath.getURIs();
+ assertTrue( "uri count", result.length == 2 );
+ assertEquals( "uri-one", uri1, result[0] );
+ assertEquals( "uri-two", uri2, result[1] );
+ }
+
+ public void testSerialization() throws Exception
+ {
+ FilesetDirective[] filesets = new FilesetDirective[0];
+ URI uri1 = new URI( "abc:def" );
+ URI uri2 = new URI( "xyz:def" );
+ URI[] uris = new URI[]{ uri1, uri2 };
+ ClasspathDirective classpath = new ClasspathDirective( filesets,
uris );
+ testSerialization( classpath );
+ }
+
+}
\ No newline at end of file

Modified:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ComponentProfileTestCase.java
==============================================================================
---
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ComponentProfileTestCase.java
(original)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ComponentProfileTestCase.java
Tue Mar 22 21:04:46 2005
@@ -45,7 +45,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id$
*/
-public class ComponentProfileTestCase extends TestCase
+public class ComponentProfileTestCase extends AbstractSerializableTestCase
{
private CategoriesDirective m_categories;
private Mode m_mode;
@@ -88,11 +88,21 @@
assertEquals( "name", m_name, profile.getName() );
assertEquals( "collection", m_collection,
profile.getCollectionPolicy() );
assertEquals( "classname", m_classname, profile.getClassname() );
- assertEquals( "categories", m_categories, profile.getCategories() );
+ assertEquals( "categories", m_categories,
profile.getCategoriesDirective() );
assertEquals( "mode", m_mode, profile.getMode() );
- assertEquals( "activation", m_activation,
profile.getActivationDirective() );
+ assertEquals( "activation", m_activation,
profile.getActivationPolicy() );
assertEquals( "parameters", m_parameters, profile.getParameters() );
assertEquals( "configuration", m_configuration,
profile.getConfiguration() );
- assertEquals( "context", m_context, profile.getContext() );
+ assertEquals( "context", m_context, profile.getContextDirective() );
}
+
+ public void testSerialization() throws Exception
+ {
+ ComponentProfile profile = new ComponentProfile(
+ m_name, m_activation, m_collection, m_classname, m_categories,
+ m_context, m_dependencies, m_parameters,
+ m_configuration, m_mode );
+ testSerialization( profile );
+ }
+
}

Added:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/CompositionDirectiveTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/CompositionDirectiveTestCase.java
Tue Mar 22 21:04:46 2005
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.data.test;
+
+import java.net.URI;
+
+import net.dpml.composition.data.Mode;
+import net.dpml.composition.data.DeploymentProfile;
+import net.dpml.composition.data.CompositionDirective;
+
+import net.dpml.logging.data.CategoriesDirective;
+
+/**
+ * CompositionDirectiveTestCase tests the overall behaviour and
+ * serialization integrity.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: ParameterTestCase.java 1518 2005-01-17 17:13:05Z niclas $
+ */
+public class CompositionDirectiveTestCase extends
AbstractSerializableTestCase
+{
+ public void testNullURI() throws Exception
+ {
+ URI uri = null;
+ String name = "name";
+ try
+ {
+ CompositionDirective directive = new CompositionDirective( name,
uri );
+ }
+ catch( NullPointerException npe )
+ {
+ // Success
+ }
+ }
+
+ public void testName() throws Exception
+ {
+ URI uri = new URI( "abc:def" );
+ String name = "name";
+ CompositionDirective profile = new CompositionDirective( name, uri );
+ assertEquals( "name", name, profile.getName() );
+ assertEquals( "uri", uri, profile.getURI() );
+ assertNotNull( "mode", profile.getMode() );
+ assertNotNull( "categories", profile.getCategoriesDirective() );
+ }
+
+ public void testSerialization() throws Exception
+ {
+ URI uri = new URI( "abc:def" );
+ String name = "name";
+ CompositionDirective profile = new CompositionDirective( name, uri );
+ testSerialization( profile );
+ }
+}
\ No newline at end of file

Modified:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ConstructorDirectiveTestCase.java
==============================================================================
---
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ConstructorDirectiveTestCase.java
(original)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ConstructorDirectiveTestCase.java
Tue Mar 22 21:04:46 2005
@@ -31,7 +31,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id$
*/
-public class ConstructorDirectiveTestCase extends TestCase
+public class ConstructorDirectiveTestCase extends
AbstractSerializableTestCase
{
public ConstructorDirectiveTestCase( String name )
{
@@ -113,4 +113,15 @@
assertEquals( params, entry.getParameters() );
assertEquals( className, entry.getClassname() );
}
+
+ public void testSerialization() throws Exception
+ {
+ String key = "key";
+ String className = ConstructorDirectiveTestCase.class.getName();
+ String value = "val";
+ Parameter param = new Parameter( value );
+ Parameter[] params = new Parameter[]{ param };
+ ConstructorDirective directive = new ConstructorDirective( key,
className, params );
+ testSerialization( directive );
+ }
}
\ No newline at end of file

Added:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContainmentProfileTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContainmentProfileTestCase.java
Tue Mar 22 21:04:46 2005
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.data.test;
+
+import junit.framework.TestCase;
+
+import net.dpml.composition.data.ServiceDirective;
+import net.dpml.composition.data.ClasspathDirective;
+import net.dpml.composition.data.ContainmentProfile;
+import net.dpml.composition.data.ComponentProfile;
+import net.dpml.composition.data.ContextDirective;
+import net.dpml.composition.data.DependencyDirective;
+import net.dpml.composition.data.DeploymentProfile;
+import net.dpml.composition.data.ImportDirective;
+import net.dpml.composition.data.Mode;
+
+import net.dpml.configuration.Configuration;
+
+import net.dpml.configuration.impl.DefaultConfiguration;
+
+import net.dpml.logging.data.CategoriesDirective;
+import net.dpml.logging.data.CategoryDirective;
+
+import net.dpml.meta.info.InfoDescriptor;
+
+import net.dpml.parameters.Parameters;
+
+import net.dpml.parameters.impl.DefaultParameters;
+
+/**
+ * ProfileTestCase does XYZ
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: ComponentProfileTestCase.java 2112 2005-03-21 21:16:59Z
mcconnell AT dpml.net $
+ */
+public class ContainmentProfileTestCase extends AbstractSerializableTestCase
+{
+ private CategoriesDirective m_categories;
+ private Mode m_mode;
+ private int m_activation;
+ private Parameters m_parameters;
+ private Configuration m_configuration;
+ private ContextDirective m_context;
+ private DependencyDirective[] m_dependencies;
+ private String m_name;
+ private String m_classname;
+ private int m_collection;
+
+ private ComponentProfile m_componentOne;
+ private ComponentProfile m_componentTwo;
+
+ public void setUp()
+ {
+ m_componentOne = createComponentProfile( "one" );
+ m_componentTwo = createComponentProfile( "two" );
+ }
+
+ public void testProfile() throws Exception
+ {
+ String name = "container";
+ ContainmentProfile profile = createContainmentProfile( name );
+ assertEquals( "name", name, profile.getName() );
+ assertNotNull( "classpath", profile.getClasspathDirective() );
+ assertNotNull( "export", profile.getExportDirectives() );
+ assertNotNull( "profiles", profile.getProfiles() );
+ }
+
+ public void testSerialization() throws Exception
+ {
+ ContainmentProfile profile = createContainmentProfile( "container" );
+ testSerialization( profile );
+ }
+
+ private ComponentProfile createComponentProfile( String name )
+ {
+ m_classname = ComponentProfileTestCase.class.getName();
+ m_context =
+ new ContextDirective( getClass().getName(), new ImportDirective[0]
);
+ m_configuration = new DefaultConfiguration("test");
+ m_dependencies = new DependencyDirective[0];
+ m_parameters = new DefaultParameters( System.getProperties(), true );
+ m_activation = DeploymentProfile.ENABLED;
+ m_mode = Mode.IMPLICIT;
+ m_categories = new CategoriesDirective( new CategoryDirective[0] );
+ m_collection = InfoDescriptor.SOFT;
+ return new ComponentProfile(
+ name, m_activation, m_collection, m_classname, m_categories,
+ m_context, m_dependencies, m_parameters,
+ m_configuration, m_mode );
+ }
+
+ public ContainmentProfile createContainmentProfile( String name )
+ {
+ ClasspathDirective classpath = null;
+ ServiceDirective[] export = null;
+ CategoriesDirective categories = null;
+ DeploymentProfile[] components = new DeploymentProfile[]{
m_componentOne, m_componentTwo };
+ return new ContainmentProfile( name, classpath, export, categories,
components );
+ }
+
+}

Modified:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContextDirectiveTestCase.java
==============================================================================
---
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContextDirectiveTestCase.java
(original)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContextDirectiveTestCase.java
Tue Mar 22 21:04:46 2005
@@ -29,7 +29,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id$
*/
-public class ContextDirectiveTestCase extends TestCase
+public class ContextDirectiveTestCase extends AbstractSerializableTestCase
{
public ContextDirectiveTestCase( String name )
{
@@ -92,4 +92,16 @@
assertEquals( entries[0], cd.getEntryDirective( key ) );
assertNull( cd.getEntryDirective( val ) );
}
+
+ public void testSerialization() throws Exception
+ {
+ String key = "key";
+ String val = "val";
+ ImportDirective imp = new ImportDirective( key, "xxx" );
+ EntryDirective[] entries =
+ new EntryDirective[]{ imp };
+ ContextDirective cd = new ContextDirective( entries );
+ testSerialization( cd );
+ }
+
}

Added:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/DependencyDirectiveTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/DependencyDirectiveTestCase.java
Tue Mar 22 21:04:46 2005
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.data.test;
+
+import net.dpml.lang.NullArgumentException;
+
+import junit.framework.TestCase;
+
+import net.dpml.composition.data.DependencyDirective;
+
+/**
+ * ParameterTestCase does XYZ
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: ParameterTestCase.java 1518 2005-01-17 17:13:05Z niclas $
+ */
+public class DependencyDirectiveTestCase extends AbstractSerializableTestCase
+{
+ public void testNullKey() throws Exception
+ {
+ try
+ {
+ DependencyDirective directive = new DependencyDirective( null,
"anything" );
+ fail( "Null key must throw a NullPointerException" );
+ }
+ catch ( NullPointerException npe )
+ {
+ // Success!!
+ }
+
+ }
+
+ public void testDependencyDirective() throws Exception
+ {
+ String key = "key";
+ String source = "source";
+ DependencyDirective directive = new DependencyDirective( key, source
);
+ assertEquals( "key", key, directive.getKey());
+ assertEquals( "source", source, directive.getSource());
+ }
+
+ public void testSerialization() throws Exception
+ {
+ String key = "key";
+ String source = "source";
+ DependencyDirective directive = new DependencyDirective( key, source
);
+ testSerialization( directive );
+ }
+}
\ No newline at end of file

Added:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/FilesetDirectiveTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/FilesetDirectiveTestCase.java
Tue Mar 22 21:04:46 2005
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.data.test;
+
+import net.dpml.composition.data.FilesetDirective;
+import net.dpml.composition.data.FilesetDirective.Include;
+import net.dpml.composition.data.FilesetDirective.Exclude;
+
+/**
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: ParameterTestCase.java 1518 2005-01-17 17:13:05Z niclas $
+ */
+public class FilesetDirectiveTestCase extends AbstractSerializableTestCase
+{
+ public void testNullBasedir() throws Exception
+ {
+ try
+ {
+ new FilesetDirective( null, new Include[0] );
+ fail( "Did not throw expected NullPinterException" );
+ }
+ catch ( NullPointerException npe )
+ {
+ // Success!!
+ }
+ }
+
+ public void testFileset()
+ {
+ String base = "base";
+
+ Include aaa = new Include( "aaa" );
+ Include bbb = new Include( "bbb" );
+ Include[] includes = new Include[]{ aaa, bbb };
+
+ Exclude ccc = new Exclude( "ccc" );
+ Exclude ddd = new Exclude( "ddd" );
+ Exclude[] excludes = new Exclude[]{ ccc, ddd };
+
+ FilesetDirective fileset = new FilesetDirective( base, includes,
excludes );
+ assertEquals( "basedir", base, fileset.getBaseDirectory() );
+ Include[] includes2 = fileset.getIncludes();
+ assertTrue( "includes", includes.length ==
fileset.getIncludes().length );
+ assertTrue( "excludes", excludes.length ==
fileset.getExcludes().length );
+ }
+
+ public void testSerialization() throws Exception
+ {
+ String base = "base";
+
+ Include aaa = new Include( "aaa" );
+ Include bbb = new Include( "bbb" );
+ Include[] includes = new Include[]{ aaa, bbb };
+
+ Exclude ccc = new Exclude( "ccc" );
+ Exclude ddd = new Exclude( "ddd" );
+ Exclude[] excludes = new Exclude[]{ ccc, ddd };
+
+ FilesetDirective fileset = new FilesetDirective( base, includes,
excludes );
+ testSerialization( fileset );
+ }
+
+}
\ No newline at end of file

Modified:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ImportDirectiveTestCase.java
==============================================================================
---
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ImportDirectiveTestCase.java
(original)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ImportDirectiveTestCase.java
Tue Mar 22 21:04:46 2005
@@ -30,18 +30,11 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id$
*/
-public class ImportDirectiveTestCase extends TestCase
+public class ImportDirectiveTestCase extends AbstractSerializableTestCase
{
- public ImportDirectiveTestCase( String name )
- {
- super( name );
- }

- public void testEntry() throws MetaDataException
+ public void testNullEntry() throws MetaDataException
{
- String key = "key";
- String imp = "container-scoped-key";
-
try
{
new ImportDirective( null, null );
@@ -54,7 +47,7 @@

try
{
- new ImportDirective( null, imp );
+ new ImportDirective( null, "abc" );
fail( "Did not throw expected NullArgumentException" );
}
catch ( NullArgumentException npe )
@@ -64,16 +57,30 @@

try
{
- new ImportDirective( key, null );
+ new ImportDirective( "key", null );
fail( "Did not throw expected NullArgumentException" );
}
catch ( NullArgumentException npe )
{
// Success!!
}
+ }
+
+ public void testEntry() throws MetaDataException
+ {
+ String key = "key";
+ String imp = "container-scoped-key";

ImportDirective entry = new ImportDirective( key, imp );
assertEquals( key, entry.getKey() );
assertEquals( imp, entry.getImportKey() );
}
+
+ public void testSerialization() throws Exception
+ {
+ String key = "key";
+ String imp = "container-scoped-key";
+ testSerialization( new ImportDirective( key, imp ) );
+ }
+
}
\ No newline at end of file

Added:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ModeTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ModeTestCase.java
Tue Mar 22 21:04:46 2005
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.data.test;
+
+import net.dpml.composition.data.Mode;
+
+/**
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: ParameterTestCase.java 1518 2005-01-17 17:13:05Z niclas $
+ */
+public class ModeTestCase extends AbstractSerializableTestCase
+{
+ public void testImplicitUniquness() throws Exception
+ {
+ if( Mode.IMPLICIT.equals( Mode.PACKAGED ) )
+ {
+ fail( "mode IMPLICIT is matching mode PACKAGED" );
+ }
+ else if( Mode.IMPLICIT.equals( Mode.EXPLICIT ) )
+ {
+ fail( "mode IMPLICIT is matching mode EXPLICIT" );
+ }
+ }
+
+ public void testPackagedUniquness() throws Exception
+ {
+ if( Mode.PACKAGED.equals( Mode.IMPLICIT ) )
+ {
+ fail( "mode PACKAGED is matching mode IMPLICIT " );
+ }
+ else if( Mode.PACKAGED.equals( Mode.EXPLICIT ) )
+ {
+ fail( "mode PACKAGED is matching mode EXPLICIT" );
+ }
+ }
+
+ public void testExplicitUniquness() throws Exception
+ {
+ if( Mode.EXPLICIT.equals( Mode.IMPLICIT ) )
+ {
+ fail( "mode EXPLICIT is matching mode IMPLICIT " );
+ }
+ else if( Mode.EXPLICIT.equals( Mode.PACKAGED ) )
+ {
+ fail( "mode EXPLICIT is matching mode PACKAGED" );
+ }
+ }
+
+ public void testImplicitSerialization() throws Exception
+ {
+ testSerialization( Mode.IMPLICIT );
+ }
+
+ public void testPackagedSerialization() throws Exception
+ {
+ testSerialization( Mode.PACKAGED );
+ }
+
+ public void testExplicitSerialization() throws Exception
+ {
+ testSerialization( Mode.EXPLICIT );
+ }
+}
\ No newline at end of file

Added:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/NamedComponentProfileTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/NamedComponentProfileTestCase.java
Tue Mar 22 21:04:46 2005
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.data.test;
+
+import junit.framework.TestCase;
+
+import net.dpml.composition.data.NamedComponentProfile;
+import net.dpml.composition.data.DeploymentProfile;
+
+/**
+ * Test case for the NamedComponentProfile datatype.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: ComponentProfileTestCase.java 2112 2005-03-21 21:16:59Z
mcconnell AT dpml.net $
+ */
+public class NamedComponentProfileTestCase extends
AbstractSerializableTestCase
+{
+ public void testProfile() throws Exception
+ {
+ String name = "name";
+ String classname = NamedComponentProfileTestCase.class.getName();
+ String key = "key";
+ int activation = DeploymentProfile.ENABLED;
+
+ NamedComponentProfile profile = new NamedComponentProfile( name,
classname, key, activation );
+
+ assertEquals( "name", name, profile.getName() );
+ assertEquals( "classname", classname, profile.getClassname() );
+ assertEquals( "key", key, profile.getKey() );
+ assertEquals( "activation", activation,
profile.getActivationPolicy() );
+ }
+
+ public void testSerialization() throws Exception
+ {
+ String name = "name";
+ String classname = NamedComponentProfileTestCase.class.getName();
+ String key = "key";
+ int activation = DeploymentProfile.ENABLED;
+ NamedComponentProfile profile = new NamedComponentProfile( name,
classname, key, activation );
+ testSerialization( profile );
+ }
+}

Modified:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ParameterTestCase.java
==============================================================================
---
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ParameterTestCase.java
(original)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ParameterTestCase.java
Tue Mar 22 21:04:46 2005
@@ -30,7 +30,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id$
*/
-public class ParameterTestCase extends TestCase
+public class ParameterTestCase extends AbstractSerializableTestCase
{
public ParameterTestCase( String name )
{
@@ -107,4 +107,26 @@
assertEquals( ParameterTestCase.class.getName(),
param.getParameters()[1].getClassname() );

}
+
+ public void testParametersSerialization1() throws Exception
+ {
+ testSerialization( new Parameter( "abc" ) );
+ }
+
+ public void testParametersSerialization2() throws Exception
+ {
+ testSerialization( new Parameter( "java.io.File", "abc" ) );
+ }
+
+ public void testParametersSerialization3() throws Exception
+ {
+ String className = ParameterTestCase.class.getName();
+ String value = "value";
+ Parameter[] params = new Parameter[] {
+ new Parameter( "java.io.File", value ),
+ new Parameter( ParameterTestCase.class.getName(), value )
+ };
+ Parameter param = new Parameter( className, params );
+ testSerialization( param );
+ }
}
\ No newline at end of file

Added:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ProfilePackageTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ProfilePackageTestCase.java
Tue Mar 22 21:04:46 2005
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.data.test;
+
+import junit.framework.TestCase;
+
+import net.dpml.composition.data.ComponentProfile;
+import net.dpml.composition.data.ProfilePackage;
+
+/**
+ * Test case for the ProfilePackageTestCase datatype.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: ComponentProfileTestCase.java 2112 2005-03-21 21:16:59Z
mcconnell AT dpml.net $
+ */
+public class ProfilePackageTestCase extends AbstractSerializableTestCase
+{
+ public void testProfilePackage() throws Exception
+ {
+ ComponentProfile widget = new ComponentProfile( "widget",
"acme.Widget" );
+ ComponentProfile gizmo = new ComponentProfile( "gizmo", "acme.Gizmo"
);
+ ComponentProfile[] profiles = new ComponentProfile[]{ widget, gizmo
};
+ ProfilePackage pack = new ProfilePackage( profiles );
+ assertEquals( "widget", widget, pack.getComponentProfiles()[0] );
+ assertEquals( "gizmo", gizmo, pack.getComponentProfiles()[1] );
+ }
+
+ public void testSerialization() throws Exception
+ {
+ ComponentProfile widget = new ComponentProfile( "widget",
"acme.Widget" );
+ ComponentProfile gizmo = new ComponentProfile( "gizmo", "acme.Gizmo"
);
+ ComponentProfile[] profiles = new ComponentProfile[]{ widget, gizmo
};
+ ProfilePackage pack = new ProfilePackage( profiles );
+ testSerialization( pack );
+ }
+
+}

Added:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ServiceDirectiveTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ServiceDirectiveTestCase.java
Tue Mar 22 21:04:46 2005
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.data.test;
+
+import net.dpml.composition.data.ServiceDirective;
+
+import net.dpml.meta.info.ServiceDescriptor;
+import net.dpml.meta.info.ReferenceDescriptor;
+
+/**
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: ParameterTestCase.java 1518 2005-01-17 17:13:05Z niclas $
+ */
+public class ServiceDirectiveTestCase extends AbstractSerializableTestCase
+{
+ public void testServiceDirective() throws Exception
+ {
+ String path = "path";
+ ReferenceDescriptor reference = new ReferenceDescriptor( "abc" );
+ ServiceDescriptor descriptor = new ServiceDescriptor( reference );
+ ServiceDirective directive = new ServiceDirective( descriptor, path
);
+ assertEquals( "path", path, directive.getPath() );
+ }
+
+ public void testSerialization() throws Exception
+ {
+ String path = "path";
+ ReferenceDescriptor reference = new ReferenceDescriptor( "abc" );
+ ServiceDescriptor descriptor = new ServiceDescriptor( reference );
+ ServiceDirective directive = new ServiceDirective( descriptor, path
);
+ testSerialization( directive );
+ }
+}
\ No newline at end of file

Added:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/TargetDirectiveTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/TargetDirectiveTestCase.java
Tue Mar 22 21:04:46 2005
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.data.test;
+
+import net.dpml.composition.data.TargetDirective;
+
+import net.dpml.logging.data.CategoriesDirective;
+
+import net.dpml.configuration.Configuration;
+import net.dpml.configuration.impl.DefaultConfiguration;
+
+import net.dpml.parameters.Parameters;
+import net.dpml.parameters.impl.DefaultParameters;
+
+/**
+ * Test behaviour and serialization of the TargetDirective.
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: ParameterTestCase.java 1518 2005-01-17 17:13:05Z niclas $
+ */
+public class TargetDirectiveTestCase extends AbstractSerializableTestCase
+{
+ public void testTargetDirective() throws Exception
+ {
+ String path = "/path";
+ Configuration config = new DefaultConfiguration( "config" );
+ Parameters params = new DefaultParameters();
+ CategoriesDirective categories = new CategoriesDirective();
+ TargetDirective target = new TargetDirective( path, config, params,
categories );
+ assertEquals( "path", path, target.getPath() );
+ assertEquals( "config", config, target.getConfiguration() );
+ assertEquals( "params", params, target.getParameters() );
+ assertEquals( "categories", categories,
target.getCategoriesDirective() );
+ }
+
+ public void testSerialization() throws Exception
+ {
+ String path = "/path";
+ Configuration config = new DefaultConfiguration( "config" );
+ Parameters params = new DefaultParameters();
+ CategoriesDirective categories = new CategoriesDirective();
+ TargetDirective target = new TargetDirective( path, config, params,
categories );
+ testSerialization( target );
+ }
+
+}
\ No newline at end of file

Added:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/TargetsTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/TargetsTestCase.java
Tue Mar 22 21:04:46 2005
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.data.test;
+
+import net.dpml.composition.data.Targets;
+import net.dpml.composition.data.TargetDirective;
+
+import net.dpml.logging.data.CategoriesDirective;
+
+import net.dpml.configuration.Configuration;
+import net.dpml.configuration.impl.DefaultConfiguration;
+
+import net.dpml.parameters.Parameters;
+import net.dpml.parameters.impl.DefaultParameters;
+
+/**
+ * Test behaviour and serialization of the TargetDirective.
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: ParameterTestCase.java 1518 2005-01-17 17:13:05Z niclas $
+ */
+public class TargetsTestCase extends AbstractSerializableTestCase
+{
+ public void testTargetDirective() throws Exception
+ {
+ String path = "/path";
+ Configuration config = new DefaultConfiguration( "config" );
+ Parameters params = new DefaultParameters();
+ CategoriesDirective categories = new CategoriesDirective();
+ TargetDirective target = new TargetDirective( path, config, params,
categories );
+ Targets targets = new Targets( new TargetDirective[]{ target } );
+
+ assertEquals( "target", target, targets.getTarget( "/path" ) );
+ }
+
+ public void testSerialization() throws Exception
+ {
+ String path = "/path";
+ Configuration config = new DefaultConfiguration( "config" );
+ Parameters params = new DefaultParameters();
+ CategoriesDirective categories = new CategoriesDirective();
+ TargetDirective target = new TargetDirective( path, config, params,
categories );
+ Targets targets = new Targets( new TargetDirective[]{ target } );
+ testSerialization( targets );
+ }
+
+}
\ No newline at end of file

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLContainmentProfileCreator.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLContainmentProfileCreator.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLContainmentProfileCreator.java
Tue Mar 22 21:04:46 2005
@@ -150,11 +150,11 @@
}

FilesetDirective[] filesets = createFilesetDirectives( config );
- Artifact[] artifacts = createArtifactDirectives( config );
+ URI[] artifacts = createArtifactDirectives( config );
return new ClasspathDirective( filesets, artifacts );
}

- private Artifact[] createArtifactDirectives( Configuration config )
+ private URI[] createArtifactDirectives( Configuration config )
throws ConfigurationException
{
ArrayList list = new ArrayList();
@@ -168,10 +168,10 @@
{
Artifact artifact =
createArtifactDirective( children[i] );
- list.add( artifact );
+ list.add( artifact.toURI() );
}

- return (Artifact[]) list.toArray( new Artifact[0] );
+ return (URI[]) list.toArray( new URI[0] );
}

private Artifact createArtifactDirective( Configuration config )

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLTargetsCreator.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLTargetsCreator.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLTargetsCreator.java
Tue Mar 22 21:04:46 2005
@@ -95,13 +95,6 @@
}

//
- // get the applicable secuirity profile
- //
-
- Configuration security = config.getChild( "security" );
- String profile = security.getAttribute( "profile", null );
-
- //
// get the assigned categories
//

@@ -126,7 +119,7 @@
// and create the target directive
//

- return new TargetDirective( name, conf, params, categories, profile
);
+ return new TargetDirective( name, conf, params, categories );
}

private Parameters getTargetParameters( Configuration config )

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderContext.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderContext.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderContext.java
Tue Mar 22 21:04:46 2005
@@ -20,7 +20,7 @@

import java.io.File;

-import java.net.URL;
+import java.net.URI;

import net.dpml.composition.data.ClasspathDirective;

@@ -101,7 +101,7 @@
/**
* Implied url to include in the classpath.
*/
- private final URL[] m_implied;
+ private final URI[] m_implied;

/**
* The system context.
@@ -145,7 +145,7 @@
ClassLoader parent, TypeRepository types,
ServiceRepository services,
ClasspathDirective directive,
- URL[] implied )
+ URI[] implied )
throws NullArgumentException
{
super();
@@ -177,7 +177,7 @@

if( implied == null )
{
- m_implied = new URL[0];
+ m_implied = new URI[0];
}
else
{
@@ -276,7 +276,7 @@
*
* @return the implied urls
*/
- public URL[] getImplicitURLs()
+ public URI[] getImplicitURIs()
{
return m_implied;
}

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderModel.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderModel.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderModel.java
Tue Mar 22 21:04:46 2005
@@ -22,6 +22,7 @@
import java.io.IOException;

import java.net.JarURLConnection;
+import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLStreamHandler;
@@ -71,8 +72,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id$
*/
-public class DefaultClassLoaderModel
- implements ClassLoaderModel
+public class DefaultClassLoaderModel implements ClassLoaderModel
{
//==============================================================
// static
@@ -87,7 +87,7 @@

private final ClassLoaderContext m_context;

- private final String[] m_classpath;
+ private final URI[] m_classpath;

private final URL[] m_urls;

@@ -136,7 +136,7 @@

ClasspathDirective directive = context.getClasspathDirective();

- URL[] implicit = context.getImplicitURLs();
+ URI[] implicit = context.getImplicitURIs();

try
{
@@ -204,11 +204,11 @@
*
* @param logger the loggiong channel
* @param profile the profile directive
- * @param implied a sequence of implied urls
+ * @param implied a sequence of implied uris
* @return a new classloader context
*/
public ClassLoaderModel createClassLoaderModel(
- Logger logger, ContainmentProfile profile, URL[] implied )
+ Logger logger, ContainmentProfile profile, URI[] implied )
throws ModelException
{
ClassLoaderContext context =
@@ -277,7 +277,7 @@
* @return a new classloader context
*/
private ClassLoaderContext createChildContext(
- Logger logger, ContainmentProfile profile, URL[] implied )
+ Logger logger, ContainmentProfile profile, URI[] implied )
{
SystemContext system = m_context.getSystemContext();
ClasspathDirective directive =
@@ -287,7 +287,7 @@
logger, system, m_classLoader, m_types, m_services, directive,
implied );
}

- private String[] getClassPath()
+ private URI[] getClassPath()
{
return m_classpath;
}
@@ -301,10 +301,10 @@
throws Exception
{
final ArrayList list = new ArrayList();
- final String[] classpath = getClassPath();
+ final URI[] classpath = getClassPath();
for( int i=0; i<classpath.length; i++ )
{
- String entry = classpath[i];
+ URI entry = classpath[i];
URL url = createURL( entry );
if( isaCandidate( url ) )
{
@@ -314,15 +314,15 @@
return (URL[]) list.toArray( new URL[0] );
}

- private URL createURL( String path ) throws Exception
+ private URL createURL( URI uri ) throws Exception
{
- if( path.startsWith( "artifact:" ) )
+ if( "artifact".equals( uri.getScheme() ) )
{
- return Artifact.createArtifact( path ).toURL();
+ return Artifact.createArtifact( uri ).toURL();
}
else
{
- return new URL( path );
+ return uri.toURL();
}
}

@@ -356,8 +356,8 @@
}
}

- private String[] createClassPath(
- File base, ClasspathDirective directive, URL[] implicit )
+ private URI[] createClassPath(
+ File base, ClasspathDirective directive, URI[] implicit )
throws Exception
{
ArrayList classpath = new ArrayList();
@@ -371,7 +371,7 @@

for( int i=0; i<implicit.length; i++ )
{
- classpath.add( implicit[i].toString() );
+ classpath.add( implicit[i] );
}
}

@@ -388,20 +388,18 @@
}
}

- Artifact[] artifacts =
- directive.getArtifacts();
-
+ URI[] artifacts = directive.getURIs();
for( int i=0; i<artifacts.length; i++ )
{
- Artifact artifact = artifacts[i];
- classpath.add( artifact.toString() ); // <-- TODO: remove this
string based classpath handling
+ URI artifact = artifacts[i];
+ classpath.add( artifact );
}

- return (String[]) classpath.toArray( new String[0] );
+ return (URI[]) classpath.toArray( new URI[0] );
}

private void addToClassPath( List list, File[] files )
- throws IOException
+ throws Exception
{
for( int i=0; i<files.length; i++ )
{
@@ -410,10 +408,10 @@
}

private void addToClassPath( List list, File file )
- throws IOException
+ throws Exception
{
File canonical = file.getCanonicalFile();
- String uri = canonical.toURL().toString();
+ URI uri = new URI( canonical.toURL().toString() );
list.add( uri );
}

@@ -428,10 +426,7 @@
public File[] expandFileSetDirectives (
File base, FilesetDirective[] filesets ) throws IOException,
IllegalStateException
{
- //getLocalLogger().debug("base=[" + base + "]");
-
ArrayList list = new ArrayList();
-
for( int i=0; i<filesets.length; i++ )
{
FilesetDirective fileset = filesets[i];
@@ -447,7 +442,6 @@
fsm.resolveFileset();
list.addAll(fsm.getIncludes());
}
-
return (File[]) list.toArray( new File[0] );
}


Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultComponentModel.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultComponentModel.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultComponentModel.java
Tue Mar 22 21:04:46 2005
@@ -29,6 +29,7 @@
import net.dpml.composition.data.ContextDirective;
import net.dpml.composition.data.DependencyDirective;
import net.dpml.composition.data.DeploymentProfile;
+import net.dpml.composition.data.ComponentProfile;
import net.dpml.composition.data.Mode;

import net.dpml.composition.model.ComponentModel;
@@ -133,116 +134,111 @@
* the deployment context
*/
public DefaultComponentModel( ComponentContext context ) throws
ModelException
- {
- super( context );
-
- m_context = context;
-
- m_activation = getDefaultActivationPolicy();
+ {
+ super( context );

- setCollectionPolicy( m_context.getComponentProfile()
- .getCollectionPolicy() );
+ m_context = context;
+ m_activation = getDefaultActivationPolicy();

- ClassLoader classLoader = m_context.getClassLoader();
+ final ComponentProfile profile = m_context.getComponentProfile();
+ setCollectionPolicy( profile.getCollectionPolicy() );
+ ClassLoader classLoader = m_context.getClassLoader();
+ final Type type = m_context.getType();
+ if ( isConfigurable() )
+ {
+ final Configuration defaults = type.getConfiguration();
+ final Configuration explicit = profile.getConfiguration();
+ final Configuration consolidated =
+ consolidateConfigurations( explicit, defaults );
+ if ( consolidated != null )
+ {
+ setConfiguration( consolidated );
+ }
+ else
+ {
+ setConfiguration( EMPTY_CONFIGURATION );
+ }
+ }

- if ( isConfigurable() )
+ if ( isParameterizable() )
+ {
+ Parameters staticDefaults = type.getParameters();
+ final Parameters parameters = profile.getParameters();
+ if ( parameters != null )
{
- final Configuration defaults = m_context.getType()
- .getConfiguration();
- final Configuration explicit =
m_context.getComponentProfile()
- .getConfiguration();
- final Configuration consolidated = consolidateConfigurations(
- explicit, defaults );
- if ( consolidated != null )
+ if ( null == staticDefaults )
{
- setConfiguration( consolidated );
+ m_parameters = parameters;
}
else
{
- setConfiguration( EMPTY_CONFIGURATION );
+ DefaultParameters temp = new DefaultParameters();
+ temp.merge( staticDefaults );
+ temp.merge( parameters );
+ m_parameters = temp;
}
}
-
- if ( isParameterizable() )
+ else
{
- Parameters staticDefaults =
m_context.getType().getParameters();
- final Parameters parameters = m_context.getComponentProfile()
- .getParameters();
- if ( parameters != null )
+ if ( null == staticDefaults )
{
- if ( null == staticDefaults )
- {
- m_parameters = parameters;
- }
- else
- {
- DefaultParameters temp = new DefaultParameters();
- temp.merge( staticDefaults );
- temp.merge( parameters );
- m_parameters = temp;
- }
+ m_parameters = DefaultParameters.EMPTY_PARAMETERS;
}
else
{
- if ( null == staticDefaults )
- {
- m_parameters = DefaultParameters.EMPTY_PARAMETERS;
- }
- else
- {
- m_parameters = staticDefaults;
- }
+ m_parameters = staticDefaults;
}
}
+ }

- final ContextDescriptor contextDescriptor = m_context.getType()
- .getContext();
- final ContextDirective contextDirective = m_context
- .getComponentProfile().getContext();
- final Logger log = getLogger().getChildLogger( "context" );
- m_contextModel = new DefaultContextModel( log, contextDescriptor,
- contextDirective, context );
-
- //
- // create the dependency models for subsequent assembly
- // management
- //
-
- DependencyDescriptor[] dependencies = m_context.getType()
- .getDependencies();
- m_dependencies = new DefaultDependencyModel[dependencies.length];
-
- for ( int i = 0; i < dependencies.length; i++ )
- {
- DependencyDescriptor descriptor = dependencies[i];
- DependencyDirective directive = context.getComponentProfile()
- .getDependencyDirective( descriptor.getKey() );
- m_dependencies[i] = new DefaultDependencyModel( context
- .getLogger().getChildLogger( "deps" ), context
- .getPartitionName(), context.getProfile().getName(),
- descriptor, directive );
- }
+ final ContextDescriptor contextDescriptor = type.getContext();
+
+ final ContextDirective contextDirective =
profile.getContextDirective();
+ final Logger log = getLogger().getChildLogger( "context" );
+
+ m_contextModel =
+ new DefaultContextModel( log, contextDescriptor, contextDirective,
context );
+
+ //
+ // create the dependency models for subsequent assembly
+ // management
+ //
+
+ DependencyDescriptor[] dependencies = type.getDependencies();
+ m_dependencies = new DefaultDependencyModel[dependencies.length];
+ for ( int i = 0; i < dependencies.length; i++ )
+ {
+ DependencyDescriptor descriptor = dependencies[i];
+ ComponentProfile cp = context.getComponentProfile();
+ DependencyDirective directive = cp.getDependencyDirective(
descriptor.getKey() );
+ Logger depsLogger = context.getLogger().getChildLogger( "deps" );
+ String partition = context.getPartitionName();
+ DeploymentProfile dp = context.getProfile();
+ String name = dp.getName();
+ m_dependencies[i] =
+ new DefaultDependencyModel( depsLogger, partition, name,
descriptor, directive );
}
+ }

/**
* Get the default activation policy for the model.
*/
public boolean getDefaultActivationPolicy()
{
- final int activation = m_context.getComponentProfile()
- .getActivationDirective();
-
+ final ComponentProfile component = m_context.getComponentProfile();
+ final int activation = component.getActivationPolicy();
if ( activation != DeploymentProfile.DEFAULT )
{
return ( activation == DeploymentProfile.ENABLED );
}
else
{
- if ( m_context.getProfile().getMode() == Mode.EXPLICIT )
+ DeploymentProfile profile = m_context.getProfile();
+ if ( profile.getMode() == Mode.EXPLICIT )
{
Type type = m_context.getType();
- if ( type.getInfo().getLifestyle().equals(
- InfoDescriptor.TRANSIENT ) )
+ InfoDescriptor info = type.getInfo();
+ if ( info.getLifestyle().equals( InfoDescriptor.TRANSIENT ) )
{
return false;
}

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
Tue Mar 22 21:04:46 2005
@@ -554,7 +554,8 @@
public ContainmentModel addContainmentModel( URL block, URL config )
throws ModelException
{
- ContainmentModel model = createContainmentModel( null, block );
+ URI uri = convertToURI( block );
+ ContainmentModel model = createContainmentModel( null, uri );
addModel( model.getName(), model );
applyTargets( config );
return model;
@@ -937,7 +938,7 @@
final String name, final ContainmentProfile profile )
throws ModelException
{
- return createContainmentModel( name, profile, new URL[0] );
+ return createContainmentModel( name, profile, new URI[0] );
}

/**
@@ -950,7 +951,7 @@
* @return the composition model
*/
private ContainmentModel createContainmentModel(
- final String name, final ContainmentProfile profile, URL[] implicit )
+ final String name, final ContainmentProfile profile, URI[] implicit )
throws ModelException
{
final String partition = getPartition();
@@ -965,7 +966,7 @@

LoggingManager logging =
m_context.getSystemContext().getLoggingManager();
final String base = partition + name;
- logging.addCategories( base, profile.getCategories() );
+ logging.addCategories( base, profile.getCategoriesDirective() );
Logger log = logging.getLoggerForCategory( base );

try
@@ -1024,9 +1025,7 @@
try
{
URI uri = directive.getURI();
- Artifact artifact = Artifact.createArtifact( uri );
- final URL url = artifact.toURL();
- model = createContainmentModel( name, url );
+ model = createContainmentModel( name, uri );
}
catch( Throwable e )
{
@@ -1045,43 +1044,40 @@

/**
* Create a containment model that is derived from an external
- * source containment profile defintion.
+ * source containment profile definition.
*
* @param name the name of the containment model to be created.
* @param url the Url of the containment model.
* @return the containment model established by the include
*/
- private ContainmentModel createContainmentModel( String name, URL url )
+ private ContainmentModel createContainmentModel( String name, URI uri )
throws ModelException
{
- if( url.getProtocol().equals( "artifact" ) )
+ if( "artifact".equals( uri.getScheme() ) )
{
- String spec = url.toString();
-
+ String spec = uri.toString();
+
if( spec.startsWith( "artifact:block:" ) )
{
try
{
+ URL url = Artifact.createArtifact( uri ).toURL();
DefaultConfigurationBuilder builder =
new DefaultConfigurationBuilder();
Configuration config =
builder.build( url.openStream(), spec );
-
final ContainmentProfile profile =
CREATOR.createContainmentProfile( config );
-
final String message =
"including composite block: " + spec;
getLogger().debug( message );
-
return createContainmentModel( getName( name, profile ),
profile );
-
}
catch( Throwable e )
{
final String error =
"Unable to create block from descriptor ["
- + url.toString()
+ + uri.toString()
+ "] in the containmment model ["
+ getQualifiedName()
+ "] due to a build related error.";
@@ -1092,18 +1088,16 @@
{
try
{
+ URL url = Artifact.createArtifact( uri ).toURL();
final URL blockURL = new URL( url,
"/BLOCK-INF/block.xml" );
final InputStream stream = blockURL.openStream();
-
final ContainmentProfile profile =
BUILDER.createContainmentProfile( stream );
-
final String message =
"including composite block: " + blockURL.toString();
getLogger().debug( message );
-
return createContainmentModel(
- getName( name, profile ), profile, new URL[]{ url } );
+ getName( name, profile ), profile, new URI[]{ uri } );
}
catch( Throwable e )
{
@@ -1118,16 +1112,21 @@
}
else
{
+ //
+ // TODO: try and load the artifact as a serialized
DeploymnetDirective
+ //
+
final String error =
- "Don't know what to do with artifact: " + url;
+ "Don't know what to do with artifact: " + uri;
throw new ModelException( error );
}
}

- final String path = url.toString();
+ final String path = uri.toString();

try
{
+ URL url = uri.toURL();
if( path.endsWith( ".jar" ) )
{
final URL jarURL = convertToJarURL( url );
@@ -1138,13 +1137,11 @@
{
final ContainmentProfile profile =
BUILDER.createContainmentProfile( stream );
-
final String message =
"including composite block: " + blockURL.toString();
getLogger().debug( message );
-
return createContainmentModel(
- getName( name, profile ), profile, new URL[]{ url } );
+ getName( name, profile ), profile, new URI[]{ uri } );
}
catch( Throwable e )
{
@@ -1163,37 +1160,29 @@
new DefaultConfigurationBuilder();
Configuration config =
builder.build( path );
-
final ContainmentProfile profile =
CREATOR.createContainmentProfile( config );
-
final String message =
"including composite block: " + path;
getLogger().debug( message );
-
return createContainmentModel( getName( name, profile ),
profile );
}
else if( path.endsWith( "/" ) )
{
verifyPath( path );
-
final URL blockURL =
new URL( url.toString() + "BLOCK-INF/block.xml" );
-
DefaultConfigurationBuilder builder =
new DefaultConfigurationBuilder();
Configuration config =
builder.build( blockURL.toString() );
-
final ContainmentProfile profile =
CREATOR.createContainmentProfile( config );
-
final String message =
"including composite block: " + blockURL.toString();
getLogger().debug( message );
-
return createContainmentModel(
- getName( name, profile ), profile, new URL[]{ url } );
+ getName( name, profile ), profile, new URI[]{ uri } );
}
else if( path.endsWith( ".bar" ) )
{
@@ -1204,7 +1193,7 @@
else
{
verifyPath( path );
- return createContainmentModel( name, new URL( path + "/" ) );
+ return createContainmentModel( name, new URI( path + "/" ) );
}
}
catch( ModelException e )
@@ -1276,19 +1265,28 @@
return profile.getName();
}

-/* Never used. TODO: Remove.
- * Conver a file to a jar url.
- *
- * @param file the file to convert
- * @return the converted url
- * @exception MalformedURLException if something goes wrong
+ /**
+ * Conver a classic url to uri.
*
- private URL convertToJarURL( File file ) throws MalformedURLException
+ * @param url the url to convert
+ * @return the uri
+ * @exception ModelException if something goes wrong
+ */
+ private URI convertToURI( URL url ) throws ModelException
{
- URL url = file.toURL();
- return convertToJarURL( url );
+ try
+ {
+ return new URI( url.toExternalForm() );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Failed to convert the url [" +
+ url
+ + "] to a uri.";
+ throw new ModelException( error, e );
+ }
}
-*/

/**
* Conver a classic url to a jar url. If the supplied url protocol is not
@@ -1355,7 +1353,6 @@
}
}

-
private TargetDirective[] getTargets( final URL url )
throws ModelException
{

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModelComponentHelper.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModelComponentHelper.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModelComponentHelper.java
Tue Mar 22 21:04:46 2005
@@ -116,7 +116,7 @@
final String name = profile.getName();
final String partition = m_model.getPartition();
LoggingManager logging = system.getLoggingManager();
- CategoriesDirective categories = profile.getCategories();
+ CategoriesDirective categories = profile.getCategoriesDirective();
if( null != categories )
{
logging.addCategories( partition, categories );

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultDeploymentModel.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultDeploymentModel.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultDeploymentModel.java
Tue Mar 22 21:04:46 2005
@@ -19,6 +19,7 @@
package net.dpml.composition.model.impl;

import net.dpml.composition.data.Mode;
+import net.dpml.composition.data.DeploymentProfile;

import net.dpml.composition.model.Commissionable;
import net.dpml.composition.model.DeploymentModel;
@@ -91,7 +92,8 @@
m_context = context;

m_logger = m_context.getLogger();
- m_categories = m_context.getProfile().getCategories();
+ DeploymentProfile profile = m_context.getProfile();
+ m_categories = profile.getCategoriesDirective();
}

//--------------------------------------------------------------
@@ -260,7 +262,7 @@
public CategoriesDirective getCategories()
{
if( m_categories == null )
- return m_context.getProfile().getCategories();
+ return m_context.getProfile().getCategoriesDirective();
return m_categories;
}


Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultModelFactory.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultModelFactory.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultModelFactory.java
Tue Mar 22 21:04:46 2005
@@ -367,7 +367,7 @@
}

m_context.getSystemContext().getLoggingManager().addCategories(
- profile.getCategories() );
+ profile.getCategoriesDirective() );
final Logger logger =

m_context.getSystemContext().getLoggingManager().getLoggerForCategory("");


Modified:
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/ClassLoaderContext.java
==============================================================================
---
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/ClassLoaderContext.java
(original)
+++
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/ClassLoaderContext.java
Tue Mar 22 21:04:46 2005
@@ -19,7 +19,7 @@
package net.dpml.composition.provider;

import java.io.File;
-import java.net.URL;
+import java.net.URI;

import net.dpml.system.SystemContext;

@@ -95,11 +95,11 @@
ServiceRepository getServiceRepository();

/**
- * Return any implied urls to include in the classloader.
+ * Return any implied uris to include in the classloader.
*
- * @return the implied urls
+ * @return the implied uris
*/
- URL[] getImplicitURLs();
+ URI[] getImplicitURIs();

/**
* Return the system context.



  • svn commit: r2119 - in development/main: . metro/composition/api/src/main/net/dpml/composition/data metro/composition/api/src/main/net/dpml/composition/model metro/composition/api/src/test/net/dpml/composition/data/test metro/composition/impl/src/main/net/dpml/composition/data/builder metro/composition/impl/src/main/net/dpml/composition/model/impl metro/composition/spi/src/main/net/dpml/composition/provider, mcconnell, 03/22/2005

Archive powered by MHonArc 2.6.24.

Top of Page