Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1968 - in development/laboratory/plus: . acme composition composition/builder composition/builder/src composition/builder/src/main composition/builder/src/main/net composition/builder/src/main/net/dpml composition/builder/src/main/net/dpml/composition composition/builder/src/main/net/dpml/composition/builder composition/model composition/model/src composition/model/src/main composition/model/src/main/net composition/model/src/main/net/dpml composition/model/src/main/net/dpml/composition composition/model/src/main/net/dpml/composition/model composition/model/src/test composition/model/src/test/net composition/model/src/test/net/dpml composition/model/src/test/net/dpml/composition composition/model/src/test/net/dpml/composition/model composition/part composition/part/src composition/part/src/main composition/part/src/main/net composition/part/src/main/net/dpml composition/part/src/main/net/dpml/composition composition/part/src/main/net/dpml/composition/part composition/test test tools

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: r1968 - in development/laboratory/plus: . acme composition composition/builder composition/builder/src composition/builder/src/main composition/builder/src/main/net composition/builder/src/main/net/dpml composition/builder/src/main/net/dpml/composition composition/builder/src/main/net/dpml/composition/builder composition/model composition/model/src composition/model/src/main composition/model/src/main/net composition/model/src/main/net/dpml composition/model/src/main/net/dpml/composition composition/model/src/main/net/dpml/composition/model composition/model/src/test composition/model/src/test/net composition/model/src/test/net/dpml composition/model/src/test/net/dpml/composition composition/model/src/test/net/dpml/composition/model composition/part composition/part/src composition/part/src/main composition/part/src/main/net composition/part/src/main/net/dpml composition/part/src/main/net/dpml/composition composition/part/src/main/net/dpml/composition/part composition/test test tools
  • Date: Mon, 07 Mar 2005 15:31:28 -0500

Author: mcconnell AT dpml.net
Date: Mon Mar 7 15:31:26 2005
New Revision: 1968

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

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

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

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

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

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

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

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

development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/antlib.xml
development/laboratory/plus/composition/index.xml
development/laboratory/plus/composition/model/
development/laboratory/plus/composition/model/build.xml
development/laboratory/plus/composition/model/src/
development/laboratory/plus/composition/model/src/main/
development/laboratory/plus/composition/model/src/main/net/
development/laboratory/plus/composition/model/src/main/net/dpml/

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

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

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

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

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

development/laboratory/plus/composition/model/src/test/net/dpml/composition/

development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/

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

development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartDirectiveTestCase.java
development/laboratory/plus/composition/part/
development/laboratory/plus/composition/part/build.xml
development/laboratory/plus/composition/part/src/
development/laboratory/plus/composition/part/src/main/
development/laboratory/plus/composition/part/src/main/net/
development/laboratory/plus/composition/part/src/main/net/dpml/
development/laboratory/plus/composition/part/src/main/net/dpml/composition/

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

development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/Part.java
development/laboratory/plus/composition/test/
development/laboratory/plus/composition/test/build.xml
Removed:
development/laboratory/plus/acme/
development/laboratory/plus/build.xml
development/laboratory/plus/index.xml
development/laboratory/plus/test/
development/laboratory/plus/tools/
Log:
Take-2.

Added: development/laboratory/plus/composition/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/composition/build.xml Mon Mar 7 15:31:26
2005
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-composition" default="default" basedir="."
+ xmlns:transit="antlib:net.dpml.transit">
+
+ <transit:import uri="artifact:template:dpml/magic/reactor"/>
+
+</project>
+

Added: development/laboratory/plus/composition/builder/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/composition/builder/build.xml Mon Mar 7
15:31:26 2005
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-composition-builder" 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>
+ <antlib resource="net/dpml/composition/builder/antlib.xml"
+ urn="plugin:dpml/metro/dpml-composition-builder"/>
+ </x:export>
+ </target>
+
+</project>
+

