Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2004 - in development/laboratory/plus: . common common/control/src/main/net/dpml/metro/control common/kernel common/kernel/api common/kernel/api/src/main/net/dpml/metro/kernel common/kernel/impl common/kernel/impl/src common/kernel/impl/src/main common/kernel/impl/src/main/net/dpml/metro/kernel common/kernel/impl/src/main/net/dpml/metro/kernel/impl common/kernel/src common/part/src/main/net/dpml/metro/part composition/builder/src/main/net/dpml/composition/builder composition/control/src/main/net/dpml/composition/control composition/model composition/model/src/main/net/dpml/composition/model composition/model/src/test/net/dpml/composition/model 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: r2004 - in development/laboratory/plus: . common common/control/src/main/net/dpml/metro/control common/kernel common/kernel/api common/kernel/api/src/main/net/dpml/metro/kernel common/kernel/impl common/kernel/impl/src common/kernel/impl/src/main common/kernel/impl/src/main/net/dpml/metro/kernel common/kernel/impl/src/main/net/dpml/metro/kernel/impl common/kernel/src common/part/src/main/net/dpml/metro/part composition/builder/src/main/net/dpml/composition/builder composition/control/src/main/net/dpml/composition/control composition/model composition/model/src/main/net/dpml/composition/model composition/model/src/test/net/dpml/composition/model test/execution/src/test/net/dpml/test/execution
  • Date: Thu, 10 Mar 2005 10:21:02 -0500

Author: mcconnell AT dpml.net
Date: Thu Mar 10 10:21:02 2005
New Revision: 2004

Added:
development/laboratory/plus/common/build.xml
development/laboratory/plus/common/kernel/impl/build.xml
development/laboratory/plus/common/kernel/impl/src/
- copied from r1998, development/laboratory/plus/common/kernel/src/
development/laboratory/plus/common/kernel/impl/src/main/
- copied from r2003, development/laboratory/plus/common/kernel/src/main/

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

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

development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/ClassLoaderModel.java
Removed:

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

development/laboratory/plus/common/control/src/main/net/dpml/metro/control/Controller.java
development/laboratory/plus/common/kernel/api/ (props changed)
development/laboratory/plus/common/kernel/api/build.xml

development/laboratory/plus/common/kernel/api/src/main/net/dpml/metro/kernel/Kernel.java
development/laboratory/plus/common/kernel/build.xml
development/laboratory/plus/common/kernel/impl/ (props changed)

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

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

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

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/index.xml

development/laboratory/plus/test/execution/src/test/net/dpml/test/execution/KernelTestCase.java
Log:
Getting in place some working controllers and model listing.

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

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
Thu Mar 10 10:21:02 2005
@@ -18,6 +18,8 @@

package net.dpml.metro.control;

+import net.dpml.metro.part.Part;
+
/**
* Common interface implemented by controllers.
*
@@ -32,4 +34,7 @@
*/
String getName();

+ void load( Part part ) throws Exception;
+
+ void list( Part part );
}

Modified: development/laboratory/plus/common/kernel/api/build.xml
==============================================================================
--- development/laboratory/plus/common/kernel/api/build.xml (original)
+++ development/laboratory/plus/common/kernel/api/build.xml Thu Mar 10
10:21:02 2005
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>

-<project name="dpml-metro-kernel" default="install" basedir="."
+<project name="dpml-metro-kernel-api" default="install" basedir="."
xmlns:transit="antlib:net.dpml.transit"
xmlns:x="plugin:dpml/magic/dpml-magic-core">


Modified:
development/laboratory/plus/common/kernel/api/src/main/net/dpml/metro/kernel/Kernel.java
==============================================================================
---
development/laboratory/plus/common/kernel/api/src/main/net/dpml/metro/kernel/Kernel.java
(original)
+++
development/laboratory/plus/common/kernel/api/src/main/net/dpml/metro/kernel/Kernel.java
Thu Mar 10 10:21:02 2005
@@ -21,6 +21,7 @@
import java.io.InputStream;
import java.io.IOException;

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

/**
@@ -31,8 +32,8 @@
*/
public interface Kernel
{
- void loadPart( InputStream input ) throws IOException,
ClassNotFoundException;
+ void load( InputStream input ) throws Exception;

- Controller getPartController( Class partClass );
+ Controller getController( Part part ) throws Exception;

}

