Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2230 - in development/main/metro: automation/builder/src/main/net/dpml/automation/builder composition/api/src/main/net/dpml/composition/data composition/api/src/main/net/dpml/composition/model composition/api/src/test/net/dpml/composition/data/test composition/builder/src/main/net/dpml/composition/builder composition/builder/src/main/net/dpml/composition/builder/datatypes composition/control/src/main/net/dpml/composition/control composition/control/src/main/net/dpml/composition/models composition/impl/src/main/net/dpml/composition/data/builder composition/impl/src/main/net/dpml/composition/model/impl composition/testing/acme composition/testing/acme/src/main/net/dpml/composition/testing composition/testing/unit composition/testing/unit/src/test/net/dpml/composition/testing

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: r2230 - in development/main/metro: automation/builder/src/main/net/dpml/automation/builder composition/api/src/main/net/dpml/composition/data composition/api/src/main/net/dpml/composition/model composition/api/src/test/net/dpml/composition/data/test composition/builder/src/main/net/dpml/composition/builder composition/builder/src/main/net/dpml/composition/builder/datatypes composition/control/src/main/net/dpml/composition/control composition/control/src/main/net/dpml/composition/models composition/impl/src/main/net/dpml/composition/data/builder composition/impl/src/main/net/dpml/composition/model/impl composition/testing/acme composition/testing/acme/src/main/net/dpml/composition/testing composition/testing/unit composition/testing/unit/src/test/net/dpml/composition/testing
  • Date: Wed, 06 Apr 2005 14:50:22 -0400

Author: mcconnell AT dpml.net
Date: Wed Apr 6 14:50:19 2005
New Revision: 2230

Added:

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/PartReferenceBuilder.java

development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/TwistedGizmo.java

development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/ValueWidget.java
Removed:

development/main/metro/automation/builder/src/main/net/dpml/automation/builder/PartReferenceBuilder.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/EntryDirective.java

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

development/main/metro/composition/api/src/main/net/dpml/composition/data/Parameter.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/ParameterTestCase.java

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

development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/MicroTestCase.java
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/ContextDirective.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/ValueDirective.java

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

development/main/metro/composition/api/src/main/net/dpml/composition/model/EntryModel.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/ContainmentProfileTestCase.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/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ContextDataType.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartsDataType.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextInvocationHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/DependencyInvocationHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/models/EntryModel.java

development/main/metro/composition/control/src/main/net/dpml/composition/models/StandardComponentModel.java

development/main/metro/composition/control/src/main/net/dpml/composition/models/ValueModel.java

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

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

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultEntryModel.java
development/main/metro/composition/testing/acme/build.xml
development/main/metro/composition/testing/unit/build.xml

development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/AcmeContainerTestCase.java
Log:
Update things to allow the inclusion of components in <context> and general
updates dealing with the merging of context and dependency concerns.

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
Wed Apr 6 14:50:19 2005
@@ -212,7 +212,7 @@

if( null == context )
{
- m_context = new ContextDirective( new EntryDirective[0] );
+ m_context = new ContextDirective();
}
else
{

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
Wed Apr 6 14:50:19 2005
@@ -20,6 +20,8 @@

import java.io.Serializable;

+import net.dpml.automation.part.PartReference;
+
/**
* A context descriptor declares the context creation criteria for
* the context instance and context entries.
@@ -50,7 +52,7 @@
/**
* The set of entry directives.
*/
- private final EntryDirective[] m_entries;
+ private final PartReference[] m_entries;

/**
* The constext implementation classname.
@@ -62,14 +64,14 @@
*/
public ContextDirective()
{
- this( new EntryDirective[0] );
+ this( new PartReference[0] );
}

/**
* Creation of a context directive
* @param entries the set of entry descriptors
*/
- public ContextDirective( final EntryDirective[] entries )
+ public ContextDirective( final PartReference[] entries )
{
this( null, entries );
}
@@ -79,7 +81,7 @@
* @param classname the context implementation class
* @param entries the set of entry descriptors
*/
- public ContextDirective( final String classname, final EntryDirective[]
entries )
+ public ContextDirective( final String classname, final PartReference[]
entries )
{
m_classname = classname;
if( entries != null )
@@ -88,7 +90,7 @@
}
else
{
- m_entries = new EntryDirective[0];
+ m_entries = new PartReference[0];
}
}