Added:
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/BuilderComponent.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/BuilderComponent.java
Mon Mar 7 15:31:26 2005
@@ -0,0 +1,47 @@
+/*
+ * 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 org.apache.tools.ant.ProjectComponent;
+import org.apache.tools.ant.Location;
+
+/**
+ * The PartHandler is an abstract base class for part handlers.
+ *
+ * @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 abstract class BuilderComponent extends ProjectComponent
+{
+ private Location m_location = Location.UNKNOWN_LOCATION;
+
+ //--------------------------------------------------------------------
+ // utilities
+ //--------------------------------------------------------------------
+
+ public Location getLocation()
+ {
+ return m_location;
+ }
+
+ public void setLocation( Location location )
+ {
+ m_location = location;
+ }
+}

Added:
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/ConstructionException.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/ConstructionException.java
Mon Mar 7 15:31:26 2005
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2005 Stephen J. McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.builder;
+
+import java.net.URI;
+
+import org.apache.tools.ant.Location;
+import org.apache.tools.ant.BuildException;
+
+/**
+ * A construction exception indicates a generation phase error in the
construction
+ * of a 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 ConstructionException extends BuildException
+{
+ /**
+ * Creation of a new construction exception.
+ * @param message the exception message
+ */
+ public ConstructionException( String message )
+ {
+ super( message );
+ }
+
+ /**
+ * Creation of a new construction exception.
+ * @param message the exception message
+ * @param cause the causal exception
+ */
+ public ConstructionException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ /**
+ * Creation of a new construction exception.
+ * @param message the exception message
+ * @param cause the causal exception
+ */
+ public ConstructionException( String message, Location location )
+ {
+ super( message, location );
+ }
+
+ /**
+ * Creation of a new construction exception.
+ * @param message the exception message
+ * @param location location of the task
+ */
+ public ConstructionException( String message, Throwable cause, Location
location )
+ {
+ super( message, cause, location );
+ }
+}

Added:
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/IncludeDirectiveBuilder.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/IncludeDirectiveBuilder.java
Mon Mar 7 15:31:26 2005
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2005 Stephen J. McConnell
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.builder;
+
+import java.net.URI;
+
+import net.dpml.composition.model.IncludeDirective;
+import net.dpml.composition.part.Part;
+
+import org.apache.tools.ant.ProjectComponent;
+
+/**
+ * A builder that handles the construction of an IncludeDirective using Ant.
+ *
+ * @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 IncludeDirectiveBuilder extends BuilderComponent implements
PartBuilder
+{
+ //--------------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------------
+
+ private IncludeDirective m_delegate = new IncludeDirective();
+
+ //--------------------------------------------------------------------
+ // setters
+ //--------------------------------------------------------------------
+
+ /**
+ * Set the artifact uri.
+ * @param uri the artifact uri
+ */
+ public void setUri( final URI uri )
+ {
+ m_delegate.setURI( uri );
+ }
+
+ /**
+ * Set the name of the identifiable to the supplied value.
+ * @param name the identifying name
+ */
+ public void setName( final String name )
+ {
+ m_delegate.setName( name );
+ }
+
+ /**
+ * Return the include directive delegate.
+ * @return the include delegate
+ */
+ public IncludeDirective getIncludeDirective()
+ {
+ return m_delegate;
+ }
+
+ //--------------------------------------------------------------------
+ // PartBuilder
+ //--------------------------------------------------------------------
+
+ public Part build() throws ConstructionException
+ {
+ return getIncludeDirective();
+ }
+
+
+}

