Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1998 - in development/laboratory/plus: . common/builder common/builder/src common/builder/src/main common/builder/src/main/net common/builder/src/main/net/dpml common/builder/src/main/net/dpml/metro common/builder/src/main/net/dpml/metro/builder common/control/src/main/net/dpml/metro/control common/kernel common/kernel/src common/kernel/src/main common/kernel/src/main/net common/kernel/src/main/net/dpml common/kernel/src/main/net/dpml/metro common/kernel/src/main/net/dpml/metro/kernel composition/builder/src/main/net/dpml/composition/builder composition/control composition/control/src/main/net/dpml/composition/control composition/controller composition/model/src/main/net/dpml/composition/model composition/model/src/test/net/dpml/composition/model test/example/api/src/main/net/dpml/test/hello test/example/impl/src/main/net/dpml/test/hello/impl test/execution test/execution/src/test/net/dpml/test/execution

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: r1998 - in development/laboratory/plus: . common/builder common/builder/src common/builder/src/main common/builder/src/main/net common/builder/src/main/net/dpml common/builder/src/main/net/dpml/metro common/builder/src/main/net/dpml/metro/builder common/control/src/main/net/dpml/metro/control common/kernel common/kernel/src common/kernel/src/main common/kernel/src/main/net common/kernel/src/main/net/dpml common/kernel/src/main/net/dpml/metro common/kernel/src/main/net/dpml/metro/kernel composition/builder/src/main/net/dpml/composition/builder composition/control composition/control/src/main/net/dpml/composition/control composition/controller composition/model/src/main/net/dpml/composition/model composition/model/src/test/net/dpml/composition/model test/example/api/src/main/net/dpml/test/hello test/example/impl/src/main/net/dpml/test/hello/impl test/execution test/execution/src/test/net/dpml/test/execution
  • Date: Wed, 09 Mar 2005 14:50:10 -0500

Author: mcconnell AT dpml.net
Date: Wed Mar 9 14:50:09 2005
New Revision: 1998

Added:
development/laboratory/plus/common/builder/
development/laboratory/plus/common/builder/build.xml
development/laboratory/plus/common/builder/src/
development/laboratory/plus/common/builder/src/main/
development/laboratory/plus/common/builder/src/main/net/
development/laboratory/plus/common/builder/src/main/net/dpml/
development/laboratory/plus/common/builder/src/main/net/dpml/metro/
development/laboratory/plus/common/builder/src/main/net/dpml/metro/builder/

development/laboratory/plus/common/builder/src/main/net/dpml/metro/builder/PartBuilder.java
development/laboratory/plus/common/kernel/
development/laboratory/plus/common/kernel/build.xml
development/laboratory/plus/common/kernel/src/
development/laboratory/plus/common/kernel/src/main/
development/laboratory/plus/common/kernel/src/main/net/
development/laboratory/plus/common/kernel/src/main/net/dpml/
development/laboratory/plus/common/kernel/src/main/net/dpml/metro/
development/laboratory/plus/common/kernel/src/main/net/dpml/metro/kernel/

development/laboratory/plus/common/kernel/src/main/net/dpml/metro/kernel/DefaultKernel.java

development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/PartsDataType.java
development/laboratory/plus/composition/control/
- copied from r1987, development/laboratory/plus/composition/controller/
development/laboratory/plus/composition/control/build.xml

development/laboratory/plus/composition/control/src/main/net/dpml/composition/control/

development/laboratory/plus/composition/control/src/main/net/dpml/composition/control/DefaultController.java

development/laboratory/plus/test/example/api/src/main/net/dpml/test/hello/OutputHandler.java

development/laboratory/plus/test/example/impl/src/main/net/dpml/test/hello/impl/DefaultOutputHandler.java

development/laboratory/plus/test/execution/src/test/net/dpml/test/execution/KernelTestCase.java
Removed:

development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/PartBuilder.java
development/laboratory/plus/composition/controller/

