Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2138 - in development/main/metro: . automation/builder automation/builder/src/main/net/dpml/builder automation/control automation/part composition/builder/src/main/net/dpml/composition/builder composition/builder/src/main/net/dpml/composition/builder/datatypes composition/control/src/main/net/dpml/composition/handlers composition/testing/acme composition/testing/acme/src/main/net/dpml/composition/testing meta/api/src/main/net/dpml/meta/info

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: r2138 - in development/main/metro: . automation/builder automation/builder/src/main/net/dpml/builder automation/control automation/part composition/builder/src/main/net/dpml/composition/builder composition/builder/src/main/net/dpml/composition/builder/datatypes composition/control/src/main/net/dpml/composition/handlers composition/testing/acme composition/testing/acme/src/main/net/dpml/composition/testing meta/api/src/main/net/dpml/meta/info
  • Date: Fri, 25 Mar 2005 17:20:00 -0500

Author: mcconnell AT dpml.net
Date: Fri Mar 25 17:20:00 2005
New Revision: 2138

Added:

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
- copied, changed from r2133,
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartDataType.java
Removed:

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

development/main/metro/composition/control/src/main/net/dpml/composition/handlers/
Modified:
development/main/metro/automation/builder/ (props changed)

development/main/metro/automation/builder/src/main/net/dpml/builder/PartBuilder.java
development/main/metro/automation/control/ (props changed)
development/main/metro/automation/part/ (props changed)

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/PartsDataType.java
development/main/metro/composition/testing/acme/build.xml

development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/DefaultGizmo.java
development/main/metro/index.xml

development/main/metro/meta/api/src/main/net/dpml/meta/info/EntryDescriptor.java
Log:
Moving closer to a compatible strategy for context entry handling.

Modified:
development/main/metro/automation/builder/src/main/net/dpml/builder/PartBuilder.java
==============================================================================
---
development/main/metro/automation/builder/src/main/net/dpml/builder/PartBuilder.java
(original)
+++
development/main/metro/automation/builder/src/main/net/dpml/builder/PartBuilder.java
Fri Mar 25 17:20:00 2005
@@ -51,7 +51,5 @@
* @exception Exception if a construction error occurs
*/
Part buildPart( ClassLoader classloader )
- throws IntrospectionException, IOException, ClassNotFoundException,
- BadStrategyException;
-
+ throws IntrospectionException, IOException, ClassNotFoundException;
}

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
Fri Mar 25 17:20:00 2005
@@ -256,11 +256,11 @@
File classes = getContext().getClassesDirectory();
path.createPathElement().setLocation( classes );
ClassLoader classloader = new AntClassLoader( project, path );
- ComponentProfile profile = buildComponentProfile( classloader );

File file = getOutputFile();
try
{
+ ComponentProfile profile = buildComponentProfile( classloader );
URI uri = getDefinition().getArtifactURI( Part.ARTIFACT_TYPE );
log( "saving part to: " + uri );
URI handler = getPartHandlerURI();
@@ -268,7 +268,7 @@
PartHolder holder = new PartHolder( handler, bytes );
SerializableObjectHelper.write( holder, file );
}
- catch( IOException ioe )
+ catch( Exception ioe )
{
final String error =
"Internal error while attempting to write component part to
file ["
@@ -311,6 +311,7 @@
//---------------------------------------------------------------------

public Part buildPart( ClassLoader classloader )
+ throws IntrospectionException, IOException, ClassNotFoundException
{
return buildComponentProfile( classloader );
}
@@ -338,7 +339,8 @@
//---------------------------------------------------------------------


- private ComponentProfile buildComponentProfile( ClassLoader classloader )
+ private ComponentProfile buildComponentProfile( ClassLoader classloader
)
+ throws IntrospectionException, IOException, ClassNotFoundException
{
log( "building component: " + getName() );

@@ -355,7 +357,7 @@
int activation = getActivationPolicy();
Mode mode = Mode.EXPLICIT;
CategoriesDirective categories = getCategoriesDirective();
- ContextDirective context = getContextDirective();
+ ContextDirective context = getContextDirective( classloader );
DependencyDirective[] dependencies = getDependencyDirectives();
Parameters parameters = getParameters();
Configuration configuration = getConfiguration();
@@ -512,7 +514,8 @@
}
}

- private ContextDirective getContextDirective()
+ private ContextDirective getContextDirective( ClassLoader classloader )
+ throws IntrospectionException, IOException, ClassNotFoundException
{
if( null == m_context )
{
@@ -520,7 +523,7 @@
}
else
{
- return m_context.getContextDirective();
+ return m_context.getContextDirective( classloader );
}
}


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 17:20:00 2005
@@ -136,10 +136,10 @@
ServiceDescriptor[] services = createServiceDescriptors( subject );
DependencyDescriptor[] dependencies = createDependencyDescriptors(
subject );
CategoryDescriptor[] categories = new CategoryDescriptor[0];
- ContextDescriptor context = new ContextDescriptor( null, new
EntryDescriptor[0] );
- Configuration config = null;
- ParameterDescriptor[] params = createParameterDescriptors( subject );
+ ContextDescriptor context = createContextDescriptor( subject );
PartDescriptor[] parts = createPartDescriptors( subject );
+ Configuration config = null;
+ ParameterDescriptor[] params = new ParameterDescriptor[0];
return new Type( info, categories, context, services, dependencies,
config, params, parts );
}

