Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2076 - in development/laboratory/plus: . api/control/src/main/net/dpml/metro/control api/part/src/main/net/dpml/metro/part standard/builder/src/main/net/dpml/metro/builder/impl standard/control/src/main/net/dpml/metro/control/impl standard/part/src/main/net/dpml/metro/meta standard/part/src/main/net/dpml/metro/model standard/part/src/main/net/dpml/metro/type test/example/impl test/example/part test/execution test/execution/src/test/net/dpml/test/execution

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2076 - in development/laboratory/plus: . api/control/src/main/net/dpml/metro/control api/part/src/main/net/dpml/metro/part standard/builder/src/main/net/dpml/metro/builder/impl standard/control/src/main/net/dpml/metro/control/impl standard/part/src/main/net/dpml/metro/meta standard/part/src/main/net/dpml/metro/model standard/part/src/main/net/dpml/metro/type test/example/impl test/example/part test/execution test/execution/src/test/net/dpml/test/execution
  • Date: Tue, 15 Mar 2005 02:50:11 -0500

Author: mcconnell AT dpml.net
Date: Tue Mar 15 02:50:10 2005
New Revision: 2076

Added:

development/laboratory/plus/api/control/src/main/net/dpml/metro/control/Controller.java
- copied, changed from r2075,
development/laboratory/plus/api/control/src/main/net/dpml/metro/control/Manager.java

development/laboratory/plus/api/control/src/main/net/dpml/metro/control/DelegationException.java

development/laboratory/plus/api/control/src/main/net/dpml/metro/control/Model.java

development/laboratory/plus/api/part/src/main/net/dpml/metro/part/ServiceDescriptor.java

development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/DemoControl.java
- copied, changed from r2073,
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/ComponentPartListingControl.java

development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/MetroComponentModel.java
development/laboratory/plus/test/example/part/
development/laboratory/plus/test/example/part/build.xml
Removed:

development/laboratory/plus/api/control/src/main/net/dpml/metro/control/Handler.java

development/laboratory/plus/api/control/src/main/net/dpml/metro/control/Home.java

development/laboratory/plus/api/control/src/main/net/dpml/metro/control/Manager.java

development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/ComponentPartListingControl.java

development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/TransitHome.java

development/laboratory/plus/standard/part/src/main/net/dpml/metro/meta/ServiceDescriptor.java
Modified:

development/laboratory/plus/api/control/src/main/net/dpml/metro/control/PartHandler.java

development/laboratory/plus/api/part/src/main/net/dpml/metro/part/Descriptor.java

development/laboratory/plus/api/part/src/main/net/dpml/metro/part/Holder.java
development/laboratory/plus/api/part/src/main/net/dpml/metro/part/Part.java
development/laboratory/plus/index.xml

development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentModelBuilderTask.java

development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentTypeBuilderTask.java

development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/AbstractController.java

development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/ComponentPartController.java

development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/ComponentPartHandler.java

development/laboratory/plus/standard/part/src/main/net/dpml/metro/meta/ComponentDescriptor.java

development/laboratory/plus/standard/part/src/main/net/dpml/metro/model/ComponentModel.java

development/laboratory/plus/standard/part/src/main/net/dpml/metro/model/Model.java

development/laboratory/plus/standard/part/src/main/net/dpml/metro/type/Type.java

development/laboratory/plus/standard/part/src/main/net/dpml/metro/type/TypeHandler.java
development/laboratory/plus/test/example/impl/build.xml
development/laboratory/plus/test/execution/build.xml

development/laboratory/plus/test/execution/src/test/net/dpml/test/execution/HomeTestCase.java
Log:
Complete the picture of Part/Controller/Model relationship.

Copied:
development/laboratory/plus/api/control/src/main/net/dpml/metro/control/Controller.java
(from r2075,
development/laboratory/plus/api/control/src/main/net/dpml/metro/control/Manager.java)
==============================================================================
---
development/laboratory/plus/api/control/src/main/net/dpml/metro/control/Manager.java
(original)
+++
development/laboratory/plus/api/control/src/main/net/dpml/metro/control/Controller.java
Tue Mar 15 02:50:10 2005
@@ -18,49 +18,41 @@

package net.dpml.metro.control;

+import java.net.URI;
+import java.io.IOException;
+
import net.dpml.metro.part.Part;
import net.dpml.metro.part.ControlDescriptor;

/**
- * Part manager interface. This interface should allow the dynamic
- * addition, modification and removal of optional controllers and control
- * over the starting, monitoring and interuption of all controller instances
- * in model and application space relative to an associated part.
+ * The Controller interface defines the a control dealing with the management
+ * of all loaded parts of a particular part type.
*
* @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 Manager extends Control
+public interface Controller extends PartHandler, Control
{
- /**
- * Add a part to the collection of parts managed by this controller.
- *
- * @param part
- */
- void addPart( String name, Part part )
- throws DuplicateNameException, UnsupportedPartTypeException;

/**
- * Return an array of managed parts.
- * @return the parts array
+ * Add a part designated by a supplied uri to the management scope of the
controller
+ * and return a management view of the part.
+ * @param uri the part uri
+ * @return the management view
*/
- Part[] getParts();
+ Model addPart( URI uri ) throws IOException, DelegationException,
PartNotFoundException;

/**
- * Return an array of controller descriptors asociated
- * with the part type.
- *
- * @return the standard controller descriptor array
+ * Add a model to the management scope of the controller.
+ * @param model the model to add to the controller
*/
- //ControlDescriptor[] getControllers();
+ void addModel( Model model );