development/laboratory/plus/test/execution/src/test/net/dpml/test/execution/MarshallObjectTestCase.java
Modified:

development/laboratory/plus/common/control/src/main/net/dpml/metro/control/Controller.java

development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/ComponentModelBuilder.java

development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/ComponentModel.java

development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/PartModel.java

development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/ComponentModelTestCase.java

development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartModelTestCase.java
development/laboratory/plus/index.xml

development/laboratory/plus/test/example/impl/src/main/net/dpml/test/hello/impl/HelloComponent.java
development/laboratory/plus/test/execution/build.xml
Log:
updating to handle immutable models and an initial kernel

Added: development/laboratory/plus/common/builder/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/common/builder/build.xml Wed Mar 9
14:50:09 2005
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-metro-builder-api" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core">
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+</project>
+

Added:
development/laboratory/plus/common/builder/src/main/net/dpml/metro/builder/PartBuilder.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/common/builder/src/main/net/dpml/metro/builder/PartBuilder.java
Wed Mar 9 14:50:09 2005
@@ -0,0 +1,37 @@
+/*
+ * 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.metro.builder;
+
+import net.dpml.metro.part.Part;
+
+/**
+ * The contract for builders that create component part.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface PartBuilder
+{
+ /**
+ * Build the part.
+ * @return the serializable part
+ * @exception ConstructionException if a construction error occurs
+ */
+ Part build() throws Exception;
+}

Modified:
development/laboratory/plus/common/control/src/main/net/dpml/metro/control/Controller.java
==============================================================================
---
development/laboratory/plus/common/control/src/main/net/dpml/metro/control/Controller.java
(original)
+++
development/laboratory/plus/common/control/src/main/net/dpml/metro/control/Controller.java
Wed Mar 9 14:50:09 2005
@@ -27,12 +27,6 @@
public interface Controller
{
/**
- * Return the controller urn that identifies the controller type.
- * @return the controller type urn
- */
- String getURN();
-
- /**
* Return a human readable short name of the controller.
* @return the controller name
*/

Added: development/laboratory/plus/common/kernel/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/common/kernel/build.xml Wed Mar 9 14:50:09
2005
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-metro-kernel" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core">
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+</project>
+

Added:
development/laboratory/plus/common/kernel/src/main/net/dpml/metro/kernel/DefaultKernel.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/common/kernel/src/main/net/dpml/metro/kernel/DefaultKernel.java
Wed Mar 9 14:50:09 2005
@@ -0,0 +1,81 @@
+/*
+ * 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.metro.kernel;
+
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.IOException;
+import java.rmi.MarshalledObject;
+import java.net.URI;
+
+import net.dpml.metro.part.Part;
+import net.dpml.metro.part.PartEnvelope;
+import net.dpml.metro.control.Controller;
+import net.dpml.metro.control.ControlMonitor;
+
+/**
+ * The contract for builders that create component part.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class DefaultKernel
+{
+ public void loadPart( InputStream input ) throws IOException,
ClassNotFoundException
+ {
+ ObjectInputStream stream = new ObjectInputStream( input );
+ MarshalledObject marshalled = (MarshalledObject) stream.readObject();
+ PartEnvelope envelope = (PartEnvelope) marshalled.get();
+ URI uri = envelope.getControllerURI();
+ ControlMonitor monitor = new DefaultControlMonitor();
+ monitor.info( "loading controller uri: " + uri );
+ }
+
+ private static class DefaultControlMonitor implements ControlMonitor
+ {
+ /**
+ * Log the supplied info level message.
+ * @param mesage the message to log
+ */
+ public void info( String message )
+ {
+ System.out.println( message );
+ }
+
+ /**
+ * Log the supplied debug level message.
+ * @param mesage the message to log
+ */
+ public void debug( String message )
+ {
+ System.out.println( message );
+ }
+
+ /**
+ * Log the supplied error level message.
+ * @param mesage the message to log
+ * @param throwable the exception
+ */
+ public void error( String message, Throwable throwable )
+ {
+ System.out.println( message );
+ throwable.printStackTrace();
+ }
+ }
+}