@@ -105,7 +107,7 @@
* Return the set of entry directives.
* @return the entries
*/
- public EntryDirective[] getEntryDirectives()
+ public PartReference[] getPartReferences()
{
return m_entries;
}
@@ -116,11 +118,11 @@
* @return the entry corresponding to the supplied key or null if the
* key is unknown
*/
- public EntryDirective getEntryDirective( String key )
+ public PartReference getPartReference( String key )
{
for( int i = 0; i < m_entries.length; i++ )
{
- EntryDirective entry = m_entries[ i ];
+ PartReference entry = m_entries[ i ];
if( entry.getKey().equals( key ) )
{
return entry;
@@ -156,18 +158,18 @@
{
return false;
}
- if( getEntryDirectives().length !=
context.getEntryDirectives().length )
+ if( getPartReferences().length !=
context.getPartReferences().length )
{
return false;
}
else
{
- EntryDirective[] mine = getEntryDirectives();
- EntryDirective[] yours = context.getEntryDirectives();
+ PartReference[] mine = getPartReferences();
+ PartReference[] yours = context.getPartReferences();
for( int i=0; i<mine.length; i++ )
{
- EntryDirective p = mine[i];
- EntryDirective q = yours[i];
+ PartReference p = mine[i];
+ PartReference q = yours[i];
if( false == p.equals( q ) )
{
return false;

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
Wed Apr 6 14:50:19 2005
@@ -18,7 +18,11 @@

package net.dpml.composition.data;

-import net.dpml.lang.NullArgumentException;
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import net.dpml.automation.part.Part;

/**
* An inport directive used within a context directive to request a
container scoped values.
@@ -48,7 +52,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id$
*/
-public class ImportDirective extends EntryDirective
+public class ImportDirective implements Serializable, Part
{
/**
* The container scoped key.
@@ -59,19 +63,35 @@
* Creation of a new entry directive.
* @param key the context entry key
* @param containerKey the container scoped key value to import
- * @exception NullArgumentException if the containerKey argument is null.
+ * @exception NullPointerExceptionif the containerKey argument is null.
*/
- public ImportDirective( final String key, final String containerKey )
- throws NullArgumentException
+ public ImportDirective( final String containerKey )
+ throws NullPointerException
{
- super( key );
if( null == containerKey )
{
- throw new NullArgumentException( "containerKey" );
+ throw new NullPointerException( "containerKey" );
}
m_import = containerKey;
}

+
//--------------------------------------------------------------------------
+ // Part
+
//--------------------------------------------------------------------------
+
+ /**
+ * Return the part handler uri.
+ * @return the uri of the part handler
+ */
+ public URI getPartHandlerURI()
+ {
+ return PART_HANDLER_URI;
+ }
+
+
//--------------------------------------------------------------------------
+ // ImportDirective
+
//--------------------------------------------------------------------------
+
/**
* Return the container scoped key that defines the object to be
imported.
*
@@ -93,10 +113,6 @@
{
return false;
}
- else if( false == super.equals( other ) )
- {
- return false;
- }
else
{
if( other instanceof ImportDirective )
@@ -117,9 +133,22 @@
*/
public int hashCode()
{
- int hash = super.hashCode();
- hash ^= m_import.hashCode();
+ int hash = m_import.hashCode();
return hash;
}

+ private static URI PART_HANDLER_URI = setupURI( "@PART-HANDLER-URI@" );
+ private static URI PART_BUILDER_URI = setupURI( "@PART-BUILDER-URI@" );
+
+ protected static URI setupURI( String spec )
+ {
+ try
+ {
+ return new URI( spec );
+ }
+ catch( URISyntaxException ioe )
+ {
+ return null;
+ }
+ }
}

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ValueDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ValueDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ValueDirective.java
Wed Apr 6 14:50:19 2005
@@ -54,7 +54,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id: Parameter.java 2119 2005-03-23 02:04:46Z mcconnell AT dpml.net
$
*/
-public class ValueDirective extends EntryDirective implements Part
+public class ValueDirective implements Part, Serializable
{

//--------------------------------------------------------------------------
// state
@@ -68,20 +68,30 @@
// constructors

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

- public ValueDirective( String key, String classname, String value )
+ public ValueDirective( String classname, String value )
{
- super( key );
+ if( null == classname )
+ {
+ throw new NullPointerException( "classname" );
+ }
m_classname = classname;
m_local = value;
m_values = new Value[0];
}

- public ValueDirective( String key, String classname, Value[] values )
+ public ValueDirective( String classname, Value[] values )
{
- super( key );
+ if( null == classname )
+ {
+ throw new NullPointerException( "classname" );
+ }
+ if( null == values )
+ {
+ throw new NullPointerException( "values" );
+ }
m_classname = classname;
- m_local = null;
m_values = values;
+ m_local = null;
}


//--------------------------------------------------------------------------
@@ -116,6 +126,79 @@
return m_values;
}

+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( false == ( other instanceof ValueDirective ) )
+ {
+ return false;
+ }
+ else
+ {
+ ValueDirective value = (ValueDirective) other;
+ if( false == equals( m_classname, value.getClassname() ) )
+ {
+ return false;
+ }
+ else if( false == equals( m_local, value.getLocalValue() ) )
+ {
+ return false;
+ }
+ else if( m_values.length != value.getValues().length )
+ {
+ return false;
+ }
+ else
+ {
+ Value[] mine = getValues();
+ Value[] yours = value.getValues();
+ for( int i=0; i<mine.length; i++ )
+ {
+ Value a = mine[i];
+ Value b = yours[i];
+ if( false == equals( a, b ) )
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ }
+
+ public int hashCode()
+ {
+ int hash = getClass().getName().hashCode();
+ if( null != m_classname )
+ {
+ hash ^= m_classname.hashCode();
+ }
+ if( null != m_local )
+ {
+ hash ^= m_local.hashCode();
+ }
+ for( int i=0; i<m_values.length; i++ )
+ {
+ hash ^= m_values[i].hashCode();
+ }
+ return hash;
+ }
+
+ private boolean equals( Object o1, Object o2 )
+ {
+ if( null == o1 )
+ {
+ return ( null == o2 );
+ }
+ else
+ {
+ return o1.equals( o2 );
+ }
+ }
+

//--------------------------------------------------------------------------
// static utils

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

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/model/ContextModel.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/model/ContextModel.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/model/ContextModel.java
Wed Apr 6 14:50:19 2005
@@ -20,6 +20,8 @@

import java.util.Map;

+import net.dpml.automation.model.Model;
+
/**
* <p>Specification of a context model from which a
* a fully qualifed context can be established.</p>
@@ -49,14 +51,14 @@
*
* @return the entry models
*/
- EntryModel[] getEntryModels();
+ Model[] getEntryModels();

/**
* Return an entry model matching the supplied key.
*
* @return the entry model or null if tyhe key is unknown
*/
- EntryModel getEntryModel( String key );
+ Model getEntryModel( String key );

/**
* Set the entry model relative to a supplied key.
@@ -64,7 +66,7 @@
* @param key the entry key
* @param model the entry model
*/
- void setEntryModel( String key, EntryModel model );
+ void setEntryModel( String key, Model model );

/**
* Set the entry to a suplied value.
@@ -72,7 +74,7 @@
* @param key the entry key
* @param value the entry value
*/
- void setEntry( String key, Object value );
+ //void setEntry( String key, Object value );

/**
* Return the context map established for the component.

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/model/EntryModel.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/model/EntryModel.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/model/EntryModel.java
Wed Apr 6 14:50:19 2005
@@ -18,6 +18,8 @@

package net.dpml.composition.model;

+import net.dpml.automation.model.Model;
+
/**
* <p>Specification of a context enty model from which a
* a context value can be established.</p>
@@ -25,7 +27,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id$
*/
-public interface EntryModel
+public interface EntryModel extends Model
{
/**
* Return the context entry key.

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
Wed Apr 6 14:50:19 2005
@@ -75,7 +75,7 @@
m_name = "Test";
m_classname = ComponentProfileTestCase.class.getName();
m_context =
- new ContextDirective( getClass().getName(), new ImportDirective[0]
);
+ new ContextDirective( getClass().getName(), new PartReference[0] );
m_configuration = new DefaultConfiguration("test");
m_dependencies = new DependencyDirective[0];
m_parameters = new DefaultParameters( System.getProperties(), true );

Modified:
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/ContainmentProfileTestCase.java
(original)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContainmentProfileTestCase.java
Wed Apr 6 14:50:19 2005
@@ -96,7 +96,7 @@
{
m_classname = ComponentProfileTestCase.class.getName();
m_context =
- new ContextDirective( getClass().getName(), new ImportDirective[0]
);
+ new ContextDirective( getClass().getName(), new PartReference[0] );
m_configuration = new DefaultConfiguration("test");
m_dependencies = new DependencyDirective[0];
m_parameters = new DefaultParameters( System.getProperties(), true );

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
Wed Apr 6 14:50:19 2005
@@ -19,8 +19,10 @@

import junit.framework.TestCase;

+import net.dpml.automation.part.PartReference;
+
+import net.dpml.composition.data.ValueDirective;
import net.dpml.composition.data.ImportDirective;
-import net.dpml.composition.data.EntryDirective;
import net.dpml.composition.data.ContextDirective;

/**
@@ -49,7 +51,7 @@

try
{
- new ContextDirective( null, new EntryDirective[0] );
+ new ContextDirective( null, new PartReference[0] );
}
catch(NullPointerException npe)
{
@@ -68,38 +70,39 @@

public void testContextDirective()
{
- EntryDirective[] entries = new EntryDirective[0];
+ PartReference[] entries = new PartReference[0];
ContextDirective cd =
new ContextDirective( getClass().getName(), entries );

assertEquals( "classname", getClass().getName(), cd.getClassname());
- assertEquals( "entries", entries, cd.getEntryDirectives());
- assertEquals( "length", entries.length,
cd.getEntryDirectives().length);
+ assertEquals( "entries", entries, cd.getPartReferences());
+ assertEquals( "length", entries.length,
cd.getPartReferences().length);
}

public void testGetEntry()
{
String key = "key";
String val = "val";
- ImportDirective imp = new ImportDirective( key, "xxx" );
- EntryDirective[] entries =
- new EntryDirective[]{ imp };
+ ValueDirective imp = new ValueDirective( "xxx", "yyy" );
+ PartReference[] entries =
+ new PartReference[]{ new PartReference( key, imp ) };
ContextDirective cd = new ContextDirective( entries );

assertNull( cd.getClassname() );
- assertEquals( entries, cd.getEntryDirectives() );
- assertEquals( entries.length, cd.getEntryDirectives().length );
- assertEquals( entries[0], cd.getEntryDirective( key ) );
- assertNull( cd.getEntryDirective( val ) );
+ assertEquals( entries, cd.getPartReferences() );
+ assertEquals( entries.length, cd.getPartReferences().length );
+ assertEquals( entries[0], cd.getPartReference( key ) );
+ assertNull( cd.getPartReference( val ) );
}

public void testSerialization() throws Exception
{
String key = "key";
String val = "val";
- ImportDirective imp = new ImportDirective( key, "xxx" );
- EntryDirective[] entries =
- new EntryDirective[]{ imp };
+ ValueDirective imp = new ValueDirective( "xxx", "yyy" );
+ PartReference ref = new PartReference( key, imp );
+ PartReference[] entries =
+ new PartReference[]{ ref };
ContextDirective cd = new ContextDirective( entries );
testSerialization( cd );
}

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
Wed Apr 6 14:50:19 2005
@@ -37,30 +37,10 @@
{
try
{
- new ImportDirective( null, null );
+ new ImportDirective( null );
fail( "Did not throw expected NullArgumentException" );
}
- catch ( NullArgumentException npe )
- {
- // Success!!
- }
-
- try
- {
- new ImportDirective( null, "abc" );
- fail( "Did not throw expected NullArgumentException" );
- }
- catch ( NullArgumentException npe )
- {
- // Success!!
- }
-
- try
- {
- new ImportDirective( "key", null );
- fail( "Did not throw expected NullArgumentException" );
- }
- catch ( NullArgumentException npe )
+ catch ( NullPointerException npe )
{
// Success!!
}
@@ -68,19 +48,16 @@

public void testEntry() throws MetaDataException
{
- String key = "key";
String imp = "container-scoped-key";

- ImportDirective entry = new ImportDirective( key, imp );
- assertEquals( key, entry.getKey() );
+ ImportDirective entry = new ImportDirective( imp );
assertEquals( imp, entry.getImportKey() );
}

public void testSerialization() throws Exception
{
- String key = "key";
String imp = "container-scoped-key";
- testSerialization( new ImportDirective( key, imp ) );
+ testSerialization( new ImportDirective( imp ) );
}

}
\ No newline at end of file

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
Wed Apr 6 14:50:19 2005
@@ -46,17 +46,15 @@
import net.dpml.logging.data.CategoriesDirective;

import net.dpml.composition.data.TypeNotFoundException;
-import net.dpml.composition.data.EntryDirective;
import net.dpml.composition.data.DeploymentProfile;
-import net.dpml.composition.data.ConstructorDirective;
import net.dpml.composition.data.ContextDirective;
import net.dpml.composition.data.DependencyDirective;
import net.dpml.composition.data.ClassLoaderDirective;
import net.dpml.composition.data.ClasspathDirective;
import net.dpml.composition.data.FilesetDirective;
-import net.dpml.composition.data.Parameter;
import net.dpml.composition.data.ComponentProfile;
import net.dpml.composition.data.Mode;
+
import net.dpml.composition.control.CompositionPartHandler;

import net.dpml.composition.builder.datatypes.CategoriesDataType;
@@ -74,7 +72,7 @@
import net.dpml.automation.part.PartHolder;
import net.dpml.automation.part.PartReference;
import net.dpml.automation.builder.PartBuilder;
-import net.dpml.automation.builder.PartReferenceBuilder;
+//import net.dpml.automation.builder.PartReferenceBuilder;
import net.dpml.automation.builder.IntrospectionException;

import net.dpml.configuration.Configuration;
@@ -261,7 +259,7 @@

/**
* Add a dependencies directive to this component.
- * @return the depednencies directive
+ * @return the depedencies directive
*/
public DependenciesDataType createDependencies()
{
@@ -299,7 +297,7 @@
ComponentProfile profile = buildComponentProfile( classloader,
cld );
URI uri = getDefinition().getArtifactURI( Part.ARTIFACT_TYPE );
if( null == m_output )
- {
+ {
log( "saving part to: " + uri );
}
else
@@ -443,7 +441,9 @@
public Part buildPart( ClassLoader classloader )
throws IntrospectionException, IOException, ClassNotFoundException
{
- return buildComponentProfile( classloader );
+ String classname = getClassname();
+ Type type = loadType( classloader, classname );
+ return buildComponentProfile( type, classloader );
}

//---------------------------------------------------------------------
@@ -467,11 +467,11 @@
return m_key;
}

- public PartReference buildPartReference( ClassLoader classloader )
+ public PartReference buildPartReference( ClassLoader classloader, Type
type )
throws IntrospectionException, IOException, ClassNotFoundException
{
String key = getKey();
- Part part = buildComponentProfile( classloader );
+ Part part = buildComponentProfile( type, classloader );
return new PartReference( key, part );
}

@@ -479,7 +479,7 @@
// impl
//---------------------------------------------------------------------

- private ComponentProfile buildComponentProfile( ClassLoader classloader
)
+ private ComponentProfile buildComponentProfile( Type type, ClassLoader
classloader )
throws IntrospectionException, IOException, ClassNotFoundException
{
return buildComponentProfile( classloader, null );
@@ -488,6 +488,11 @@
private ComponentProfile buildComponentProfile( ClassLoader classloader,
ClassLoaderDirective cld )
throws IntrospectionException, IOException, ClassNotFoundException
{
+ String classname = getClassname();
+ log( "building " + classname );
+
+ Type type = loadType( classloader, classname );
+
String id = getName();
if( null != m_uri )
{
@@ -539,16 +544,14 @@
// setup classname and type
//

- String classname = getClassname();
- Type type = loadType( classloader, classname );
String lifestyle = getLifestylePolicy( type );
int collection = getCollectionPolicy( type );
int activation = getActivationPolicy();
Mode mode = Mode.EXPLICIT;
CategoriesDirective categories = getCategoriesDirective();
ContextDirective context = getContextDirective( classloader, type );
- DependencyDirective[] dependencies = getDependencyDirectives();
- PartReference[] parts = getParts( classloader );
+ DependencyDirective[] dependencies = getDependencyDirectives(
classloader, type );
+ PartReference[] parts = getParts( classloader, type );

Parameters parameters = getParameters();
Configuration configuration = getConfiguration();
@@ -728,7 +731,7 @@
throws IntrospectionException, IOException, ClassNotFoundException
{
String classname = type.getInfo().getClassname();
- ContextDirective context = createContextDirective( classloader );
+ ContextDirective context = createContextDirective( classloader, type
);

//
// validate that the context directives are declared
@@ -740,15 +743,17 @@
{
EntryDescriptor entry = entries[i];
String key = entry.getKey();
- EntryDirective directive = context.getEntryDirective( key );
- if( entry.isRequired() && ( null == directive ) )
+
+ PartReference reference = context.getPartReference( key );
+
+ if( entry.isRequired() && ( null == reference ) )
{
final String error =
"The component model ["
+ getName()
+ "] referencing the component type ["
+ classname
- + "] does not declare a context entry directive for the
non-optional entry ["
+ + "] does not declare a context entry for the non-optional
entry ["
+ key
+ "].";
throw new ConstructionException( error, getLocation() );
@@ -762,7 +767,7 @@
return context;
}

- private ContextDirective createContextDirective( ClassLoader classloader
)
+ private ContextDirective createContextDirective( ClassLoader
classloader, Type type )
throws IntrospectionException, IOException, ClassNotFoundException
{
if( null == m_context )
@@ -771,11 +776,11 @@
}
else
{
- return m_context.getContextDirective( classloader );
+ return m_context.getContextDirective( classloader, type );
}
}

- private DependencyDirective[] getDependencyDirectives()
+ private DependencyDirective[] getDependencyDirectives( ClassLoader
classloader, Type type )
{
if( null == m_dependencies )
{
@@ -783,7 +788,7 @@
}
else
{
- return m_dependencies.getDependencyDirectives();
+ return m_dependencies.getDependencyDirectives( classloader, type
);
}
}

@@ -823,7 +828,7 @@
}
}

- private PartReference[] getParts( ClassLoader classloader )
+ private PartReference[] getParts( ClassLoader classloader, Type type )
throws IntrospectionException, IOException, ClassNotFoundException
{
if( null == m_parts )
@@ -832,7 +837,7 @@
}
else
{
- return m_parts.getParts( classloader );
+ return m_parts.getParts( classloader, type );
}
}


Added:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/PartReferenceBuilder.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/PartReferenceBuilder.java
Wed Apr 6 14:50:19 2005
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2005 Stephen J. McConnell
+ *
+ * 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.builder;
+
+import java.net.URI;
+import java.io.IOException;
+
+import net.dpml.automation.part.Part;
+import net.dpml.automation.part.PartReference;
+import net.dpml.automation.control.BadStrategyException;
+import net.dpml.automation.builder.PartBuilder;
+import net.dpml.automation.builder.IntrospectionException;
+
+import net.dpml.meta.info.Type;
+
+/**
+ * The contract for builders that create component part.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface PartReferenceBuilder
+{
+ /**
+ * Return the key identifying the part that this builder is building.
+ */
+ String getKey();
+
+ /**
+ * Build the part.
+ * @param classloader the classloader to use if type creation is required
+ * @return the serializable part
+ * @exception Exception if a construction error occurs
+ */
+ PartReference buildPartReference( ClassLoader classloader, Type type )
+ throws IntrospectionException, IOException, ClassNotFoundException;
+}

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
Wed Apr 6 14:50:19 2005
@@ -495,7 +495,7 @@
validateNonArrayReturnType( method, returnType );
validateInterfaceReturnType( method, returnType );
validateNoExceptions( method );
- validateNoParameters( method );
+ validateAtMostOneParameter( method );

String key = getPartKey( method, "get" );
String type = returnType.getName();

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ContextDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ContextDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ContextDataType.java
Wed Apr 6 14:50:19 2005
@@ -24,13 +24,18 @@
import java.io.IOException;

import net.dpml.automation.part.Part;
+import net.dpml.automation.part.PartReference;
import net.dpml.automation.builder.PartBuilder;
+//import net.dpml.automation.builder.PartReferenceBuilder;
import net.dpml.automation.builder.IntrospectionException;

import net.dpml.composition.data.ContextDirective;
-import net.dpml.composition.data.ConstructorDirective;
-import net.dpml.composition.data.EntryDirective;
-import net.dpml.composition.data.Parameter;
+
+import net.dpml.composition.builder.ComponentBuilderTask;
+import net.dpml.composition.builder.PartReferenceBuilder;
+
+import net.dpml.meta.info.Type;
+

/**
* A context directive class.
@@ -69,39 +74,35 @@
return builder;
}

+ public ComponentBuilderTask createComponent()
+ {
+ ComponentBuilderTask builder = new ComponentBuilderTask();
+ m_builders.add( builder );
+ return builder;
+ }
+
/**
* Return all of the context entries within the context directive.
* @return the set of context entries
*/
- public PartBuilder[] getBuilders()
+ public PartReferenceBuilder[] getBuilders()
{
- return (PartBuilder[]) m_builders.toArray( new PartBuilder[0] );
+ return (PartReferenceBuilder[]) m_builders.toArray( new
PartReferenceBuilder[0] );
}

- public ContextDirective getContextDirective( ClassLoader classloader )
+ public ContextDirective getContextDirective( ClassLoader classloader,
Type type )
throws IntrospectionException, IOException, ClassNotFoundException
{
String classname = getClassname();
- PartBuilder[] builders = getBuilders();
- EntryDirective[] entryDirectives = new EntryDirective[
builders.length ];
+ PartReferenceBuilder[] builders = getBuilders();
+ PartReference[] references = new PartReference[ builders.length ];
for( int i=0; i<builders.length; i++ )
{
- PartBuilder builder = builders[i];
- Part part = builder.buildPart( classloader );
- if( part instanceof EntryDirective )
- {
- entryDirectives[i] = (EntryDirective) part;
- }
- else
- {
- final String error =
- "Incompatible part type ["
- + part.getClass().getName()
- + "]";
- throw new IllegalStateException( error );
- }
+ PartReferenceBuilder builder = builders[i];
+ PartReference reference = builder.buildPartReference(
classloader, type );
+ references[i] = reference;
}
- return new ContextDirective( classname, entryDirectives );
+ return new ContextDirective( classname, references );
}
}


Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java
Wed Apr 6 14:50:19 2005
@@ -24,6 +24,8 @@

import net.dpml.composition.data.DependencyDirective;

+import net.dpml.meta.info.Type;
+
/**
* Dependecies data type
*/
@@ -51,14 +53,14 @@
return (DependencyDataType[]) m_dependencies.toArray( new
DependencyDataType[0] );
}

- public DependencyDirective[] getDependencyDirectives()
+ public DependencyDirective[] getDependencyDirectives( ClassLoader
classloader, Type type )
{
DependencyDataType[] deps = getDependencies();
DependencyDirective[] dependencies = new DependencyDirective[
deps.length ];
for( int i=0; i<dependencies.length; i++ )
{
DependencyDataType dep = deps[i];
- DependencyDirective directive = dep.getDependencyDirective();
+ DependencyDirective directive = dep.getDependencyDirective(
classloader, type );
dependencies[i] = directive;
}
return dependencies;
@@ -108,7 +110,7 @@
return m_source;
}

- public DependencyDirective getDependencyDirective()
+ public DependencyDirective getDependencyDirective( ClassLoader
classloader, Type type )
{
String key = getKey();
String source = getSource();

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
Wed Apr 6 14:50:19 2005
@@ -25,17 +25,28 @@
import java.net.URISyntaxException;

import net.dpml.automation.part.Part;
+import net.dpml.automation.part.PartReference;
import net.dpml.automation.builder.PartBuilder;
+//import net.dpml.automation.builder.PartReferenceBuilder;

import net.dpml.composition.data.ValueDirective;
import net.dpml.composition.data.ValueDirective.Value;
+import net.dpml.composition.builder.ConstructionException;
+import net.dpml.composition.builder.PartReferenceBuilder;
+
+import net.dpml.meta.info.Type;
+import net.dpml.meta.info.EntryDescriptor;
+import net.dpml.meta.info.DependencyDescriptor;
+
+import org.apache.tools.ant.BuildException;

/**
* A simple part datatype.
*/
-public class EntryDataType extends ValueDataType implements PartBuilder
+public class EntryDataType extends ValueDataType implements
PartReferenceBuilder
{
private String m_key;
+ private ClassLoader m_classloader;

/**
* Set the key that this directive qualifies.
@@ -61,22 +72,39 @@
}

//---------------------------------------------------------------------
- // PartBuilder
+ // PartReferenceBuilder
//---------------------------------------------------------------------

- public Part buildPart( ClassLoader classloader )
- {
- return getValueDirective( classloader );
- }
-
/**
* Return the key identifying the part that this builder is building.
*/
public String getKey()
{
+ if( null == m_key )
+ {
+ final String error =
+ "Missing 'key' attribute declaration.";
+ throw new ConstructionException( error );
+ }
return m_key;
}

+ public PartReference buildPartReference( ClassLoader classloader, Type
type )
+ {
+ String key = getKey();
+ Part part = getValueDirective( classloader, type );
+ return new PartReference( key, part );
+ }
+
+ //---------------------------------------------------------------------
+ // PartBuilder
+ //---------------------------------------------------------------------
+
+ //public Part buildPart( ClassLoader classloader )
+ //{
+ // return getValueDirective( classloader );
+ //}
+
/**
* Return a urn identitifying the part handler for this builder.
*
@@ -91,14 +119,40 @@
// implementation
//---------------------------------------------------------------------

- public ValueDirective getValueDirective( ClassLoader classloader )
+ public ValueDirective getValueDirective( ClassLoader classloader, Type
type )
{
- String key = getKey();
String classname = getClassname();
+ String key = getKey();
+ if( null == classname )
+ {
+ EntryDescriptor entry = type.getContext().getEntry( key );
+ if( null != entry )
+ {
+ classname = entry.getClassname();
+ }
+ else
+ {
+ DependencyDescriptor dep = type.getDependency( key );
+ if( null != dep )
+ {
+ classname = dep.getReference().getClassname();
+ }
+ }
+ }
+ if( null == classname )
+ {
+ final String error =
+ "Unable to construct a value directive for the key ["
+ + key
+ + "] relative to the component type ["
+ + type.getInfo().getClassname()
+ + "] as the primary classname was not resolvable.";
+ throw new ConstructionException( error );
+ }
String value = getValue();
if( null != value )
{
- return new ValueDirective( key, classname, value );
+ return new ValueDirective( classname, value );
}
else
{
@@ -109,7 +163,7 @@
ValueDataType p = params[i];
values[i] = p.constructValue();
}
- return new ValueDirective( key, classname, values );
+ return new ValueDirective( classname, values );
}
}

@@ -131,6 +185,5 @@
return null;
}
}
-
}


Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartsDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartsDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartsDataType.java
Wed Apr 6 14:50:19 2005
@@ -26,10 +26,13 @@
import net.dpml.automation.part.Part;
import net.dpml.automation.part.PartReference;
import net.dpml.automation.builder.PartBuilder;
-import net.dpml.automation.builder.PartReferenceBuilder;
+//import net.dpml.automation.builder.PartReferenceBuilder;
import net.dpml.automation.builder.IntrospectionException;

import net.dpml.composition.builder.ComponentBuilderTask;
+import net.dpml.composition.builder.PartReferenceBuilder;
+
+import net.dpml.meta.info.Type;

import org.apache.tools.ant.Task;
import org.apache.tools.ant.Target;
@@ -70,12 +73,12 @@
* Create a new constructed value builder.
* @return a part builder
*/
- //public EntryDataType createValue()
- //{
- // final EntryDataType builder = new EntryDataType();
- // m_builders.add( builder );
- // return builder;
- //}
+ public EntryDataType createValue()
+ {
+ final EntryDataType builder = new EntryDataType();
+ m_builders.add( builder );
+ return builder;
+ }

/**
* Operation used to construct a custom part type directive.
@@ -173,7 +176,7 @@
* Return the set of parts contained within this container.
* @return the contained parts
*/
- public PartReference[] getParts( ClassLoader classloader )
+ public PartReference[] getParts( ClassLoader classloader, Type type )
throws IntrospectionException, IOException, ClassNotFoundException
{
PartReferenceBuilder[] builders = (PartReferenceBuilder[])
m_builders.toArray( new PartReferenceBuilder[0] );
@@ -181,7 +184,7 @@
for( int i=0; i<builders.length; i++ )
{
PartReferenceBuilder builder = builders[i];
- parts[i] = builder.buildPartReference( classloader );
+ parts[i] = builder.buildPartReference( classloader, type );
}
return parts;
}

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
Wed Apr 6 14:50:19 2005
@@ -28,6 +28,7 @@
import java.util.Collections;
import java.util.WeakHashMap;
import java.util.ArrayList;
+import java.util.Hashtable;
import java.lang.reflect.Proxy;
import java.lang.reflect.InvocationHandler;

@@ -49,7 +50,9 @@
import net.dpml.composition.data.ComponentProfile;
import net.dpml.composition.data.ClasspathDirective;
import net.dpml.composition.data.ClassLoaderDirective;
+import net.dpml.composition.data.ValueDirective;
import net.dpml.composition.models.StandardComponentModel;
+import net.dpml.composition.models.ValueModel;

import net.dpml.logging.Logger;

@@ -139,6 +142,11 @@
ComponentProfile profile = (ComponentProfile) part;
return getComponentModel( model, partition, parent, profile );
}
+ else if( part instanceof ValueDirective )
+ {
+ ValueDirective value = (ValueDirective) part;
+ return getValueModel( model, partition, parent, value );
+ }
else
{
URI uri = part.getPartHandlerURI();
@@ -167,6 +175,11 @@
StandardComponentModel componentModel = (StandardComponentModel)
model;
return m_factory.incarnate( componentModel );
}
+ else if( model instanceof ValueModel )
+ {
+ ValueModel value = (ValueModel) model;
+ return value.getValue();
+ }
else
{
return model.getController().create( model );
@@ -188,6 +201,11 @@
Holder holder = getHolder( componentModel , null );
return holder.newProxy();
}
+ else if( model instanceof ValueModel )
+ {
+ ValueModel value = (ValueModel) model;
+ return value.getValue();
+ }
else
{
return model.getController().resolve( model );
@@ -359,6 +377,22 @@
}
}

+ /**
+ * Return the model for a supplied part.
+ *
+ * @param model the enclosing model
+ * @param partition the enclosing partition
+ * @param parent the parent classloader
+ * @param profile the part profile
+ * @return the model
+ */
+ public ValueModel getValueModel(
+ Model model, String partition, ClassLoader parent, ValueDirective
value )
+ throws DelegationException, ModelException
+ {
+ return new ValueModel( this, parent, value, new Hashtable() );
+ }
+
//--------------------------------------------------------------------
// private
//--------------------------------------------------------------------

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextInvocationHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextInvocationHandler.java
Wed Apr 6 14:50:19 2005
@@ -25,18 +25,20 @@
import java.util.Hashtable;
import java.util.Map;

+import net.dpml.automation.control.Controller;
import net.dpml.automation.control.LifecycleException;
+import net.dpml.automation.control.ControlRuntimeException;
import net.dpml.automation.model.ModelException;
+import net.dpml.automation.model.Model;

import net.dpml.composition.models.StandardComponentModel;
-import net.dpml.composition.models.EntryModel;
import net.dpml.composition.models.ValueModel;
import net.dpml.composition.data.ContextDirective;
-import net.dpml.composition.data.EntryDirective;
+import net.dpml.composition.data.ImportDirective;
import net.dpml.composition.data.ValueDirective;

import net.dpml.meta.info.Type;
-import net.dpml.meta.info.EntryDescriptor;
+//import net.dpml.meta.info.EntryDescriptor;

import net.dpml.system.SystemContext;

@@ -62,13 +64,13 @@
/**
* A map of context entries published by the model and keyed by entry key.
*/
- private final Map m_entries = new Hashtable();
+ //private final Map m_entries = new Hashtable();

/**
* A map of the entry descriptors published by the component type
* and keyed by entry key.
*/
- private final Map m_descriptors = new Hashtable();
+ //private final Map m_descriptors = new Hashtable();

/**
* The component model.
@@ -96,57 +98,6 @@
m_system = system;
m_model = model;
m_type = model.getType();
-
- //
- // get the set of context entries declared by the component type
- // and for each entry determine the context entry model to
- // use for context entry value resolution
- //
-
- EntryDescriptor[] entries = m_type.getContext().getEntries();
- ContextDirective context = model.getContextDirective();
- ClassLoader classloader = model.getClassLoader();
-
- for( int i=0; i<entries.length; i++ )
- {
- EntryDescriptor entry = entries[i];
- final String key = entry.getKey();
- EntryDirective directive = context.getEntryDirective( key );
-
- if( null == directive )
- {
- if( entry.isRequired() )
- {
- final String error =
- "The component model ["
- + model.getQualifiedName()
- + "] does not delcare a context directive for the key "
- + key
- + "].";
- throw new LifecycleException( error );
- }
- }
- else
- {
- m_descriptors.put( key, entry );
- if( directive instanceof ValueDirective )
- {
- ValueDirective value = (ValueDirective) directive;
- ValueModel m = new ValueModel( classloader, entry,
value, m_entries );
- m_entries.put( key, m );
- }
- else
- {
- final String error =
- "Unrecognized entry directive class ["
- + directive.getClass().getName()
- + "] withing the component model ["
- + model.getQualifiedName()
- + "].";
- throw new LifecycleException( error );
- }
- }
- }
}

//-------------------------------------------------------------------
@@ -181,55 +132,63 @@

String name = method.getName();
String key = getKeyFromMethod( method );
- EntryDescriptor entry = (EntryDescriptor) m_descriptors.get( key );
+ final Model provider = m_model.getProvider( key );
+ Object instance = getInstance( key, provider, args );

- if( null == entry )
+ if( instance instanceof String )
{
- final String error =
- "Illegal request for an undeclared context entry ["
- + key
- + "] withing the component type ["
- + m_type.getInfo().getClassname()
- + "].";
- throw new IllegalArgumentException( error );
+ String v = (String) instance;
+ if( v.startsWith( "urn:metro:" ) )
+ {
+ if( "urn:metro:name".equals( v ) )
+ {
+ return m_model.getName();
+ }
+ else if( "urn:metro:partition".equals( v ) )
+ {
+ return m_model.getPartition();
+ }
+ else
+ {
+ final String error =
+ "Context entry urn ["
+ + v
+ + "] not recognized.";
+ throw new IllegalArgumentException( error );
+ }
+ }
}
+ return instance;
+ }

- //
- // we have a valid key
- //
-
- EntryModel model = (EntryModel) m_entries.get( key );
- if( null == model )
+ private Object getInstance( String key, Model provider, final Object[]
args )
+ {
+ if( null == key )
{
- return returnClientSuppliedDefaultArgument( entry, args );
+ throw new NullPointerException( "key" );
}
- else
+ if( null != provider )
{
- Object value = model.getValue();
- if( value instanceof String )
+ try
{
- String v = (String) value;
- if( v.startsWith( "urn:metro:" ) )
- {
- if( "urn:metro:name".equals( v ) )
- {
- return m_model.getName();
- }
- else if( "urn:metro:partition".equals( v ) )
- {
- return m_model.getPartition();
- }
- else
- {
- final String error =
- "Context entry urn ["
- + v
- + "] not recognized.";
- throw new IllegalArgumentException( error );
- }
- }
+ return provider.resolve();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected runtime error while attempting to resolve the
context value for the key ["
+ + key
+ + "] using the provider ["
+ + provider
+ + "] for the component type ["
+ + m_type.getInfo().getClassname()
+ + "].";
+ throw new ControlRuntimeException( error, e );
}
- return value;
+ }
+ else
+ {
+ return returnClientSuppliedDefaultArgument( key, args );
}
}

@@ -261,13 +220,13 @@
return first + remainder;
}

- private Object returnClientSuppliedDefaultArgument( EntryDescriptor
entry, Object[] args )
+ private Object returnClientSuppliedDefaultArgument( String key, Object[]
args )
{
if( args.length < 1 )
{
final String error =
"Insuffient arguments to resolve a default value for the key ["
- + entry.getKey()
+ + key
+ "] within the component type ["
+ m_type.getInfo().getName()
+ "].";

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/DependencyInvocationHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/DependencyInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/DependencyInvocationHandler.java
Wed Apr 6 14:50:19 2005
@@ -116,8 +116,7 @@

try
{
- Controller controller = provider.getController();
- return controller.resolve( provider );
+ return provider.resolve();
}
catch( Throwable e )
{

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/models/EntryModel.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/models/EntryModel.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/models/EntryModel.java
Wed Apr 6 14:50:19 2005
@@ -18,7 +18,9 @@

package net.dpml.composition.models;

+import net.dpml.automation.model.Model;
import net.dpml.automation.model.ModelException;
+import net.dpml.automation.control.Controller;

import net.dpml.meta.info.EntryDescriptor;

@@ -28,13 +30,14 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id: DefaultEntryModel.java 1518 2005-01-17 17:13:05Z niclas $
*/
-public abstract class EntryModel
+public abstract class EntryModel implements Model
{
//--------------------------------------------------------------
// state
//--------------------------------------------------------------

- private EntryDescriptor m_descriptor;
+ //private EntryDescriptor m_descriptor;
+ private Controller m_controller;

//--------------------------------------------------------------
// constructor
@@ -46,17 +49,62 @@
* @param descriptor the context entry descriptor
* @exception NullPointerException is the descriptor argument is null.
*/
- public EntryModel( EntryDescriptor descriptor )
+ public EntryModel( Controller controller )
throws NullPointerException
{
- if( descriptor == null )
- {
- throw new NullPointerException( "descriptor" );
- }
- m_descriptor = descriptor;
+ //if( descriptor == null )
+ //{
+ // throw new NullPointerException( "descriptor" );
+ //}
+ //m_descriptor = descriptor;
+ m_controller = controller;
}

//--------------------------------------------------------------
+ // Model
+ //--------------------------------------------------------------
+
+ public Object create() throws Exception
+ {
+ return getValue();
+ }
+
+ public Object resolve() throws Exception
+ {
+ return getValue();
+ }
+
+ public Object resolve( Object key ) throws Exception
+ {
+ throw new UnsupportedOperationException( "resolve/1" );
+ }
+
+ public void release( Object object )
+ {
+ }
+
+ public Controller getController()
+ {
+ return m_controller;
+ }
+
+ public String getName()
+ {
+ throw new UnsupportedOperationException( "getName/0" );
+ }
+
+ public String getPartition()
+ {
+ throw new UnsupportedOperationException( "getPartition/0" );
+ }
+
+ public String getQualifiedName()
+ {
+ throw new UnsupportedOperationException( "getQualifiedName/0" );
+ }
+
+
+ //--------------------------------------------------------------
// EntryModel
//--------------------------------------------------------------

@@ -65,10 +113,10 @@
*
* @return the key
*/
- public String getKey()
- {
- return m_descriptor.getKey();
- }
+ //public String getKey()
+ //{
+ // return m_descriptor.getKey();
+ //}

/**
* Return the context entry value.

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/models/StandardComponentModel.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/models/StandardComponentModel.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/models/StandardComponentModel.java
Wed Apr 6 14:50:19 2005
@@ -37,6 +37,7 @@

import net.dpml.composition.data.ComponentProfile;
import net.dpml.composition.data.ContextDirective;
+import net.dpml.composition.data.ValueDirective;
import net.dpml.composition.data.DependencyDirective;
import net.dpml.composition.control.CompositionClassLoader;
import net.dpml.composition.control.CompositionController;
@@ -46,6 +47,7 @@
import net.dpml.meta.info.ServiceDescriptor;
import net.dpml.meta.info.DependencyDescriptor;
import net.dpml.meta.info.PartDescriptor;
+import net.dpml.meta.info.EntryDescriptor;

/**
* The implementation of a component model.
@@ -159,6 +161,47 @@
}

//
+ // build the context model
+ //
+
+ ContextDirective context = profile.getContextDirective();
+ EntryDescriptor[] entries = m_type.getContext().getEntries();
+ for( int i=0; i<entries.length; i++ )
+ {
+ EntryDescriptor entry = entries[i];
+ final String key = entry.getKey();
+ PartReference reference = context.getPartReference( key );
+ if( null == reference )
+ {
+ if( entry.isRequired() )
+ {
+ final String error =
+ "The component model ["
+ + getQualifiedName()
+ + "] does not declare a context entry for the key "
+ + key
+ + "].";
+ throw new ModelRuntimeException( error );
+ }
+ }
+ else
+ {
+ Part part = reference.getPart();
+ if( part instanceof ValueDirective )
+ {
+ ValueDirective value = (ValueDirective) part;
+ Model m = new ValueModel( controller, classloader,
value, m_providers );
+ m_providers.put( key, m );
+ }
+ else
+ {
+ Model m = controller.getModel( partition, classloader,
part );
+ m_providers.put( key, m );
+ }
+ }
+ }
+
+ //
// If this component model has been asserted as a root model then it
cannot
// have any non-optional dependencies. If the model is nested within
another
// model then we can attempt to resolve dependencies using the
supplied enclosing

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/models/ValueModel.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/models/ValueModel.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/models/ValueModel.java
Wed Apr 6 14:50:19 2005
@@ -21,6 +21,7 @@
import java.lang.reflect.Constructor;
import java.util.Map;

+import net.dpml.automation.control.Controller;
import net.dpml.automation.model.ModelException;

import net.dpml.composition.data.ValueDirective;
@@ -41,7 +42,6 @@
//--------------------------------------------------------------

private final ValueDirective m_directive;
- private final EntryDescriptor m_descriptor;
private final ClassLoader m_classloader;
private final Map m_map;

@@ -59,22 +59,22 @@
* @exception NullArgumentException if either the directive argument or
the
* context argument is null.
*/
- public ValueModel( ClassLoader classloader, EntryDescriptor descriptor,
ValueDirective directive, Map entries )
+ public ValueModel( Controller controller, ClassLoader classloader,
ValueDirective directive, Map entries )
throws ModelException, NullPointerException
{
- super( descriptor );
+ super( controller );
if( directive == null )
{
throw new NullPointerException( "directive" );
}
- m_descriptor = descriptor;
m_directive = directive;
m_classloader = classloader;
m_map = entries;

- validate();
+ //validate();
}

+ /*
private void validate()
throws ModelException
{
@@ -155,6 +155,7 @@
throw new ModelException( error );
}
}
+ */

//--------------------------------------------------------------
// EntryModel
@@ -173,7 +174,8 @@
return m_value;
}

- String target = m_descriptor.getKey();
+ //String target = m_descriptor.getKey();
+ String target = "???";
Object object = null;
try
{
@@ -186,30 +188,23 @@
catch( Throwable e )
{
final String error =
- "Cannot establish a constructed context entry for the key " +
target
+ "Cannot establish a constructed context entry for the key "
+ + target
+ " due to a runtime failure.";
throw new ModelException( error, e );
}

- if( !m_descriptor.isVolatile() )
- {
- m_value = object;
- }
+ //if( !m_descriptor.isVolatile() )
+ //{
+ // m_value = object;
+ //}

return object;
}

private String getReturnTypeClassname()
{
- String classname = m_directive.getClassname();
- if( null == classname )
- {
- return m_descriptor.getClassname();
- }
- else
- {
- return classname;
- }
+ return m_directive.getClassname();
}

/**

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLComponentProfileCreator.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLComponentProfileCreator.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLComponentProfileCreator.java
Wed Apr 6 14:50:19 2005
@@ -36,13 +36,12 @@
import net.dpml.composition.data.ClasspathDirective;
import net.dpml.composition.data.DeploymentProfile;
import net.dpml.composition.data.ComponentProfile;
-import net.dpml.composition.data.ConstructorDirective;
import net.dpml.composition.data.ContextDirective;
import net.dpml.composition.data.DependencyDirective;
-import net.dpml.composition.data.EntryDirective;
import net.dpml.composition.data.ImportDirective;
+import net.dpml.composition.data.ValueDirective;
+import net.dpml.composition.data.ValueDirective.Value;
import net.dpml.composition.data.Mode;
-import net.dpml.composition.data.Parameter;

import net.dpml.meta.info.InfoDescriptor;

@@ -208,7 +207,7 @@
}

final String classname = config.getAttribute( "class", null );
- EntryDirective[] entries = getEntries( config.getChildren( "entry" )
);
+ PartReference[] entries = getEntries( config.getChildren( "entry" )
);
return new ContextDirective( classname, entries );
}

@@ -219,17 +218,17 @@
* @return the entry directives
* @throws ConfigurationException if an error occurs
*/
- protected EntryDirective[] getEntries( Configuration[] configs )
+ protected PartReference[] getEntries( Configuration[] configs )
throws ConfigurationException
{
ArrayList list = new ArrayList();
for( int i = 0; i < configs.length; i++ )
{
Configuration conf = configs[ i ];
- EntryDirective entry = getEntry( conf );
+ PartReference entry = getEntry( conf );
list.add( entry );
}
- return (EntryDirective[])list.toArray( new EntryDirective[ 0 ] );
+ return (PartReference[])list.toArray( new PartReference[ 0 ] );
}

/**
@@ -239,7 +238,7 @@
* @return the entry directive
* @throws ConfigurationException if an error occurs
*/
- protected EntryDirective getEntry( Configuration conf )
+ protected PartReference getEntry( Configuration conf )
throws ConfigurationException
{
final String key = conf.getAttribute( "key" );
@@ -249,14 +248,15 @@
String value = conf.getValue( null );
if( null != value )
{
- return new ConstructorDirective(
- key, classname, value );
+ ValueDirective directive = new ValueDirective( classname,
value );
+ return new PartReference( key, directive );
}
else
{
Configuration[] configs = conf.getChildren( "param" );
- Parameter[] params = getParameters( configs );
- return new ConstructorDirective( key, classname, params );
+ Value[] params = getParameters( configs );
+ ValueDirective directive = new ValueDirective( classname,
params );
+ return new PartReference( key, directive );
}
}
else
@@ -278,7 +278,8 @@
if( name.equals( "import" ) )
{
final String importKey = child.getAttribute( "key" );
- return new ImportDirective( key, importKey );
+ ImportDirective imp = new ImportDirective( importKey );
+ return new PartReference( key, imp );
}
else if( name.equals( "constructor" ) )
{
@@ -287,13 +288,15 @@
Configuration[] paramsConf = child.getChildren( "param" );
if( paramsConf.length > 0 )
{
- Parameter[] params = getParameters( paramsConf );
- return new ConstructorDirective( key,
constructorClassname, params );
+ Value[] params = getParameters( paramsConf );
+ ValueDirective v = new ValueDirective(
constructorClassname, params );
+ return new PartReference( key, v );
}
else
{
- return new ConstructorDirective(
- key, constructorClassname, (String) child.getValue(
null ) );
+ ValueDirective v = new ValueDirective(
+ constructorClassname, (String) child.getValue( null )
);
+ return new PartReference( key, v );
}
}
else
@@ -305,7 +308,6 @@
}
}

-
/**
* Utility method to create a set of parameter directive.
*
@@ -313,16 +315,16 @@
* @return the parameter directives
* @throws ConfigurationException if an error occurs
*/
- protected Parameter[] getParameters( Configuration[] configs )
+ protected Value[] getParameters( Configuration[] configs )
throws ConfigurationException
{
ArrayList list = new ArrayList();
for( int i = 0; i < configs.length; i++ )
{
- Parameter parameter = getParameter( configs[ i ] );
+ Value parameter = getParameter( configs[ i ] );
list.add( parameter );
}
- return (Parameter[])list.toArray( new Parameter[ 0 ] );
+ return (Value[])list.toArray( new Value[ 0 ] );
}

/**
@@ -332,7 +334,7 @@
* @return the parameter directive
* @throws ConfigurationException if an error occurs
*/
- protected Parameter getParameter( Configuration config )
+ protected Value getParameter( Configuration config )
throws ConfigurationException
{
String classname = config.getAttribute( "class", "java.lang.String"
);
@@ -340,12 +342,12 @@
if( params.length == 0 )
{
String value = config.getValue( null );
- return new Parameter( classname, value );
+ return new Value( classname, value );
}
else
{
- Parameter[] parameters = getParameters( params );
- return new Parameter( classname, parameters );
+ Value[] parameters = getParameters( params );
+ return new Value( classname, parameters );
}
}
}

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContextModel.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContextModel.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContextModel.java
Wed Apr 6 14:50:19 2005
@@ -21,14 +21,15 @@
import java.util.Hashtable;
import java.util.Map;

-import net.dpml.composition.data.ConstructorDirective;
+import net.dpml.automation.part.Part;
+import net.dpml.automation.part.PartReference;
+import net.dpml.automation.model.Model;
+
import net.dpml.composition.data.ValueDirective;
import net.dpml.composition.data.ContextDirective;
-import net.dpml.composition.data.EntryDirective;
import net.dpml.composition.data.ImportDirective;

import net.dpml.composition.model.ContextModel;
-import net.dpml.composition.model.EntryModel;
import net.dpml.composition.model.ModelException;
import net.dpml.composition.model.ModelRuntimeException;

@@ -148,9 +149,8 @@
// the mechanism for building the context entry
//

- EntryDirective entryDirective =
- directive.getEntryDirective( key );
- if( null == entryDirective )
+ PartReference reference = directive.getPartReference( key );
+ if( null == reference )
{
if( entry.isRequired() )
{
@@ -162,35 +162,22 @@
}
else
{
- if( entryDirective instanceof ImportDirective )
+ Part part = reference.getPart();
+ if( part instanceof ImportDirective )
{
//
// importing under an alias of a container scoped key
//

- ImportDirective importDirective =
- (ImportDirective) entryDirective;
+ ImportDirective importDirective = (ImportDirective)
part;
String ref = importDirective.getImportKey();
DefaultImportModel model =
new DefaultImportModel( entry, ref, m_context );
setEntryModel( alias, model );
}
- else if( entryDirective instanceof ConstructorDirective )
- {
- ConstructorDirective constructor =
- (ConstructorDirective) entryDirective;
- DefaultConstructorModel model =
- new DefaultConstructorModel(
- entry,
- constructor,
- context,
- m_map );
- setEntryModel( alias, model );
- }
- else if( entryDirective instanceof ValueDirective )
+ else if( part instanceof ValueDirective )
{
- ValueDirective value =
- (ValueDirective) entryDirective;
+ ValueDirective value = (ValueDirective) part;
DefaultValueModel model =
new DefaultValueModel(
entry,
@@ -202,7 +189,7 @@
else
{
String modelClass =
- entryDirective.getClass().getName();
+ part.getClass().getName();
final String error =
REZ.getString(
"context.unsupported-directive.error",
@@ -250,9 +237,9 @@
*
* @return the entry models
*/
- public EntryModel[] getEntryModels()
+ public Model[] getEntryModels()
{
- return (EntryModel[]) m_map.values().toArray( new EntryModel[0] );
+ return (Model[]) m_map.values().toArray( new Model[0] );
}

/**
@@ -260,9 +247,9 @@
*
* @return the entry model or null if tyhe key is unknown
*/
- public EntryModel getEntryModel( String key )
+ public Model getEntryModel( String key )
{
- return (EntryModel) m_map.get( key );
+ return (Model) m_map.get( key );
}

/**
@@ -271,7 +258,7 @@
* @param key the entry key
* @param model the entry model
*/
- public void setEntryModel( String key, EntryModel model )
+ public void setEntryModel( String key, Model model )
{
m_map.put( key, model );
}
@@ -284,18 +271,19 @@
*/
public void setEntry( String key, Object value )
{
- EntryDescriptor descriptor = m_descriptor.getEntry( key );
- if( null == descriptor )
- {
- final String error =
- "Invalid context entry key ["
- + key
- + "].";
- throw new ModelRuntimeException( error );
- }
- OverrideEntryModel model =
- new OverrideEntryModel( descriptor, value );
- setEntryModel( key, model );
+ throw new UnsupportedOperationException( "setEntry" );
+ // EntryDescriptor descriptor = m_descriptor.getEntry( key );
+ // if( null == descriptor )
+ // {
+ // final String error =
+ // "Invalid context entry key ["
+ // + key
+ // + "].";
+ // throw new ModelRuntimeException( error );
+ // }
+ // OverrideEntryModel model =
+ // new OverrideEntryModel( descriptor, value );
+ // setEntryModel( key, model );
}

/**

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultEntryModel.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultEntryModel.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultEntryModel.java
Wed Apr 6 14:50:19 2005
@@ -18,6 +18,8 @@

package net.dpml.composition.model.impl;

+import net.dpml.automation.control.Controller;
+
import net.dpml.composition.model.EntryModel;
import net.dpml.composition.model.ModelException;

@@ -60,6 +62,50 @@
}

//==============================================================
+ // Model
+ //==============================================================
+
+ public Object create() throws Exception
+ {
+ return getValue();
+ }
+
+ public Object resolve() throws Exception
+ {
+ return getValue();
+ }
+
+ public Object resolve( Object key ) throws Exception
+ {
+ throw new UnsupportedOperationException( "resolve/1" );
+ }
+
+ public void release( Object instance )
+ {
+ }
+
+ public Controller getController()
+ {
+ throw new UnsupportedOperationException( "getController/0" );
+ }
+
+ public String getQualifiedName()
+ {
+ throw new UnsupportedOperationException( "getQualifiedName/0" );
+ }
+
+ public String getPartition()
+ {
+ throw new UnsupportedOperationException( "getQualifiedName/0" );
+ }
+
+ public String getName()
+ {
+ throw new UnsupportedOperationException( "getName/0" );
+ }
+
+
+ //==============================================================
// EntryModel
//==============================================================


Modified: development/main/metro/composition/testing/acme/build.xml
==============================================================================
--- development/main/metro/composition/testing/acme/build.xml (original)
+++ development/main/metro/composition/testing/acme/build.xml Wed Apr 6
14:50:19 2005
@@ -10,9 +10,10 @@
<!-- create the component types -->
<types xmlns="plugin:dpml/composition/dpml-composition-builder">
<type class="net.dpml.composition.testing.DefaultWidget"/>
+ <type class="net.dpml.composition.testing.MicroWidget"/>
<type class="net.dpml.composition.testing.DefaultGizmo"/>
<type class="net.dpml.composition.testing.AcmeContainer"/>
- <type class="net.dpml.composition.testing.MicroWidget"/>
+ <type class="net.dpml.composition.testing.TwistedGizmo"/>
</types>

<!-- simple component -->

Added:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/TwistedGizmo.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/TwistedGizmo.java
Wed Apr 6 14:50:19 2005
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * 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.testing;
+
+import net.dpml.logging.Logger;
+
+/**
+ * AbstractCompositionTestCase
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: CompositionTestCase.java 1393 2005-01-06 10:27:10Z niclas $
+ */
+public class TwistedGizmo implements Gizmo
+{
+ //------------------------------------------------------------------
+ // static
+ //------------------------------------------------------------------
+
+ /**
+ * Declaration to the container that this component is thread-safe.
+ */
+ public static final boolean TYPE_THREADSAFE_CAPABLE = true;
+
+ //------------------------------------------------------------------
+ // state
+ //------------------------------------------------------------------
+
+ /**
+ * The logging channel.
+ */
+ private final Logger m_logger;
+
+ //------------------------------------------------------------------
+ // constructor
+ //------------------------------------------------------------------
+
+ /**
+ * Creation of a new gizmo component. This gizmo aquires a widget via the
+ * context.
+ *
+ * @param logger the logging channel assigned by the container
+ * @param dependencies the requested dependencies
+ */
+ public TwistedGizmo( Logger logger, Context context )
+ {
+ m_logger = logger;
+ Widget widget = context.getWidget();
+ widget.doWidgetTypeStuff();
+ logger.debug( "done");
+ }
+
+ //------------------------------------------------------------------
+ // implementation
+ //------------------------------------------------------------------
+
+ public void dispose()
+ {
+ m_logger.debug( "disposal" );
+ }
+
+ //------------------------------------------------------------------
+ // concerns
+ //------------------------------------------------------------------
+
+ public interface Context
+ {
+ Widget getWidget();
+ }
+}

Added:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/ValueWidget.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/ValueWidget.java
Wed Apr 6 14:50:19 2005
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * 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.testing;
+
+/**
+ * Component implementation that demonstrates the use of a context
inner-class.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: CompositionTestCase.java 1393 2005-01-06 10:27:10Z niclas $
+ */
+public class ValueWidget implements Widget
+{
+ //------------------------------------------------------------------
+ // Widget
+ //------------------------------------------------------------------
+
+ /**
+ * Implementation of the widget service contract.
+ */
+ public void doWidgetTypeStuff()
+ {
+ // not much I can do
+ }
+
+}

Modified: development/main/metro/composition/testing/unit/build.xml
==============================================================================
--- development/main/metro/composition/testing/unit/build.xml (original)
+++ development/main/metro/composition/testing/unit/build.xml Wed Apr 6
14:50:19 2005
@@ -7,7 +7,11 @@

<target name="build" depends="standard.build">

- <!-- simple component example -->
+ <!--
+ Simple component example.
+ This is a ver simple component with not dependencies. It is used
+ primarily to validate constext entry construction.
+ -->
<component dest="target/test/acme-simple.part"
xmlns="plugin:dpml/composition/dpml-composition-builder"
class="net.dpml.composition.testing.DefaultWidget"
@@ -22,7 +26,14 @@
</context>
</component>

- <!-- custom context entry example -->
+ <!--
+ Custom context entry example.
+ Demonstration of the creation of a non-trivial custom context entry.
+ In this example the context entry is an instance of the class Dimension
+ which is created with two int arguments. The MicroWidget component
+ class accesses this via the Context constructor value and uses it
+ to calculate a size value.
+ -->
<component dest="target/test/acme-micro.part"
xmlns="plugin:dpml/composition/dpml-composition-builder"
class="net.dpml.composition.testing.MicroWidget"
@@ -35,7 +46,13 @@
</context>
</component>

- <!-- composite component example -->
+ <!--
+ Composite component example.
+ This is a example of a composite component (the AcmeContainer class)
+ with parts that it manages. The parts include a gizmo and widget
+ component which are automatically resolved by the container and supplied
+ to the AcmeContainer component via the Parts constructor argument.
+ -->
<component dest="target/test/acme-container.part"
xmlns="plugin:dpml/composition/dpml-composition-builder"
class="net.dpml.composition.testing.AcmeContainer"
@@ -59,6 +76,51 @@
</parts>
</component>

+ <!--
+ Composite component example.
+ Instead of using a component to fulfill the dependnecy we are using a
simple
+ constructed value long the lines of values we add to context entries.
+ In this example we are using the same composite container as above
demonstrating
+ the complete separation of requirement (provided by class introspection)
from
+ solution (provided in the directives gererated here).
+ -->
+ <component dest="target/test/acme-test-container.part"
+ xmlns="plugin:dpml/composition/dpml-composition-builder"
+ class="net.dpml.composition.testing.AcmeContainer"
+ name="acme">
+ <parts>
+ <value key="widget"
class="net.dpml.composition.testing.ValueWidget"/>
+ <component name="gizmo"
class="net.dpml.composition.testing.DefaultGizmo">
+ <dependencies>
+ <dependency key="widget" source="widget"/>
+ </dependencies>
+ </component>
+ </parts>
+ </component>
+
+ <!--
+ Composite component example.
+ Include a component in the context defintion of another component.
+ -->
+ <component dest="target/test/twisted-gizmo.part"
+ xmlns="plugin:dpml/composition/dpml-composition-builder"
+ class="net.dpml.composition.testing.TwistedGizmo"
+ name="acme">
+ <context>
+ <component key="widget" name="widget"
class="net.dpml.composition.testing.DefaultWidget"
+ xmlns="plugin:dpml/composition/dpml-composition-builder" >
+ <context>
+ <entry key="foo" value="bar"/>
+ <entry key="width" value="12"/>
+ <entry key="height" value="100"/>
+ <entry key="name" value="urn:metro:name"/>
+ <entry key="partition" value="urn:metro:partition"/>
+ <entry key="workingDirectory" value="acme/workspace"/>
+ </context>
+ </component>
+ </context>
+ </component>
+
</target>

</project>

Modified:
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/AcmeContainerTestCase.java
==============================================================================
---
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/AcmeContainerTestCase.java
(original)
+++
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/AcmeContainerTestCase.java
Wed Apr 6 14:50:19 2005
@@ -34,17 +34,60 @@
* @version $Id: AbstractDescriptorTestCase.java 1556 2005-01-22 12:43:42Z
niclas $
*/
public class AcmeContainerTestCase extends TestCase
-{
- private static final String PATH = "acme-container.part";
-
+{
+ /**
+ * Test the construction of a non-trival context entry.
+ */
+ public void testMicroWidget() throws Exception
+ {
+ final String path = "acme-micro.part";
+ CompositionHelper helper = new CompositionHelper();
+ URI uri = helper.toURI( path );
+ Model model = helper.getCompositionManager().addPart( uri );
+ Object acme = model.resolve();
+ model.release( acme );
+ helper.dispose();
+ }
+
/**
* Test the construction of a component that contains two child components
* (widget and gizmo).
*/
- public void testResolve() throws Exception
+ public void testAcmeContainer() throws Exception
+ {
+ final String path = "acme-container.part";
+ CompositionHelper helper = new CompositionHelper();
+ URI uri = helper.toURI( path );
+ Model model = helper.getCompositionManager().addPart( uri );
+ Object acme = model.resolve();
+ model.release( acme );
+ helper.dispose();
+ }
+
+ /**
+ * Test the construction of a component that contains two child components
+ * (widget and gizmo) where the widget is a value object.
+ */
+ public void testTestContainer() throws Exception
+ {
+ final String path = "acme-test-container.part";
+ CompositionHelper helper = new CompositionHelper();
+ URI uri = helper.toURI( path );
+ Model model = helper.getCompositionManager().addPart( uri );
+ Object acme = model.resolve();
+ model.release( acme );
+ helper.dispose();
+ }
+
+ /**
+ * Test the construction of a component that is supplied with
+ * a dependent component via the context.
+ */
+ public void testTwistedGizmo() throws Exception
{
- CompositionHelper helper = new CompositionHelper( false );
- URI uri = helper.toURI( PATH );
+ final String path = "twisted-gizmo.part";
+ CompositionHelper helper = new CompositionHelper();
+ URI uri = helper.toURI( path );
Model model = helper.getCompositionManager().addPart( uri );
Object acme = model.resolve();
model.release( acme );



  • svn commit: r2230 - in development/main/metro: automation/builder/src/main/net/dpml/automation/builder composition/api/src/main/net/dpml/composition/data composition/api/src/main/net/dpml/composition/model composition/api/src/test/net/dpml/composition/data/test composition/builder/src/main/net/dpml/composition/builder composition/builder/src/main/net/dpml/composition/builder/datatypes composition/control/src/main/net/dpml/composition/control composition/control/src/main/net/dpml/composition/models composition/impl/src/main/net/dpml/composition/data/builder composition/impl/src/main/net/dpml/composition/model/impl composition/testing/acme composition/testing/acme/src/main/net/dpml/composition/testing composition/testing/unit composition/testing/unit/src/test/net/dpml/composition/testing, mcconnell, 04/06/2005

Archive powered by MHonArc 2.6.24.

Top of Page