Modified: development/laboratory/plus/common/kernel/build.xml
==============================================================================
--- development/laboratory/plus/common/kernel/build.xml (original)
+++ development/laboratory/plus/common/kernel/build.xml Thu Mar 10 10:21:02
2005
@@ -4,7 +4,7 @@
xmlns:transit="antlib:net.dpml.transit"
xmlns:x="plugin:dpml/magic/dpml-magic-core">

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

</project>


Added: development/laboratory/plus/common/kernel/impl/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/common/kernel/impl/build.xml Thu Mar 10
10:21:02 2005
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-metro-kernel-impl" 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/impl/src/main/net/dpml/metro/kernel/impl/DefaultKernel.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/common/kernel/impl/src/main/net/dpml/metro/kernel/impl/DefaultKernel.java
Thu Mar 10 10:21:02 2005
@@ -0,0 +1,110 @@
+/*
+ * 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.impl;
+
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.IOException;
+import java.io.Serializable;
+import java.rmi.MarshalledObject;
+import java.net.URI;
+import java.util.Map;
+import java.util.Hashtable;
+
+import net.dpml.metro.part.Part;
+import net.dpml.metro.kernel.Kernel;
+import net.dpml.metro.control.Controller;
+import net.dpml.metro.control.ControlMonitor;
+import net.dpml.transit.repository.StandardLoader;
+
+/**
+ * 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 implements Kernel
+{
+ private Map m_controllers = new Hashtable();
+ private ControlMonitor m_monitor = new DefaultControlMonitor();
+
+ public void load( InputStream input ) throws Exception
+ {
+ ObjectInputStream stream = new ObjectInputStream( input );
+ MarshalledObject marshalled = (MarshalledObject) stream.readObject();
+ Part part = (Part) marshalled.get();
+ Controller controller = getController( part );
+ controller.load( part );
+ getControlMonitor().info( "done" );
+ }
+
+ public Controller getController( Part part ) throws Exception
+ {
+ URI uri = part.getStrategyURN();
+ Controller controller = (Controller) m_controllers.get( uri );
+ ControlMonitor monitor = getControlMonitor();
+ if( null == controller )
+ {
+ ClassLoader classloader = part.getClass().getClassLoader();
+ StandardLoader loader = new StandardLoader();
+ monitor.info( "loading controller uri: " + uri );
+ controller =
+ (Controller) loader.getPlugin( classloader, uri, new Object[]{
this, monitor } );
+ m_controllers.put( uri, controller );
+ }
+ return controller;
+ }
+
+ private ControlMonitor getControlMonitor()
+ {
+ return m_monitor;
+ }
+
+ 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();
+ }
+ }
+}

Added:
development/laboratory/plus/common/part/src/main/net/dpml/metro/part/Part.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/common/part/src/main/net/dpml/metro/part/Part.java
Thu Mar 10 10:21:02 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.part;
+
+import java.io.Serializable;
+import java.net.URI;
+
+/**
+ * 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 extends Serializable
+{
+ /**
+ * Return a urn identifying the part strategy.
+ * @return the strategy urn
+ */
+ public URI getStrategyURN();
+}

Modified:
development/laboratory/plus/common/part/src/main/net/dpml/metro/part/PartEnvelope.java
==============================================================================
---
development/laboratory/plus/common/part/src/main/net/dpml/metro/part/PartEnvelope.java
(original)
+++
development/laboratory/plus/common/part/src/main/net/dpml/metro/part/PartEnvelope.java
Thu Mar 10 10:21:02 2005
@@ -36,7 +36,7 @@
/**
* The part.
*/
- private final Serializable m_part;
+ private final Part m_part;

/**
* The part primary controller.
@@ -49,7 +49,7 @@
* @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 )
+ public PartEnvelope( Part part, URI controller )
{
if( null == part )
{
@@ -64,7 +64,7 @@
}

/**
- * Return the urn oof the primary controller of the part.
+ * Return the urn of the primary controller of the part.
* @return the primary controller urn
*/
public URI getControllerURI()
@@ -76,7 +76,7 @@
* Return the serializable part.
* @return the part
*/
- public Object getPart()
+ public Part getPart()
{
return m_part;
}

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
Thu Mar 10 10:21:02 2005
@@ -29,14 +29,20 @@
import java.rmi.MarshalledObject;
import java.util.List;
import java.util.LinkedList;
+import java.util.ArrayList;