Modified:
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/ComponentModelBuilder.java
==============================================================================
---
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/ComponentModelBuilder.java
(original)
+++
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/ComponentModelBuilder.java
Wed Mar 9 14:50:09 2005
@@ -27,11 +27,14 @@
import java.io.ObjectOutputStream;
import java.net.URI;
import java.rmi.MarshalledObject;
+import java.util.List;
+import java.util.LinkedList;

import net.dpml.composition.model.ComponentModel;

import net.dpml.metro.part.Part;
import net.dpml.metro.part.PartEnvelope;
+import net.dpml.metro.builder.PartBuilder;

import net.dpml.magic.tasks.ProjectTask;

@@ -50,7 +53,9 @@
// state
//--------------------------------------------------------------------

- private ComponentModel m_delegate = new ComponentModel();
+ private String m_name;
+ private String m_classname;
+ private PartsDataType m_parts;

//--------------------------------------------------------------------
// setters
@@ -62,34 +67,49 @@
*/
public void setName( final String name )
{
- m_delegate.setName( name );
+System.out.println( "setting name: " + name );
+ m_name = name;
}

/**
* Set the name of the identifiable to the supplied value.
* @param name the identifying name
*/
- public void setClass( final String name )
+ public void setClass( final String classname )
{
- m_delegate.setClassname( name );
+System.out.println( "setting classname: " + classname );
+ m_classname = classname;
}

- /**
- * Return the include directive delegate.
- * @return the include delegate
- */
- public ComponentModel getComponentModel()
+ public PartsDataType createParts()
{
- return m_delegate;
+ if( null == m_parts )
+ {
+System.out.println( "creating parts element" );
+ m_parts = new PartsDataType( this );
+ }
+ return m_parts;
}

//--------------------------------------------------------------------
// PartBuilder
//--------------------------------------------------------------------

- public Part build() throws ConstructionException
+ public Part build() throws Exception
+ {
+System.out.println( "building part" );
+ return buildComponentModel();
+ }
+
+ /**
+ * Return the include directive delegate.
+ * @return the include delegate
+ */
+ public ComponentModel buildComponentModel() throws Exception
{
- return getComponentModel();
+System.out.println( "building component model" );
+ Part[] parts = createParts().getParts();
+ return new ComponentModel( m_classname, m_name, parts );
}

//--------------------------------------------------------------------
@@ -98,6 +118,7 @@

