Skip to Content.
Sympa Menu

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

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: r1976 - in development/laboratory/plus/composition: . builder builder/src/main/net/dpml/composition/builder manager manager/src manager/src/main manager/src/main/net manager/src/main/net/dpml manager/src/main/net/dpml/composition manager/src/main/net/dpml/composition/manager model model/src/main/net/dpml/composition/model part test test/src test/src/test test/src/test/net test/src/test/net/dpml test/src/test/net/dpml/composition test/src/test/net/dpml/composition/test
  • Date: Tue, 08 Mar 2005 10:47:56 -0500

Author: mcconnell AT dpml.net
Date: Tue Mar 8 10:47:56 2005
New Revision: 1976

Added:

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

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

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

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

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

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

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

development/laboratory/plus/composition/test/src/test/net/dpml/composition/test/MarshallObjectTestCase.java
Modified:
development/laboratory/plus/composition/builder/ (props changed)

development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/antlib.xml
development/laboratory/plus/composition/index.xml
development/laboratory/plus/composition/model/ (props changed)
development/laboratory/plus/composition/part/ (props changed)
development/laboratory/plus/composition/test/ (props changed)
development/laboratory/plus/composition/test/build.xml
Log:
model serialization test

Added:
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/ComponentModelBuilder.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/ComponentModelBuilder.java
Tue Mar 8 10:47:56 2005
@@ -0,0 +1,185 @@
+/*
+ * 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 java.rmi.MarshalledObject;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.part.Part;
+
+import net.dpml.magic.tasks.ProjectTask;
+
+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 ComponentModelBuilder extends ProjectTask implements PartBuilder
+{
+ //--------------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------------
+
+ private ComponentModel m_delegate = new ComponentModel();
+
+ //--------------------------------------------------------------------
+ // setters
+ //--------------------------------------------------------------------
+
+ /**
+ * 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 );
+ }
+
+ /**
+ * Set the name of the identifiable to the supplied value.
+ * @param name the identifying name
+ */
+ public void setClass( final String name )
+ {
+ m_delegate.setClassname( name );
+ }
+
+ /**
+ * Return the include directive delegate.
+ * @return the include delegate
+ */
+ public ComponentModel getComponentModel()
+ {
+ return m_delegate;
+ }
+
+ //--------------------------------------------------------------------
+ // PartBuilder
+ //--------------------------------------------------------------------
+
+ public Part build() throws ConstructionException
+ {
+ return getComponentModel();
+ }
+
+ //--------------------------------------------------------------------
+ // Task
+ //--------------------------------------------------------------------
+
+ public void execute()
+ {
+ Part part = build();
+ marshall( part );
+ }
+
+ public void marshall( Part part )
+ {
+ ObjectOutputStream output = null;
+ FileOutputStream stream = null;
+ File file = getOutputFile();
+ try
+ {
+ MarshalledObject object = new MarshalledObject( part );
+ stream = new FileOutputStream( file );
+ output = new ObjectOutputStream( stream );
+ output.writeObject( object );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to marchall an object."
+ + "\ndestination: " + file
+ + "\nclass: " + part.getClass().getName()
+ + "\nreason: " + e.toString();
+ throw new ConstructionException( error, e, getLocation() );
+ }
+ finally
+ {
+ closeStream( output );
+ }
+ }
+
+ 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 );
+ output.flush();
+ }
+ 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;
+ }
+ }
+ }
+
+}

Modified:
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/antlib.xml
==============================================================================
---
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/antlib.xml
(original)
+++
development/laboratory/plus/composition/builder/src/main/net/dpml/composition/builder/antlib.xml
Tue Mar 8 10:47:56 2005
@@ -1,5 +1,6 @@
<?xml version="1.0"?>

<antlib>
+ <taskdef name="component"
classname="net.dpml.composition.builder.ComponentModelBuilder"/>
<taskdef name="include"
classname="net.dpml.composition.builder.IncludeDirectiveBuilderTask"/>
</antlib>

