Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2131 - in development/main/metro/composition: api/src/main/net/dpml/composition/data builder/src/main/net/dpml/composition/builder builder/src/main/net/dpml/composition/builder/datatypes testing/acme testing/acme/src/main/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: r2131 - in development/main/metro/composition: api/src/main/net/dpml/composition/data builder/src/main/net/dpml/composition/builder builder/src/main/net/dpml/composition/builder/datatypes testing/acme testing/acme/src/main/net/dpml/composition/testing
  • Date: Fri, 25 Mar 2005 12:46:23 -0500

Author: mcconnell AT dpml.net
Date: Fri Mar 25 12:46:20 2005
New Revision: 2131

Added:

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

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

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ValueDataType.java
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/datatypes/PartsDataType.java
development/main/metro/composition/testing/acme/build.xml

development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultWidget.java
Log:
Add clean implementation of valuetype part.

Added:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ValueDirective.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ValueDirective.java
Fri Mar 25 12:46:20 2005
@@ -0,0 +1,324 @@
+/*
+ * 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.lang.NullArgumentException;
+
+import net.dpml.part.Part;
+
+/**
+ * A <code>Value</code> represents a single constructor typed argument
value. The directive
+ * container a classname (default value of <code>java.lang.String</code>)
and possible sub-directives.
+ * The directives value is established by creating a new instance using the
classname
+ * together with the values directived from the sub-sidiary directives as
constructor arguments.
+ *
+ * <p><b>XML</b></p>
+ * <p>A value is a nested structure containing a string value or contructor
parameter arguments.</p>
+ * <pre>
+ * <font color="gray">&lt;-- Simple string param declaration --&gt;</font>
+ *
+ * &lt;value&gt;<font color="darkred">London</font>&lt;/value&gt;
+ *
+ * <font color="gray">&lt;-- Typed value declaration --&gt;</font>
+ *
+ * &lt;value class="<font color="darkred">java.io.File</font>"&gt;<font
color="darkred">./home</font>&lt;/value&gt;
+ *
+ * <font color="gray">&lt;-- Multi-argument parameter declaration
--&gt;</font>
+ *
+ * &lt;value class="<font color="darkred">MyClass</font>"&gt;
+ * &lt;value class="<font color="darkred">java.io.File</font>"><font
color="darkred">./home</font>&lt;/value&gt;
+ * &lt;value&gt;<font color="darkred">London</font>&lt;/value&gt;
+ * &lt;/value&gt;
+ * </pre>
+ *
+ * @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 implements Serializable, Part
+{
+
//--------------------------------------------------------------------------
+ // state
+
//--------------------------------------------------------------------------
+
+ private final String m_key;
+ private final String m_classname;
+ private final String m_value;
+ private final Value[] m_values;
+
+
//--------------------------------------------------------------------------
+ // constructors
+
//--------------------------------------------------------------------------
+
+ public ValueDirective( String key, String classname, String value )
+ {
+ m_key = key;
+ m_classname = classname;
+ m_value = value;
+ m_values = new Value[0];
+ }
+
+ public ValueDirective( String key, String classname, Value[] values )
+ {
+ m_key = key;
+ m_classname = classname;
+ m_value = null;
+ m_values = values;
+ }
+
+
//--------------------------------------------------------------------------
+ // ValueDirective
+
//--------------------------------------------------------------------------
+
+ public String getKey()
+ {
+ return m_key;
+ }
+
+ public String getClassname()
+ {
+ return m_classname;
+ }
+
+ public String getValue()
+ {
+ return m_value;
+ }
+
+ public Value[] getValues()
+ {
+ return m_values;
+ }
+
+
//--------------------------------------------------------------------------
+ // Part
+
//--------------------------------------------------------------------------
+
+ /**
+ * Return the part handler uri.
+ * @return the uri of the part handler
+ */
+ public URI getPartHandlerURI()
+ {
+ return PART_HANDLER_URI;
+ }
+
+
//--------------------------------------------------------------------------
+ // static utils
+
//--------------------------------------------------------------------------
+
+ public static class Value implements Serializable
+ {
+ /**
+ * The classname to use as the parameter implementation class
(defaults to java.lang.String)
+ */
+ private final String m_classname;
+
+ /**
+ * The supplied argument.
+ */
+ private String m_argument;
+
+ /**
+ * The sub-directives from which the value for this value directive
may be derived.
+ */
+ private final Value[] m_children;
+
+ /**
+ * Creation of a new value directive using the default
<code>java.lang.String</code>
+ * type and a supplied value.
+ *
+ * @param value the string value
+ */
+ public Value( final String value )
+ {
+ m_classname = "java.lang.String";
+ m_children = new Value[ 0 ];
+ m_argument = value;
+ }
+
+ /**
+ * Creation of a new entry directive using a supplied classname and
value.
+ * @param classname the classname of the value
+ * @param value the value constructor value
+ * @exception NullArgumentException if the classname argument is
null.
+ */
+ public Value( final String classname, final String value )
+ throws NullArgumentException
+ {
+ if( null == classname )
+ {
+ throw new NullArgumentException( "classname" );
+ }
+
+ m_classname = classname;
+ m_children = new Value[ 0 ];
+ m_argument = value;
+ }
+
+ /**
+ * Creation of a new entry directive.
+ * @param classname the classname of the entry implementation
+ * @param children implementation class constructor directives
+ * @exception NullArgumentException if either the classname argument
or the
+ * children argument is null, or any of the elements in the
+ * children array is null.
+ */
+ public Value( final String classname, final Value[] children )
+ throws NullArgumentException
+ {
+ if( null == classname )
+ {
+ throw new NullArgumentException( "classname" );
+ }
+ if( null == children )
+ {
+ throw new NullArgumentException( "children" );
+ }
+ for( int i = 0; i < children.length; i++ )
+ {
+ if( children[ i ] == null )
+ {
+ throw new NullArgumentException( "child [" + i + "]" );
+ }
+ }
+ m_classname = classname;
+ m_children = children;
+ }
+
+ /**
+ * Return the classname of the parameter implementation to use.
+ * @return the classname
+ */
+ public String getClassname()
+ {
+ return m_classname;
+ }
+
+ /**
+ * Return the argument (may be null).
+ */
+ public String getArgument()
+ {
+ return m_argument;
+ }
+
+ /**
+ * Return the constructor descriptors for this value descriptor.
+ */
+ public Value[] getValueDirectives()
+ {
+ return m_children;
+ }
+
+ /**
+ * 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 Value )
+ {
+ Value param = (Value) other;
+ if( false == m_classname.equals( param.getClassname() ) )
+ {
+ return false;
+ }
+ if( null == m_argument )
+ {
+ if( null != param.getArgument() )
+ {
+ return false;
+ }
+ }
+ else if( false == m_argument.equals( param.getArgument()
) )
+ {
+ return false;
+ }
+ if( getValueDirectives().length !=
param.getValueDirectives().length )
+ {
+ return false;
+ }
+ else
+ {
+ Value[] myParams = getValueDirectives();
+ Value[] yourParams = param.getValueDirectives();
+ for( int i=0; i<myParams.length; i++ )
+ {
+ Value p = myParams[i];
+ Value q = yourParams[i];
+ if( false == p.equals( q ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = m_classname.hashCode();
+ if( null != m_argument )
+ {
+ hash ^= m_argument.hashCode();
+ }
+ for( int i=0; i<m_children.length; i++ )
+ {
+ hash ^= m_children[i].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
Fri Mar 25 12:46:20 2005
@@ -26,7 +26,10 @@
import java.util.List;
import java.util.LinkedList;
import java.util.ArrayList;
+import java.util.Properties;
import java.lang.reflect.Method;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
import java.net.URI;

import net.dpml.meta.info.Type;
@@ -170,9 +173,10 @@
catch( IntrospectionException e )
{
final String error =
- "Internal error while attempting to construct type ["
+ "Introdspection error while attempting to construct type ["
+ m_classname
- + "]";
+ + "]. "
+ + e.getMessage();
throw new BuildException( error, e, getLocation() );
}
}
@@ -216,13 +220,240 @@
return m_classname;
}

- private InfoDescriptor createInfoDescriptor( Class subject )
+ private InfoDescriptor createInfoDescriptor( Class subject ) throws
IntrospectionException
{
- String classname = subject.getName();
String name = getName();
- return new InfoDescriptor( name, classname );
+ String classname = subject.getName();
+ boolean threadsafe = getThreadSafeCapability( subject );
+ int lifestylePreference = getLifestylePreference( subject );
+ String lifestyle = InfoDescriptor.getLifestylePreferenceKey(
lifestylePreference );
+ int collectionPolicy = getCollectionPolicyPreference( subject );
+ String collection = InfoDescriptor.getCollectionPolicyKey(
collectionPolicy );
+ String schema = getConfigurationSchema( subject );
+ Properties properties = getTypeProperties( subject );
+ return new InfoDescriptor(
+ name, classname, null, lifestyle, collection, schema, threadsafe,
true, properties );
+ }
+
+ private boolean getThreadSafeCapability( Class subject ) throws
IntrospectionException
+ {
+ try
+ {
+ Field field = subject.getDeclaredField(
"TYPE_THREADSAFE_CAPABLE" );
+ if( field.getModifiers() == Modifier.STATIC )
+ {
+ return field.getBoolean( null );
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch( NoSuchFieldException e )
+ {
+ return false;
+ }
+ catch( IllegalArgumentException e )
+ {
+ final String error =
+ "The component type ["
+ + subject.getName()
+ + "] declares an invalid static field TYPE_THREADSAFE_POLICY
declaration. "
+ + "Could not convert the value to a boolean.";
+ throw new IntrospectionException( error );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "An unexpected error occured while resolving the static
TYPE_THREADSAFE_POLICY field on the type ["
+ + subject.getName()
+ + "].";
+ throw new IntrospectionException( error );
+ }
+
+ }
+
+ private int getLifestylePreference( Class subject ) throws
IntrospectionException
+ {
+ try
+ {
+ Field field = subject.getDeclaredField(
"TYPE_LIFESTYLE_PREFERENCE" );
+ if( field.getModifiers() == Modifier.STATIC )
+ {
+ return field.getInt( null );
+ }
+ else
+ {
+ return InfoDescriptor.TRANSIENT_LIFESTYLE;
+ }
+ }
+ catch( NoSuchFieldException e )
+ {
+ return InfoDescriptor.TRANSIENT_LIFESTYLE;
+ }
+ catch( IllegalArgumentException e )
+ {
+ final String error =
+ "The component type ["
+ + subject.getName()
+ + "] declares an invalid static field
TYPE_LIFESTYLE_PREFERENCE declaration. "
+ + "Could not convert the value to an int.";
+ throw new IntrospectionException( error );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "An unexpected error occured while resolving the static
TYPE_LIFESTYLE_PREFERENCE field on the type ["
+ + subject.getName()
+ + "].";
+ throw new IntrospectionException( error );
+ }
+ }
+
+ private int getCollectionPolicyPreference( Class subject ) throws
IntrospectionException
+ {
+ try
+ {
+ Field field = subject.getDeclaredField(
"TYPE_COLLECTION_PREFERENCE" );
+ if( field.getModifiers() == Modifier.STATIC )
+ {
+ return field.getInt( null );
+ }
+ else
+ {
+ return InfoDescriptor.UNDEFINED;
+ }
+ }
+ catch( NoSuchFieldException e )
+ {
+ return InfoDescriptor.UNDEFINED;
+ }
+ catch( IllegalArgumentException e )
+ {
+ final String error =
+ "The component type ["
+ + subject.getName()
+ + "] declares an invalid static field
TYPE_COLLECTION_PREFERENCE declaration. "
+ + "Could not convert the value to an int.";
+ throw new IntrospectionException( error );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "An unexpected error occured while resolving the static
TYPE_COLLECTION_PREFERENCE field on the type ["
+ + subject.getName()
+ + "].";
+ throw new IntrospectionException( error );
+ }
}

+ private String getConfigurationSchema( Class subject ) throws
IntrospectionException
+ {
+ try
+ {
+ Field field = subject.getDeclaredField(
"TYPE_CONFIGURATION_SCHEMA" );
+ if( field.getModifiers() == Modifier.STATIC )
+ {
+ if( String.class.isAssignableFrom( field.getType() ) )
+ {
+ return (String) field.get( null );
+ }
+ else
+ {
+ final String error =
+ "The component type ["
+ + subject.getName()
+ + "] declares an invalid static field
TYPE_CONFIGURATION_SCHEMA declaration. "
+ + "The declared type is not assignable to a string.";
+ throw new IntrospectionException( error );
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+ catch( NoSuchFieldException e )
+ {
+ return null;
+ }
+ catch( IllegalArgumentException e )
+ {
+ final String error =
+ "The component type ["
+ + subject.getName()
+ + "] declares an invalid static field
TYPE_CONFIGURATION_SCHEMA declaration. "
+ + "Could not convert the value to an string.";
+ throw new IntrospectionException( error );
+ }
+ catch( IntrospectionException e )
+ {
+ throw e;
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "An unexpected error occured while resolving the static
TYPE_CONFIGURATION_SCHEMA field on the type ["
+ + subject.getName()
+ + "].";
+ throw new IntrospectionException( error );
+ }
+ }
+
+ private Properties getTypeProperties( Class subject ) throws
IntrospectionException
+ {
+ try
+ {
+ Field field = subject.getDeclaredField( "TYPE_INFO_PROPERTIES" );
+ if( field.getModifiers() == Modifier.STATIC )
+ {
+ if( Properties.class.isAssignableFrom( field.getType() ) )
+ {
+ return (Properties) field.get( null );
+ }
+ else
+ {
+ final String error =
+ "The component type ["
+ + subject.getName()
+ + "] declares an invalid static field
TYPE_INFO_PROPERTIES declaration. "
+ + "The declared type is not assignable to a
java.util.Properties value.";
+ throw new IntrospectionException( error );
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+ catch( NoSuchFieldException e )
+ {
+ return null;
+ }
+ catch( IllegalArgumentException e )
+ {
+ final String error =
+ "The component type ["
+ + subject.getName()
+ + "] declares an invalid static field TYPE_INFO_PROPERTIES
declaration. "
+ + "Could not convert the value to an instance of
java.util.Properties.";
+ throw new IntrospectionException( error );
+ }
+ catch( IntrospectionException e )
+ {
+ throw e;
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "An unexpected error occured while resolving the static
TYPE_INFO_PROPERTIES field on the type ["
+ + subject.getName()
+ + "].";
+ throw new IntrospectionException( error );
+ }
+ }
+
+
/**
* If the class contains an inner class named "Dependencies" then
* resolve the key/inteterface clasname pairs based on the inner class

Added:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartDataType.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartDataType.java
Fri Mar 25 12:46:20 2005
@@ -0,0 +1,137 @@
+/*
+ * 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.part.Part;
+
+import net.dpml.builder.PartBuilder;
+
+import net.dpml.composition.data.ValueDirective;
+import net.dpml.composition.data.ValueDirective.Value;
+
+/**
+ * A simple part datatype.
+ */
+public class PartDataType extends ValueDataType implements PartBuilder
+{
+ private String m_key;
+
+ /**
+ * Set the key that this directive qualifies.
+ * @param key the context entry key
+ */
+ public void setKey( final String key )
+ {
+ m_key = key ;
+ }
+
+ //---------------------------------------------------------------------
+ // Builder
+ //---------------------------------------------------------------------
+
+ /**
+ * Return a uri identitifying the builder.
+ *
+ * @return the builder uri
+ */
+ public URI getBuilderURI()
+ {
+ return PART_BUILDER_URI;
+ }
+
+ //---------------------------------------------------------------------
+ // PartBuilder
+ //---------------------------------------------------------------------
+
+ public Part buildPart( ClassLoader classloader )
+ {
+ return getValueDirective( classloader );
+ }
+
+ /**
+ * Return the key identifying the part that this builder is building.
+ */
+ public String getKey()
+ {
+ return m_key;
+ }
+
+ /**
+ * Return a urn identitifying the part handler for this builder.
+ *
+ * @return a strategy uri
+ */
+ public URI getPartHandlerURI()
+ {
+ return PART_HANDLER_URI;
+ }
+
+ //---------------------------------------------------------------------
+ // implementation
+ //---------------------------------------------------------------------
+
+ public ValueDirective getValueDirective( ClassLoader classloader )
+ {
+ String key = getKey();
+ String classname = getClassname();
+ String value = getValue();
+ if( null != value )
+ {
+ return new ValueDirective( key, classname, value );
+ }
+ else
+ {
+ ValueDataType[] params = getValueDataTypes();
+ Value[] values = new Value[ params.length ];
+ for( int i=0; i<params.length; i++ )
+ {
+ ValueDataType p = params[i];
+ values[i] = p.constructValue();
+ }
+ return new ValueDirective( key, classname, values );
+ }
+ }
+
+ //---------------------------------------------------------------------
+ // 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/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
Fri Mar 25 12:46:20 2005
@@ -63,6 +63,17 @@
}

/**
+ * Create a new constructed part builder.
+ * @return a part builder
+ */
+ public PartDataType createValue()
+ {
+ final PartDataType builder = new PartDataType();
+ m_builders.add( builder );
+ return builder;
+ }
+
+ /**
* Operation used to construct a custom part type directive.
* @param uri the part handler uri
* @param name the element name

Added:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ValueDataType.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ValueDataType.java
Fri Mar 25 12:46:20 2005
@@ -0,0 +1,113 @@
+/*
+ * 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 net.dpml.composition.data.ValueDirective.Value;
+
+
+/**
+ * Defintion of a context entry parameter directive.
+ */
+public class ValueDataType
+{
+ private String m_classname;
+ private String m_value;
+ private List m_params = new ArrayList();
+
+ /**
+ * Set the context entry classname.
+ * @param classname the context entry classname
+ */
+ public void setClass( final String classname )
+ {
+ m_classname = classname;
+ }
+
+ /**
+ * Return the context entry parameter classname.
+ * @return the classname
+ */
+ public String getClassname()
+ {
+ return m_classname;
+ }
+
+ /**
+ * Set the value of the context entry parameter.
+ * @param value the param value
+ */
+ public void setValue( final String value )
+ {
+ m_value = value;
+ }
+
+ /**
+ * Return the value of the context entry param.
+ * @return the value
+ */
+ public String getValue()
+ {
+ return m_value;
+ }
+
+ /**
+ * Create, assign and return a new nested entry constructor parameter.
+ * @return the new context entry param
+ */
+ public ValueDataType createValue()
+ {
+ final ValueDataType param = new ValueDataType();
+ m_params.add( param );
+ return param;
+ }
+
+ /**
+ * Return the set of nested param directives.
+ * @return the params
+ */
+ public ValueDataType[] getValueDataTypes()
+ {
+ return (ValueDataType[]) m_params.toArray( new ValueDataType[0] );
+ }
+
+ public Value constructValue()
+ {
+ String classname = getClassname();
+ String value = getValue();
+ if( null != value )
+ {
+ return new Value( classname, value );
+ }
+ else
+ {
+ ValueDataType[] params = getValueDataTypes();
+ Value[] values = new Value[ params.length ];
+ for( int i=0; i<values.length; i++ )
+ {
+ ValueDataType p = params[i];
+ values[i] = p.constructValue();
+ }
+ return new Value( classname, values );
+ }
+ }
+}

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 Fri Mar 25
12:46:20 2005
@@ -25,7 +25,10 @@
<dependency key="widget" source="widget"/>
</dependencies>
<parts>
- <component name="secret"
class="net.dpml.composition.testing.DefaultWidget"/>
+ <value key="foo" value="bar"/>
+ <value key="date" class="java.util.Date"/>
+ <value key="info" class="java.net.URI"
value="link:acme/parts/acme-parts-list"/>
+ <component key="widget" name="secret"
class="net.dpml.composition.testing.DefaultWidget"/>
</parts>
</component>
</container>

Modified:
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/DefaultWidget.java
Fri Mar 25 12:46:20 2005
@@ -28,6 +28,12 @@
public class DefaultWidget implements Widget
{
//------------------------------------------------------------------
+ // static
+ //------------------------------------------------------------------
+
+ public static final boolean TYPE_THREADSAFE_CAPABLE = true;
+
+ //------------------------------------------------------------------
// state
//------------------------------------------------------------------




  • svn commit: r2131 - in development/main/metro/composition: api/src/main/net/dpml/composition/data builder/src/main/net/dpml/composition/builder builder/src/main/net/dpml/composition/builder/datatypes testing/acme testing/acme/src/main/net/dpml/composition/testing, mcconnell, 03/25/2005

Archive powered by MHonArc 2.6.24.

Top of Page