Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1979 - in development/laboratory/plus/composition: builder/src/main/net/dpml/composition/builder model/src/test/net/dpml/composition/model part/src/main/net/dpml/composition/part 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: r1979 - in development/laboratory/plus/composition: builder/src/main/net/dpml/composition/builder model/src/test/net/dpml/composition/model part/src/main/net/dpml/composition/part test/src/test/net/dpml/composition/test
  • Date: Tue, 08 Mar 2005 14:22:50 -0500

Author: mcconnell AT dpml.net
Date: Tue Mar 8 14:22:50 2005
New Revision: 1979

Added:

development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/ComponentModelTestCase.java
- copied, changed from r1968,
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/IncludeDirectiveTestCase.java

development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartModelTestCase.java
- copied, changed from r1968,
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartDirectiveTestCase.java

development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/ControlMonitor.java

development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/Controller.java

development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/PartEnvelope.java

development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/StartableController.java
Removed:

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/model/src/test/net/dpml/composition/model/IncludeDirectiveTestCase.java

development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartDirectiveTestCase.java
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/antlib.xml

development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/Part.java

development/laboratory/plus/composition/test/src/test/net/dpml/composition/test/MarshallObjectTestCase.java
Log:


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
Tue Mar 8 14:22:50 2005
@@ -30,9 +30,11 @@

import net.dpml.composition.model.ComponentModel;
import net.dpml.composition.part.Part;
+import net.dpml.composition.part.PartEnvelope;

import net.dpml.magic.tasks.ProjectTask;

+import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ProjectComponent;

/**
@@ -95,62 +97,49 @@

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 );
+ Part part = build();
+ URI uri = new URI( "acme:gizmo" );
+ PartEnvelope envelope = new PartEnvelope( part, uri );
+ marshall( envelope );
}
- catch( Throwable e )
+ catch( BuildException 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() );
+ throw e;
}
- finally
+ catch( Throwable e )
{
- closeStream( output );
+ final String error =
+ "Internal error while attempting to marchall the envelope.";
+ throw new BuildException( error, e, getLocation() );
}
}

- public void externalize( Part part )
+ public void marshall( PartEnvelope envelope )
{
ObjectOutputStream output = null;
FileOutputStream stream = null;
File file = getOutputFile();
try
{
+ MarshalledObject object = new MarshalledObject( envelope );
stream = new FileOutputStream( file );
output = new ObjectOutputStream( stream );
- output.writeObject( part );
- output.flush();
+ output.writeObject( object );
}
catch( Throwable e )
{
final String error =
- "Unexpected error while attempting to write part to output
stream."
+ "Unexpected error while attempting to marchall an object."
+ "\ndestination: " + file
- + "\nclass: " + part.getClass().getName()
+ + "\nclass: " + envelope.getPart().getClass().getName()
+ "\nreason: " + e.toString();
throw new ConstructionException( error, e, getLocation() );
}
finally
{
closeStream( output );
- closeStream( stream );
}
}


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 14:22:50 2005
@@ -2,5 +2,4 @@

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

Copied:
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/ComponentModelTestCase.java
(from r1968,
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/IncludeDirectiveTestCase.java)
==============================================================================
---
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/IncludeDirectiveTestCase.java
(original)
+++
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/ComponentModelTestCase.java
Tue Mar 8 14:22:50 2005
@@ -36,29 +36,28 @@
* @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
+public class ComponentModelTestCase extends TestCase
{
- private IncludeDirective m_part;
+ private ComponentModel m_part;

public void setUp()
{
- m_part = new IncludeDirective();
+ m_part = new ComponentModel();
}

- public void testSetUri() throws Exception
+ public void testSetClassname() throws Exception
{
- final URI uri = new URI( "abc:def" );
- m_part.setURI( uri );
- assertEquals( "uri", uri, m_part.getURI() );
+ final String classname = "aaa.bbb.Ccc";
+ m_part.setClassname( classname );
+ assertEquals( "classname", classname, m_part.getClassname() );
}

- public void testNullURI()
+ public void testNullClasname()
{
- final URI uri = null;
try
{
- m_part.setURI( uri );
- fail( "No NPE while setting uri to null." );
+ m_part.setClassname( null );
+ fail( "No NPE while setting classname to null." );
}
catch( NullPointerException npe )
{
@@ -69,23 +68,23 @@
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 );
+ final String classname = "aaa.bbb.Ccc";
+ ComponentModel model = new ComponentModel();
+ model.setName( name );
+ model.setClassname( classname );

File file = new File( "test.out" );
ObjectOutputStream oos = new ObjectOutputStream( new
FileOutputStream( file ) );
- oos.writeObject( directive );
+ oos.writeObject( model );
oos.close();

ObjectInputStream ois = new ObjectInputStream( new FileInputStream(
file ) );
- IncludeDirective serialized = (IncludeDirective) ois.readObject();
+ ComponentModel serialized = (ComponentModel) ois.readObject();
ois.close();
file.delete();

- assertEquals( "equals", directive, serialized );
- assertEquals( "hashcode", directive.hashCode(),
serialized.hashCode() );
+ assertEquals( "equals", model, serialized );
+ assertEquals( "hashcode", model.hashCode(), serialized.hashCode() );

}
}

Copied:
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartModelTestCase.java
(from r1968,
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartDirectiveTestCase.java)
==============================================================================
---
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartDirectiveTestCase.java
(original)
+++
development/laboratory/plus/composition/model/src/test/net/dpml/composition/model/PartModelTestCase.java
Tue Mar 8 14:22:50 2005
@@ -30,13 +30,13 @@
* @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
+public class PartModelTestCase extends TestCase
{
- private PartDirective m_part;
+ private PartModel m_part;

public void setUp()
{
- m_part = new PartDirective();
+ m_part = new PartModel();
}

public void testSetName()

Added:
development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/ControlMonitor.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/ControlMonitor.java
Tue Mar 8 14:22:50 2005
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+/**
+ * Common interface implemented by controllers.
+ *
+ * @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 ControlMonitor
+{
+ void info( String message );
+
+ void debug( String message );
+
+ void error( String message, Throwable cause );
+}

Added:
development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/Controller.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/Controller.java
Tue Mar 8 14:22:50 2005
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+/**
+ * Common interface implemented by controllers.
+ *
+ * @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 Controller
+{
+ String getURN();
+
+ String getName();
+
+}

Modified:
development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/Part.java
==============================================================================
---
development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/Part.java
(original)
+++
development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/Part.java
Tue Mar 8 14:22:50 2005
@@ -18,12 +18,14 @@

package net.dpml.composition.part;

+import java.io.Serializable;
+
/**
* 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
+public interface Part extends Serializable
{
}

Added:
development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/PartEnvelope.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/PartEnvelope.java
Tue Mar 8 14:22:50 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.part;
+
+import java.io.Serializable;
+import java.net.URI;
+
+/**
+ * The PartEnvelope associates a part with a controller uri. It is an
immutable
+ * datatype for usage in scenarios involving serialization and subsequent
marchalling
+ * under a part deployment. Deployment of a part assumes a parent manager
that is
+ * resonsible for controller establishment and supply of a part to the
associated
+ * 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 PartEnvelope implements Serializable
+{
+ /**
+ * The part.
+ */
+ private final Serializable m_part;
+
+ /**
+ * The part primary controller.
+ */
+ private final URI m_uri;
+
+ /**
+ * A PartEnvelope associates a part and it's primary controller.
+ * @param part the serializable part
+ * @param controller a urn identifying the primary controller of the part.
+ * The urn shall be resolved to an instance of a StartableController.
+ */
+ public PartEnvelope( Serializable part, URI controller )
+ {
+ if( null == part )
+ {
+ throw new NullPointerException( "part" );
+ }
+ if( null == controller )
+ {
+ throw new NullPointerException( "controller" );
+ }
+ m_uri = controller;
+ m_part = part;
+ }
+
+ /**
+ * Return the urn oof the primary controller of the part.
+ * @return the primary controller urn
+ */
+ public URI getControllerURI()
+ {
+ return m_uri;
+ }
+
+ /**
+ * Return the serializable part.
+ * @return the part
+ */
+ public Serializable getPart()
+ {
+ return m_part;
+ }
+}