Modified: development/laboratory/plus/composition/index.xml
==============================================================================
--- development/laboratory/plus/composition/index.xml (original)
+++ development/laboratory/plus/composition/index.xml Tue Mar 8 10:47:56
2005
@@ -29,10 +29,11 @@
<version>1.0.0</version>
<status>SNAPSHOT</status>
<types>
- <type>jar</type>
+ <type>xpart</type>
</types>
</info>
<dependencies>
+ <include key="dpml-transit-main"/>
<include key="dpml-composition-builder"/>
</dependencies>
</project>
@@ -50,8 +51,8 @@
</info>
<dependencies>
<include key="dpml-magic-core"/>
- <include key="dpml-composition-model"/>
- <include key="dpml-composition-part"/>
+ <include key="dpml-composition-model" tag="api"/>
+ <include key="dpml-composition-part" tag="api"/>
<include key="ant"/>
</dependencies>
</project>

Added:
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/ComponentModel.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/ComponentModel.java
Tue Mar 8 10:47:56 2005
@@ -0,0 +1,90 @@
+/*
+ * 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 ComponentModel extends PartModel
+{
+ private String m_classname;
+
+ /**
+ * 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
+ */
+ public String getClassname()
+ {
+ return m_classname;
+ }
+
+ public int hashCode()
+ {
+ validate();
+ int hash = super.hashCode();
+ hash ^= m_classname.hashCode();
+ return hash;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof ComponentModel )
+ {
+ validate();
+ ComponentModel part = (ComponentModel) other;
+ if( super.equals( part ) )
+ {
+ return getClassname().equals( part.getClassname() );
+ }
+ }
+ return false;
+ }
+
+ protected void validate() throws IllegalStateException
+ {
+ if( null == m_classname )
+ {
+ throw new IllegalStateException( "classname" );
+ }
+ }
+}

Added:
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/Model.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/Model.java
Tue Mar 8 10:47:56 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 model 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 Model extends Serializable
+{
+}

Added:
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/PartModel.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/PartModel.java
Tue Mar 8 10:47:56 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 PartModel implements Part, Model
+{
+ 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 PartModel )
+ {
+ 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" );
+ }
+ }
+}

Added: development/laboratory/plus/composition/test/build.properties
==============================================================================
--- (empty file)
+++ development/laboratory/plus/composition/test/build.properties Tue
Mar 8 10:47:56 2005
@@ -0,0 +1,2 @@
+
+project.test.fork = true

Modified: development/laboratory/plus/composition/test/build.xml
==============================================================================
--- development/laboratory/plus/composition/test/build.xml (original)
+++ development/laboratory/plus/composition/test/build.xml Tue Mar 8
10:47:56 2005
@@ -7,13 +7,15 @@
<transit:import uri="artifact:template:dpml/magic/standard"/>

<target name="init" depends="standard.init">
+ <filter token="XPATH"
value="target/deliverables/xparts/${project.filename}"/>
+ <x:filter feature="plugin" key="dpml-composition-test"
token="XPATH_URI"/>
<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 name="package" depends="standard.package">
+ <component xmlns="plugin:dpml/metro/dpml-composition-builder"
+ class="net.dpml.demo.HelloComponent" name="hello"/>
</target>

</project>

Added:
development/laboratory/plus/composition/test/src/test/net/dpml/composition/test/MarshallObjectTestCase.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/test/src/test/net/dpml/composition/test/MarshallObjectTestCase.java
Tue Mar 8 10:47:56 2005
@@ -0,0 +1,66 @@
+/*
+ * 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.test;
+
+import java.io.*;
+import java.rmi.*;
+import java.net.URI;
+import java.net.URL;
+
+import net.dpml.transit.artifact.Handler;
+
+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 MarshallObjectTestCase extends TestCase
+{
+ static
+ {
+ System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
+ }
+
+ private static final String XPATH = "@XPATH@";
+
+ private File m_file;
+
+ public void setUp() throws Exception
+ {
+ File basedir = new File( System.getProperty( "project.basedir" ) );
+ m_file = new File( basedir, XPATH );
+ System.out.println( m_file.getAbsolutePath() );
+ System.out.println( System.getProperty( "basedir" ) );
+
+ }
+
+ public void testLoading() throws Exception
+ {
+ InputStream input = new FileInputStream(
m_file.getCanonicalFile() );
+ ObjectInputStream stream = new ObjectInputStream( input );
+ MarshalledObject object = (MarshalledObject) stream.readObject();
+ Object result = object.get();
+ }
+
+}



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

Archive powered by MHonArc 2.6.24.

Top of Page