import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.ClassLoaderModel;

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

import net.dpml.magic.tasks.ProjectTask;
+import net.dpml.magic.model.Resource;
+import net.dpml.magic.model.ResourceRef;
+import net.dpml.magic.model.Definition;
+import net.dpml.magic.model.Policy;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ProjectComponent;
@@ -115,7 +121,32 @@
{
System.out.println( "building component model" );
Part[] parts = createParts().getParts();
- return new ComponentModel( m_classname, m_name, parts );
+ ClassLoaderModel classloader = createClassLoaderModel();
+ return new ComponentModel( m_classname, m_name, classloader, parts );
+ }
+
+ private ClassLoaderModel createClassLoaderModel()
+ {
+ ArrayList list = new ArrayList();
+ Definition def = getDefinition();
+ final ResourceRef[] resources =
+ def.getResourceRefs( getProject(), Policy.RUNTIME,
ResourceRef.ANY, true );
+ for( int i=0; i<resources.length; i++ )
+ {
+ final ResourceRef ref = resources[i];
+ final Policy policy = ref.getPolicy();
+ if( policy.isRuntimeEnabled() )
+ {
+ final Resource resource = getIndex().getResource( ref );
+ if( "jar".equals( resource.getInfo().getType() ) )
+ {
+ URI uri = resource.getArtifactURI( "jar" );
+ list.add( uri );
+ }
+ }
+ }
+ URI[] uris = (URI[]) list.toArray( new URI[0] );
+ return new ClassLoaderModel( uris );
}

//--------------------------------------------------------------------
@@ -128,9 +159,7 @@
try
{
Part part = build();
- URI uri = new URI( DEFAULT_CONTROLLER_URI );
- PartEnvelope envelope = new PartEnvelope( part, uri );
- marshall( envelope );
+ marshall( part );
}
catch( BuildException e )
{
@@ -139,29 +168,29 @@
catch( Throwable e )
{
final String error =
- "Internal error while attempting to marchall the envelope.";
+ "Internal error while attempting to marshall the part.";
throw new BuildException( error, e, getLocation() );
}
}

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

Modified:
development/laboratory/plus/composition/control/src/main/net/dpml/composition/control/DefaultController.java
==============================================================================
---
development/laboratory/plus/composition/control/src/main/net/dpml/composition/control/DefaultController.java
(original)
+++
development/laboratory/plus/composition/control/src/main/net/dpml/composition/control/DefaultController.java
Thu Mar 10 10:21:02 2005
@@ -20,7 +20,11 @@

import java.net.URI;

+import net.dpml.metro.part.Part;
+import net.dpml.metro.kernel.Kernel;
+
import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.ClassLoaderModel;

import net.dpml.metro.control.Controller;
import net.dpml.metro.control.ControlMonitor;
@@ -43,18 +47,16 @@
//--------------------------------------------------------------------

private final ControlMonitor m_monitor;
- private final ComponentModel m_model;
+ private final Kernel m_kernel;

//--------------------------------------------------------------------
// constructor
//--------------------------------------------------------------------

- public DefaultController( ControlMonitor monitor, ComponentModel model )
+ public DefaultController( Kernel kernel, ControlMonitor monitor )
{
- m_model = model;
m_monitor = monitor;
-
- listModel();
+ m_kernel = kernel;
}

//--------------------------------------------------------------------
@@ -66,46 +68,37 @@
return CONTROLLER_NAME;
}

- //--------------------------------------------------------------------
- // imlementation
- //--------------------------------------------------------------------
-
- private ComponentModel getModel()
- {
- return m_model;
- }
-
- private ControlMonitor getMonitor()
- {
- return m_monitor;
- }
-
- private void listModel()
+ public void load( Part part ) throws Exception
{
- StringBuffer buffer = new StringBuffer();
- buffer.append( LINE );
- buffer.append( "\nModel Listing" );
- buffer.append( "\nname:" + getModel().getName() );
- buffer.append( "\nclassname:" + getModel().getClassname() );
- Object[] parts = getModel().getParts();
- buffer.append( "\nparts:" + parts.length );
- getMonitor().info( buffer.toString() );
+ if( part instanceof ComponentModel )
+ {
+ ComponentModel model = (ComponentModel) part;
+ list( model );
+ }
+ else
+ {
+ final String error =
+ "Part type not recognized.";
+ throw new IllegalArgumentException( error );
+ }
}