/**
- * Returns the descriptor of a named controller.
- *
- * @return the controller descriptor
+ * Return a management view of a part.
+ * @param part the part to present
+ * @return the management view
*/
- //ControlDescriptor getControlDescriptor( String name ) throws
NoSuchControlException;
-
- // MUCH MORE PENDING
+ Model getModel( Part part ) throws DelegationException;

}

Added:
development/laboratory/plus/api/control/src/main/net/dpml/metro/control/DelegationException.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/api/control/src/main/net/dpml/metro/control/DelegationException.java
Tue Mar 15 02:50:10 2005
@@ -0,0 +1,45 @@
+/*
+ * 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.control;
+
+import java.net.URI;
+
+/**
+ * Exception thrown when an attempt is made to reference an unknown handler.
+ *
+ * @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 DelegationException extends Exception
+{
+ private URI m_target;
+
+ public DelegationException( URI target, String message, Throwable cause )
+ {
+ super( message, cause );
+ m_target = target;
+ }
+
+ public URI getDelegationTarget()
+ {
+ return m_target;
+ }
+
+}
+

Added:
development/laboratory/plus/api/control/src/main/net/dpml/metro/control/Model.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/api/control/src/main/net/dpml/metro/control/Model.java
Tue Mar 15 02:50:10 2005
@@ -0,0 +1,36 @@
+/*
+ * 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.control;
+
+import java.io.Serializable;
+
+/**
+ * The Model interface defines a common management view of a component part.
Operations
+ * delcared on this interface concern the managment of component instances
associated
+ * with a subject part.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface Model
+{
+ void setName( String name );
+
+ String getName();
+}

Modified:
development/laboratory/plus/api/control/src/main/net/dpml/metro/control/PartHandler.java
==============================================================================
---
development/laboratory/plus/api/control/src/main/net/dpml/metro/control/PartHandler.java
(original)
+++
development/laboratory/plus/api/control/src/main/net/dpml/metro/control/PartHandler.java
Tue Mar 15 02:50:10 2005
@@ -31,10 +31,40 @@
*/
public interface PartHandler
{
+ /**
+ * Returns the uri of the handler.
+ * @return the handler uri
+ */
URI getURI();

- Part loadPart( URI uri )
- throws BadStrategyException, PartNotFoundException, IOException;
+ /**
+ * Load the model controller.
+ * @return the controller
+ */
+ Controller getModelController();

- Part loadPart( URI strategy, byte[] bytes ) throws BadStrategyException,
IOException;
+ /**
+ * Load a part handler giiven a handler uri.
+ * @return the part handler
+ */
+ PartHandler loadPartHandler( URI uri )
+ throws HandlerNotFoundException, IOException, DelegationException;
+
+ /**
+ * Load a part from serialized form. The uri is assumed to be a uri that
+ * can be transformed to a URL from which an input stream to a PartHolder
+ * can be established. If the uri is a transit uri the URL will be
established
+ * automatically.
+ *
+ * @return the part estracted from the part handler referenced by the uri
+ */
+ public Part loadPart( URI uri )
+ throws DelegationException, PartNotFoundException, IOException;
+
+ /**
+ * Load a part from a serialized object byte array.
+ * @param bytes the byte array
+ * @return the part
+ */
+ Part loadPart( byte[] bytes ) throws IOException;
}