Added:
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/IncludeDirectiveBuilderTask.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/IncludeDirectiveBuilderTask.java
Mon Mar 7 15:31:26 2005
@@ -0,0 +1,133 @@
+/*
+ * 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.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URI;
+
+import net.dpml.composition.model.IncludeDirective;
+import net.dpml.composition.part.Part;
+import net.dpml.magic.tasks.ProjectTask;
+
+import org.apache.tools.ant.Task;
+
+/**
+ * A builder that handles the construction of an IncludeDirective using Ant.
+ *
+ * @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 IncludeDirectiveBuilderTask extends ProjectTask
+{
+ //--------------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------------
+
+ private IncludeDirectiveBuilder m_builder;
+
+ //--------------------------------------------------------------------
+ // setters
+ //--------------------------------------------------------------------
+
+ public void init()
+ {
+ m_builder = new IncludeDirectiveBuilder();
+ }
+
+ public void setUri( URI uri )
+ {
+ m_builder.setUri( uri );
+ }
+
+ public void setName( String name )
+ {
+ m_builder.setName( name );
+ }
+
+ //--------------------------------------------------------------------
+ // Task
+ //--------------------------------------------------------------------
+
+ public void execute()
+ {
+ IncludeDirective part = m_builder.getIncludeDirective();
+ externalize( part );
+ }
+
+ public void externalize( Part part )
+ {
+ ObjectOutputStream output = null;
+ FileOutputStream stream = null;
+ File file = getOutputFile();
+ try
+ {
+ stream = new FileOutputStream( file );
+ output = new ObjectOutputStream( stream );
+ output.writeObject( part );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to write part to output
stream."
+ + "\ndestination: " + file
+ + "\nclass: " + part.getClass().getName()
+ + "\nreason: " + e.toString();
+ throw new ConstructionException( error, e, getLocation() );
+ }
+ finally
+ {
+ closeStream( output );
+ closeStream( stream );
+ }
+ }
+
+ private File getOutputFile()
+ {
+ File dir = getContext().getDeliverablesDirectory( "xpart" );
+ String filename = getDefinition().getFilename( "xpart" );
+ File file = new File( dir, filename );
+ File parent = file.getParentFile();
+ if( !parent.exists() )
+ {
+ parent.mkdirs();
+ }
+ return file;
+ }
+
+ private void closeStream( OutputStream out )
+ {
+ if( null != out )
+ {
+ try
+ {
+ out.close();
+ }
+ catch( IOException ioe )
+ {
+ boolean ignoreMe = true;
+ }
+ }
+ }
+}

Added:
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/PartBuilder.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/PartBuilder.java
Mon Mar 7 15:31:26 2005
@@ -0,0 +1,39 @@
+/*
+ * 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 net.dpml.composition.part.Part;
+
+import org.apache.tools.ant.Task;
+
+/**
+ * The contract for builders that create component 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 interface PartBuilder
+{
+ /**
+ * Build the part.
+ * @return the serializable part
+ * @exception ConstructionException if a construction error occurs
+ */
+ Part build() throws ConstructionException;
+}

Added:
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/antlib.xml
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/antlib.xml
Mon Mar 7 15:31:26 2005
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+
+<antlib>
+ <taskdef name="include"
classname="net.dpml.composition.builder.IncludeDirectiveBuilderTask"/>
+</antlib>

Added: development/laboratory/plus/composition/index.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/composition/index.xml Mon Mar 7 15:31:26
2005
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Copyright 2005 Stephen J McConnell
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied.
+
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+
+<index>
+
+ <import uri="artifact:module:dpml/magic/dpml-magic#SNAPSHOT"/>
+
+ <project basedir="test">
+ <info>
+ <group>dpml/metro</group>
+ <name>dpml-composition-test</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <types>
+ <type>jar</type>
+ </types>
+ </info>
+ <dependencies>
+ <include key="dpml-composition-builder"/>
+ </dependencies>
+ </project>
+
+ <project basedir="builder">
+ <info>
+ <group>dpml/metro</group>
+ <name>dpml-composition-builder</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <types>
+ <type>jar</type>
+ <type>plugin</type>
+ </types>
+ </info>
+ <dependencies>
+ <include key="dpml-magic-core"/>
+ <include key="dpml-composition-model"/>
+ <include key="dpml-composition-part"/>
+ <include key="ant"/>
+ </dependencies>
+ </project>
+
+ <project basedir="model">
+ <info>
+ <group>dpml/metro</group>
+ <name>dpml-composition-model</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <types>
+ <type>jar</type>
+ </types>
+ </info>
+ <dependencies>
+ <include key="dpml-composition-part"/>
+ </dependencies>
+ </project>
+
+ <project basedir="part">
+ <info>
+ <group>dpml/metro</group>
+ <name>dpml-composition-part</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <types>
+ <type>jar</type>
+ </types>
+ </info>
+ </project>
+
+</index>