public void execute()
{
+System.out.println( "executing" );
try
{
Part part = build();

Added:
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/PartsDataType.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/PartsDataType.java
Wed Mar 9 14:50:09 2005
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2005 Stephen J. McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.builder;
+
+import java.util.List;
+import java.util.LinkedList;
+
+import net.dpml.metro.part.Part;
+import net.dpml.metro.builder.PartBuilder;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.Target;
+import org.apache.tools.ant.ProjectHelper;
+import org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.DynamicElementNS;
+import org.apache.tools.ant.taskdefs.Sequential;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Location;
+
+/**
+ * The task is a container of parts.
+ *
+ * @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 PartsDataType extends ProjectComponent implements
DynamicElementNS
+{
+ private List m_builders = new LinkedList();
+ private Task m_owner;
+
+ public PartsDataType( Task owner )
+ {
+ setProject( owner.getProject() );
+ m_owner = owner;
+ }
+
+ /**
+ * Operation used to construct a custom part type directive.
+ * @param uri the part handler uri
+ * @param name the element name
+ * @param qualified the qualified name
+ */
+ public Object createDynamicElement( String uri, String name, String
qualified )
+ {
+ String path = getProject().replaceProperties( uri );
+ PartBuilder builder = loadPartHandler( path, name );
+ m_builders.add( builder );
+ return builder;
+ }
+
+ private PartBuilder loadPartHandler( String uri, String name ) throws
BuildException
+ {
+ String urn = uri + ":" + name;
+
+ PartBuilder partBuilder = null;
+ String target = m_owner.getOwningTarget().getName();
+ Location location = m_owner.getLocation();
+ ClassLoader context = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(
getClass().getClassLoader() );
+ return (PartBuilder) getProject().createDataType( urn );
+ }
+ catch( ClassCastException e )
+ {
+ final String error =
+ "The custom part builder ["
+ + partBuilder.getClass().getName()
+ + "] established by the uri ["
+ + urn
+ + "] declared by the element <"
+ + name
+ + "> under the task <"
+ + m_owner.getTaskName()
+ + "><parts> within the target <"
+ + target
+ + "> does not implement the net.dpml.metro.tools.PartBuilder
interface.";
+ throw new BuildException( error, e, location );
+ }
+ catch( BuildException e )
+ {
+ final String error =
+ "Unable to load the plugin from the uri ["
+ + urn
+ + "] to handle the custom part type declared by the element <"
+ + name
+ + "> within <"
+ + m_owner.getTaskName()
+ + "><parts> under the target <"
+ + target
+ + ">.";
+ throw new BuildException( error, e, location );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected exception while attempting to load the custom part
handler with the uri ["
+ + urn
+ + "] declared by the element <"
+ + name
+ + "> within <"
+ + m_owner.getTaskName()
+ + "><parts> under the target <"
+ + target
+ + ">.";
+ throw new BuildException( error, e, location );
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( context );
+ }
+ }
+
+ /**
+ * Return the set of parts contained within this container.
+ * @return the contained parts
+ */
+ public Part[] getParts() throws Exception
+ {
+
+ PartBuilder[] builders = (PartBuilder[]) m_builders.toArray( new
PartBuilder[0] );
+ Part[] parts = new Part[ builders.length ];
+ for( int i=0; i<builders.length; i++ )
+ {
+ PartBuilder builder = builders[i];
+ parts[i] = builder.build();
+ }
+ return parts;
+ }
+
+}

Added: development/laboratory/plus/composition/control/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/composition/control/build.xml Wed Mar 9
14:50:09 2005
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-composition-control" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core">
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="package" depends="standard.package">
+ <x:export class="net.dpml.composition.control.DefaultController"/>
+ </target>
+
+</project>
+

Added:
development/laboratory/plus/composition/control/src/main/net/dpml/composition/control/DefaultController.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/control/src/main/net/dpml/composition/control/DefaultController.java
Wed Mar 9 14:50:09 2005
@@ -0,0 +1,95 @@
+/*
+ * 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.control;
+
+import java.net.URI;
+
+import net.dpml.composition.model.ComponentModel;
+
+import net.dpml.metro.part.Part;
+import net.dpml.metro.control.Controller;
+import net.dpml.metro.control.ControlMonitor;
+
+/**
+ * A initial test controller.
+ *
+ * @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 DefaultController implements Controller
+{
+ private static final String LINE =
+ "------------------------------------------------------------";
+
+ private static final String CONTROLLER_NAME = "controller";
+
+ //--------------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------------
+
+ private final ControlMonitor m_monitor;
+ private final ComponentModel m_model;
+
+ //--------------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------------
+
+ public DefaultController( ControlMonitor monitor, ComponentModel model )
+ {
+ m_model = model;
+ m_monitor = monitor;
+
+ listModel();
+ }
+
+ //--------------------------------------------------------------------
+ // Controller
+ //--------------------------------------------------------------------
+
+ public String getName()
+ {
+ return CONTROLLER_NAME;
+ }
+
+ //--------------------------------------------------------------------
+ // imlementation
+ //--------------------------------------------------------------------
+
+ private ComponentModel getModel()
+ {
+ return m_model;
+ }
+
+ private ControlMonitor getMonitor()
+ {
+ return m_monitor;
+ }
+
+ private void listModel()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( LINE );
+ buffer.append( "\nModel Listing" );
+ buffer.append( "\nname:" + getModel().getName() );
+ buffer.append( "\nclassname:" + getModel().getClassname() );
+ Part[] parts = getModel().getParts();
+ buffer.append( "\nparts:" + parts.length );
+ getMonitor().info( buffer.toString() );
+ }
+}

Modified:
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/ComponentModel.java
==============================================================================
---
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/ComponentModel.java
(original)
+++
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/ComponentModel.java
Wed Mar 9 14:50:09 2005
@@ -30,22 +30,38 @@
public class ComponentModel extends PartModel
{
private String m_classname;
+ private Part[] m_parts;

- /**
- * Set the name of the component implementation class.
- * @param classname the component implementation clasname
- * @exception NullPointerException if the supplied classname is null
- */
- public void setClassname( String classname )
+ public ComponentModel( String classname, String name, Part[] parts )
{
+ super( name );
if( null == classname )
{
throw new NullPointerException( "classname" );
}
+ if( null == parts )
+ {
+ throw new NullPointerException( "parts" );
+ }
m_classname = classname;
+ m_parts = parts;
}

/**
+ * Set the name of the component implementation class.
+ * @param classname the component implementation clasname
+ * @exception NullPointerException if the supplied classname is null
+ */
+ //public void setClassname( String classname )
+ //{
+ // if( null == classname )
+ // {
+ // throw new NullPointerException( "classname" );
+ // }
+ // m_classname = classname;
+ //}
+
+ /**
* Return the name of the part.
* @return the part name
*/
@@ -54,9 +70,18 @@
return m_classname;
}