Modified:
development/laboratory/plus/api/part/src/main/net/dpml/metro/part/Descriptor.java
==============================================================================
---
development/laboratory/plus/api/part/src/main/net/dpml/metro/part/Descriptor.java
(original)
+++
development/laboratory/plus/api/part/src/main/net/dpml/metro/part/Descriptor.java
Tue Mar 15 02:50:10 2005
@@ -29,6 +29,7 @@
*/
public class Descriptor implements Serializable
{
+
private static final String[] EMPTY_PROPERTY_NAMES = new String[0];

/**

Modified:
development/laboratory/plus/api/part/src/main/net/dpml/metro/part/Holder.java
==============================================================================
---
development/laboratory/plus/api/part/src/main/net/dpml/metro/part/Holder.java
(original)
+++
development/laboratory/plus/api/part/src/main/net/dpml/metro/part/Holder.java
Tue Mar 15 02:50:10 2005
@@ -31,18 +31,18 @@
*/
public class Holder implements Serializable
{
- private final URI m_strategy;
+ private final URI m_handler;
private final byte[] m_part;

- public Holder( URI strategy, byte[] part )
+ public Holder( URI handler, byte[] part )
{
- m_strategy = strategy;
+ m_handler = handler;
m_part = part;
}

protected URI getURI()
{
- return m_strategy;
+ return m_handler;
}

public byte[] getByteArray()
@@ -53,7 +53,7 @@
public int hashCode()
{
int hash = super.hashCode();
- hash ^= m_strategy.hashCode();
+ hash ^= m_handler.hashCode();
for( int i=0; i<m_part.length; i++ )
{
hash ^= new Byte( m_part[i] ).hashCode();
@@ -95,7 +95,7 @@

public String toString()
{
- return "[holder strategy:" + m_strategy + " size:" + m_part.length +
"]";
+ return "[holder handler:" + m_handler + " size:" + m_part.length +
"]";
}

}

Modified:
development/laboratory/plus/api/part/src/main/net/dpml/metro/part/Part.java
==============================================================================
---
development/laboratory/plus/api/part/src/main/net/dpml/metro/part/Part.java
(original)
+++
development/laboratory/plus/api/part/src/main/net/dpml/metro/part/Part.java
Tue Mar 15 02:50:10 2005
@@ -36,8 +36,9 @@
URI getPartHandlerURI();

/**
- * Return an array of control descriptors associated with the part.
- * @return the control descriptor array
+ * Return an array of service descriptors associated with the part.
+ * @return the service descriptor array
*/
- ControlDescriptor[] getControlDescriptors();
+ ServiceDescriptor[] getServiceDescriptors();
+
}

Added:
development/laboratory/plus/api/part/src/main/net/dpml/metro/part/ServiceDescriptor.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/api/part/src/main/net/dpml/metro/part/ServiceDescriptor.java
Tue Mar 15 02:50:10 2005
@@ -0,0 +1,104 @@
+/*
+ * 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.util.Properties;
+
+/**
+ * Description of a service provision capability exposed by a component type.
+ *
+ * @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 ServiceDescriptor extends Descriptor
+{
+
//------------------------------------------------------------------------------
+ // state
+
//------------------------------------------------------------------------------
+
+ private final String m_type;
+
+
//------------------------------------------------------------------------------
+ // constructors
+
//------------------------------------------------------------------------------
+
+ public ServiceDescriptor( final String type )
+ {
+ this( type, null );
+ }
+
+ public ServiceDescriptor( final String type, Properties properties )
+ {
+ super( properties );
+ if( null == type )
+ {
+ throw new NullPointerException( "type" );
+ }
+ m_type = type;
+ }
+
+
//------------------------------------------------------------------------------
+ // ServiceDescriptor
+
//------------------------------------------------------------------------------
+
+ public String getClassname()
+ {
+ return m_type;
+ }
+
+
//------------------------------------------------------------------------------
+ // Object
+
//------------------------------------------------------------------------------
+
+ public int hashCode()
+ {
+ int hash = super.hashCode();
+ hash ^= m_type.hashCode();
+ return hash;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( super.equals( other ) == false )
+ {
+ return false;
+ }
+ else if( other instanceof ServiceDescriptor)
+ {
+ ServiceDescriptor service = (ServiceDescriptor) other;
+ if( false == getClassname().equals( service.getClassname() ) )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+}

Modified: development/laboratory/plus/index.xml
==============================================================================
--- development/laboratory/plus/index.xml (original)
+++ development/laboratory/plus/index.xml Tue Mar 15 02:50:10 2005
@@ -165,6 +165,24 @@
</plugins>
</project>

+ <project basedir="test/example/part">
+ <info>
+ <group>dpml/metro</group>
+ <name>dpml-test-hello-part</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <types>
+ <type>part</type>
+ </types>
+ </info>
+ <dependencies>
+ <include key="dpml-test-hello-impl" build="true"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-metro-builder-impl"/>
+ </plugins>
+ </project>
+
<project basedir="test/execution">
<info>
<group>dpml/metro</group>
@@ -178,6 +196,7 @@
<dependencies>
<include key="dpml-test-hello-api" tag="api"/>
<include key="dpml-test-hello-impl" tag="impl"/>
+ <include key="dpml-test-hello-part" tag="impl"/>
<include key="dpml-transit-main" test="true" runtime="false"/>
<include key="dpml-metro-control-impl" test="true" runtime="false"/>
</dependencies>

Modified:
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentModelBuilderTask.java
==============================================================================
---
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentModelBuilderTask.java
(original)
+++
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentModelBuilderTask.java
Tue Mar 15 02:50:10 2005
@@ -38,10 +38,12 @@
import net.dpml.metro.builder.PartBuilder;
import net.dpml.metro.builder.IntrospectionException;
import net.dpml.metro.builder.BuilderRuntimeException;
+
import net.dpml.metro.meta.PartDescriptor;

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

import net.dpml.metro.type.Registry;
import net.dpml.metro.type.Type;
@@ -164,28 +166,26 @@
{
System.out.println( "## building part");
}
+
Type type = resolveType( classloader );
-System.out.println( "## resolved type: " + type );
+ ServiceDescriptor[] services = type.getServiceDescriptors();
URI registry = resolveRegistryURI();
String classname = type.getClassname();
TypeReference reference = new TypeReference( registry, classname );
-System.out.println( "## typeref: " + reference );
-
-
//******************************************************************************//
- // Lots of things to be done here concerning the validation,
//
- // configuration, and assembly of the part. Also to be included
here is //
- // the ability to add custom aspect builders and corresponding
controllers //
- // and have these aspects visible at the generic part level.
//
-
//******************************************************************************//

if( null != descriptor )
{
//checkTypeMeetsCriteria( reference, descriptor );
}

- return new ComponentModel( PART_HANDLER_URI, reference );
+ return new ComponentModel( PART_HANDLER_URI, reference, services );
}

+ /**
+ * If <component> element is nested somewhere within a <registry> tag
then
+ * construct a type instance otherwise retirieve the type instance from a
+ * registry identified by the component tag's uri attribute.
+ */
private Type resolveType( ClassLoader classloader )
throws IntrospectionException, IOException,
ClassNotFoundException,
RegistryNotFoundException, BadStrategyException,
TypeNotFoundException

Modified:
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentTypeBuilderTask.java
==============================================================================
---
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentTypeBuilderTask.java
(original)
+++
development/laboratory/plus/standard/builder/src/main/net/dpml/metro/builder/impl/ComponentTypeBuilderTask.java
Tue Mar 15 02:50:10 2005
@@ -30,13 +30,13 @@
import java.net.URI;

import net.dpml.metro.meta.ComponentDescriptor;
-import net.dpml.metro.meta.ServiceDescriptor;
import net.dpml.metro.meta.DependencyDescriptor;
import net.dpml.metro.meta.PartDescriptor;
import net.dpml.metro.meta.InfoDescriptor;

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

import net.dpml.metro.builder.PartBuilder;
import net.dpml.metro.builder.IntrospectionException;

Modified:
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/AbstractController.java
==============================================================================
---
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/AbstractController.java
(original)
+++
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/AbstractController.java
Tue Mar 15 02:50:10 2005
@@ -26,10 +26,8 @@
import net.dpml.metro.part.Part;
import net.dpml.metro.model.ComponentModel;

-import net.dpml.metro.control.Home;
import net.dpml.metro.control.Control;
import net.dpml.metro.control.PartHandler;
-import net.dpml.metro.control.Manager;
import net.dpml.metro.control.Monitor;
import net.dpml.metro.control.DuplicateNameException;
import net.dpml.metro.control.UnsupportedPartTypeException;

Modified:
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/ComponentPartController.java
==============================================================================
---
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/ComponentPartController.java
(original)
+++
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/ComponentPartController.java
Tue Mar 15 02:50:10 2005
@@ -20,18 +20,24 @@

import java.net.URI;
import java.net.URISyntaxException;
-import java.util.Map;
-import java.util.Hashtable;
+import java.io.IOException;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+import java.util.WeakHashMap;

import net.dpml.metro.part.Part;
import net.dpml.metro.model.ComponentModel;

-import net.dpml.metro.control.Home;
import net.dpml.metro.control.PartHandler;
-import net.dpml.metro.control.Manager;
+import net.dpml.metro.control.Controller;
import net.dpml.metro.control.Monitor;
+import net.dpml.metro.control.Model;
import net.dpml.metro.control.DuplicateNameException;
import net.dpml.metro.control.UnsupportedPartTypeException;
+import net.dpml.metro.control.DelegationException;
+import net.dpml.metro.control.HandlerNotFoundException;
+import net.dpml.metro.control.PartNotFoundException;

/**
* A initial test controller.
@@ -39,28 +45,46 @@
* @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 ComponentPartController extends ComponentPartHandler implements
Manager
+public class ComponentPartController extends ComponentPartHandler implements
Controller
{
//--------------------------------------------------------------------
// state
//--------------------------------------------------------------------

- private Thread m_thread;
- private Map m_map = new Hashtable();
- private Monitor m_monitor;
+ private final Thread m_thread;
+ private final Set m_models = Collections.synchronizedSet( new HashSet()
);
+ private final Monitor m_monitor;

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

- public ComponentPartController( Home home, Monitor monitor )
+ public ComponentPartController()
+ {
+ this( new ConsoleMonitor( "metro", false ) );
+ }
+
+ public ComponentPartController( Monitor monitor )
{
super();
- m_thread = new Worker( home, this );
+ m_thread = new Worker( this );
m_monitor = monitor;
}

//--------------------------------------------------------------------
+ // PartHandler
+ //--------------------------------------------------------------------
+
+ /**
+ * Load the model controller.
+ * @return the controller
+ */
+ public Controller getModelController()
+ {
+ return this;
+ }
+
+ //--------------------------------------------------------------------
// Controller
//--------------------------------------------------------------------

@@ -75,39 +99,80 @@
* @param name the name identifying the part within the collection
* @param part the part to add
*/
- public void addPart( String name, Part part )
- throws DuplicateNameException, UnsupportedPartTypeException
+ public Model addPart( URI uri )
+ throws IOException, DelegationException, PartNotFoundException
{
- if( null != m_map.get( name ) )
- {
- throw new DuplicateNameException( name );
- }
- else if( part instanceof ComponentModel )
- {
- m_map.put( name, part );
- }
- else
- {
- throw new UnsupportedPartTypeException( part );
- }
+ Part part = loadPart( uri );
+ return addPart( part );
}

/**
- * Return an array of managed parts.
- * @return the parts array
+ * Add a model to the management scope of the controller.
+ * @param model the model to add to the controller
*/
- public Part[] getParts()
+ public void addModel( Model model )
{
- return getComponentParts();
+ m_models.add( model );
+ }
+
+ /**
+ * Add a part to the collection of parts managed by this controller.
+ *
+ * @param name the name identifying the part within the collection
+ * @param part the part to add
+ */
+ private Model addPart( Part part )
+ throws DelegationException
+ {
+ Model model = getModel( part );
+ m_models.add( model );
+ return model;
}

/**
* Return an array of managed parts.
* @return the parts array
*/
- public ComponentModel[] getComponentParts()
+ public Model[] getManagedModels()
+ {
+ return (Model[]) m_models.toArray( new Model[0] );
+ }
+
+ /**
+ * Return a management view of a part.
+ * @param part the part to present
+ * @return the management view
+ */
+ public Model getModel( Part part ) throws DelegationException
{
- return (ComponentModel[]) m_map.values().toArray( new
ComponentModel[0] );
+ URI uri = part.getPartHandlerURI();
+ if( getURI().equals( uri ) )
+ {
+ return new MetroComponentModel( part );
+ }
+ else
+ {
+ try
+ {
+ PartHandler handler = loadPartHandler( uri );
+ Controller controller = handler.getModelController();
+ return controller.getModel( part );
+ }
+ catch( HandlerNotFoundException e )
+ {
+ final String error =
+ "Requested part handler ["
+ + uri
+ + "] not found.";
+ throw new DelegationException( uri, error, e );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error raised by delegate while requesting part
model.";
+ throw new DelegationException( uri, error, e );
+ }
+ }
}

/**
@@ -126,14 +191,14 @@
m_thread.interrupt();
}

- public void listPart()
+ public void list()
{
- getMonitor().info( "listing part in the master controller" );
- ComponentModel[] parts = (ComponentModel[]) getComponentParts();
- for( int i=0; i<parts.length; i++ )
+ getMonitor().info( "listing models in the controller" );
+ Model[] models = getManagedModels();
+ for( int i=0; i<models.length; i++ )
{
- Part part = parts[i];
- getMonitor().info( "part: " + part );
+ Model model = models[i];
+ getMonitor().info( "model: " + model );
}
}

@@ -169,12 +234,10 @@
*/
private static class Worker extends Thread
{
- private final Home m_home;
private final ComponentPartController m_parent;

- public Worker( Home home, ComponentPartController parent )
+ public Worker( ComponentPartController parent )
{
- m_home = home;
m_parent = parent;
}


Modified:
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/ComponentPartHandler.java
==============================================================================
---
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/ComponentPartHandler.java
(original)
+++
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/ComponentPartHandler.java
Tue Mar 15 02:50:10 2005
@@ -22,19 +22,24 @@
import java.io.IOException;
import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
-import java.rmi.MarshalledObject;
+import java.util.WeakHashMap ;
import java.net.URI;
import java.net.URL;

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

+import net.dpml.metro.control.Controller;
import net.dpml.metro.control.PartNotFoundException;
import net.dpml.metro.control.PartHandler;
import net.dpml.metro.control.BadStrategyException;
import net.dpml.metro.control.PartHandlerRuntimeException;
+import net.dpml.metro.control.HandlerNotFoundException;
+import net.dpml.metro.control.DelegationException;

import net.dpml.transit.artifact.Handler;
+import net.dpml.transit.repository.StandardLoader;
+import net.dpml.transit.TransitException;

/**
* Definition of a type handler.
@@ -42,22 +47,105 @@
* @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 ComponentPartHandler implements PartHandler
+public abstract class ComponentPartHandler implements PartHandler
{
+ /**
+ * Map containing the foreign part handlers. The map keys
+ * are the string representation of the handler uri. The entry is the
+ * handler.
+ */
+ private final WeakHashMap m_handlers = new WeakHashMap();
+
+ /**
+ * Transit repository handler used for resolving foreign handlers.
+ */
+ private final StandardLoader m_loader;
+
+ public ComponentPartHandler()
+ {
+ try
+ {
+ m_loader = new StandardLoader();
+ }
+ catch( TransitException e )
+ {
+ final String error =
+ "Internal error during handler initialization.";
+ throw new PartHandlerRuntimeException( error, e );
+ }
+ }
+
+ /**
+ * Returns the uri of this handler.
+ * @return the handler uri
+ */
public URI getURI()
{
return PART_HANDLER_URI;
}

+ /**
+ * Load the model controller.
+ * @return the controller
+ */
+ public abstract Controller getModelController();
+
+ /**
+ * Load a part from serialized form. The uri is assumed to be a uri that
+ * can be transformed to a URL from which an input stream to a PartHolder
+ * can be established. If the uri is a transit uri the URL will be
established
+ * automatically. If the uri references a foreign part handler the
implementation
+ * will attempt to locate and delegate part loading requests to the
foreign
+ * handler.
+ *
+ * @return the part estracted from the part handler referenced by the uri
+ */
public Part loadPart( URI uri )
- throws BadStrategyException, PartNotFoundException, IOException
+ throws PartNotFoundException, IOException, DelegationException
{
- System.out.println( "## loading part uri: " + uri );
+ return loadSerializedPart( uri );
+ }

- URL url = resolveURL( uri );
+ public Part loadPart( byte[] bytes ) throws IOException
+ {
+ try
+ {
+ ByteArrayInputStream input = new ByteArrayInputStream( bytes );
+ ObjectInputStream stream = new ObjectInputStream( input );
+ return (Part) stream.readObject();
+ }
+ catch( IOException e )
+ {
+ throw e;
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to load a part from a byte
array.";
+ throw new PartHandlerRuntimeException( error, e );
+ }
+ }

- System.out.println( "## loading part: " + url );
+ /**
+ * Load a part handler giiven a handler uri.
+ * @return the part handler
+ */
+ public PartHandler loadPartHandler( URI uri ) throws
HandlerNotFoundException, DelegationException, IOException
+ {
+ if( false == getURI().equals( uri ) )
+ {
+ return resolvePartHandler( uri );
+ }
+ else
+ {
+ return this;
+ }
+ }

+ private Part loadSerializedPart( URI uri )
+ throws IOException, DelegationException, PartNotFoundException
+ {
+ URL url = resolveURL( uri );
InputStream input = url.openStream();
if( null == input )
{
@@ -67,14 +155,35 @@
try
{
PartHolder holder = (PartHolder) stream.readObject();
- URI handler = holder.getPartHandlerURI();
- return loadPart( handler, holder.getByteArray() );
+ URI foreign = holder.getPartHandlerURI();
+ if( false == getURI().equals( foreign ) )
+ {
+ try
+ {
+ PartHandler handler = resolvePartHandler( uri );
+ return handler.loadPart( holder.getByteArray() );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Delegate raised an error while attempting to load a
serialized part ["
+ + uri
+ + "] using the external handler ["
+ + foreign
+ + "].";
+ throw new DelegationException( foreign, error, e );
+ }
+ }
+ else
+ {
+ return loadPart( holder.getByteArray() );
+ }
}
- catch( BadStrategyException e )
+ catch( IOException e )
{
throw e;
}
- catch( IOException e )
+ catch( DelegationException e )
{
throw e;
}
@@ -88,39 +197,48 @@
}
}

- public Part loadPart( URI handler, byte[] bytes ) throws
BadStrategyException, IOException
+ private URL resolveURL( URI uri ) throws IOException
{
- if( false == getURI().equals( handler ) )
+ if( "artifact".equals( uri.getScheme() ) )
{
- throw new BadStrategyException( getURI(), handler );
+ return new URL( null, uri.toString(), new Handler() );
}
- try
+ else
{
- ByteArrayInputStream input = new ByteArrayInputStream( bytes );
- ObjectInputStream stream = new ObjectInputStream( input );
- return (Part) stream.readObject();
+ return uri.toURL();
}
- catch( IOException e )
+ }
+
+ protected PartHandler resolvePartHandler( URI uri ) throws
HandlerNotFoundException, IOException
+ {
+ if( getURI().equals( uri ) )
{
- throw e;
+ return this;
}
- catch( Throwable e )
+ String key = uri.toString();
+ synchronized( m_handlers )
{
- final String error =
- "Unexpected error while attempting to load a part from a byte
array.";
- throw new PartHandlerRuntimeException( error, e );
+ PartHandler handler = (PartHandler) m_handlers.get( key );
+ if( null == handler )
+ {
+ handler = loadHandler( uri );
+ m_handlers.put( key, handler );
+ }
+ return handler;
}
}

- private URL resolveURL( URI uri ) throws IOException
+ private PartHandler loadHandler( URI uri ) throws
HandlerNotFoundException
{
- if( "artifact".equals( uri.getScheme() ) )
+ ClassLoader classloader = PartHandler.class.getClassLoader();
+ ConsoleMonitor monitor = new ConsoleMonitor( "manager", true );
+ try
{
- return new URL( null, uri.toString(), new Handler() );
+ return (PartHandler) m_loader.getPlugin( classloader, uri, new
Object[]{ this, monitor } );
}
- else
+ catch( IOException e )
{
- return uri.toURL();
+ throw new HandlerNotFoundException( uri, e );
}
}


Copied:
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/DemoControl.java
(from r2073,
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/ComponentPartListingControl.java)
==============================================================================
---
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/ComponentPartListingControl.java
(original)
+++
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/DemoControl.java
Tue Mar 15 02:50:10 2005
@@ -24,10 +24,9 @@
import net.dpml.metro.part.Part;
import net.dpml.metro.model.ComponentModel;

-import net.dpml.metro.control.Home;
import net.dpml.metro.control.PartHandler;
import net.dpml.metro.control.Control;
-import net.dpml.metro.control.Manager;
+import net.dpml.metro.control.Controller;
import net.dpml.metro.control.Monitor;

/**
@@ -36,15 +35,15 @@
* @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 ComponentPartListingControl extends AbstractController
implements Control
+public class DemoControl extends AbstractController implements Control
{
//--------------------------------------------------------------------
// constructor
//--------------------------------------------------------------------

- public ComponentPartListingControl( Manager manager, Monitor monitor,
Part part )
+ public DemoControl( Controller controller, Monitor monitor, Part part )
{
- super( "listing", new Worker( manager, monitor, part ) );
+ super( "listing", new Worker( controller, monitor, part ) );
}

//--------------------------------------------------------------------
@@ -56,13 +55,13 @@
*/
private static class Worker extends Thread
{
- private final Manager m_manager;
+ private final Controller m_controller;
private final Monitor m_monitor;
private final Part m_part;

- public Worker( Manager manager, Monitor monitor, Part part )
+ public Worker( Controller controller, Monitor monitor, Part part )
{
- m_manager = manager;
+ m_controller = controller;
m_monitor = monitor;
m_part = part;
}

Added:
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/MetroComponentModel.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/standard/control/src/main/net/dpml/metro/control/impl/MetroComponentModel.java
Tue Mar 15 02:50:10 2005
@@ -0,0 +1,53 @@
+/*
+ * 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.control.impl;
+
+import java.io.Serializable;
+
+import net.dpml.metro.part.Part;
+import net.dpml.metro.control.Model;
+
+/**
+ * Implement of a view of a part presented as a managable 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 MetroComponentModel implements Model, Serializable
+{
+ private final Part m_part;
+
+ private String m_name;
+
+ public MetroComponentModel( Part part )
+ {
+ m_part = part;
+ }
+
+ public void setName( String name )
+ {
+ m_name = name;
+ // notify all part listerns of the name change
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+}

Modified:
development/laboratory/plus/standard/part/src/main/net/dpml/metro/meta/ComponentDescriptor.java
==============================================================================
---
development/laboratory/plus/standard/part/src/main/net/dpml/metro/meta/ComponentDescriptor.java
(original)
+++
development/laboratory/plus/standard/part/src/main/net/dpml/metro/meta/ComponentDescriptor.java
Tue Mar 15 02:50:10 2005
@@ -23,6 +23,7 @@

import net.dpml.metro.type.Type;
import net.dpml.metro.part.Descriptor;
+import net.dpml.metro.part.ServiceDescriptor;

/**
* Description of a component type.

Modified:
development/laboratory/plus/standard/part/src/main/net/dpml/metro/model/ComponentModel.java
==============================================================================
---
development/laboratory/plus/standard/part/src/main/net/dpml/metro/model/ComponentModel.java
(original)
+++
development/laboratory/plus/standard/part/src/main/net/dpml/metro/model/ComponentModel.java
Tue Mar 15 02:50:10 2005
@@ -18,11 +18,12 @@

package net.dpml.metro.model;

-import java.io.Serializable;
+import java.util.Properties;
import java.net.URI;

import net.dpml.metro.part.Part;
-import net.dpml.metro.part.ControlDescriptor;
+import net.dpml.metro.part.ServiceDescriptor;
+import net.dpml.metro.part.Descriptor;
import net.dpml.metro.type.TypeReference;

/**
@@ -32,34 +33,36 @@
* @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 implements Part, Serializable
+public class ComponentModel extends Descriptor implements Part
{
private TypeReference m_type;
- private ControlDescriptor[] m_controls;
- private URI m_controller;
+ private ServiceDescriptor[] m_services;
+ private URI m_handler;

- public ComponentModel( URI controller, TypeReference type )
+ public ComponentModel( URI handler, TypeReference type )
{
- this( controller, type, EMPTY_CONTROLS );
+ this( handler, type, EMPTY_SERVICES, null );
}

- public ComponentModel( URI controller, TypeReference type,
ControlDescriptor[] controls )
+ public ComponentModel( URI handler, TypeReference type,
ServiceDescriptor[] services )
{
+ this( handler, type, services, null );
+ }
+
+ public ComponentModel( URI handler, TypeReference type,
ServiceDescriptor[] services, Properties properties )
+ {
+ super( properties );
if( null == type )
{
throw new NullPointerException( "type" );
}
- if( null == controller )
+ if( null == services )
{
- throw new NullPointerException( "controller" );
- }
- if( null == controls )
- {
- throw new NullPointerException( "controls" );
+ throw new NullPointerException( "services" );
}
m_type = type;
- m_controls = controls;
- m_controller = controller;
+ m_services = services;
+ m_handler = handler;
}

/**
@@ -68,7 +71,7 @@
*/
public URI getPartHandlerURI()
{
- return m_controller;
+ return m_handler;
}

/**
@@ -81,12 +84,12 @@
}

/**
- * Return a reference to the type managed by this part.
+ * Return an array of the services available from this part.
* @return the type reference
*/
- public ControlDescriptor[] getControlDescriptors()
+ public ServiceDescriptor[] getServiceDescriptors()
{
- return m_controls;
+ return m_services;
}

public int hashCode()
@@ -119,6 +122,6 @@
}
}

- private static final ControlDescriptor[] EMPTY_CONTROLS = new
ControlDescriptor[0];
+ private static final ServiceDescriptor[] EMPTY_SERVICES = new
ServiceDescriptor[0];

}

Modified:
development/laboratory/plus/standard/part/src/main/net/dpml/metro/model/Model.java
==============================================================================
---
development/laboratory/plus/standard/part/src/main/net/dpml/metro/model/Model.java
(original)
+++
development/laboratory/plus/standard/part/src/main/net/dpml/metro/model/Model.java
Tue Mar 15 02:50:10 2005
@@ -26,6 +26,6 @@
* @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
+public interface Model
{
}

Modified:
development/laboratory/plus/standard/part/src/main/net/dpml/metro/type/Type.java
==============================================================================
---
development/laboratory/plus/standard/part/src/main/net/dpml/metro/type/Type.java
(original)
+++
development/laboratory/plus/standard/part/src/main/net/dpml/metro/type/Type.java
Tue Mar 15 02:50:10 2005
@@ -21,6 +21,8 @@
import java.io.Serializable;
import java.net.URI;

+import net.dpml.metro.part.ServiceDescriptor;
+
/**
* The common interface implemented by all component parts.
*
@@ -30,4 +32,6 @@
public interface Type extends Serializable
{
String getClassname();
+
+ ServiceDescriptor[] getServiceDescriptors();
}

Modified:
development/laboratory/plus/standard/part/src/main/net/dpml/metro/type/TypeHandler.java
==============================================================================
---
development/laboratory/plus/standard/part/src/main/net/dpml/metro/type/TypeHandler.java
(original)
+++
development/laboratory/plus/standard/part/src/main/net/dpml/metro/type/TypeHandler.java
Tue Mar 15 02:50:10 2005
@@ -22,7 +22,6 @@
import java.io.IOException;
import java.net.URI;

-import net.dpml.metro.control.Handler;
import net.dpml.metro.control.BadStrategyException;

/**
@@ -31,8 +30,10 @@
* @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 TypeHandler extends Handler
+public interface TypeHandler
{
+ URI getURI();
+
Type loadType( TypeReference reference )
throws RegistryNotFoundException, BadStrategyException,
TypeNotFoundException, IOException;


Modified: development/laboratory/plus/test/example/impl/build.xml
==============================================================================
--- development/laboratory/plus/test/example/impl/build.xml (original)
+++ development/laboratory/plus/test/example/impl/build.xml Tue Mar 15
02:50:10 2005
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>

+<!-- example of the creation of a serialized registry of component types -->
+
<project name="dpml-test-hello-impl" default="install" basedir="."
xmlns:transit="antlib:net.dpml.transit"
xmlns:x="plugin:dpml/magic/dpml-magic-core">
@@ -10,7 +12,6 @@
<x:property feature="uri" type="registry" name="registry.uri"/>
<x:property key="dpml-metro-control-impl" feature="plugin"
name="debugger.uri"/>

- <!-- example of the creation of a serialized registry -->
<registry xmlns="plugin:dpml/metro/dpml-metro-builder-impl">
<type class="net.dpml.test.hello.impl.HelloComponent">
<controls>
@@ -22,9 +23,6 @@
</type>
</registry>

- <!-- example of the creation of a standalone part -->
- <component xmlns="plugin:dpml/metro/dpml-metro-builder-impl"
- class="net.dpml.test.hello.impl.HelloComponent"
uri="${registry.uri}"/>
</target>

</project>

Added: development/laboratory/plus/test/example/part/build.xml
==============================================================================
--- (empty file)
+++ development/laboratory/plus/test/example/part/build.xml Tue Mar 15
02:50:10 2005
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!-- example of the creation of a standalone part from an external registry
-->
+
+<project name="dpml-test-hello-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"/>
+
+ <target name="package" depends="standard.package">
+ <x:property key="dpml-test-hello-impl" feature="uri" type="registry"
name="registry.uri"/>
+ <component xmlns="plugin:dpml/metro/dpml-metro-builder-impl"
+ class="net.dpml.test.hello.impl.HelloComponent"
uri="${registry.uri}"/>
+ </target>
+
+</project>
+

Modified: development/laboratory/plus/test/execution/build.xml
==============================================================================
--- development/laboratory/plus/test/execution/build.xml (original)
+++ development/laboratory/plus/test/execution/build.xml Tue Mar 15
02:50:10 2005
@@ -7,23 +7,9 @@
<transit:import uri="artifact:template:dpml/magic/standard"/>

<target name="init" depends="standard.init">
- <x:property name="spec" key="dpml-test-hello-impl" feature="uri"
type="part"/>
+ <x:property name="spec" key="dpml-test-hello-part" feature="uri"
type="part"/>
<filter token="HELLO-PART-URI" value="${spec}"/>
- <filter token="PATH"
value="target/deliverables/parts/${project.filename}"/>
- <x:filter token="PART-CONTROLLER-URI" key="dpml-metro-control-impl"
feature="plugin"/>
- <x:property key="dpml-test-hello-impl" feature="uri" type="registry"
name="hello.registry"/>
</target>

- <!--
- <target name="package" depends="standard.package">
- <component xmlns="plugin:dpml/metro/dpml-metro-builder-impl"
- class="net.dpml.test.hello.impl.HelloComponent"
uri="${hello.registry}">
- <parts>
- <component class="net.dpml.test.hello.impl.DefaultOutputHandler"
key="OutputHandler"/>
- </parts>
- </component>
- </target>
- -->
-
</project>


Modified:
development/laboratory/plus/test/execution/src/test/net/dpml/test/execution/HomeTestCase.java
==============================================================================
---
development/laboratory/plus/test/execution/src/test/net/dpml/test/execution/HomeTestCase.java
(original)
+++
development/laboratory/plus/test/execution/src/test/net/dpml/test/execution/HomeTestCase.java
Tue Mar 15 02:50:10 2005
@@ -25,7 +25,11 @@
import java.net.URI;

import net.dpml.metro.part.Part;
-import net.dpml.metro.control.impl.TransitHome;
+import net.dpml.metro.control.Controller;
+import net.dpml.metro.control.PartHandler;
+import net.dpml.metro.control.Model;
+
+import net.dpml.metro.control.impl.ComponentPartController;

import junit.framework.TestCase;

@@ -38,37 +42,37 @@
*/
public class HomeTestCase extends TestCase
{
- static
- {
- System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
- }
-
- private static final String CONTROLLER_URI_SPEC = "@PATH@";
-
- private TransitHome m_home;
+ //--------------------------------------------------------------------
+ // state
+ //--------------------------------------------------------------------
+
+ private Controller m_controller;
+
+ //--------------------------------------------------------------------
+ // TestCase
+ //--------------------------------------------------------------------

public void setUp() throws Exception
{
- m_home = new TransitHome();
+ m_controller = new ComponentPartController();
}

public void testHome() throws Exception
{
- Part part = m_home.loadPart( HELLO_PART_URI );
- System.out.println( "#part: " + part );
+ Model model = m_controller.addPart( HELLO_PART_URI );
+ System.out.println( "#model: " + model );
+ }
+
+ //--------------------------------------------------------------------
+ // static utilities for testcase
+ //--------------------------------------------------------------------

- /*
- Controller controller = m_home.loadController( HELLO_PART_URI );
- File basedir = new File( System.getProperty( "project.basedir" ) );
- File file = new File( basedir, PATH );
- URL url = file.toURL();
- Part part = m_home.loadPart( uri );
- System.out.println( "#part: " + part );
- */
+ static
+ {
+ System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
}

private static final URI HELLO_PART_URI = createStaticURI(
"@HELLO-PART-URI@" );
- private static final URI PART_CONTROLLER_URI = createStaticURI(
"@PART-CONTROLLER-URI@" );

private static URI createStaticURI( String path )
{



  • svn commit: r2076 - in development/laboratory/plus: . api/control/src/main/net/dpml/metro/control api/part/src/main/net/dpml/metro/part standard/builder/src/main/net/dpml/metro/builder/impl standard/control/src/main/net/dpml/metro/control/impl standard/part/src/main/net/dpml/metro/meta standard/part/src/main/net/dpml/metro/model standard/part/src/main/net/dpml/metro/type test/example/impl test/example/part test/execution test/execution/src/test/net/dpml/test/execution, mcconnell, 03/14/2005

Archive powered by MHonArc 2.6.24.

Top of Page