- private void listModel( Object part )
+ public void list( Part part )
{
StringBuffer buffer = new StringBuffer();
buffer.append( LINE );
buffer.append( "\nModel Listing" );
buffer.append( "\nmodel class:" + part.getClass().getName() );
+ buffer.append( "\nstrategy urn:" + part.getStrategyURN() );
if( part instanceof ComponentModel )
{
ComponentModel model = (ComponentModel) part;
buffer.append( "\nname:" + model.getName() );
buffer.append( "\nclassname:" + model.getClassname() );
- Object[] parts = model.getParts();
- buffer.append( "\nparts:" + parts.length );
- getMonitor().info( buffer.toString() );
+ listServices( model, buffer );
+ listDependencies( model, buffer );
+ listClassLoader( model, buffer );
+ listParts( model, buffer );
}
else
{
@@ -114,10 +107,68 @@
// controller for the type of part we have just encountered
//

- getMonitor().info( "unknown part" );
+ try
+ {
+ Controller controller = getKernel().getController( part );
+ controller.list( part );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to resolve a controller
for the part ["
+ + part.getStrategyURN()
+ + "]";
+ getMonitor().error( error, e );
+ }
+ }
+ }
+
+ private void listServices( ComponentModel part, StringBuffer buffer )
+ {
+ buffer.append( "\nservices: NOT IMPLEMENTED " );
+ }
+
+ private void listDependencies( ComponentModel part, StringBuffer buffer )
+ {
+ buffer.append( "\ndependencies: NOT IMPLEMENTED " );
+ }
+
+ private void listParts( ComponentModel part, StringBuffer buffer )
+ {
+ Part[] parts = part.getParts();
+ buffer.append( "\nparts:" + parts.length );
+ getMonitor().info( buffer.toString() );
+ for( int i=0; i<parts.length; i++ )
+ {
+ Part p = parts[i];
+ list( p );
+ }
+ }

+ private void listClassLoader( ComponentModel part, StringBuffer buffer )
+ {
+ ClassLoaderModel model = part.getClassLoaderModel();
+ URI[] uris = model.getURIs();
+ buffer.append( "\nclass loader model entries: " + uris.length );
+ for( int i=0; i<uris.length; i++ )
+ {
+ URI uri = uris[i];
+ buffer.append( "\n" + i + " " + uri );
}
}

+ //--------------------------------------------------------------------
+ // imlementation
+ //--------------------------------------------------------------------
+
+ private ControlMonitor getMonitor()
+ {
+ return m_monitor;
+ }
+
+ private Kernel getKernel()
+ {
+ return m_kernel;
+ }

}

Modified: development/laboratory/plus/composition/model/build.xml
==============================================================================
--- development/laboratory/plus/composition/model/build.xml (original)
+++ development/laboratory/plus/composition/model/build.xml Thu Mar 10
10:21:02 2005
@@ -6,6 +6,10 @@

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

+ <target name="init" depends="standard.init">
+ <x:filter key="dpml-composition-control" feature="plugin"
token="STRATEGY-URI"/>
+ </target>
+
<target name="package" depends="standard.package">
<x:export>
<antlib resource="net/dpml/composition/model/antlib.xml"