+ /**
+ * Return the set of parts within this component.
+ * @return the parts
+ */
+ public Part[] getParts()
+ {
+ return m_parts;
+ }
+
public int hashCode()
{
- validate();
+ //validate();
int hash = super.hashCode();
hash ^= m_classname.hashCode();
return hash;
@@ -70,14 +95,40 @@
}
else if( other instanceof ComponentModel )
{
- validate();
+ //validate();
ComponentModel part = (ComponentModel) other;
- if( super.equals( part ) )
+ if( !super.equals( part ) )
{
- return getClassname().equals( part.getClassname() );
+ return false;
}
+ else if( !getClassname().equals( part.getClassname() ) )
+ {
+ return false;
+ }
+ else if( getParts().length != part.getParts().length )
+ {
+ return false;
+ }
+ else
+ {
+ Part[] myParts = getParts();
+ Part[] yourParts = part.getParts();
+ for( int i=0; i<myParts.length; i++ )
+ {
+ Part p = myParts[i];
+ Part q = yourParts[i];
+ if( !p.equals( q ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ else
+ {
+ return false;
}
- return false;
}

protected void validate() throws IllegalStateException

Modified:
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/PartModel.java
==============================================================================
---
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/PartModel.java
(original)
+++
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/PartModel.java
Wed Mar 9 14:50:09 2005
@@ -31,12 +31,7 @@
{
private String m_name;

- /**
- * Set the name of the part.
- * @param name the part name
- * @exception NullPointerException if the supplied name argument is null
- */
- public void setName( String name )
+ public PartModel( String name )
{
if( null == name )
{
@@ -46,6 +41,20 @@
}

/**
+ * Set the name of the part.
+ * @param name the part name
+ * @exception NullPointerException if the supplied name argument is null
+ */
+ //public void setName( String name )
+ //{
+ // if( null == name )
+ // {
+ // throw new NullPointerException( "name" );
+ // }
+ // m_name = name;
+ //}
+
+ /**
* Return the name of the part.
* @return the part name
*/
@@ -56,7 +65,7 @@

public int hashCode()
{
- validate();
+ //validate();
return getName().hashCode();
}

@@ -68,18 +77,18 @@
}
if( other instanceof PartModel )
{
- validate();
+ //validate();
PartModel part = (PartModel) other;
return getName().equals( part.getName() );
}
return false;
}

- protected void validate() throws IllegalStateException
- {
- if( null == m_name )
- {
- throw new IllegalStateException( "name" );
- }
- }
+ //protected void validate() throws IllegalStateException
+ //{
+ // if( null == m_name )
+ // {
+ // throw new IllegalStateException( "name" );
+ // }
+ //}
}

Modified:
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/ComponentModelTestCase.java
==============================================================================
---
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/ComponentModelTestCase.java
(original)
+++
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/ComponentModelTestCase.java
Wed Mar 9 14:50:09 2005
@@ -28,6 +28,8 @@

import junit.framework.TestCase;

+import net.dpml.metro.part.Part;
+

/**
* The part directive is a directive that can be handled as a part within a
@@ -38,25 +40,20 @@
*/
public class ComponentModelTestCase extends TestCase
{
- private ComponentModel m_part;
-
- public void setUp()
- {
- m_part = new ComponentModel();
- }
-
+
public void testSetClassname() throws Exception
{
+ final String name = "name";
final String classname = "aaa.bbb.Ccc";
- m_part.setClassname( classname );
- assertEquals( "classname", classname, m_part.getClassname() );
+ ComponentModel part = new ComponentModel( classname, name, new
Part[0] );
+ assertEquals( "classname", classname, part.getClassname() );
}

- public void testNullClasname()
+ public void testNullClassname()
{
try
{
- m_part.setClassname( null );
+ ComponentModel part = new ComponentModel( null, "abc", new
Part[0] );
fail( "No NPE while setting classname to null." );
}
catch( NullPointerException npe )
@@ -65,13 +62,24 @@
}
}

+ public void testNullParts()
+ {
+ try
+ {
+ ComponentModel part = new ComponentModel( "abc", "abc", null );
+ fail( "No NPE while setting parts to null." );
+ }
+ catch( NullPointerException npe )
+ {
+ // ok
+ }
+ }
+
public void testSerialization() throws Exception
{
final String name = "name";
final String classname = "aaa.bbb.Ccc";
- ComponentModel model = new ComponentModel();
- model.setName( name );
- model.setClassname( classname );
+ ComponentModel model = new ComponentModel( classname, name, new
Part[0] );

File file = new File( "test.out" );
ObjectOutputStream oos = new ObjectOutputStream( new
FileOutputStream( file ) );

Modified:
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartModelTestCase.java
==============================================================================
---
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartModelTestCase.java
(original)
+++
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartModelTestCase.java
Wed Mar 9 14:50:09 2005
@@ -32,26 +32,18 @@
*/
public class PartModelTestCase extends TestCase
{
- private PartModel m_part;
-
- public void setUp()
- {
- m_part = new PartModel();
- }
-
public void testSetName()
{
final String name = "abc";
- m_part.setName( name );
- assertEquals( "name", name, m_part.getName() );
+ PartModel part = new PartModel( name );
+ assertEquals( "name", name, part.getName() );
}

public void testNullName()
{
- final String name = null;
try
{
- m_part.setName( name );
+ PartModel part = new PartModel( null );
fail( "No NPE while setting name to null." );
}
catch( NullPointerException npe )
@@ -62,7 +54,7 @@

public void testImplementsPart()
{
- assertTrue( "implements Part interface", ( m_part instanceof Part )
);
+ assertTrue( "implements Part", ( new PartModel( "abc" ) instanceof
Part ) );
}

}

Modified: development/laboratory/plus/index.xml
==============================================================================
--- development/laboratory/plus/index.xml (original)
+++ development/laboratory/plus/index.xml Wed Mar 9 14:50:09 2005
@@ -34,6 +34,21 @@
</info>
</project>

+ <project basedir="common/builder">
+ <info>
+ <group>dpml/metro</group>
+ <name>dpml-metro-builder-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <types>
+ <type>jar</type>
+ </types>
+ </info>
+ <dependencies>
+ <include key="dpml-metro-part-api" tag="api"/>
+ </dependencies>
+ </project>
+
<project basedir="common/control">
<info>
<group>dpml/metro</group>
@@ -46,6 +61,22 @@
</info>
</project>

+ <project basedir="common/kernel">
+ <info>
+ <group>dpml/metro</group>
+ <name>dpml-metro-kernel</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <types>
+ <type>jar</type>
+ </types>
+ </info>
+ <dependencies>
+ <include key="dpml-metro-part-api"/>
+ <include key="dpml-metro-control-api"/>
+ </dependencies>
+ </project>
+
<project basedir="composition/builder">
<info>
<group>dpml/metro</group>
@@ -60,6 +91,7 @@
<dependencies>
<include key="dpml-composition-model" tag="api"/>
<include key="dpml-metro-part-api" tag="api"/>
+ <include key="dpml-metro-builder-api"/>
<include key="dpml-magic-core"/>
<include key="ant"/>
</dependencies>
@@ -80,6 +112,22 @@
</dependencies>
</project>

+ <project basedir="composition/control">
+ <info>
+ <group>dpml/metro</group>
+ <name>dpml-composition-control</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <types>
+ <type>jar</type>
+ </types>
+ </info>
+ <dependencies>
+ <include key="dpml-metro-control-api"/>
+ <include key="dpml-composition-model"/>
+ </dependencies>
+ </project>
+
<project basedir="test/example/api">
<info>
<group>dpml/metro</group>
@@ -119,7 +167,9 @@
</info>
<dependencies>
<include key="dpml-transit-main"/>
- <include key="dpml-composition-builder"/>
+ <include key="dpml-metro-kernel" test="true" runtime="false"/>
+ <include key="dpml-composition-builder" test="true" runtime="false"/>
+ <include key="dpml-composition-control" test="true" runtime="false"/>
<include key="dpml-test-hello-impl"/>
</dependencies>
</project>

Added:
development/laboratory/plus/test/example/api/src/main/net/dpml/test/hello/OutputHandler.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/test/example/api/src/main/net/dpml/test/hello/OutputHandler.java
Wed Mar 9 14:50:09 2005
@@ -0,0 +1,30 @@
+/*
+ * 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.test.hello;
+
+/**
+ * A demonstration hello component.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface OutputHandler
+{
+ void publish( String message );
+}

Added:
development/laboratory/plus/test/example/impl/src/main/net/dpml/test/hello/impl/DefaultOutputHandler.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/test/example/impl/src/main/net/dpml/test/hello/impl/DefaultOutputHandler.java
Wed Mar 9 14:50:09 2005
@@ -0,0 +1,35 @@
+/*
+ * 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.test.hello;
+
+import net.dpml.test.hello.OutputHandler;
+
+/**
+ * A demonstration hello component.
+ *
+ * @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 DefaultOutputHandler implements OutputHandler
+{
+ public void publish( String message )
+ {
+ System.out.println( message );
+ }
+}

Modified:
development/laboratory/plus/test/example/impl/src/main/net/dpml/test/hello/impl/HelloComponent.java
==============================================================================
---
development/laboratory/plus/test/example/impl/src/main/net/dpml/test/hello/impl/HelloComponent.java
(original)
+++
development/laboratory/plus/test/example/impl/src/main/net/dpml/test/hello/impl/HelloComponent.java
Wed Mar 9 14:50:09 2005
@@ -19,6 +19,7 @@
package net.dpml.test.hello.impl;

import net.dpml.test.hello.Hello;
+import net.dpml.test.hello.OutputHandler;

/**
* A demonstration hello component.
@@ -28,8 +29,20 @@
*/
public class HelloComponent implements Hello
{
+ public interface Dependencies
+ {
+ OutputHandler getPublisher();
+ }
+
+ private Dependencies m_dependencies;
+
+ public HelloComponent( Dependencies dependencies )
+ {
+ m_dependencies = dependencies;
+ }
+
public void sayHello()
{
- System.out.println( "hello" );
+ m_dependencies.getPublisher().publish( "hello" );
}
}

Modified: development/laboratory/plus/test/execution/build.xml
==============================================================================
--- development/laboratory/plus/test/execution/build.xml (original)
+++ development/laboratory/plus/test/execution/build.xml Wed Mar 9
14:50:09 2005
@@ -2,7 +2,8 @@

<project name="dpml-test-execution" default="install" basedir="."
xmlns:transit="antlib:net.dpml.transit"
- xmlns:x="plugin:dpml/magic/dpml-magic-core" >
+ xmlns:x="plugin:dpml/magic/dpml-magic-core"
+ xmlns:m="plugin:dpml/metro/dpml-composition-builder" >

<transit:import uri="artifact:template:dpml/magic/standard"/>

@@ -13,8 +14,23 @@
</target>

<target name="package" depends="standard.package">
- <component xmlns="plugin:dpml/metro/dpml-composition-builder"
- class="net.dpml.test.hello.impl.HelloComponent" name="hello"/>
+ <x:path id="test.path"/>
+ <pathconvert pathsep="," property="test.path" refid="test.path"/>
+ <echo>${test.path}</echo>
+ <!--
+ <m:component xmlns="plugin:dpml/metro/dpml-composition-builder"
+ class="net.dpml.test.hello.impl.HelloComponent" name="hello"/>
+ -->
+ <m:component class="net.dpml.test.hello.impl.HelloComponent"
name="hello">
+ <!--
+ <dependencies>
+ <dependency key="publisher" provider="output"/>
+ </dependencies>
+ -->
+ <parts>
+ <m:component class="net.dpml.test.hello.impl.DefaultOutputHandler"
name="output"/>
+ </parts>
+ </m:component>
</target>

</project>

Added:
development/laboratory/plus/test/execution/src/test/net/dpml/test/execution/KernelTestCase.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/test/execution/src/test/net/dpml/test/execution/KernelTestCase.java
Wed Mar 9 14:50:09 2005
@@ -0,0 +1,60 @@
+/*
+ * 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.test.execution;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import net.dpml.metro.kernel.DefaultKernel;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Kernel testcase.
+ *
+ * @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 KernelTestCase extends TestCase
+{
+ static
+ {
+ System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
+ }
+
+ private static final String XPATH = "@XPATH@";
+
+ private DefaultKernel m_kernel;
+
+ public void setUp() throws Exception
+ {
+ m_kernel = new DefaultKernel();
+ }
+
+ public void testKernel() throws Exception
+ {
+ File basedir = new File( System.getProperty( "project.basedir" ) );
+ File file = new File( basedir, XPATH );
+ InputStream input = new FileInputStream( file.getCanonicalFile() );
+ m_kernel.loadPart( input );
+ }
+
+}



  • svn commit: r1998 - in development/laboratory/plus: . common/builder common/builder/src common/builder/src/main common/builder/src/main/net common/builder/src/main/net/dpml common/builder/src/main/net/dpml/metro common/builder/src/main/net/dpml/metro/builder common/control/src/main/net/dpml/metro/control common/kernel common/kernel/src common/kernel/src/main common/kernel/src/main/net common/kernel/src/main/net/dpml common/kernel/src/main/net/dpml/metro common/kernel/src/main/net/dpml/metro/kernel composition/builder/src/main/net/dpml/composition/builder composition/control composition/control/src/main/net/dpml/composition/control composition/controller composition/model/src/main/net/dpml/composition/model composition/model/src/test/net/dpml/composition/model test/example/api/src/main/net/dpml/test/hello test/example/impl/src/main/net/dpml/test/hello/impl test/execution test/execution/src/test/net/dpml/test/execution, mcconnell, 03/09/2005

Archive powered by MHonArc 2.6.24.

Top of Page