Added: development/laboratory/plus/composition/model/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/composition/model/build.xml Mon Mar 7
15:31:26 2005
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-composition-model" 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>
+ <antlib resource="net/dpml/composition/model/antlib.xml"
+ urn="plugin:dpml/metro/dpml-composition-model"/>
+ </x:export>
+ </target>
+
+</project>
+

Added:
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/Directive.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/Directive.java
Mon Mar 7 15:31:26 2005
@@ -0,0 +1,31 @@
+/*
+ * 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.model;
+
+import java.io.Serializable;
+
+/**
+ * The base class for all directives.
+ *
+ * @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 Directive extends Serializable
+{
+}

Added:
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/IncludeDirective.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/IncludeDirective.java
Mon Mar 7 15:31:26 2005
@@ -0,0 +1,105 @@
+/*
+ * 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.model;
+
+import java.net.URI;
+
+/**
+ * The include directive provides support for the inclusion of an arbitary
part
+ * within a 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 IncludeDirective extends PartDirective
+{
+ //--------------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------------
+
+ private static final long serialVersionUID = 1L;
+
+ //--------------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------------
+
+ private URI m_uri;
+
+ //--------------------------------------------------------------------
+ // ProjectComponent
+ //--------------------------------------------------------------------
+
+ /**
+ * Set the artifact uri.
+ * @param spec the artifact uri
+ */
+ public void setURI( final URI uri ) throws IllegalArgumentException
+ {
+ if( null == uri )
+ {
+ throw new NullPointerException( "uri" );
+ }
+ m_uri = uri;
+ }
+
+ /**
+ * Return the artifact urn
+ * @return the artifact urn value
+ */
+ public URI getURI()
+ {
+ return m_uri;
+ }
+
+ public int hashCode()
+ {
+ validate();
+ int hash = super.hashCode();
+ hash ^= m_uri.hashCode();
+ return hash;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof IncludeDirective )
+ {
+ validate();
+ IncludeDirective part = (IncludeDirective) other;
+ if( super.equals( part ) )
+ {
+ return getURI().equals( part.getURI() );
+ }
+ }
+ return false;
+ }
+
+ protected void validate() throws IllegalStateException
+ {
+ super.validate();
+ if( null == m_uri )
+ {
+ throw new IllegalStateException( "uri" );
+ }
+ }
+
+}

Added:
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/PartDirective.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/PartDirective.java
Mon Mar 7 15:31:26 2005
@@ -0,0 +1,85 @@
+/*
+ * 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.model;
+
+import net.dpml.composition.part.Part;
+
+/**
+ * The part directive is a directive that can be handled as a part within a
+ * component model.
+ *
+ * @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 PartDirective implements Part, Directive
+{
+ 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 )
+ {
+ if( null == name )
+ {
+ throw new NullPointerException( "name" );
+ }
+ m_name = name;
+ }
+
+ /**
+ * Return the name of the part.
+ * @return the part name
+ */
+ public String getName()
+ {
+ return m_name;
+ }
+
+ public int hashCode()
+ {
+ validate();
+ return getName().hashCode();
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ if( other instanceof PartDirective )
+ {
+ validate();
+ PartDirective part = (PartDirective) other;
+ return getName().equals( part.getName() );
+ }
+ return false;
+ }
+
+ protected void validate() throws IllegalStateException
+ {
+ if( null == m_name )
+ {
+ throw new IllegalStateException( "name" );
+ }
+ }
+}