@@ -494,7 +494,7 @@
validateNoExceptions( method );
validateNoParameters( method );

- String key = method.getName().substring( 3 );
+ String key = getPartKey( method );
String type = returnType.getName();
return new DependencyDescriptor( key, type );
}
@@ -620,20 +620,26 @@
}
}

- private ParameterDescriptor[] createParameterDescriptors( Class subject
)
+ private ContextDescriptor createContextDescriptor( Class subject )
throws IntrospectionException
+ {
+ EntryDescriptor[] entries = createEntryDescriptors( subject );
+ return new ContextDescriptor( null, entries );
+ }
+
+ private EntryDescriptor[] createEntryDescriptors( Class subject )
throws IntrospectionException
{
String classname = subject.getName();
Class[] classes = subject.getClasses();
- Class param = locateClass( "$Parameters", classes );
+ Class param = locateClass( "$Context", classes );
if( null == param )
{
- return new ParameterDescriptor[0];
+ return new EntryDescriptor[0];
}
else
{
//
- // For each method in the Parameters interface we construct a
parameter
+ // For each method in the Context inner-interface we construct a
// descriptor that establishes the part key, type, and required
status.
//

@@ -642,10 +648,10 @@
for( int i=0; i<methods.length; i++ )
{
Method method = methods[i];
- ParameterDescriptor descriptor = createParameterDescriptor(
method );
+ EntryDescriptor descriptor = createEntryDescriptor( method );
list.add( descriptor );
}
- return (ParameterDescriptor[]) list.toArray( new
ParameterDescriptor[0] );
+ return (EntryDescriptor[]) list.toArray( new EntryDescriptor[0]
);
}
}

