notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2235 - in development/main/metro: automation/control/src/main/net/dpml/automation/control composition/api/src/main/net/dpml/composition/data 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/testing/acme composition/testing/acme/src/main/net/dpml/composition/testing composition/testing/unit composition/testing/unit/src/test/net/dpml/composition/testing
- From: mcconnell AT dpml.net
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2235 - in development/main/metro: automation/control/src/main/net/dpml/automation/control composition/api/src/main/net/dpml/composition/data 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/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 23:36:32 -0400
Author: mcconnell AT dpml.net
Date: Wed Apr 6 23:36:30 2005
New Revision: 2235
Added:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ReferenceDirective.java
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ReferenceDataType.java
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeComponent.java
- copied, changed from r2234,
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeContainer.java
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/GizmoComponent.java
- copied, changed from r2234,
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultGizmo.java
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetComponent.java
- copied, changed from r2234,
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultWidget.java
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetValue.java
- copied, changed from r2234,
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/ValueWidget.java
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/CompositeTestCase.java
- copied, changed from r2230,
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/AcmeContainerTestCase.java
Removed:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeContainer.java
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultGizmo.java
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultWidget.java
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/MicroWidget.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
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/AcmeContainerTestCase.java
Modified:
development/main/metro/automation/control/src/main/net/dpml/automation/control/Controller.java
development/main/metro/automation/control/src/main/net/dpml/automation/control/UnsupportedPartTypeException.java
development/main/metro/composition/api/src/main/net/dpml/composition/data/DependencyDirective.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/TypesTask.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/ValueDataType.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/models/StandardComponentModel.java
development/main/metro/composition/control/src/main/net/dpml/composition/models/ValueModel.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/SimpleTestCase.java
Log:
Update codebase to handle dependencies through context (see
composition/testing/acme for component source examples and
composition/testing/unit/build.xml for examples of <component> directives).
Modified:
development/main/metro/automation/control/src/main/net/dpml/automation/control/Controller.java
==============================================================================
---
development/main/metro/automation/control/src/main/net/dpml/automation/control/Controller.java
(original)
+++
development/main/metro/automation/control/src/main/net/dpml/automation/control/Controller.java
Wed Apr 6 23:36:30 2005
@@ -101,6 +101,14 @@
Model getProvider( Model model, String path );
/**
+ * Return a model identified by the supplied path within the supplied
model.
+ * @param model the enclosing model
+ * @param uri the nested part address
+ * @return the nested model or null if the model is not found
+ */
+ Model getProvider( Model model, URI uri );
+
+ /**
* Dispose of the supplied model.
*
* @param model the model to apply disposal to
Modified:
development/main/metro/automation/control/src/main/net/dpml/automation/control/UnsupportedPartTypeException.java
==============================================================================
---
development/main/metro/automation/control/src/main/net/dpml/automation/control/UnsupportedPartTypeException.java
(original)
+++
development/main/metro/automation/control/src/main/net/dpml/automation/control/UnsupportedPartTypeException.java
Wed Apr 6 23:36:30 2005
@@ -29,7 +29,7 @@
* @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 class UnsupportedPartTypeException extends Exception
+public class UnsupportedPartTypeException extends RuntimeException
{
private String m_type;
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
Wed Apr 6 23:36:30 2005
@@ -19,16 +19,36 @@
package net.dpml.composition.data;
import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import net.dpml.automation.part.Part;
/**
- * A DependencyDirective contains information describing how a
- * dependency should be resolved.
+ * A DependencyDirective is a reference to another part within the scope of
the
+ * containing part.
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id$
*/
-public final class DependencyDirective implements Serializable
+public final class DependencyDirective implements Serializable, Part
{
+
//--------------------------------------------------------------------------
+ // Part
+
//--------------------------------------------------------------------------
+
+ /**
+ * Return the part handler uri.
+ * @return the uri of the part handler
+ */
+ public URI getPartHandlerURI()
+ {
+ return PART_HANDLER_URI;
+ }
+
+
//--------------------------------------------------------------------------
+ // DependencyDirective
+
//--------------------------------------------------------------------------
/**
* The dependency key that the directive refers to.
@@ -137,4 +157,18 @@
}
}
+ 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;
+ }
+ }
}
Added:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ReferenceDirective.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ReferenceDirective.java
Wed Apr 6 23:36:30 2005
@@ -0,0 +1,133 @@
+/*
+ * 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.data;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import net.dpml.automation.part.Part;
+
+/**
+ * A reference directive is a reference to a part within the enclosing part's
+ * context or parts.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: ImportDirective.java 2230 2005-04-06 18:50:19Z
mcconnell AT dpml.net $
+ */
+public class ReferenceDirective implements Serializable, Part
+{
+ /**
+ * The container scoped key.
+ */
+ private final URI m_uri;
+
+ /**
+ * Creation of a new entry directive.
+ * @param key the context entry key
+ * @param containerKey the container scoped key value to import
+ * @exception NullPointerExceptionif the containerKey argument is null.
+ */
+ public ReferenceDirective( final URI uri )
+ throws NullPointerException
+ {
+ if( null == uri )
+ {
+ throw new NullPointerException( "uri" );
+ }
+ m_uri = uri;
+ }
+
+
//--------------------------------------------------------------------------
+ // Part
+
//--------------------------------------------------------------------------
+
+ /**
+ * Return the part handler uri.
+ * @return the uri of the part handler
+ */
+ public URI getPartHandlerURI()
+ {
+ return PART_HANDLER_URI;
+ }
+
+
//--------------------------------------------------------------------------
+ // ImportDirective
+
//--------------------------------------------------------------------------
+
+ /**
+ * Return the uri reference.
+ *
+ * @return the uri
+ */
+ public URI getURI()
+ {
+ return m_uri;
+ }
+
+ /**
+ * 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 ReferenceDirective )
+ {
+ ReferenceDirective directive = (ReferenceDirective) other;
+ return m_uri.equals( directive.getURI() );
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = m_uri.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/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 23:36:30 2005
@@ -1054,7 +1054,7 @@
catch( ClassNotFoundException e )
{
final String error =
- "Component class reference ["
+ "Cannot build a component type because the class ["
+ m_classname
+ "] is not present in the project path.";
throw new BuildException( error );
Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypesTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypesTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypesTask.java
Wed Apr 6 23:36:30 2005
@@ -127,6 +127,10 @@
final String error = e.getMessage();
throw new BuildException( error, e, getLocation() );
}
+ catch( BuildException e )
+ {
+ throw e;
+ }
catch( Exception e )
{
final String error =
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 23:36:30 2005
@@ -26,7 +26,6 @@
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;
@@ -67,13 +66,33 @@
* Create a new constructed part builder.
* @return a part builder
*/
- public EntryDataType createEntry()
+ public ReferenceDataType createReference()
+ {
+ final ReferenceDataType builder = new ReferenceDataType();
+ m_builders.add( builder );
+ return builder;
+ }
+
+ /**
+ * Create a new constructed part builder.
+ * @return a part builder
+ */
+ public EntryDataType createValue()
{
final EntryDataType builder = new EntryDataType();
m_builders.add( builder );
return builder;
}
+ /**
+ * Create a new constructed part builder.
+ * @return a part builder
+ */
+ public EntryDataType createEntry()
+ {
+ return createValue();
+ }
+
public ComponentBuilderTask createComponent()
{
ComponentBuilderTask builder = new ComponentBuilderTask();
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 23:36:30 2005
@@ -22,7 +22,12 @@
import java.util.LinkedList;
import java.util.ArrayList;
+import net.dpml.automation.part.Part;
+import net.dpml.automation.part.PartReference;
+
import net.dpml.composition.data.DependencyDirective;
+import net.dpml.composition.builder.PartReferenceBuilder;
+import net.dpml.composition.builder.ConstructionException;
import net.dpml.meta.info.Type;
@@ -69,12 +74,15 @@
/**
* A dependency directive.
*/
- public static class DependencyDataType
+ public static class DependencyDataType implements PartReferenceBuilder
{
private String m_source;
-
private String m_key;
+
//---------------------------------------------------------------------
+ // PartReferenceBuilder ?? not needed
+
//---------------------------------------------------------------------
+
/**
* Set the key that this depedency directive qualifies.
* @param key the dependency key
@@ -85,15 +93,32 @@
}
/**
- * Get the dependency directive key.
+ * 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 = getDependencyDirective( classloader, type );
+ return new PartReference( key, part );
+ }
+
+
//---------------------------------------------------------------------
+ // DependencyDataType
+
//---------------------------------------------------------------------
+
/**
- * Set the address of the source component to fulofill the dependency.
+ * Set the address of the source component to fullfill the dependency.
* @param source the source component address
*/
public void setSource( final String source )
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 23:36:30 2005
@@ -27,8 +27,8 @@
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.ReferenceDirective;
import net.dpml.composition.data.ValueDirective;
import net.dpml.composition.data.ValueDirective.Value;
import net.dpml.composition.builder.ConstructionException;
@@ -47,6 +47,7 @@
{
private String m_key;
private ClassLoader m_classloader;
+ private URI m_uri;
/**
* Set the key that this directive qualifies.
@@ -54,7 +55,7 @@
*/
public void setKey( final String key )
{
- m_key = key ;
+ m_key = key;
}
//---------------------------------------------------------------------
Added:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ReferenceDataType.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ReferenceDataType.java
Wed Apr 6 23:36:30 2005
@@ -0,0 +1,157 @@
+/*
+ * 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.datatypes;
+
+import java.util.List;
+import java.util.LinkedList;
+import java.util.ArrayList;
+import java.net.URI;
+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.composition.data.ReferenceDirective;
+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 ReferenceDataType implements PartReferenceBuilder
+{
+ private String m_key;
+ private ClassLoader m_classloader;
+ private URI m_uri;
+
+ /**
+ * Set the key that this directive qualifies.
+ * @param key the context entry key
+ */
+ public void setKey( final String key )
+ {
+ m_key = key;
+ }
+
+ /**
+ * Set the uri that this directive references.
+ * @param key the context entry key
+ */
+ public void setURI( final URI uri )
+ {
+ m_uri = uri;
+ }
+
+ /**
+ * Return the uri reference.
+ * @return the uri
+ */
+ public URI getURI()
+ {
+ return m_uri;
+ }
+
+ //---------------------------------------------------------------------
+ // Builder
+ //---------------------------------------------------------------------
+
+ /**
+ * Return a uri identitifying the builder.
+ *
+ * @return the builder uri
+ */
+ public URI getBuilderURI()
+ {
+ return PART_BUILDER_URI;
+ }
+
+ //---------------------------------------------------------------------
+ // PartReferenceBuilder
+ //---------------------------------------------------------------------
+
+ /**
+ * 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();
+ URI uri = getURI();
+ Part part = new ReferenceDirective( m_uri );
+ return new PartReference( key, part );
+ }
+
+ //---------------------------------------------------------------------
+ // PartBuilder
+ //---------------------------------------------------------------------
+
+ //public Part buildPart( ClassLoader classloader )
+ //{
+ // return getValueDirective( classloader );
+ //}
+
+ /**
+ * Return a urn identitifying the part handler for this builder.
+ *
+ * @return a strategy uri
+ */
+ public URI getPartHandlerURI()
+ {
+ return PART_HANDLER_URI;
+ }
+
+ //---------------------------------------------------------------------
+ // static utilities
+ //---------------------------------------------------------------------
+
+ 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/builder/src/main/net/dpml/composition/builder/datatypes/ValueDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ValueDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ValueDataType.java
Wed Apr 6 23:36:30 2005
@@ -18,6 +18,7 @@
package net.dpml.composition.builder.datatypes;
+import java.net.URI;
import java.util.List;
import java.util.LinkedList;
import java.util.ArrayList;
@@ -30,9 +31,10 @@
*/
public class ValueDataType
{
- private String m_classname;
- private String m_value;
- private List m_params = new ArrayList();
+ private String m_classname;
+ private String m_value;
+ private List m_params = new ArrayList();
+
/**
* Set the context entry classname.
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 23:36:30 2005
@@ -36,6 +36,7 @@
import net.dpml.automation.control.PartHandler;
import net.dpml.automation.control.Controller;
+import net.dpml.automation.control.ControlRuntimeException;
import net.dpml.automation.control.Monitor;
import net.dpml.automation.control.DuplicateNameException;
import net.dpml.automation.control.DelegationException;
@@ -152,7 +153,7 @@
URI uri = part.getPartHandlerURI();
if( getURI().equals( uri ) )
{
- throw new UnsupportedOperationException(
part.getClass().getName() );
+ throw new UnsupportedPartTypeException(
part.getClass().getName() );
}
else
{
@@ -265,12 +266,37 @@
}
}
+ /**
+ * Return a component model using a supplied path using the supplied
+ * model as the source for path resolution. If the model is a standard
+ * composition model the implementation will attempt to resolve the path
+ * using internal parts. If that is not successfull, the implementation
+ * will attempt to resolve the path relative to the registered context
+ * entries. If this fails, a null value will be returned. If the supplied
+ * model is not a composition model then the request will be delegated to
+ * the models controller.
+ *
+ * @param model the model to use for path resolution
+ * @param path the path identifying a internal part or context entry
+ */
public Model getProvider( Model model, String path )
{
if( model instanceof StandardComponentModel )
{
- StandardComponentModel componentModel = (StandardComponentModel)
model;
- return getProviderComponentModel( componentModel, path );
+ StandardComponentModel m = (StandardComponentModel) model;
+ Model provider = m.getPart( path );
+ if( null == provider )
+ {
+ return m.getProvider( path );
+ }
+ else
+ {
+ return provider;
+ }
+ }
+ else if( model instanceof ValueModel )
+ {
+ return null;
}
else
{
@@ -279,6 +305,53 @@
}
/**
+ * Return a component model using a supplied path using the supplied
+ * model as the source for path resolution. If the model is a standard
+ * composition model the implementation will attempt to resolve the path
+ * using internal parts. If that is not successfull, the implementation
+ * will attempt to resolve the path relative to the registered context
+ * entries. If this fails, a null value will be returned. If the supplied
+ * model is not a composition model then the request will be delegated to
+ * the models controller.
+ *
+ * @param model the model to use for path resolution
+ * @param uri the path identifying a internal part or context entry
+ */
+ public Model getProvider( Model model, URI uri )
+ {
+ if( model instanceof StandardComponentModel )
+ {
+ final String scheme = uri.getScheme();
+ final String path = uri.getSchemeSpecificPart();
+ StandardComponentModel m = (StandardComponentModel) model;
+ if( "parts".equals( scheme ) )
+ {
+ return m.getPart( path );
+ }
+ else if( "context".equals( scheme ) )
+ {
+ return m.getProvider( path );
+ }
+ else
+ {
+ final String error =
+ "Unrecognized reference uri ["
+ + uri
+ + "].";
+ throw new ControlRuntimeException( error );
+ }
+ }
+ else if( model instanceof ValueModel )
+ {
+ return null;
+ }
+ else
+ {
+ return model.getController().getProvider( model, uri );
+ }
+ }
+
+ /**
* Dispose of the controller.
*/
public void dispose()
@@ -397,19 +470,6 @@
// private
//--------------------------------------------------------------------
- /**
- * Locate and return a component model nested within the supplied model
using
- * the address expressed by the path argument.
- *
- * @param model the enclosing model
- * @param the path to the requested model
- * @return the nested model (possibly null)
- */
- private Model getProviderComponentModel( StandardComponentModel model,
String path )
- {
- return model.getPart( path );
- }
-
private Holder getHolder( StandardComponentModel model, Object key )
throws LifecycleException
{
if( null == key )
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 23:36:30 2005
@@ -62,17 +62,6 @@
private final SystemContext m_system;
/**
- * A map of context entries published by the model and keyed by entry key.
- */
- //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();
-
- /**
* The component model.
*/
private final StandardComponentModel m_model;
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 23:36:30 2005
@@ -19,6 +19,7 @@
package net.dpml.composition.models;
import java.io.Serializable;
+import java.net.URI;
import java.util.Map;
import java.util.Hashtable;
import java.util.WeakHashMap;
@@ -39,6 +40,7 @@
import net.dpml.composition.data.ContextDirective;
import net.dpml.composition.data.ValueDirective;
import net.dpml.composition.data.DependencyDirective;
+import net.dpml.composition.data.ReferenceDirective;
import net.dpml.composition.control.CompositionClassLoader;
import net.dpml.composition.control.CompositionController;
import net.dpml.composition.control.Holder;
@@ -186,18 +188,8 @@
}
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 );
- }
+ Model m = loadPartReference( reference, controller,
classloader, parent );
+ m_providers.put( key, m );
}
}
@@ -205,7 +197,7 @@
// 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
- // model and dependency directves declared in this model's profile.
If a
+ // model and dependency directives declared in this model's profile.
If a
// dependency directive is not available and the dependency is
required
// (non-optional) then flag the model as unresolved.
//
@@ -234,34 +226,82 @@
else
{
String key = dependency.getKey();
- DependencyDirective directive =
profile.getDependencyDirective( key );
- if( null == directive )
+
+ PartReference reference = context.getPartReference( key );
+
+ if( reference != null )
{
- if( required )
- {
- Exception e = new
MissingDependencyDirectiveException( this, key );
- m_errors.add( e );
- }
+ Model m = loadPartReference( reference, controller,
classloader, parent );
+ m_providers.put( key, m );
}
else
{
- Controller manager = parent.getController();
- String path = directive.getSource();
- Model model = manager.getProvider( parent, path );
- if( null == model )
+ // THE FOLLOWING WILL BE REMOVED ONCE DEPS/CONTEXT ARE
SORTED
+ // AT THE TYPE LEVEL
+
+ DependencyDirective directive =
profile.getDependencyDirective( key );
+ if( null == directive )
{
- final Exception e = new
UnresolvableDependencyException( this, directive );
- m_errors.add( e );
+ if( required )
+ {
+ Exception e = new
MissingDependencyDirectiveException( this, key );
+ m_errors.add( e );
+ }
}
else
{
- m_providers.put( key, model );
+ String path = directive.getSource();
+ Model model = controller.getProvider( parent, path );
+ if( null == model )
+ {
+ final Exception e = new
UnresolvableDependencyException( this, directive );
+ m_errors.add( e );
+ }
+ else
+ {
+ m_providers.put( key, model );
+ }
}
}
}
}
}
+ private Model loadPartReference( PartReference reference, Controller
controller, ClassLoader classloader, Model parent )
+ throws DelegationException, ModelException
+ {
+ Part part = reference.getPart();
+ if( part instanceof ValueDirective )
+ {
+ ValueDirective value = (ValueDirective) part;
+ return new ValueModel( controller, classloader, value,
m_providers );
+ }
+ else if( part instanceof ReferenceDirective )
+ {
+ ReferenceDirective ref = (ReferenceDirective) part;
+ URI uri = ref.getURI();
+ Model m = controller.getProvider( parent, uri );
+ if( null != m )
+ {
+ return m;
+ }
+ else
+ {
+ final String error =
+ "Unresolvable reference ["
+ + uri
+ + "] in the component ["
+ + this
+ + "].";
+ throw new ModelException( error );
+ }
+ }
+ else
+ {
+ return controller.getModel( this, getQualifiedName() + "/",
classloader, part );
+ }
+ }
+
public Throwable[] getIssues()
{
if( m_errors.isEmpty() )
@@ -454,4 +494,9 @@
throw new InvalidModelException( this, issues );
}
}
+
+ public String toString()
+ {
+ return getQualifiedName();
+ }
}
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 23:36:30 2005
@@ -113,7 +113,8 @@
Class target = null;
try
{
- target = m_classloader.loadClass( descriptorClassName );
+ //target = m_classloader.loadClass( descriptorClassName );
+ target = getValueClass( classname );
}
catch( ClassNotFoundException e )
{
@@ -129,7 +130,8 @@
Class source = null;
try
{
- source = m_classloader.loadClass( directiveClassName );
+ source = getValueClass( classname );
+ //source = m_classloader.loadClass( directiveClassName );
}
catch( ClassNotFoundException e )
{
@@ -292,7 +294,8 @@
String classname = parameters[i].getClassname();
try
{
- params[i] = m_classloader.loadClass( classname );
+ //params[i] = m_classloader.loadClass( classname );
+ params[i] = getValueClass( classname );
}
catch ( Throwable e )
{
@@ -436,42 +439,7 @@
if( clazz.isPrimitive() )
{
- if( Integer.TYPE == clazz )
- {
- return Integer.valueOf( argument );
- }
- else if( Boolean.TYPE == clazz )
- {
- return Boolean.valueOf( argument );
- }
- else if( Byte.TYPE == clazz )
- {
- return Byte.valueOf( argument );
- }
- else if( Short.TYPE == clazz )
- {
- return Short.valueOf( argument );
- }
- else if( Long.TYPE == clazz )
- {
- return Long.valueOf( argument );
- }
- else if( Float.TYPE == clazz )
- {
- return Float.valueOf( argument );
- }
- else if( Double.TYPE == clazz )
- {
- return Double.valueOf( argument );
- }
- else
- {
- final String error =
- "The primitive return type ["
- + clazz.getName()
- + "] is not supported.";
- throw new ModelException( error );
- }
+ return getPrimitiveValue( clazz, argument );
}
try
@@ -512,6 +480,46 @@
}
}
+ private Object getPrimitiveValue( Class clazz, String argument ) throws
ModelException
+ {
+ if( Integer.TYPE == clazz )
+ {
+ return Integer.valueOf( argument );
+ }
+ else if( Boolean.TYPE == clazz )
+ {
+ return Boolean.valueOf( argument );
+ }
+ else if( Byte.TYPE == clazz )
+ {
+ return Byte.valueOf( argument );
+ }
+ else if( Short.TYPE == clazz )
+ {
+ return Short.valueOf( argument );
+ }
+ else if( Long.TYPE == clazz )
+ {
+ return Long.valueOf( argument );
+ }
+ else if( Float.TYPE == clazz )
+ {
+ return Float.valueOf( argument );
+ }
+ else if( Double.TYPE == clazz )
+ {
+ return Double.valueOf( argument );
+ }
+ else
+ {
+ final String error =
+ "The primitive return type ["
+ + clazz.getName()
+ + "] is not supported.";
+ throw new ModelException( error );
+ }
+ }
+
/**
* Return the classname of the parameter implementation to use.
* @return the parameter class
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
23:36:30 2005
@@ -9,24 +9,25 @@
<!-- 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.TwistedGizmo"/>
+ <type class="net.dpml.composition.testing.WidgetComponent"/>
+ <type class="net.dpml.composition.testing.GizmoComponent"/>
+ <type class="net.dpml.composition.testing.AcmeComponent"/>
</types>
<!-- simple component -->
<component xmlns="plugin:dpml/composition/dpml-composition-builder"
- name="widget" class="net.dpml.composition.testing.DefaultWidget"
- activation="true">
+ name="widget" class="net.dpml.composition.testing.WidgetComponent">
<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"/>
+ <value key="foo" value="bar"/>
+ <value key="width" value="12"/>
+ <value key="height" value="100"/>
+ <value key="name" value="urn:metro:name"/>
+ <value key="partition" value="urn:metro:partition"/>
+ <value key="workingDirectory" value="acme/workspace"/>
+ <value key="dimension"
class="net.dpml.composition.testing.Dimension">
+ <value class="int" value="35"/>
+ <value class="int" value="21"/>
+ </value>
</context>
</component>
@@ -35,7 +36,7 @@
<!--
<target name="package" depends="standard.package">
<echo>Writing types</echo>
- <type-writer class="net.dpml.composition.testing.AcmeContainer"
+ <type-writer class="net.dpml.composition.testing.WidgetComponent"
xmlns="plugin:dpml/composition/dpml-composition-builder"/>
<echo>Building block</echo>
</target>
Copied:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeComponent.java
(from r2234,
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeContainer.java)
==============================================================================
---
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeContainer.java
(original)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeComponent.java
Wed Apr 6 23:36:30 2005
@@ -28,7 +28,7 @@
* @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 AcmeContainer
+public class AcmeComponent
{
//------------------------------------------------------------------
// static
@@ -53,7 +53,7 @@
*
* @param logger the logging channel asign by the container
*/
- public AcmeContainer( final Logger logger, Parts parts )
+ public AcmeComponent( final Logger logger, Parts parts )
{
m_logger = logger;
logger.debug( "getting widget" );
@@ -63,7 +63,7 @@
Gizmo gizmo = parts.getGizmo();
logger.debug( "getting gizmo impl" );
- DefaultGizmo newGizmo = parts.createGizmo();
+ GizmoComponent newGizmo = parts.createGizmo();
logger.debug( "getting identified gizmo" );
Gizmo myGizmo = parts.getGizmo( "my-gizmo" );
@@ -127,7 +127,7 @@
*
* @return the gizmo component
*/
- DefaultGizmo createGizmo();
+ GizmoComponent createGizmo();
/**
* Optional release of an instance of the gizmo component.
Copied:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/GizmoComponent.java
(from r2234,
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultGizmo.java)
==============================================================================
---
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultGizmo.java
(original)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/GizmoComponent.java
Wed Apr 6 23:36:30 2005
@@ -25,7 +25,7 @@
* @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 DefaultGizmo implements Gizmo
+public class GizmoComponent implements Gizmo
{
//------------------------------------------------------------------
// static
@@ -51,17 +51,17 @@
/**
* Creation of a new gizmo component. Gizmo has a dependency
- * on the widget service (declared under the Dependencies
+ * on the widget service (declared under the Context
* inner interface). It is also a disposable component
* identified by the public dispose method).
*
* @param logger the logging channel assigned by the container
* @param dependencies the requested dependencies
*/
- public DefaultGizmo( Logger logger, Dependencies dependencies )
+ public GizmoComponent( Logger logger, Context context )
{
m_logger = logger;
- Widget widget = dependencies.getWidget();
+ Widget widget = context.getWidget();
widget.doWidgetTypeStuff();
logger.debug( "ready");
}
@@ -79,7 +79,7 @@
// concerns
//------------------------------------------------------------------
- public interface Dependencies
+ public interface Context
{
Widget getWidget();
}
Copied:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetComponent.java
(from r2234,
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultWidget.java)
==============================================================================
---
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultWidget.java
(original)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetComponent.java
Wed Apr 6 23:36:30 2005
@@ -28,7 +28,7 @@
* @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 DefaultWidget implements Widget
+public class WidgetComponent implements Widget
{
//------------------------------------------------------------------
// static
@@ -71,7 +71,7 @@
* @param logger the logging channel asigned by the container
* @param context the assign component context
*/
- public DefaultWidget( final Logger logger, final Context context )
+ public WidgetComponent( final Logger logger, final Context context )
{
m_context = context;
m_logger = logger;
@@ -143,6 +143,13 @@
+ width
+ " and a height of "
+ height );
+
+ Dimension dimension = m_context.getDimension( null );
+ if( null != dimension )
+ {
+ int size = dimension.getSize();
+ m_logger.debug( "size: " + size );
+ }
}
//------------------------------------------------------------------
@@ -157,5 +164,6 @@
int getWidth();
int getHeight( int defaultHeight );
File getWorkingDirectory();
+ Dimension getDimension( Dimension d );
}
}
Copied:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetValue.java
(from r2234,
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/ValueWidget.java)
==============================================================================
---
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/ValueWidget.java
(original)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/WidgetValue.java
Wed Apr 6 23:36:30 2005
@@ -24,7 +24,7 @@
* @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
+public class WidgetValue implements Widget
{
//------------------------------------------------------------------
// Widget
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
23:36:30 2005
@@ -9,40 +9,29 @@
<!--
Simple component example.
- This is a ver simple component with not dependencies. It is used
- primarily to validate constext entry construction.
+ This is a simple component with no dependencies. It is used
+ primarily to validate context entry construction. It includes
+ an example of a of a non-trivial custom context entry under the
+ 'dimension' key. In this example the context entry is an instance
+ of the class Dimension which is created with two int arguments.
+ The DefaultWidget component class accesses this via the Context
+ constructor value and uses it to calculate a size value.
-->
<component dest="target/test/acme-simple.part"
xmlns="plugin:dpml/composition/dpml-composition-builder"
- class="net.dpml.composition.testing.DefaultWidget"
+ class="net.dpml.composition.testing.WidgetComponent"
name="widget">
<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>
-
- <!--
- 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"
- name="widget">
- <context>
- <entry key="dimension"
class="net.dpml.composition.testing.Dimension">
- <value class="int" value="12"/>
- <value class="int" value="100"/>
- </entry>
+ <value key="foo" value="bar"/>
+ <value key="width" value="12"/>
+ <value key="height" value="100"/>
+ <value key="dimension"
class="net.dpml.composition.testing.Dimension">
+ <value class="int" value="35"/>
+ <value class="int" value="21"/>
+ </value>
+ <value key="name" value="urn:metro:name"/>
+ <value key="partition" value="urn:metro:partition"/>
+ <value key="workingDirectory" value="acme/workspace"/>
</context>
</component>
@@ -51,76 +40,58 @@
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.
+ to the AcmeContainer component via the Parts constructor argument.
+ Note that we are not including the Dimension arguments in the context
+ thereby demonstrating optional context entry semantic. A feature of
+ this example is the usage of a reference element as the mechanisms
+ to wire the context 'widget' part into the context supplied to the
+ 'gizmo' component.
-->
<component dest="target/test/acme-container.part"
xmlns="plugin:dpml/composition/dpml-composition-builder"
- class="net.dpml.composition.testing.AcmeContainer"
+ class="net.dpml.composition.testing.AcmeComponent"
name="acme">
<parts>
- <component name="widget"
class="net.dpml.composition.testing.DefaultWidget">
+ <component name="widget"
class="net.dpml.composition.testing.WidgetComponent">
<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"/>
+ <value key="foo" value="bar"/>
+ <value key="width" value="12"/>
+ <value key="height" value="100"/>
+ <value key="name" value="urn:metro:name"/>
+ <value key="partition" value="urn:metro:partition"/>
+ <value key="workingDirectory" value="acme/workspace"/>
</context>
</component>
- <component name="gizmo"
class="net.dpml.composition.testing.DefaultGizmo">
- <dependencies>
- <dependency key="widget" source="widget"/>
- </dependencies>
+ <component name="gizmo"
class="net.dpml.composition.testing.GizmoComponent">
+ <context>
+ <reference key="widget" uri="parts:widget"/>
+ </context>
</component>
</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
+ Instead of using a component to fulfill a dependnecy we are using a
simple
+ constructed value along the lines of values we add to context entries.
+ In this example we are using the same composite component - demonstrating
the complete separation of requirement (provided by class introspection)
from
- solution (provided in the directives gererated here).
+ solution (provided in the directives generated here).
-->
<component dest="target/test/acme-test-container.part"
xmlns="plugin:dpml/composition/dpml-composition-builder"
- class="net.dpml.composition.testing.AcmeContainer"
+ class="net.dpml.composition.testing.AcmeComponent"
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" >
+ <value key="widget"
class="net.dpml.composition.testing.WidgetValue"/>
+ <component name="gizmo"
class="net.dpml.composition.testing.GizmoComponent">
<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"/>
+ <reference key="widget" uri="parts:widget"/>
</context>
</component>
- </context>
+ </parts>
</component>
</target>
-
+
</project>
Copied:
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/CompositeTestCase.java
(from r2230,
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/CompositeTestCase.java
Wed Apr 6 23:36:30 2005
@@ -33,35 +33,17 @@
* @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 class AcmeContainerTestCase extends TestCase
+public class CompositeTestCase extends TestCase
{
- /**
- * 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).
+ * widget and gizmo where both are components and gizmo declares a
dependency
+ * on widget.
*/
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();
+ execute( "acme-container.part" );
}
/**
@@ -70,27 +52,16 @@
*/
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();
+ execute( "acme-test-container.part" );
}
- /**
- * Test the construction of a component that is supplied with
- * a dependent component via the context.
- */
- public void testTwistedGizmo() throws Exception
+ private void execute( String path ) throws Exception
{
- 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 );
+ Object object = model.resolve();
+ model.release( object );
helper.dispose();
}
}
Modified:
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/SimpleTestCase.java
==============================================================================
---
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/SimpleTestCase.java
(original)
+++
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/SimpleTestCase.java
Wed Apr 6 23:36:30 2005
@@ -61,7 +61,7 @@
Model model = helper.getCompositionManager().addPart( uri );
try
{
- DefaultWidget widget = (DefaultWidget) model.resolve();
+ WidgetComponent widget = (WidgetComponent) model.resolve();
fail( "Casting to implementation class!" );
}
catch( ClassCastException e )
@@ -79,7 +79,7 @@
CompositionHelper helper = new CompositionHelper();
URI uri = helper.toURI( PATH );
Model model = helper.getCompositionManager().addPart( uri );
- DefaultWidget widget = (DefaultWidget) model.create();
+ WidgetComponent widget = (WidgetComponent) model.create();
String name = widget.getName();
assertEquals( "name", "widget", name );
String newName = "freight";
- svn commit: r2235 - in development/main/metro: automation/control/src/main/net/dpml/automation/control composition/api/src/main/net/dpml/composition/data 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/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.