Added:
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/IncludeDirectiveTestCase.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/IncludeDirectiveTestCase.java
Mon Mar 7 15:31:26 2005
@@ -0,0 +1,91 @@
+/*
+ * 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.model;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+
+/**
+ * The part directive is a directive that can be handled as a part within a
+ * component model.
+ *
+ * @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 IncludeDirectiveTestCase extends TestCase
+{
+ private IncludeDirective m_part;
+
+ public void setUp()
+ {
+ m_part = new IncludeDirective();
+ }
+
+ public void testSetUri() throws Exception
+ {
+ final URI uri = new URI( "abc:def" );
+ m_part.setURI( uri );
+ assertEquals( "uri", uri, m_part.getURI() );
+ }
+
+ public void testNullURI()
+ {
+ final URI uri = null;
+ try
+ {
+ m_part.setURI( uri );
+ fail( "No NPE while setting uri to null." );
+ }
+ catch( NullPointerException npe )
+ {
+ // ok
+ }
+ }
+
+ public void testSerialization() throws Exception
+ {
+ final String name = "name";
+ final URI uri = new URI( "abc:def" );
+ IncludeDirective directive = new IncludeDirective();
+ directive.setName( name );
+ directive.setURI( uri );
+
+ File file = new File( "test.out" );
+ ObjectOutputStream oos = new ObjectOutputStream( new
FileOutputStream( file ) );
+ oos.writeObject( directive );
+ oos.close();
+
+ ObjectInputStream ois = new ObjectInputStream( new FileInputStream(
file ) );
+ IncludeDirective serialized = (IncludeDirective) ois.readObject();
+ ois.close();
+ file.delete();
+
+ assertEquals( "equals", directive, serialized );
+ assertEquals( "hashcode", directive.hashCode(),
serialized.hashCode() );
+
+ }
+}

Added:
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartDirectiveTestCase.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartDirectiveTestCase.java
Mon Mar 7 15:31:26 2005
@@ -0,0 +1,68 @@
+/*
+ * 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.model;
+
+import net.dpml.composition.part.Part;
+
+import junit.framework.TestCase;
+
+
+/**
+ * The part directive is a directive that can be handled as a part within a
+ * component model.
+ *
+ * @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 PartDirectiveTestCase extends TestCase
+{
+ private PartDirective m_part;
+
+ public void setUp()
+ {
+ m_part = new PartDirective();
+ }
+
+ public void testSetName()
+ {
+ final String name = "abc";
+ m_part.setName( name );
+ assertEquals( "name", name, m_part.getName() );
+ }
+
+ public void testNullName()
+ {
+ final String name = null;
+ try
+ {
+ m_part.setName( name );
+ fail( "No NPE while setting name to null." );
+ }
+ catch( NullPointerException npe )
+ {
+ // ok
+ }
+ }
+
+ public void testImplementsPart()
+ {
+ assertTrue( "implements Part interface", ( m_part instanceof Part )
);
+ }
+
+}

Added: development/laboratory/plus/composition/part/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/composition/part/build.xml Mon Mar 7
15:31:26 2005
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-composition-part" 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/composition/part/src/main/net/dpml/composition/part/Part.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/Part.java
Mon Mar 7 15:31:26 2005
@@ -0,0 +1,29 @@
+/*
+ * 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.part;
+
+/**
+ * The common interface implemented by all component 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 interface Part
+{
+}

Added: development/laboratory/plus/composition/test/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/composition/test/build.xml Mon Mar 7
15:31:26 2005
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-composition-test" 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="init" depends="standard.init">
+ <x:property name="builder.uri" feature="plugin"
key="dpml-composition-builder"/>
+ <transit:plugin uri="${builder.uri}"/>
+ </target>
+
+ <target name="test" depends="standard.test">
+ <include xmlns="plugin:dpml/metro/dpml-composition-builder"
+ uri="artifact:whatever:abc/def/ghi" name="fred"/>
+ </target>
+
+</project>
+



  • svn commit: r1968 - in development/laboratory/plus: . acme composition composition/builder composition/builder/src composition/builder/src/main composition/builder/src/main/net composition/builder/src/main/net/dpml composition/builder/src/main/net/dpml/composition composition/builder/src/main/net/dpml/composition/builder composition/model composition/model/src composition/model/src/main composition/model/src/main/net composition/model/src/main/net/dpml composition/model/src/main/net/dpml/composition composition/model/src/main/net/dpml/composition/model composition/model/src/test composition/model/src/test/net composition/model/src/test/net/dpml composition/model/src/test/net/dpml/composition composition/model/src/test/net/dpml/composition/model composition/part composition/part/src composition/part/src/main composition/part/src/main/net composition/part/src/main/net/dpml composition/part/src/main/net/dpml/composition composition/part/src/main/net/dpml/composition/part composition/test test tools, mcconnell, 03/07/2005

Archive powered by MHonArc 2.6.24.

Top of Page