Added:
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/ClassLoaderModel.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/composition/model/src/main/net/dpml/composition/model/ClassLoaderModel.java
Thu Mar 10 10:21:02 2005
@@ -0,0 +1,100 @@
+/*
+ * 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;
+import java.net.URI;
+
+import net.dpml.metro.part.Part;
+
+/**
+ * Immutable description of a set of classloader uris.
+ *
+ * @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 ClassLoaderModel implements Model
+{
+ private final URI[] m_uris;
+
+ public ClassLoaderModel( URI[] uris )
+ {
+ if( null == uris )
+ {
+ throw new NullPointerException( "uris" );
+ }
+ m_uris = uris;
+ }
+
+ /**
+ * Return the set of uris declared within the classloader model.
+ * @return the uris
+ */
+ public URI[] getURIs()
+ {
+ return m_uris;
+ }
+
+ public int hashCode()
+ {
+ int hash = 0;
+ URI[] uris = getURIs();
+ for( int i=0; i<uris.length; i++ )
+ {
+ URI uri = uris[i];
+ hash ^= uri.hashCode();
+ }
+ return hash;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof ClassLoaderModel )
+ {
+ ClassLoaderModel model = (ClassLoaderModel) other;
+ if( getURIs().length != model.getURIs().length )
+ {
+ return false;
+ }
+ else
+ {
+ URI[] myURIs = getURIs();
+ URI[] yourURIs = model.getURIs();
+ for( int i=0; i<myURIs.length; i++ )
+ {
+ URI a = myURIs[i];
+ URI b = yourURIs[i];
+ if( !a.equals( b ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+}

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
Thu Mar 10 10:21:02 2005
@@ -20,6 +20,7 @@

import java.io.Serializable;

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

/**
* The part directive is a directive that can be handled as a part within a
@@ -31,9 +32,10 @@
public class ComponentModel extends PartModel
{
private String m_classname;
- private Serializable[] m_parts;
+ private Part[] m_parts;
+ private ClassLoaderModel m_classloader;

- public ComponentModel( String classname, String name, Serializable[]
parts )
+ public ComponentModel( String classname, String name, ClassLoaderModel
classloader, Part[] parts )
{
super( name );
if( null == classname )
@@ -44,6 +46,11 @@
{
throw new NullPointerException( "parts" );
}
+ if( null == classloader )
+ {
+ throw new NullPointerException( "classloader" );
+ }
+ m_classloader = classloader;
m_classname = classname;
m_parts = parts;
}
@@ -61,11 +68,20 @@
* Return the set of parts within this component.
* @return the parts
*/
- public Object[] getParts()
+ public Part[] getParts()
{
return m_parts;
}

+ /**
+ * Return the the clasloader model for the part.
+ * @return the classloader model
+ */
+ public ClassLoaderModel getClassLoaderModel()
+ {
+ return m_classloader;
+ }
+
public int hashCode()
{
int hash = super.hashCode();
@@ -96,12 +112,12 @@
}
else
{
- Object[] myParts = getParts();
- Object[] yourParts = part.getParts();
+ Part[] myParts = getParts();
+ Part[] yourParts = part.getParts();
for( int i=0; i<myParts.length; i++ )
{
- Object p = myParts[i];
- Object q = yourParts[i];
+ Part p = myParts[i];
+ Part q = yourParts[i];
if( !p.equals( q ) )
{
return false;

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
Thu Mar 10 10:21:02 2005
@@ -18,6 +18,10 @@

package net.dpml.composition.model;

+import java.net.URI;
+
+import net.dpml.metro.part.Part;
+
/**
* The part directive is a directive that can be handled as a part within a
* component model.
@@ -25,8 +29,24 @@
* @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 Model
+public class PartModel implements Model, Part
{
+ private static final String STRATEGY = "@STRATEGY-URI@";
+
+ private static final URI STRATEGY_URI = createStrategyURI();
+
+ private static URI createStrategyURI()
+ {
+ try
+ {
+ return new URI( STRATEGY );
+ }
+ catch( Throwable e )
+ {
+ return null;
+ }
+ }
+
private String m_name;

public PartModel( String name )
@@ -42,6 +62,15 @@
* Return the name of the part.
* @return the part name
*/
+ public URI getStrategyURN()
+ {
+ return STRATEGY_URI;
+ }
+
+ /**
+ * Return the name of the part.
+ * @return the part name
+ */
public String getName()
{
return m_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
Thu Mar 10 10:21:02 2005
@@ -27,6 +27,8 @@
import java.io.Serializable;
import java.net.URI;

+import net.dpml.metro.part.Part;
+
import junit.framework.TestCase;


@@ -44,15 +46,39 @@
{
final String name = "name";
final String classname = "aaa.bbb.Ccc";
- ComponentModel part = new ComponentModel( classname, name, new
Serializable[0] );
+ final ClassLoaderModel classloader = new ClassLoaderModel( new
URI[0] );
+ ComponentModel part = new ComponentModel( classname, name,
classloader, new Part[0] );
assertEquals( "classname", classname, part.getClassname() );
}

+ public void testSetClassLoaderModel() throws Exception
+ {
+ final String name = "name";
+ final String classname = "aaa.bbb.Ccc";
+ final ClassLoaderModel classloader = new ClassLoaderModel( new
URI[0] );
+ ComponentModel part = new ComponentModel( classname, name,
classloader, new Part[0] );
+ assertEquals( "classloader", classloader, part.getClassLoaderModel()
);
+ }
+
public void testNullClassname()
{
try
{
- ComponentModel part = new ComponentModel( null, "abc", new
Serializable[0] );
+ final ClassLoaderModel classloader = new ClassLoaderModel( new
URI[0] );
+ ComponentModel part = new ComponentModel( null, "abc",
classloader, new Part[0] );
+ fail( "No NPE while setting classname to null." );
+ }
+ catch( NullPointerException npe )
+ {
+ // ok
+ }
+ }
+
+ public void testNullClassLoaderModel()
+ {
+ try
+ {
+ ComponentModel part = new ComponentModel( "name", "abc", null,
new Part[0] );
fail( "No NPE while setting classname to null." );
}
catch( NullPointerException npe )
@@ -65,7 +91,8 @@
{
try
{
- ComponentModel part = new ComponentModel( "abc", "abc", null );
+ final ClassLoaderModel classloader = new ClassLoaderModel( new
URI[0] );
+ ComponentModel part = new ComponentModel( "abc", "abc",
classloader, null );
fail( "No NPE while setting parts to null." );
}
catch( NullPointerException npe )
@@ -78,7 +105,8 @@
{
final String name = "name";
final String classname = "aaa.bbb.Ccc";
- ComponentModel model = new ComponentModel( classname, name, new
Serializable[0] );
+ final ClassLoaderModel classloader = new ClassLoaderModel( new
URI[0] );
+ ComponentModel model = new ComponentModel( classname, name,
classloader, new Part[0] );

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

Modified: development/laboratory/plus/index.xml
==============================================================================
--- development/laboratory/plus/index.xml (original)
+++ development/laboratory/plus/index.xml Thu Mar 10 10:21:02 2005
@@ -59,12 +59,15 @@
<type>jar</type>
</types>
</info>
+ <dependencies>
+ <include key="dpml-metro-part-api" tag="api"/>
+ </dependencies>
</project>

- <project basedir="common/kernel">
+ <project basedir="common/kernel/api">
<info>
<group>dpml/metro</group>
- <name>dpml-metro-kernel</name>
+ <name>dpml-metro-kernel-api</name>
<version>1.0.0</version>
<status>SNAPSHOT</status>
<types>
@@ -74,6 +77,21 @@
<dependencies>
<include key="dpml-metro-part-api"/>
<include key="dpml-metro-control-api"/>
+ </dependencies>
+ </project>
+
+ <project basedir="common/kernel/impl">
+ <info>
+ <group>dpml/metro</group>
+ <name>dpml-metro-kernel-impl</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <types>
+ <type>jar</type>
+ </types>
+ </info>
+ <dependencies>
+ <include key="dpml-metro-kernel-api"/>
<include key="dpml-transit-main"/>
</dependencies>
</project>
@@ -124,6 +142,7 @@
</types>
</info>
<dependencies>
+ <include key="dpml-metro-kernel-api"/>
<include key="dpml-metro-control-api"/>
<include key="dpml-composition-model"/>
</dependencies>
@@ -168,7 +187,7 @@
</info>
<dependencies>
<include key="dpml-transit-main"/>
- <include key="dpml-metro-kernel" test="true" runtime="false"/>
+ <include key="dpml-metro-kernel-impl" 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"/>

Modified:
development/laboratory/plus/test/execution/src/test/net/dpml/test/execution/KernelTestCase.java
==============================================================================
---
development/laboratory/plus/test/execution/src/test/net/dpml/test/execution/KernelTestCase.java
(original)
+++
development/laboratory/plus/test/execution/src/test/net/dpml/test/execution/KernelTestCase.java
Thu Mar 10 10:21:02 2005
@@ -22,7 +22,7 @@
import java.io.FileInputStream;
import java.io.InputStream;

-import net.dpml.metro.kernel.DefaultKernel;
+import net.dpml.metro.kernel.impl.DefaultKernel;

import junit.framework.TestCase;

@@ -54,7 +54,7 @@
File basedir = new File( System.getProperty( "project.basedir" ) );
File file = new File( basedir, XPATH );
InputStream input = new FileInputStream( file.getCanonicalFile() );
- m_kernel.loadPart( input );
+ m_kernel.load( input );
}

}



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

Archive powered by MHonArc 2.6.24.

Top of Page