Added:
development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/StartableController.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/part/src/main/net/dpml/composition/part/StartableController.java
Tue Mar 8 14:22:50 2005
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+/**
+ * Common interface implemented by controllers.
+ *
+ * @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 StartableController extends Controller
+{
+
+ void start( ControlMonitor monitor ) throws Exception;
+
+ void stop();
+
+}

Modified:
development/laboratory/plus/composition/test/src/test/net/dpml/composition/test/MarshallObjectTestCase.java
==============================================================================
---
development/laboratory/plus/composition/test/src/test/net/dpml/composition/test/MarshallObjectTestCase.java
(original)
+++
development/laboratory/plus/composition/test/src/test/net/dpml/composition/test/MarshallObjectTestCase.java
Tue Mar 8 14:22:50 2005
@@ -24,6 +24,7 @@
import java.net.URL;

import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.part.PartEnvelope;

import net.dpml.transit.artifact.Handler;

@@ -46,7 +47,7 @@

private static final String XPATH = "@XPATH@";

- private ComponentModel m_model;
+ private PartEnvelope m_envelope;

public void setUp() throws Exception
{
@@ -55,13 +56,15 @@
InputStream input = new FileInputStream( file.getCanonicalFile() );
ObjectInputStream stream = new ObjectInputStream( input );
MarshalledObject marshalled = (MarshalledObject) stream.readObject();
- m_model = (ComponentModel) marshalled.get();
+ m_envelope = (PartEnvelope) marshalled.get();
}

public void testLoading() throws Exception
{
- System.out.println( "NAME: " + m_model.getName() );
- System.out.println( "CLASS: " + m_model.getClassname() );
+ ComponentModel model = (ComponentModel) m_envelope.getPart();
+ System.out.println( "URI: " + m_envelope.getControllerURI() );
+ System.out.println( "NAME: " + model.getName() );
+ System.out.println( "CLASS: " + model.getClassname() );
}

}



  • svn commit: r1979 - in development/laboratory/plus/composition: builder/src/main/net/dpml/composition/builder model/src/test/net/dpml/composition/model part/src/main/net/dpml/composition/part test/src/test/net/dpml/composition/test, mcconnell, 03/08/2005

Archive powered by MHonArc 2.6.24.

Top of Page