@@ -654,7 +660,7 @@
* The method is the method used by the component implementation to get
the parameter
* instance.
*/
- private ParameterDescriptor createParameterDescriptor( Method method )
+ private EntryDescriptor createEntryDescriptor( Method method )
throws IntrospectionException
{
validateMethodName( method );
@@ -665,10 +671,14 @@
Class returnType = method.getReturnType();
if( method.getParameterTypes().length == 0 )
{
+ //
+ // required context entry
+ //
+
validateNonNullReturnType( method, returnType );
validateNonArrayReturnType( method, returnType );
String type = returnType.getName();
- return new ParameterDescriptor( key, type,
ParameterDescriptor.REQUIRED );
+ return new EntryDescriptor( key, type, EntryDescriptor.REQUIRED
);
}
else if( method.getParameterTypes().length == 1 )
{
@@ -677,12 +687,12 @@
if( returnType.isAssignableFrom( param ) )
{
String type = param.getName();
- return new ParameterDescriptor( key, type,
ParameterDescriptor.OPTIONAL );
+ return new EntryDescriptor( key, type,
EntryDescriptor.OPTIONAL );
}
else
{
final String error =
- "Parameter asessor declares an optional default parameter
class ["
+ "Context entry assessor declares an optional default
parameter class ["
+ param.getName()
+ "] which is not assignable to the return type ["
+ returnType.getName()
@@ -693,7 +703,7 @@
else
{
final String error =
- "Unable to establish a required or optional parameter method
pattern on the method ["
+ "Unable to establish a required or optional context entry
method pattern on the method ["
+ method.getName()
+ "]";
throw new IntrospectionException( error );
@@ -709,7 +719,18 @@
{
String name = method.getName();
String key = name.substring( prefix.length() );
- return key;
+ return formatKey( key );
+ }
+
+ private String formatKey( String key )
+ {
+ if( key.length() < 1 )
+ {
+ throw new IllegalArgumentException( "key" );
+ }
+ String first = key.substring( 0, 1 ).toLowerCase();
+ String remainder = key.substring( 1 );
+ return first + remainder;
}

private Class locateClass( String postfix, Class[] classes )

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
Fri Mar 25 17:20:00 2005
@@ -21,6 +21,11 @@
import java.util.List;
import java.util.LinkedList;
import java.util.ArrayList;
+import java.io.IOException;
+
+import net.dpml.part.Part;
+import net.dpml.builder.PartBuilder;
+import net.dpml.builder.IntrospectionException;

import net.dpml.composition.data.ContextDirective;
import net.dpml.composition.data.ConstructorDirective;
@@ -33,7 +38,7 @@
public class ContextDataType
{
private String m_class;
- private List m_entries = new ArrayList();
+ private List m_builders = new ArrayList();

/**
* Declare a custom context implementation classname.
@@ -54,171 +59,51 @@
}

/**
- * Create, add and return a new entry directive to the context.
- * @return a new context entry directive
+ * Create a new constructed part builder.
+ * @return a part builder
*/
- public Entry createEntry()
+ public EntryDataType createEntry()
{
- final Entry entry = new Entry();
- m_entries.add( entry );
- return entry;
+ final EntryDataType builder = new EntryDataType();
+ m_builders.add( builder );
+ return builder;
}

/**
* Return all of the context entries within the context directive.
* @return the set of context entries
*/
- public Entry[] getEntries()
+ public PartBuilder[] getBuilders()
{
- return (Entry[]) m_entries.toArray( new Entry[0] );
+ return (PartBuilder[]) m_builders.toArray( new PartBuilder[0] );
}

- public ContextDirective getContextDirective()
+ public ContextDirective getContextDirective( ClassLoader classloader )
+ throws IntrospectionException, IOException, ClassNotFoundException
{
- Entry[] entries = getEntries();
- EntryDirective[] entryDirectives = new EntryDirective[
entries.length ];
- for( int i=0; i<entries.length; i++ )
- {
- Entry entry = entries[i];
- entryDirectives[i] = entry.getEntryDirective();
+ PartBuilder[] builders = getBuilders();
+System.out.println( "## BUILDERS " + builders.length );
+ EntryDirective[] entryDirectives = new EntryDirective[
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 );
+ }
}
String classname = getClassname();
+System.out.println( "## CONTEXT : " + entryDirectives.length );
return new ContextDirective( classname, entryDirectives );
}
-
- /**
- * Defintion of a context entry directive.
- */
- public static class Entry extends Param
- {
- private String m_key;
-
- /**
- * Set the context enty key that this directive qualifies.
- * @param key the context entry key
- */
- public void setKey( final String key )
- {
- m_key = key ;
- }
-
- /**
- * Return the context entry key.
- * @return the entry key
- */
- public String getKey()
- {
- return m_key;
- }
-
- public EntryDirective getEntryDirective()
- {
- String key = getKey();
- String classname = getClassname();
- String value = getValue();
- if( null != value )
- {
- return new ConstructorDirective( key, classname, value );
- }
- else
- {
- Param[] params = getParams();
- Parameter[] parameters = new Parameter[ params.length ];
- for( int i=0; i<parameters.length; i++ )
- {
- Param p = params[i];
- parameters[i] = p.getParameter();
- }
- return new ConstructorDirective( key, classname, parameters
);
- }
- }
- }
-
- /**
- * Defintion of a context entry parameter directive.
- */
- public static class Param
- {
- 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 Param createParam()
- {
- final Param param = new Param();
- m_params.add( param );
- return param;
- }
-
- /**
- * Return the set of nested param directives.
- * @return the params
- */
- public Param[] getParams()
- {
- return (Param[]) m_params.toArray( new Param[0] );
- }
-
- public Parameter getParameter()
- {
- String classname = getClassname();
- String value = getValue();
- if( null != value )
- {
- return new Parameter( classname, value );
- }
- else
- {
- Param[] params = getParams();
- Parameter[] parameters = new Parameter[ params.length ];
- for( int i=0; i<parameters.length; i++ )
- {
- Param p = params[i];
- parameters[i] = p.getParameter();
- }
- return new Parameter( classname, parameters );
- }
- }
- }
}


Copied:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
(from r2133,
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/PartDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
Fri Mar 25 17:20:00 2005
@@ -34,7 +34,7 @@
/**
* A simple part datatype.
*/
-public class PartDataType extends ValueDataType implements PartBuilder
+public class EntryDataType extends ValueDataType implements PartBuilder
{
private String m_key;


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 17:20:00 2005
@@ -66,9 +66,9 @@
* Create a new constructed part builder.
* @return a part builder
*/
- public PartDataType createValue()
+ public EntryDataType createValue()
{
- final PartDataType builder = new PartDataType();
+ final EntryDataType builder = new EntryDataType();
m_builders.add( builder );
return builder;
}

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
17:20:00 2005
@@ -17,10 +17,10 @@
<container xmlns="plugin:dpml/composition/dpml-composition-builder"
name="acme">
<component name="widget"
class="net.dpml.composition.testing.DefaultWidget"/>
<component name="gizmo"
class="net.dpml.composition.testing.DefaultGizmo">
- <parameters>
- <parameter name="width" value="789"/>
- <parameter name="height" value="1024"/>
- </parameters>
+ <context>
+ <entry key="width" value="12"/>
+ <entry key="height" value="100"/>
+ </context>
<dependencies>
<dependency key="widget" source="widget"/>
</dependencies>
@@ -35,7 +35,6 @@

</target>

- <!--
<target name="package" depends="standard.package">
<echo>Writing types</echo>
<type-writer class="net.dpml.composition.testing.DefaultWidget"
@@ -44,6 +43,7 @@
xmlns="plugin:dpml/composition/dpml-composition-builder"/>
<echo>Building block</echo>
</target>
+ <!--
-->

</project>

Modified:
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/DefaultGizmo.java
Fri Mar 25 17:20:00 2005
@@ -35,42 +35,42 @@
private final Widget m_widget;

//------------------------------------------------------------------
- // facards
+ // constructor
//------------------------------------------------------------------

- public interface Dependencies
+ /**
+ * Creation of a new widget component.
+ *
+ * @param logger the logging channel assigned by the container
+ * @param dependencies the requested dependencies
+ */
+ public DefaultGizmo( Logger logger, Dependencies dependencies, Parts
parts )
{
- Widget getTheAcmeWidget();
+ m_logger = logger;
+ m_widget = dependencies.getTheAcmeWidget();
+ m_logger.info( "up and running with: " + m_widget.toString() );
}

- public interface Parameters
+ //------------------------------------------------------------------
+ // facards
+ //------------------------------------------------------------------
+
+ public interface Context
{
int getWidth();

int getHeight( int defaultHeight );
}

+ public interface Dependencies
+ {
+ Widget getTheAcmeWidget();
+ }
+
public interface Parts
{
Widget createWidget();
Widget getWidget();
void releaseWidget( Widget widget );
}
-
- //------------------------------------------------------------------
- // constructor
- //------------------------------------------------------------------
-
- /**
- * Creation of a new widget component.
- *
- * @param logger the logging channel assigned by the container
- * @param dependencies the requested dependencies
- */
- public DefaultGizmo( Logger logger, Dependencies dependencies )
- {
- m_logger = logger;
- m_widget = dependencies.getTheAcmeWidget();
- m_logger.info( "up and running with: " + m_widget.toString() );
- }
}

Modified: development/main/metro/index.xml
==============================================================================
--- development/main/metro/index.xml (original)
+++ development/main/metro/index.xml Fri Mar 25 17:20:00 2005
@@ -169,6 +169,7 @@
</info>
<dependencies>
<include key="dpml-context-api"/>
+ <include key="dpml-meta-api"/>
</dependencies>
</project>


Modified:
development/main/metro/meta/api/src/main/net/dpml/meta/info/EntryDescriptor.java
==============================================================================
---
development/main/metro/meta/api/src/main/net/dpml/meta/info/EntryDescriptor.java
(original)
+++
development/main/metro/meta/api/src/main/net/dpml/meta/info/EntryDescriptor.java
Fri Mar 25 17:20:00 2005
@@ -36,6 +36,9 @@
public final class EntryDescriptor
implements Serializable
{
+ public static final boolean OPTIONAL = true;
+ public static final boolean REQUIRED = false;
+
/**
* The name the component uses to lookup entry.
*/



  • svn commit: r2138 - in development/main/metro: . automation/builder automation/builder/src/main/net/dpml/builder automation/control automation/part composition/builder/src/main/net/dpml/composition/builder composition/builder/src/main/net/dpml/composition/builder/datatypes composition/control/src/main/net/dpml/composition/handlers composition/testing/acme composition/testing/acme/src/main/net/dpml/composition/testing meta/api/src/main/net/dpml/meta/info, mcconnell, 03/25/2005

Archive powered by MHonArc 2.6.24.

Top of Page