notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2943 - in development: main/metro/central/src/main/net/dpml/metro/central main/metro/composition main/metro/composition/builder/src/main/net/dpml/composition/builder main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes main/metro/composition/control main/metro/composition/control/src/main/net/dpml/composition/control main/metro/composition/control/src/main/net/dpml/composition/data main/metro/composition/control/src/main/net/dpml/composition/info main/metro/composition/control/src/main/net/dpml/composition/model main/metro/composition/control/src/main/net/dpml/composition/runtime main/metro/composition/control/src/test/net/dpml/composition/data main/metro/composition/control/src/test/net/dpml/composition/management main/metro/part/src/main/net/dpml/part/control main/metro/part/src/main/net/dpml/part/manager main/metro/part/src/main/net/dpml/part/model main/metro/part/src/main/net/dpml/part/part main/test/components/plus/src/main/net/dpml/test/acme/plus main/test/components/simple/src/main/net/dpml/test/acme main/test/unit/plus/src/test/net/dpml/test/acme/plus main/test/unit/simple main/test/unit/simple/src/test/net/dpml/test/acme main/transit/core/handler/src/main/net/dpml/transit/util planet/http/demo/src/main/net/dpml/http planet/http/demo/src/test/net/dpml/http planet/http/impl/src/main/net/dpml/http/impl
- From: mcconnell AT dpml.net
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2943 - in development: main/metro/central/src/main/net/dpml/metro/central main/metro/composition main/metro/composition/builder/src/main/net/dpml/composition/builder main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes main/metro/composition/control main/metro/composition/control/src/main/net/dpml/composition/control main/metro/composition/control/src/main/net/dpml/composition/data main/metro/composition/control/src/main/net/dpml/composition/info main/metro/composition/control/src/main/net/dpml/composition/model main/metro/composition/control/src/main/net/dpml/composition/runtime main/metro/composition/control/src/test/net/dpml/composition/data main/metro/composition/control/src/test/net/dpml/composition/management main/metro/part/src/main/net/dpml/part/control main/metro/part/src/main/net/dpml/part/manager main/metro/part/src/main/net/dpml/part/model main/metro/part/src/main/net/dpml/part/part main/test/components/plus/src/main/net/dpml/test/acme/plus main/test/components/simple/src/main/net/dpml/test/acme main/test/unit/plus/src/test/net/dpml/test/acme/plus main/test/unit/simple main/test/unit/simple/src/test/net/dpml/test/acme main/transit/core/handler/src/main/net/dpml/transit/util planet/http/demo/src/main/net/dpml/http planet/http/demo/src/test/net/dpml/http planet/http/impl/src/main/net/dpml/http/impl
- Date: Thu, 30 Jun 2005 22:52:29 -0400
Author: mcconnell AT dpml.net
Date: Thu Jun 30 22:52:28 2005
New Revision: 2943
Added:
development/main/metro/composition/control/src/main/net/dpml/composition/data/TODO.txt
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/AbstractHandler.java
- copied, changed from r2941,
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/AbstractComponent.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentHandler.java
- copied, changed from r2941,
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentEntry.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/CompositionHandler.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextMap.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LifestyleHandler.txt
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/PartsTable.java
- copied, changed from r2941,
development/main/metro/composition/control/src/main/net/dpml/composition/model/PartsTable.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueHandler.java
- copied, changed from r2941,
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueEntry.java
development/main/metro/part/src/main/net/dpml/part/manager/ComponentException.java
development/main/metro/part/src/main/net/dpml/part/manager/ComponentNotFoundException.java
development/main/metro/part/src/main/net/dpml/part/manager/ComponentRuntimeException.java
development/main/metro/part/src/main/net/dpml/part/manager/ContainmentException.java
development/main/metro/part/src/main/net/dpml/part/manager/DuplicateKeyException.java
- copied, changed from r2941,
development/main/metro/part/src/main/net/dpml/part/model/DuplicateKeyException.java
development/main/metro/part/src/main/net/dpml/part/manager/PartClassNotFoundException.java
- copied, changed from r2941,
development/main/metro/part/src/main/net/dpml/part/model/PartClassNotFoundException.java
development/main/metro/part/src/main/net/dpml/part/manager/ResourceUnavailableException.java
- copied, changed from r2941,
development/main/metro/part/src/main/net/dpml/part/model/ResourceUnavailableException.java
development/main/metro/part/src/main/net/dpml/part/manager/ServiceClassNotFoundException.java
- copied, changed from r2941,
development/main/metro/part/src/main/net/dpml/part/model/ServiceClassNotFoundException.java
development/main/metro/part/src/main/net/dpml/part/manager/TypeClassNotFoundException.java
- copied, changed from r2941,
development/main/metro/part/src/main/net/dpml/part/model/TypeClassNotFoundException.java
development/main/test/unit/simple/src/test/net/dpml/test/acme/ContainerTestCase.java
Removed:
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifestyleHandler.java
development/main/metro/composition/control/src/main/net/dpml/composition/model/
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/AbstractComponent.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentEntry.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentTable.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/CompositionManager.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueEntry.java
development/main/metro/composition/control/src/test/net/dpml/composition/data/
development/main/metro/composition/control/src/test/net/dpml/composition/management/
development/main/metro/part/src/main/net/dpml/part/model/
Modified:
development/main/metro/central/src/main/net/dpml/metro/central/MetroHelper.java
development/main/metro/central/src/main/net/dpml/metro/central/PartContentHandler.java
development/main/metro/composition/build.xml
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
development/main/metro/composition/control/build.xml
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
development/main/metro/composition/control/src/main/net/dpml/composition/data/ComponentProfile.java
development/main/metro/composition/control/src/main/net/dpml/composition/data/ValueDirective.java
development/main/metro/composition/control/src/main/net/dpml/composition/info/PartDescriptor.java
development/main/metro/composition/control/src/main/net/dpml/composition/info/Type.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/Appliance.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentController.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextInvocationHandler.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextManagerInvocationHandler.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LifecycleHandler.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LoggingHandler.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/Manager.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ManagerInvocationHandler.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/PartsInvocationHandler.java
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueController.java
development/main/metro/part/src/main/net/dpml/part/control/Controller.java
development/main/metro/part/src/main/net/dpml/part/control/LifecycleException.java
development/main/metro/part/src/main/net/dpml/part/manager/Component.java
development/main/metro/part/src/main/net/dpml/part/manager/Container.java
development/main/metro/part/src/main/net/dpml/part/part/Part.java
development/main/test/components/plus/src/main/net/dpml/test/acme/plus/ConfigurableContainer.java
development/main/test/components/simple/src/main/net/dpml/test/acme/AcmeContainer.java
development/main/test/components/simple/src/main/net/dpml/test/acme/WidgetComponent.java
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/ConfigurationTestCase.java
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/ManagementTestCase.java
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/URLTestCase.java
development/main/test/unit/simple/build.xml
development/main/test/unit/simple/src/test/net/dpml/test/acme/CompositeTestCase.java
development/main/test/unit/simple/src/test/net/dpml/test/acme/ExampleTestCase.java
development/main/test/unit/simple/src/test/net/dpml/test/acme/SimpleTestCase.java
development/main/transit/core/handler/src/main/net/dpml/transit/util/StandardFormatter.java
development/planet/http/demo/src/main/net/dpml/http/Demo.java
development/planet/http/demo/src/test/net/dpml/http/HttpTestCase.java
development/planet/http/impl/src/main/net/dpml/http/impl/HttpServerImpl.java
Log:
General progress.
Modified:
development/main/metro/central/src/main/net/dpml/metro/central/MetroHelper.java
==============================================================================
---
development/main/metro/central/src/main/net/dpml/metro/central/MetroHelper.java
(original)
+++
development/main/metro/central/src/main/net/dpml/metro/central/MetroHelper.java
Thu Jun 30 22:52:28 2005
@@ -28,7 +28,6 @@
import java.util.Date;
import net.dpml.composition.control.CompositionController;
-import net.dpml.composition.runtime.CompositionManager;
import net.dpml.part.control.Controller;
import net.dpml.part.control.ControllerContext;
@@ -65,7 +64,6 @@
// state
//------------------------------------------------------------------
- private CompositionManager m_manager;
private CompositionController m_controller;
//------------------------------------------------------------------
@@ -85,7 +83,6 @@
Logger logger = new LoggingAdapter( "metro" );
DefaultContentModel model = new DefaultContentModel( logger, null,
type, title, properties );
m_controller = new CompositionController( model );
- m_manager = new CompositionManager( m_controller );
}
public MetroHelper( ContentModel model ) throws Exception
@@ -95,7 +92,6 @@
throw new NullPointerException( "model" );
}
m_controller = new CompositionController( model );
- m_manager = new CompositionManager( m_controller );
}
//------------------------------------------------------------------
@@ -107,11 +103,6 @@
return m_controller;
}
- public CompositionManager getCompositionManager()
- {
- return m_manager;
- }
-
public URI toURI( String path )
{
try
@@ -128,7 +119,6 @@
public void dispose()
{
- getCompositionManager().dispose();
System.gc();
}
Modified:
development/main/metro/central/src/main/net/dpml/metro/central/PartContentHandler.java
==============================================================================
---
development/main/metro/central/src/main/net/dpml/metro/central/PartContentHandler.java
(original)
+++
development/main/metro/central/src/main/net/dpml/metro/central/PartContentHandler.java
Thu Jun 30 22:52:28 2005
@@ -41,7 +41,6 @@
import net.dpml.part.control.ControllerContext;
import net.dpml.part.part.Part;
-import net.dpml.part.model.Model;
import net.dpml.part.manager.Component;
import net.dpml.transit.Transit;
@@ -99,16 +98,11 @@
{
return getPart( url );
}
- else if( Model.class.isAssignableFrom( c ) )
- {
- return getModel( url );
- }
else if( Component.class.isAssignableFrom( c ) )
{
try
{
- Model model = getModel( url );
- return m_controller.getComponent( model );
+ return getComponent( url );
}
catch( Throwable e )
{
@@ -116,23 +110,18 @@
"Unable to load provider: " + url;
throw new RuntimeException( error, e );
}
-
- }
- else if( Remote.class.isAssignableFrom( c ) )
- {
- return getModel( url );
}
else if( Object.class.equals( c ) )
{
- Model model = getModel( url );
+ Component component = getComponent( url );
try
{
- return m_controller.getComponent( model ).resolve(
false );
+ return component.resolve( false );
}
catch( Throwable e )
{
final String error =
- "Unable to load part: " + url;
+ "Unable to load component: " + url;
throw new RuntimeException( error, e );
}
}
@@ -163,18 +152,18 @@
}
}
- private Model getModel( URL url )
+ private Component getComponent( URL url )
{
try
{
String path = url.toExternalForm();
URI uri = new URI( path );
- return m_controller.getModel( uri );
+ return m_controller.newComponent( uri );
}
catch( Throwable e )
{
final String error =
- "Error occured while attempting to load part: " + url;
+ "Error occured while attempting to load component: " + url;
throw new RuntimeException( error, e );
}
}
Modified: development/main/metro/composition/build.xml
==============================================================================
--- development/main/metro/composition/build.xml (original)
+++ development/main/metro/composition/build.xml Thu Jun 30 22:52:28
2005
@@ -5,10 +5,4 @@
<transit:import uri="artifact:template:dpml/magic/reactor"/>
- <target name="patch">
- <replace token="net.dpml.meta.info" value="net.dpml.composition.info"
dir=".">
- <include name="**/*.java"/>
- </replace>
- </target>
-
</project>
Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
Thu Jun 30 22:52:28 2005
@@ -228,42 +228,6 @@
private boolean getThreadSafeCapability( Class subject ) throws
IntrospectionException
{
return m_threadsafe;
-
- /*
- try
- {
- Field field = subject.getDeclaredField(
"TYPE_THREADSAFE_CAPABLE" );
- if( Modifier.isStatic( field.getModifiers() ) )
- {
- return field.getBoolean( null );
- }
- else
- {
- return false;
- }
- }
- catch( NoSuchFieldException e )
- {
- return false;
- }
- catch( IllegalArgumentException e )
- {
- final String error =
- "The component type ["
- + subject.getName()
- + "] declares an invalid static field TYPE_THREADSAFE_POLICY
declaration. "
- + "Could not convert the value to a boolean.";
- throw new IntrospectionException( error );
- }
- catch( Exception e )
- {
- final String error =
- "An unexpected error occured while resolving the static
TYPE_THREADSAFE_POLICY field on the type ["
- + subject.getName()
- + "].";
- throw new IntrospectionException( error );
- }
- */
}
private String getLifestylePreference( Class subject, boolean threadsafe
) throws IntrospectionException
@@ -283,97 +247,11 @@
return InfoDescriptor.TRANSIENT;
}
}
-
- /*
- try
- {
- Field field = subject.getDeclaredField(
"TYPE_LIFESTYLE_PREFERENCE" );
- if( Modifier.isStatic( field.getModifiers() ) )
- {
- return (String) field.get( null );
- }
- else
- {
- if( threadsafe )
- {
- return InfoDescriptor.SINGLETON;
- }
- else
- {
- return InfoDescriptor.TRANSIENT;
- }
- }
- }
- catch( NoSuchFieldException e )
- {
- if( threadsafe )
- {
- return InfoDescriptor.SINGLETON;
- }
- else
- {
- return InfoDescriptor.TRANSIENT;
- }
- }
- catch( IllegalArgumentException e )
- {
- final String error =
- "The component type ["
- + subject.getName()
- + "] declares an invalid static field
TYPE_LIFESTYLE_PREFERENCE declaration. "
- + "Could not convert the value to an string.";
- throw new IntrospectionException( error );
- }
- catch( Exception e )
- {
- final String error =
- "An unexpected error occured while resolving the static
TYPE_LIFESTYLE_PREFERENCE field on the type ["
- + subject.getName()
- + "].";
- throw new IntrospectionException( error );
- }
- */
}
private String getCollectionPolicyPreference( Class subject ) throws
IntrospectionException
{
return m_collection;
-
- /*
- try
- {
- Field field = subject.getDeclaredField(
"TYPE_COLLECTION_PREFERENCE" );
- if( Modifier.isStatic( field.getModifiers() ) )
- {
- return (String) field.get( null );
- }
- else
- {
- return null;
- }
- }
- catch( NoSuchFieldException e )
- {
- return null;
- }
- catch( IllegalArgumentException e )
- {
- final String error =
- "The component type ["
- + subject.getName()
- + "] declares an invalid static field
TYPE_COLLECTION_PREFERENCE declaration. "
- + "Could not convert the value to an string.";
- throw new IntrospectionException( error );
- }
- catch( Exception e )
- {
- final String error =
- "An unexpected error occured while resolving the static
TYPE_COLLECTION_PREFERENCE field on the type ["
- + subject.getName()
- + "].";
- throw new IntrospectionException( error );
- }
- */
}
private String getConfigurationSchema( Class subject ) throws
IntrospectionException
@@ -587,7 +465,7 @@
for( int i=0; i<keys.length; i++ )
{
String key = keys[i];
- Operation[] operations = getOperations( key, methods );
+ Operation[] operations = getOperations( subject, key,
methods );
PartDescriptor descriptor = new PartDescriptor( key,
operations );
descriptors[i] = descriptor;
}
@@ -596,7 +474,7 @@
}
}
- private Operation[] getOperations( String key, Method[] methods ) throws
IntrospectionException
+ private Operation[] getOperations( Class subject, String key, Method[]
methods ) throws IntrospectionException
{
ArrayList list = new ArrayList();
for( int i=0; i<methods.length; i++ )
@@ -604,14 +482,14 @@
Method method = methods[i];
if( key.equals( PartDescriptor.getPartKey( method ) ) )
{
- Operation operation = getOperation( key, method );
+ Operation operation = getOperation( subject, key, method );
list.add( operation );
}
}
return (Operation[]) list.toArray( new Operation[0] );
}
- private Operation getOperation( String key, Method method ) throws
IntrospectionException
+ private Operation getOperation( Class subject, String key, Method method
) throws IntrospectionException
{
final String name = method.getName();
final int semantic = PartDescriptor.getPartSemantic( method );
@@ -628,19 +506,9 @@
validateNonNullReturnType( method );
validateAtMostOneParameter( method );
}
- else if( PartDescriptor.PROVIDER_KEY.equals( postfix ) )
- {
- validateNonNullReturnType( method );
- validateAtMostOneParameter( method );
- }
- else if( PartDescriptor.MODEL_KEY.equals( postfix ) )
- {
- validateNonNullReturnType( method );
- validateNoParameters( method );
- }
else
{
- validateSelectPattern( method );
+ validateSelectPattern( subject, method );
}
return new Operation( PartDescriptor.GET, postfix, type );
}
@@ -1016,21 +884,21 @@
}
}
- private void validateSelectPattern( Method method )
+ private void validateSelectPattern( Class subject, Method method )
throws IntrospectionException
{
Class[] parameterTypes = method.getParameterTypes();
int n = parameterTypes.length;
- if( n == 2 )
+ if( n == 1 )
{
- Class b = parameterTypes[1];
+ Class b = parameterTypes[0];
if( false == Boolean.TYPE.isAssignableFrom( b ) )
{
String name = method.getName();
final String error =
- "Second parameter in the select method ["
- + name
- + "] is not assignable to a boolean.";
+ "Part accessor ["
+ + subject.getName() + "#" + name
+ + "] is declaring an illegal non-boolean parameter.";
throw new IntrospectionException( error );
}
}
Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
Thu Jun 30 22:52:28 2005
@@ -38,7 +38,6 @@
{
private String m_key;
private ClassLoader m_classloader;
- private URI m_uri;
/**
* Set the key that this directive qualifies.
Modified: development/main/metro/composition/control/build.xml
==============================================================================
--- development/main/metro/composition/control/build.xml (original)
+++ development/main/metro/composition/control/build.xml Thu Jun 30
22:52:28 2005
@@ -22,8 +22,4 @@
</rmic>
</target>
- <target name="package" depends="standard.package">
- <x:export class="net.dpml.composition.runtime.CompositionManager"/>
- </target>
-
</project>
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
Thu Jun 30 22:52:28 2005
@@ -27,11 +27,7 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URISyntaxException;
-import java.rmi.RemoteException;
import java.util.ArrayList;
-import java.util.Observable;
-import java.util.Observer;
-import java.util.Map.Entry;
import net.dpml.logging.Logger;
@@ -40,12 +36,11 @@
import net.dpml.composition.data.ComponentProfile;
import net.dpml.composition.data.ValueDirective;
-import net.dpml.composition.runtime.ComponentEntry;
+import net.dpml.composition.runtime.ComponentHandler;
+import net.dpml.composition.runtime.ValueHandler;
import net.dpml.composition.runtime.ValueController;
import net.dpml.composition.runtime.ComponentController;
-
-import net.dpml.composition.model.CompositionModel;
-import net.dpml.composition.model.ValueModel;
+import net.dpml.composition.runtime.CompositionHandler;
import net.dpml.part.control.ControllerContext;
import net.dpml.part.control.HandlerNotFoundException;
@@ -56,9 +51,9 @@
import net.dpml.part.control.Disposable;
import net.dpml.part.control.LifecycleException;
import net.dpml.part.control.PartNotFoundException;
-import net.dpml.part.model.Model;
-import net.dpml.part.model.ModelException;
import net.dpml.part.manager.Component;
+import net.dpml.part.manager.ComponentException;
+import net.dpml.part.manager.Container;
import net.dpml.part.part.Part;
import net.dpml.transit.model.ContentModel;
@@ -69,7 +64,7 @@
* @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 CompositionController extends CompositionPartHandler implements
Controller, Observer
+public class CompositionController extends CompositionPartHandler implements
Controller
{
//--------------------------------------------------------------------
// static
@@ -82,10 +77,12 @@
//--------------------------------------------------------------------
private final ControllerContext m_context;
- private final LifestyleHandler m_lifestyleHandler;
private final ValueController m_valueController;
+ private final ComponentController m_componentController;
private final Logger m_logger;
+ //private final LifestyleHandler m_lifestyleHandler;
+
//--------------------------------------------------------------------
// constructor
//--------------------------------------------------------------------
@@ -108,9 +105,11 @@
m_logger = m_context.getLogger();
m_valueController = new ValueController( this );
+ m_componentController = new ComponentController( m_logger, this );
+
m_logger.info( "metro controller established" );
- ComponentController manager = new ComponentController( m_logger,
this );
- m_lifestyleHandler = new LifestyleHandler( m_logger, manager );
+
+ //m_lifestyleHandler = new LifestyleHandler( m_logger,
m_componentController );
}
Logger getLogger()
@@ -118,6 +117,16 @@
return m_logger;
}
+ public ComponentController getComponentController()
+ {
+ return m_componentController;
+ }
+
+ public ValueController getValueController()
+ {
+ return m_valueController;
+ }
+
//--------------------------------------------------------------------
// PartHandler
//--------------------------------------------------------------------
@@ -128,31 +137,13 @@
*/
public Controller getController()
{
- return getCompositionController();
- }
-
- //--------------------------------------------------------------------
- // Observer
- //--------------------------------------------------------------------
-
- public void update( Observable observable, Object event )
- {
+ return this;
}
//--------------------------------------------------------------------
// Controller
//--------------------------------------------------------------------
- public File getWorkingDirectory()
- {
- return m_context.getWorkingDirectory();
- }
-
- public File getTempDirectory()
- {
- return m_context.getTempDirectory();
- }
-
/**
* Return a system resource relative to the supplied urn. Standard
* urn values are listed in the following table.
@@ -160,16 +151,16 @@
* <li>system:context.uri</li>
* <li>system:work.dir</li>
* <li>system:temp.dir</li>
- * <li>model:name</li>
- * <li>model:uri</li>
- * <li>model:partition</li>
+ * <li>component:name</li>
+ * <li>component:uri</li>
+ * <li>component:partition</li>
* </ol>
* @param model the model
* @param urn the uniform resource identifier
* @return the resource
* @exception IllegalArgumentException if the urn is not recognized
*/
- public Object getResource( Model model, URI urn )
+ public Object getResource( Component component, URI urn )
{
String scheme = urn.getScheme();
String key = urn.getSchemeSpecificPart();
@@ -181,11 +172,11 @@
}
else if( "work.dir".equals( key ) )
{
- return m_context.getWorkingDirectory();
+ return getWorkingDirectory();
}
else if( "temp.dir".equals( key ) )
{
- return m_context.getTempDirectory();
+ return getTempDirectory();
}
else
{
@@ -196,36 +187,23 @@
throw new IllegalArgumentException( error );
}
}
- else if( "model".equals( scheme ) )
+ else if( "component".equals( scheme ) )
{
- try
+ if( "name".equals( key ) )
+ {
+ return component.getName();
+ }
+ else if( "uri".equals( key ) )
{
- if( "partition".equals( key ) )
- {
- return model.getPartition();
- }
- if( "name".equals( key ) )
- {
- return model.getKey();
- }
- else if( "uri".equals( key ) )
- {
- return model.getURI();
- }
- else
- {
- final String error =
- "Requested model resource urn ["
- + urn
- + "] is not recognized.";
- throw new IllegalArgumentException( error );
- }
+ return component.getURI();
}
- catch( RemoteException e )
+ else
{
final String error =
- "Remote error occured while resolving modle value.";
- throw new ControlRuntimeException( CONTROLLER_URI, error, e
);
+ "Requested component resource urn ["
+ + urn
+ + "] is not recognized.";
+ throw new IllegalArgumentException( error );
}
}
else
@@ -238,254 +216,90 @@
}
}
- public String getName()
- {
- return getPartition().toASCIIString();
- }
-
- public Model getPart( CompositionModel model, String key )
+ public File getWorkingDirectory()
{
- return model.getPartsTable().getModel( key );
+ return m_context.getWorkingDirectory();
}
- public Component getContextEntry( CompositionModel model, String key )
+ public File getTempDirectory()
{
- return model.getContextTable().getEntry( key );
+ return m_context.getTempDirectory();
}
- /**
- * Add a part to the collection of parts managed by this controller.
- *
- * @param uri a uri identifying the part to add
- * @return the model of the part
- */
- public Model getModel( URI uri )
- throws IOException, DelegationException, ModelException,
PartNotFoundException,
- HandlerNotFoundException, DelegationException
+ public String getName()
{
- return getModel( uri, null );
+ return getPartition().toASCIIString();
}
/**
- * Return a model using a par turi and key.
+ * Construct a new top-level component.
*
* @param uri a uri identifying the part
* @param key the key to assign to the model
* @return the model of the part
*/
- public Model getModel( URI uri, String key )
- throws IOException, DelegationException, ModelException,
PartNotFoundException,
- HandlerNotFoundException, DelegationException
+ public Component newComponent( URI uri )
+ throws IOException, ComponentException, PartNotFoundException,
HandlerNotFoundException, DelegationException
{
- m_logger.debug( "loading part " + uri );
- Part part = loadPart( uri );
- ClassLoader anchor = net.dpml.part.part.Part.class.getClassLoader();
- return getModel( anchor, part, key );
- }
+ m_logger.debug( "loading component " + uri );
- /**
- * Return the model for a supplied part.
- *
- * @param classloader the parent classloader
- * @param part the part datastructure
- * @param key the key to assign to the model
- * @return the model
- */
- public Model getModel( ClassLoader classloader, Part part, String key )
- throws ModelException, HandlerNotFoundException, DelegationException
- {
- if( isRecognizedPart( part ) )
- {
- return getModel( null, classloader, part, key );
- }
- else
- {
- Controller controller = getPartHandler( part );
- return controller.getModel( classloader, part, key );
- }
- }
+ ClassLoader classloader =
net.dpml.part.part.Part.class.getClassLoader();
- /**
- * Return a nested model for a supplied part using enclosing model.
- *
- * @param model the enclosing model
- * @param classloader the parent classloader
- * @param part the part datastructure
- * @param key the key to assign to the model
- * @return the model
- */
- public Model getModel( CompositionModel model, ClassLoader classloader,
Part part, String key )
- throws ModelException
- {
- if( part instanceof ComponentProfile )
- {
- final ComponentProfile profile = (ComponentProfile) part;
- getLogger().debug( "creating nested model using " + profile );
- URI partition = getPartition( model );
- ClassLoader parent = getClassLoader( partition, classloader,
profile );
- try
- {
- if( null == model )
- {
- if( null == key )
- {
- return new CompositionModel( this, partition,
parent, profile );
- }
- else
- {
- return new CompositionModel( this, partition,
parent, profile, key );
- }
- }
- else
- {
- return new CompositionModel( this, model, partition,
parent, profile, key );
- }
- }
- catch( RemoteException e )
- {
- final String error =
- "A remote exception occured while attempting to construct
a composition model.";
- throw new ControlRuntimeException( CONTROLLER_URI, error, e
);
- }
- }
- else if( part instanceof ValueDirective )
- {
- final ValueDirective directive = (ValueDirective) part;
- getLogger().debug( "creating nested value model using " +
directive );
- URI partition = getPartition( model );
- try
- {
- return new ValueModel(
- m_logger, key, this, partition, m_valueController,
classloader, directive, model );
- }
- catch( RemoteException e )
- {
- final String error =
- "A remote exception occured while attempting to construct
a value model.";
- throw new ControlRuntimeException( CONTROLLER_URI, error, e
);
- }
- }
- else
- {
- final String error =
- "The request to construct a model for the part type ["
- + part.getClass().getName()
- + "] is not supported.";
- throw new UnsupportedOperationException( error );
- }
- }
-
- /**
- * Return a nested component for a supplied part.
- *
- * @param classloader the parent classloader
- * @param part the part datastructure
- * @param key the key to assign to the model
- * @return the model
- */
- public Component getComponent( ClassLoader classloader, Part part,
String key )
- throws ModelException, HandlerNotFoundException, DelegationException
- {
- return getComponent( null, classloader, part, key );
- }
-
- /**
- * Return a nested component for a supplied part using enclosing model.
- *
- * @param model the enclosing model
- * @param classloader the parent classloader
- * @param part the part datastructure
- * @param key the key to assign to the model
- * @return the model
- */
- public Component getComponent(
- CompositionModel model, ClassLoader classloader, Part part, String key
)
- throws ModelException, HandlerNotFoundException, DelegationException
- {
+ Part part = loadPart( uri );
if( isRecognizedPart( part ) )
{
- Model componentModel = getModel( model, classloader, part, key );
- return getComponent( componentModel );
+ return newComponent( classloader, null, part, null );
}
else
{
Controller controller = getPartHandler( part );
- return controller.getComponent( classloader, part, key );
+ return controller.newComponent( classloader, null, part, null );
}
}
/**
- * Return a default instance model.
- *
- * @param model the reference model
- * @return the model
+ * Creation of a new component using a supplied value directive and
identifier.
+ * @param part the value directive
+ * @param id the value handler identifier
+ * @return the value handler component
*/
- public Component getComponent( Model model )
- {
- if( model instanceof ValueModel )
- {
- ValueModel m = (ValueModel) model;
- try
- {
- return m.getComponent();
- }
- catch( RemoteException e )
- {
- final String error =
- "A remote exception occured while attempting to resolve a
component for a value model.";
- throw new ControlRuntimeException( CONTROLLER_URI, error, e
);
- }
- }
- else
- {
- return getComponentEntry( model, null );
- }
- }
+ public Component newComponent( ClassLoader classloader, Component
parent, Part part, String name )
+ throws ComponentException, HandlerNotFoundException,
DelegationException
- /**
- * Return a default instance model.
- *
- * @param model the reference model
- * @param key the instance identity
- * @return the model
- */
- public Component getComponent( Model model, Object key )
- {
- return getComponentEntry( model, key );
- }
-
- /**
- * Return a default instance model.
- *
- * @param model the reference model
- * @param key the instance identity
- * @return the model
- */
- public ComponentEntry getComponentEntry( Model model, Object key )
{
- if( null == model )
- {
- throw new NullPointerException( "model" );
- }
- if( model instanceof CompositionModel )
+ URI partition = getPartition( parent );
+ if( isRecognizedPart( part ) )
{
- CompositionModel m = (CompositionModel) model;
- if( null == key )
+ if( part instanceof ValueDirective )
{
- return m_lifestyleHandler.aquire( m );
+ ValueDirective directive = (ValueDirective) part;
+ String defaultName = directive.getKey();
+ String theName = getName( defaultName, name );
+ URI id = createURI( partition, theName );
+ return new ValueHandler( m_logger, this, classloader, id,
directive, parent );
+ }
+ else if( part instanceof ComponentProfile )
+ {
+ ComponentProfile profile = (ComponentProfile) part;
+ String defaultName = profile.getName();
+ String theName = getName( defaultName, name );
+ URI id = createURI( partition, theName );
+ ClassLoader loader = getClassLoader( classloader, id,
profile );
+ return new CompositionHandler( m_logger, this, loader, id,
profile, parent );
}
else
{
- return m_lifestyleHandler.aquire( m, key );
+ final String error =
+ "Unsupported part implementation class ["
+ + part.getClass().getName()
+ + "] passed to newComponent/4.";
+ throw new UnsupportedOperationException( error );
}
}
else
{
- final String error =
- "Unsupported model implementation class ["
- + model.getClass().getName()
- + "] passed to resolve/3.";
- throw new UnsupportedOperationException( error );
+ Controller controller = getPartHandler( part );
+ return controller.newComponent( classloader, parent, part, name
);
}
}
@@ -493,36 +307,32 @@
// CompositionController
//--------------------------------------------------------------------
- /**
- * Load the model controller.
- * @return the controller
- */
- public CompositionController getCompositionController()
- {
- return this;
- }
-
private URI getPartition()
{
return m_context.getURI();
}
- private URI getPartition( Model model )
+ private URI getPartition( Component component )
{
- if( null == model )
+ if( null == component )
{
return getPartition();
}
else
{
- try
- {
- return model.getURI();
- }
- catch( RemoteException e )
- {
- throw new ControlRuntimeException( CONTROLLER_URI,
e.getMessage(), e.getCause() );
- }
+ return component.getURI();
+ }
+ }
+
+ private String getName( String defaultValue, String preferredValue )
+ {
+ if( null != preferredValue )
+ {
+ return preferredValue;
+ }
+ else
+ {
+ return defaultValue;
}
}
@@ -530,7 +340,7 @@
// private
//--------------------------------------------------------------------
- private ClassLoader getClassLoader( URI partition, ClassLoader parent,
ComponentProfile profile )
+ private ClassLoader getClassLoader( ClassLoader parent, URI partition,
ComponentProfile profile )
{
final String name = profile.getName();
final ClassLoaderDirective cld = profile.getClassLoaderDirective();
@@ -724,4 +534,205 @@
return null;
}
}
+
+ //public Model getPart( CompositionModel model, String key )
+ //{
+ // return model.getPartsTable().getModel( key );
+ //}
+
+ //public Component getContextEntry( CompositionModel model, String key )
+ //{
+ // return model.getContextTable().getEntry( key );
+ //}
+
+ /**
+ * Add a part to the collection of parts managed by this controller.
+ *
+ * @param uri a uri identifying the part to add
+ * @return the model of the part
+ */
+ //public Model getModel( URI uri )
+ // throws IOException, DelegationException, ModelException,
PartNotFoundException,
+ // HandlerNotFoundException, DelegationException
+ //{
+ // return getModel( uri, null );
+ //}
+
+ /**
+ * Return a model using a par turi and key.
+ *
+ * @param uri a uri identifying the part
+ * @param key the key to assign to the model
+ * @return the model of the part
+ */
+ //public Model getModel( URI uri, String key )
+ // throws IOException, DelegationException, ModelException,
PartNotFoundException,
+ // HandlerNotFoundException, DelegationException
+ //{
+ // m_logger.debug( "loading part " + uri );
+ // Part part = loadPart( uri );
+ // ClassLoader anchor =
net.dpml.part.part.Part.class.getClassLoader();
+ // return getModel( anchor, part, key );
+ //}
+
+ /**
+ * Return the model for a supplied part.
+ *
+ * @param classloader the parent classloader
+ * @param part the part datastructure
+ * @param key the key to assign to the model
+ * @return the model
+ */
+ //public Model getModel( ClassLoader classloader, Part part, String key
)
+ // throws ModelException, HandlerNotFoundException, DelegationException
+ //{
+ // if( isRecognizedPart( part ) )
+ // {
+ // return getModel( null, classloader, part, key );
+ // }
+ // else
+ // {
+ // Controller controller = getPartHandler( part );
+ // return controller.getModel( classloader, part, key );
+ // }
+ //}
+
+ /**
+ * Return a nested model for a supplied part using enclosing model.
+ *
+ * @param model the enclosing model
+ * @param classloader the parent classloader
+ * @param part the part datastructure
+ * @param key the key to assign to the model
+ * @return the model
+ */
+ //public Model getModel( CompositionModel model, ClassLoader
classloader, Part part, String key )
+ // throws ModelException
+ //{
+ // if( part instanceof ComponentProfile )
+ // {
+ // final ComponentProfile profile = (ComponentProfile) part;
+ // getLogger().debug( "creating nested model using " + profile );
+ // URI partition = getPartition( model );
+ // ClassLoader parent = getClassLoader( partition, classloader,
profile );
+ // try
+ // {
+ // if( null == model )
+ // {
+ // if( null == key )
+ // {
+ // return new CompositionModel( this, partition,
parent, profile );
+ // }
+ // else
+ // {
+ // return new CompositionModel( this, partition,
parent, profile, key );
+ // }
+ // }
+ // else
+ // {
+ // return new CompositionModel( this, model, partition,
parent, profile, key );
+ // }
+ // }
+ // catch( RemoteException e )
+ // {
+ // final String error =
+ // "A remote exception occured while attempting to
construct a composition model.";
+ // throw new ControlRuntimeException( CONTROLLER_URI, error,
e );
+ // }
+ // }
+ // else if( part instanceof ValueDirective )
+ // {
+ // final ValueDirective directive = (ValueDirective) part;
+ // getLogger().debug( "creating nested value model using " +
directive );
+ // URI partition = getPartition( model );
+ // URI uri = createURI( partition, key );
+ // try
+ // {
+ // return new ValueModel(
+ // key, partition, uri, classloader, directive, model );
+ // }
+ // catch( RemoteException e )
+ // {
+ // final String error =
+ // "A remote exception occured while attempting to
construct a value model.";
+ // throw new ControlRuntimeException( CONTROLLER_URI, error,
e );
+ // }
+ // }
+ // else
+ // {
+ // final String error =
+ // "The request to construct a model for the part type ["
+ // + part.getClass().getName()
+ // + "] is not supported.";
+ // throw new UnsupportedOperationException( error );
+ // }
+ //}
+
+ /**
+ * Return a nested component for a supplied part.
+ *
+ * @param classloader the parent classloader
+ * @param part the part datastructure
+ * @param key the key to assign to the model
+ * @return the model
+ */
+ //public Component getComponent( ClassLoader classloader, Part part,
String key )
+ // throws ModelException, HandlerNotFoundException, DelegationException
+ //{
+ // return getComponent( null, classloader, part, key );
+ //}
+
+ /**
+ * Return a nested component for a supplied part using enclosing model.
+ *
+ * @param model the enclosing model
+ * @param classloader the parent classloader
+ * @param part the part datastructure
+ * @param key the key to assign to the model
+ * @return the model
+ */
+ //public Component getComponent(
+ // CompositionModel model, ClassLoader classloader, Part part, String
key )
+ // throws ModelException, HandlerNotFoundException, DelegationException
+ //{
+ // if( isRecognizedPart( part ) )
+ // {
+ // Model componentModel = getModel( model, classloader, part, key
);
+ // return getComponent( componentModel );
+ // }
+ // else
+ // {
+ // Controller controller = getPartHandler( part );
+ // return controller.getComponent( classloader, part, key );
+ // }
+ //}
+
+ /**
+ * Return a default instance model.
+ *
+ * @param model the reference model
+ * @return the model
+ */
+ //public Component getComponent( Model model )
+ //{
+ // if( model instanceof ValueModel )
+ // {
+ // ValueModel m = (ValueModel) model;
+ // try
+ // {
+ // return new ValueHandler( this, m_logger, m,
m_valueController );
+ // }
+ // catch( Throwable e )
+ // {
+ // final String error =
+ // "An unexpected exception occured while attempting to
resolve a component for a value model.";
+ // throw new ControlRuntimeException( CONTROLLER_URI, error,
e );
+ // }
+ // }
+ // else
+ // {
+ // return getComponentHandler( model, null );
+ // }
+ //}
+
}
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/data/ComponentProfile.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/data/ComponentProfile.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/data/ComponentProfile.java
Thu Jun 30 22:52:28 2005
@@ -155,8 +155,13 @@
throws NullPointerException
{
this(
- name, DeploymentProfile.DEFAULT,
InfoDescriptor.UNDEFINED_COLLECTION, "request", classname, null, null, null,
- null, null, null, null, Mode.IMPLICIT );
+ name,
+ DeploymentProfile.DEFAULT,
+ InfoDescriptor.UNDEFINED_COLLECTION,
+ "request",
+ classname,
+ null, null, null, null, null, null, null,
+ Mode.IMPLICIT );
}
/**
Added:
development/main/metro/composition/control/src/main/net/dpml/composition/data/TODO.txt
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/data/TODO.txt
Thu Jun 30 22:52:28 2005
@@ -0,0 +1,4 @@
+
+
+Rename xxxProfile to xxxDirective.
+
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/data/ValueDirective.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/data/ValueDirective.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/data/ValueDirective.java
Thu Jun 30 22:52:28 2005
@@ -80,6 +80,7 @@
m_key = key;
m_classname = classname;
m_local = value;
+
m_values = new Value[0];
}
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/info/PartDescriptor.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/info/PartDescriptor.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/info/PartDescriptor.java
Thu Jun 30 22:52:28 2005
@@ -65,8 +65,6 @@
public static final String CONTEXT_MAP_KEY = "ContextMap";
public static final String CONTEXT_MANAGER_KEY = "ContextManager";
public static final String COMPONENT_KEY = "Component";
- public static final String PROVIDER_KEY = "Provider";
- public static final String MODEL_KEY = "Model";
public static String toString( int semantic )
{
@@ -95,14 +93,6 @@
{
return CONTEXT_MAP_KEY;
}
- else if( name.endsWith( MODEL_KEY ) )
- {
- return MODEL_KEY;
- }
- else if( name.endsWith( PROVIDER_KEY ) )
- {
- return PROVIDER_KEY;
- }
else if( name.endsWith( COMPONENT_KEY ) )
{
return COMPONENT_KEY;
@@ -159,20 +149,6 @@
String substring = name.substring( 0, j );
return formatKey( substring, 3 );
}
- else if( name.endsWith( MODEL_KEY ) )
- {
- int n = MODEL_KEY.length();
- int j = name.length() - n;
- String substring = name.substring( 0, j );
- return formatKey( substring, 3 );
- }
- else if( name.endsWith( PROVIDER_KEY ) )
- {
- int n = PROVIDER_KEY.length();
- int j = name.length() - n;
- String substring = name.substring( 0, j );
- return formatKey( substring, 3 );
- }
else if( name.endsWith( COMPONENT_KEY ) )
{
int n = COMPONENT_KEY.length();
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/info/Type.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/info/Type.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/info/Type.java
Thu Jun 30 22:52:28 2005
@@ -27,7 +27,7 @@
import net.dpml.configuration.Configuration;
-import net.dpml.part.model.ModelException;
+import net.dpml.part.manager.ComponentException;
/**
* This class contains the meta information about a particular
@@ -53,7 +53,7 @@
{
static final long serialVersionUID = 1L;
- public static Type loadType( Class clazz ) throws ModelException
+ public static Type loadType( Class clazz ) throws ComponentException
{
String path = clazz.getName().replace( '.', '/' ) + ".type";
URL url = clazz.getClassLoader().getResource( path );
@@ -76,7 +76,7 @@
final String error =
"Unexpected error occured while attempting to load a type."
+ "\nResource path: " + path;
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
}
Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/AbstractHandler.java
(from r2941,
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/AbstractComponent.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/AbstractComponent.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/AbstractHandler.java
Thu Jun 30 22:52:28 2005
@@ -29,6 +29,7 @@
import net.dpml.part.manager.Component;
import net.dpml.part.manager.AvailabilityEvent;
import net.dpml.part.manager.AvailabilityListener;
+
import net.dpml.part.state.StateEvent;
import net.dpml.part.state.StateListener;
import net.dpml.part.state.State;
@@ -42,7 +43,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id: LifestyleManager.java 259 2004-10-30 07:24:40Z mcconnell $
*/
-public abstract class AbstractComponent extends WeakEventProducer implements
Component
+public abstract class AbstractHandler extends WeakEventProducer implements
Component
{
private static final State NULL_STATE = new State( true );
@@ -50,7 +51,7 @@
private boolean m_initialized = false;
- public AbstractComponent( Logger logger )
+ public AbstractHandler( Logger logger )
{
super();
m_logger = logger;
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/Appliance.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/Appliance.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/Appliance.java
Thu Jun 30 22:52:28 2005
@@ -32,19 +32,18 @@
/**
* An appliance is an invocation handler maintained by a component. It is
used
- * during the construction of proxies to the component model holding the
appliance.
+ * during the construction of proxies to the component holding the appliance.
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id: ApplianceInvocationHandler.java 2106 2005-03-21 18:46:10Z
mcconnell AT dpml.net $
*/
-final class Appliance
- implements InvocationHandler, AvailabilityListener, Disposable
+final class Appliance implements InvocationHandler, AvailabilityListener,
Disposable
{
//-------------------------------------------------------------------
// state
//-------------------------------------------------------------------
- private final ComponentEntry m_component;
+ private final ComponentHandler m_component;
private boolean m_available = true;
private boolean m_disposed = false;
@@ -55,9 +54,9 @@
/**
* Create a proxy invocation handler.
*
- * @param component the component model
+ * @param component the component
*/
- Appliance( ComponentEntry component )
+ Appliance( ComponentHandler component )
{
assertNotNull( component, "component" );
m_component = component;
@@ -96,8 +95,8 @@
{
final String error =
"Component is not currently available."
- + "\nComponent URI: " + m_component.getURI()
- + "\nClass: " +
m_component.getCompositionModel().getDeploymentClass().getName();
+ + "\nComponent: " + m_component.getURI()
+ + "\nClass: " + m_component.getDeploymentClass().getName();
throw new ResourceUnavailableException( error );
}
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentController.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentController.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentController.java
Thu Jun 30 22:52:28 2005
@@ -41,14 +41,13 @@
import net.dpml.logging.Logger;
-import net.dpml.composition.model.CompositionModel;
import net.dpml.composition.control.CompositionController;
import net.dpml.part.control.ControlException;
import net.dpml.part.control.ControlRuntimeException;
import net.dpml.part.control.Disposable;
import net.dpml.part.manager.Component;
-import net.dpml.part.model.DuplicateKeyException;
+import net.dpml.part.manager.DuplicateKeyException;
import net.dpml.part.state.State;
import net.dpml.part.state.Transition;
import net.dpml.part.state.ResourceUnavailableException;
@@ -80,10 +79,9 @@
{
m_controller = controller;
m_logger = logger;
+
m_lifecycleHandler = new LifecycleHandler( logger, controller );
- URI uri = controller.getURI();
- String path = uri.getSchemeSpecificPart();
- m_uri = CompositionController.createURI( "manager", path );
+ m_uri = controller.getURI();
}
public URI getURI()
@@ -101,28 +99,27 @@
return m_logger;
}
- public Object resolve( Component component ) throws Exception
+ public Object resolve( ComponentHandler component ) throws Exception
{
return resolve( component, true );
}
public Object resolve( Component component, boolean policy ) throws
Exception
{
- if( component instanceof ComponentEntry )
+ if( component instanceof ComponentHandler )
{
- ComponentEntry entry = (ComponentEntry) component;
+ ComponentHandler handler = (ComponentHandler) component;
if( policy )
{
- return entry.getProxy();
+ return handler.getProxy();
}
else
{
- Object instance = getInstance( entry );
- if( false == entry.isInitialized() )
+ if( false == handler.isInitialized() )
{
- initialize( entry );
+ initialize( handler );
}
- return instance;
+ return getInstance( handler );
}
}
else
@@ -173,17 +170,17 @@
*/
public void initialize( Component component ) throws Exception
{
- if( component instanceof ComponentEntry )
+ if( component instanceof ComponentHandler )
{
- ComponentEntry entry = (ComponentEntry) component;
+ ComponentHandler entry = (ComponentHandler) component;
initializeComponent( entry );
}
else
{
final String error =
- "Unsupported component model implementation class."
+ "Unsupported component implementation class."
+ "\nComponent: " + component.getURI()
- + "\nModel Class: " + component.getClass().getName()
+ + "\nClass: " + component.getClass().getName()
+ "\nMethod: initialize/1";
throw new IllegalArgumentException( error );
}
@@ -202,7 +199,7 @@
* @exception Exception if an error is raised by a handler assigned to
* and invoked initialization transition
*/
- private synchronized void initializeComponent( ComponentEntry component
) throws Exception
+ private synchronized void initializeComponent( ComponentHandler
component ) throws Exception
{
if( component.isInitialized() )
{
@@ -212,7 +209,7 @@
Object instance = getInstance( component );
List visited = new LinkedList();
State graph = component.getStateGraph();
- Class subject = component.getCompositionModel().getDeploymentClass();
+ Class subject = component.getDeploymentClass();
validate( subject, graph );
boolean flag = true;
while( flag )
@@ -257,7 +254,7 @@
component.setInitialized( true );
}
- private Object getInstance( ComponentEntry component )
+ private Object getInstance( ComponentHandler component )
{
Object instance = component.getLocalInstance();
if( null == instance)
@@ -272,9 +269,8 @@
URI uri = getURI();
final String error =
"Unable to establish a component instance."
- + "\nComponent URI: " + component.getURI()
- + "\nComponent Model: " +
component.getCompositionModel().getURI()
- + "\nClass: " +
component.getCompositionModel().getDeploymentClass();
+ + "\nComponent: " + component.getURI()
+ + "\nClass: " + component.getDeploymentClass();
throw new ControlRuntimeException( uri, error, e );
}
}
@@ -414,9 +410,9 @@
*/
public State apply( Component component, String key ) throws Exception
{
- if( component instanceof ComponentEntry )
+ if( component instanceof ComponentHandler )
{
- ComponentEntry entry = (ComponentEntry) component;
+ ComponentHandler entry = (ComponentHandler) component;
if( false == entry.isInitialized() )
{
initialize( entry );
@@ -436,7 +432,7 @@
}
}
- private Transition getNamedTransition( ComponentEntry component, String
key )
+ private Transition getNamedTransition( ComponentHandler component,
String key )
{
State state = component.getState();
try
@@ -445,7 +441,7 @@
}
catch( NoSuchTransitionException e )
{
- String classname =
component.getCompositionModel().getDeploymentClass().getName();
+ String classname = component.getDeploymentClass().getName();
final String error =
"Invalid transition key ["
+ key
@@ -474,7 +470,7 @@
* @return TRUE if the transition was executed
* @exception if a error occurs in transition execution
*/
- private boolean applyTransition( ComponentEntry entry, Transition
transition ) throws Exception
+ private boolean applyTransition( ComponentHandler entry, Transition
transition ) throws Exception
{
if( null == entry )
{
@@ -527,9 +523,9 @@
*/
public void execute( Component component, String key ) throws Exception
{
- if( component instanceof ComponentEntry )
+ if( component instanceof ComponentHandler )
{
- ComponentEntry entry = (ComponentEntry) component;
+ ComponentHandler entry = (ComponentHandler) component;
if( false == entry.isInitialized() )
{
initialize( entry );
@@ -565,7 +561,7 @@
}
}
- private Operation getNamedOperation( ComponentEntry component, String
key )
+ private Operation getNamedOperation( ComponentHandler component, String
key )
{
State state = component.getState();
try
@@ -574,7 +570,7 @@
}
catch( NoSuchOperationException e )
{
- String classname =
component.getCompositionModel().getDeploymentClass().getName();
+ String classname = component.getDeploymentClass().getName();
final String error =
"Invalid operation key ["
+ key
@@ -607,7 +603,7 @@
* @param target the target of the transition
* @excetion Exception of an invocation or handler error occurs
*/
- private void execution( ComponentEntry entry, URI uri, State state,
State target ) throws Exception
+ private void execution( ComponentHandler entry, URI uri, State state,
State target ) throws Exception
{
if( null == uri )
{
@@ -632,8 +628,24 @@
Object instance = getInstance( entry );
Class c = instance.getClass();
Method method = locateMethod( c, spec );
- Class[] parameters = method.getParameterTypes();
- Object[] args = resolveArguments( entry, parameters, state,
target );
+ Object[] args = null;
+ try
+ {
+ Class[] parameters = method.getParameterTypes();
+ args = resolveArguments( entry, parameters, state,
target );
+ }
+ catch( Throwable e )
+ {
+ URI controller = getURI();
+ final String error =
+ "Unable to apply transition due to an error while
resolving transition method parameters."
+ + "\nComponent: " + entry.getURI()
+ + "\nTransition URI: " + uri
+ + "\nCurrent state: " + state
+ + "\nTarget state: " + target;
+ throw new ControlException( controller, error, e );
+ }
+
try
{
method.invoke( instance, args );
@@ -669,7 +681,7 @@
* @param target the transition target state (possible null when handling
operations)
* @return the populated object array
*/
- private Object[] resolveArguments( ComponentEntry entry, Class[]
parameters, State state, State target )
+ private Object[] resolveArguments( ComponentHandler entry, Class[]
parameters, State state, State target )
{
Object instance = getInstance( entry );
boolean firstStateAssigned = false;
@@ -712,9 +724,10 @@
else
{
final String error =
- "Could not resolve a argument value for the parameter type
["
- + c.getName()
- + "].";
+ "Could not resolve a argument value for a parameter."
+ + "\nParameter type: " + c.getName()
+ + "\nPosition: " + i
+ + "\nComponent: " + instance.getClass().getName();
throw new RuntimeException( error );
}
}
@@ -742,9 +755,9 @@
*/
public synchronized void terminate( Component component )
{
- if( component instanceof ComponentEntry )
+ if( component instanceof ComponentHandler )
{
- ComponentEntry entry = (ComponentEntry) component;
+ ComponentHandler entry = (ComponentHandler) component;
try
{
executeTermination( entry );
@@ -753,7 +766,7 @@
{
// recusive termination path
String error = e.getMessage();
- getLogger().warn( error );
+ getLogger().warn( error, e );
}
finally
{
@@ -772,7 +785,7 @@
}
}
- synchronized void executeTermination( ComponentEntry component ) throws
RecursiveTerminationException
+ synchronized void executeTermination( ComponentHandler component )
throws RecursiveTerminationException
{
if( false == component.isInitialized() )
{
@@ -841,21 +854,46 @@
private Method locateMethod( Class c, String operation ) throws
ValidationException
{
Method[] methods = c.getMethods();
+
+ ArrayList list = new ArrayList();
for( int i=0; i<methods.length; i++ )
{
Method method = methods[i];
String name = method.getName();
- if( operation.equals( method.getName() ) )
+ if( operation.equals( name ) )
{
- return method;
+ list.add( method );
}
}
- final String error =
- "Class does not implement a public method '"
- + operation
- + "'."
- + "\nClass: " + c.getName();
- throw new ValidationException( error );
- }
+ Method[] candidates = (Method[]) list.toArray( new Method[0] );
+ if( candidates.length == 1 )
+ {
+ return candidates[0];
+ }
+ else if( candidates.length > 1 )
+ {
+ for( int i=0; i<candidates.length; i++ )
+ {
+ Method method = candidates[i];
+ int n = method.getParameterTypes().length;
+ if( n == 0 )
+ {
+ return method;
+ }
+ }
+ final String error =
+ "Component implementation class contains duplicate transition
methods."
+ + "\nTransition method: " + c.getName() + "#" + operation;
+ throw new ValidationException( error );
+ }
+ else
+ {
+ final String error =
+ "Class does not implement a public transition method '" +
operation
+ + "'."
+ + "\nClass: " + c.getName();
+ throw new ValidationException( error );
+ }
+ }
}
Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentHandler.java
(from r2941,
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentEntry.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentEntry.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentHandler.java
Thu Jun 30 22:52:28 2005
@@ -37,87 +37,252 @@
import net.dpml.activity.Executable;
import net.dpml.activity.Startable;
-import net.dpml.composition.model.ContextTable;
-import net.dpml.composition.model.CompositionModel;
+import net.dpml.composition.data.ComponentProfile;
+import net.dpml.composition.data.ContextDirective;
+import net.dpml.composition.info.DependencyDescriptor;
+import net.dpml.composition.info.EntryDescriptor;
+import net.dpml.composition.info.ServiceDescriptor;
+import net.dpml.composition.info.Type;
import net.dpml.composition.control.CompositionController;
import net.dpml.composition.event.EventProducer;
import net.dpml.composition.event.WeakEventProducer;
+import net.dpml.configuration.Configuration;
+import net.dpml.configuration.Configurable;
+import net.dpml.configuration.impl.DefaultConfiguration;
+
import net.dpml.logging.Logger;
+import net.dpml.parameters.Parameters;
+import net.dpml.parameters.Parameterizable;
+import net.dpml.parameters.impl.DefaultParameters;
+
import net.dpml.part.control.Identifiable;
import net.dpml.part.control.LifecycleException;
+import net.dpml.part.control.HandlerNotFoundException;
+import net.dpml.part.control.DelegationException;
import net.dpml.part.state.StateEvent;
import net.dpml.part.state.StateListener;
import net.dpml.part.state.State;
import net.dpml.part.state.ResourceUnavailableException;
import net.dpml.part.manager.Component;
+import net.dpml.part.manager.ComponentException;
+import net.dpml.part.manager.ComponentRuntimeException;
import net.dpml.part.manager.AvailabilityEvent;
import net.dpml.part.manager.AvailabilityListener;
-import net.dpml.part.model.Model;
+import net.dpml.part.manager.TypeClassNotFoundException;
+import net.dpml.part.manager.ServiceClassNotFoundException;
+import net.dpml.part.manager.ComponentNotFoundException;
+import net.dpml.part.part.Part;
+import net.dpml.part.part.PartReference;
/**
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id: LifestyleManager.java 259 2004-10-30 07:24:40Z mcconnell $
*/
-public class ComponentEntry extends WeakEventProducer implements Entry,
Component
+public class ComponentHandler extends WeakEventProducer implements
Component, Configurable, Parameterizable
{
private final Map m_proxies = new WeakHashMap();
- private final Object m_key;
private final Logger m_logger;
- private final CompositionModel m_model;
+ private final ComponentProfile m_profile;
+ private final CompositionController m_controller;
+ private final ClassLoader m_classloader;
private final URI m_uri;
+ private final ComponentController m_manager;
private final ContextMap m_context;
private final State m_graph;
+ private final PartsTable m_parts;
+ private final String m_lifestyle;
private State m_state;
private boolean m_initialized = false;
- private ComponentController m_manager;
+ private Configuration m_configuration;
+ private Parameters m_parameters;
- private Object m_instance;
+ private Type m_type;
+ private Class m_class;
+ private Class[] m_interfaces;
private boolean m_disposed = false;
+ private Object m_instance;
- public ComponentEntry(
- Logger logger, ComponentController manager, CompositionModel model,
Object key )
+ public ComponentHandler(
+ Logger logger, CompositionController controller, ClassLoader
classloader,
+ URI uri, ComponentProfile profile, Component parent )
+ throws ComponentException, HandlerNotFoundException,
DelegationException
{
super();
- m_manager = manager;
m_logger = logger;
- m_model = model;
+ m_controller = controller;
+ m_classloader = classloader;
+ m_profile = profile;
+ m_uri = uri;
+
+ m_manager = controller.getComponentController();
+ m_class = loadComponentClass( classloader, profile );
+ m_type = Type.loadType( m_class );
+ m_lifestyle = profile.getLifestylePolicy();
+ m_interfaces = loadServiceClasses( classloader, m_type );
+ m_parts = new PartsTable( this );
+ m_context = new ContextMap( this, parent );
+ m_graph = resolveStateGraph( m_class );
+ m_state = m_graph;
+ m_configuration = m_profile.getConfiguration();
+ m_parameters = m_profile.getParameters();
+
+ //
+ // Get the set of parts within this part and add them as nested
models
+ // within this model.
+ //
- if( null == key )
+ PartReference[] parts = profile.getParts();
+ for( int i=0; i<parts.length; i++ )
{
- m_key = new Integer( System.identityHashCode( this ) );
+ PartReference reference = parts[i];
+ String key = reference.getKey();
+ Part part = reference.getPart();
+ getPartsTable().addPart( key, part );
}
- else
- {
- m_key = key;
+
+ //
+ // Build the context model. The initial population of the context
+ // model is establised by reading in the set of PartReference
instances
+ // contained within the ContextDirective. Each part reference is
located
+ // using a context entry key. The part reference holds the part
+ // that will be used to construct a context entry. The context
+ // entry getValue() operation is used to resolve the
+ // context value accessible via the context key.
+ //
+
+ ContextDirective context = profile.getContextDirective();
+ EntryDescriptor[] entries = m_type.getContext().getEntries();
+ for( int i=0; i<entries.length; i++ )
+ {
+ EntryDescriptor entry = entries[i];
+ final String key = entry.getKey();
+ PartReference reference = context.getPartReference( key );
+ if( null == reference )
+ {
+ if( entry.isRequired() )
+ {
+ final String error =
+ "Unresolved context entry."
+ + "\nComponent: " + getURI()
+ + "\nContext Key: " + key;
+ throw new ComponentRuntimeException( error );
+ }
+ }
+ else
+ {
+ Part part = reference.getPart();
+ getContextMap().addEntry( key, part );
+ }
}
//
- // Create a uri identifying the instance. If the instance key is
CompositionController.SELF then
- // we use the model's uri, otherwise the key is assigned as the
fragment part of the uri using the model
- // uri as the base.
+ // If this component has been asserted as a root component then it
cannot
+ // have any non-optional dependencies. If the component is nested
within another
+ // component then we can attempt to resolve dependencies using the
supplied enclosing
+ // component and dependency directives declared in this component's
profile. If a
+ // dependency directive is not available and the dependency is
required
+ // (non-optional) then we flag the model as unresolved.
//
- URI base = model.getURI();
- if( CompositionController.SELF.equals( key ) )
+ DependencyDescriptor[] dependencies = m_type.getDependencies();
+ for( int i=0; i<dependencies.length; i++ )
{
- m_uri = base;
+ DependencyDescriptor dependency = dependencies[i];
+ String key = dependency.getKey();
+ boolean required = dependency.isRequired();
+ PartReference reference = context.getPartReference( key );
+ if( null == reference )
+ {
+ if( dependency.isRequired() )
+ {
+ final String error =
+ "Unresolved dependency."
+ + "\nComponent: " + getURI()
+ + "\nKey: " + key;
+ throw new ComponentException( error );
+ }
+ }
+ else
+ {
+ Part part = reference.getPart();
+ getContextMap().addEntry( key, part );
+ }
+ }
+ }
+
+ /**
+ * Return the short name of this component.
+ * @return the component name
+ */
+ public String getName()
+ {
+ return m_profile.getName();
+ }
+
+ Type getType()
+ {
+ return m_type;
+ }
+
+ Class getDeploymentClass()
+ {
+ return m_class;
+ }
+
+ String getLifestylePolicy()
+ {
+ return m_lifestyle;
+ }
+
+ CompositionController getController()
+ {
+ return m_controller;
+ }
+
+ ClassLoader getClassLoader()
+ {
+ return m_classloader;
+ }
+
+ public void configure( Configuration configuration )
+ {
+ m_configuration = configuration;
+ }
+
+ Configuration getConfiguration()
+ {
+ if( null == m_configuration )
+ {
+ return new DefaultConfiguration( "configuration", null );
}
else
{
- String fragment = getFragment( m_key );
- m_uri = CompositionController.createInstanceURI( base, fragment
);
+ return m_configuration;
}
+ }
- m_context = new ContextMap( model );
- m_graph = resolveStateGraph( model.getDeploymentClass() );
- m_state = m_graph;
+ public void parameterize( Parameters parameters )
+ {
+ m_parameters = parameters;
+ }
+
+ Parameters getParameters()
+ {
+ if( null == m_parameters )
+ {
+ return DefaultParameters.EMPTY_PARAMETERS;
+ }
+ else
+ {
+ return m_parameters;
+ }
}
/**
@@ -197,11 +362,6 @@
}
}
- public Model getModel()
- {
- return m_model;
- }
-
public Manager getManager()
{
return m_manager;
@@ -363,24 +523,10 @@
return m_logger;
}
- public Object getKey()
- {
- return m_key;
- }
-
- public CompositionModel getCompositionModel()
- {
- return m_model;
- }
-
/**
- * Return a uri identifiying the instance. The scheme specific part of
the
- * uri will correspond to the model uri. If the instance identity is not
equal
- * to CompositionModel#SELF then the uri will be supplimented with the
fragment
- * corresponding to the instance identity.
+ * Return a uri identifiying the instance.
*
* @return the instance uri
- * @see #getKey
*/
public URI getURI()
{
@@ -396,26 +542,12 @@
*/
public Object getProxy()
{
- CompositionModel model = getCompositionModel();
- ClassLoader classloader = model.getClassLoader();
- Class[] interfaces = model.getServiceClasses();
Appliance appliance = new Appliance( this );
- Object proxy = Proxy.newProxyInstance( classloader, interfaces,
appliance );
+ Object proxy = Proxy.newProxyInstance( m_classloader, m_interfaces,
appliance );
//m_proxies.put( proxy, this );
return proxy;
}
- /**
- * Unsupported operation.
- * @param value ignored
- * @return nothing
- * @exception UnsupportedOperationException is always thrown
- */
- public Object setValue( Object value )
- {
- throw new UnsupportedOperationException( "setValue/1" );
- }
-
/**
* Return the implementation instance managed by this holder.
* @return the implementation instance
@@ -434,17 +566,20 @@
}
/**
- * Returns an map containing context values keyed by context entry key
that
- * override the default model context entry mapping. The context map is
used
- * by context managers to handle per-instance context customization.
+ * Returns an map containing context values keyed by context entry key.
*
- * @return the context map for the instance managed by this holder
+ * @return the context map for the instance managed by this component
*/
public ContextMap getContextMap()
{
return m_context;
}
+ public PartsTable getPartsTable()
+ {
+ return m_parts;
+ }
+
/**
* Disposal sets the disposed flag on this holder to true and triggers
* etherialization of any proxy references that this holder has relative
@@ -469,8 +604,7 @@
// pass
}
- getCompositionModel().getComponentTable().remove( this );
-
+ //getCompositionModel().getComponentTable().remove( this );
//synchronized( m_proxies )
//{
// m_disposed = true;
@@ -498,7 +632,7 @@
/**
* Called by a proxy as a result of finalization or explicit disposal
request.
* If there are no further proxies to this instance then the
implementation
- * will invoke self disposal.
+ * will invoke self dispose.
*
* @param proxy the proxy to remove from the set of proxies referncing the
* instance handled by this holder
@@ -529,34 +663,16 @@
protected void finalize()
{
m_logger.debug( "component model finalization in " + getURI() );
- try
- {
- dispose();
- }
- catch( Throwable e )
- {
- e.printStackTrace();
- }
- }
-
- private String getFragment( Object key )
- {
- if( key instanceof String )
- {
- return (String) key;
- }
- else if( key instanceof Integer )
- {
- return key.toString();
- }
- else
- {
- return "" + System.identityHashCode( key );
- }
+ dispose();
}
private State resolveStateGraph( Class subject )
{
+ //
+ // TODO: this has to be thrown away as soon as we have
+ // the composition builder upgraded to handle the state graph
+ // generation into the component type descriptor.
+
try
{
Field field = subject.getField( "STATE_GRAPH" );
@@ -645,48 +761,51 @@
return new State( true );
}
- /**
- * The context map is a wrapper around the model's context map.
- * If a local value is declared in this map that value is returned,
otherwise
- * the returned value defaults to the model's value. One aspect of this
- * is that modifications to shared (model level) entries will impact all
- * other instances backed by the same model.
- */
- public static class ContextMap extends Hashtable
+ private Class loadComponentClass( ClassLoader classloader,
ComponentProfile profile )
{
- private CompositionModel m_model;
-
- public ContextMap( CompositionModel model )
+ final String classname = profile.getClassname();
+ try
+ {
+ return classloader.loadClass( classname );
+ }
+ catch( ClassNotFoundException cnfe )
{
- m_model = model;
+ throw new TypeClassNotFoundException( classname );
}
+ catch( NoClassDefFoundError e )
+ {
+ final String error =
+ "Cannot load component class due to a missing dependent class."
+ + "\nDeployment Class: " + classname
+ + "\nMissing Class: " + e.getMessage()
+ + "\n\n" + classloader.toString();
+ throw new ComponentRuntimeException( error, e );
+ }
+ }
- public Object getValue( String key, Object[] args )
+ private Class[] loadServiceClasses( ClassLoader classloader, Type type )
+ {
+ ServiceDescriptor[] services = m_type.getServices();
+ Class[] interfaces = new Class[ services.length ];
+ for( int i=0; i<interfaces.length; i++ )
{
- Object value = get( key );
- if( null != value )
- {
- return value;
- }
- else
- {
- try
- {
- ContextTable table = getModel().getContextTable();
- return table.getValue( key, args );
- }
- catch( RemoteException e )
- {
- final String error =
- "Remote exception while attempting to resolve content
model context table.";
- throw new RuntimeException( error, e );
- }
- }
+ ServiceDescriptor service = services[i];
+ interfaces[i] = loadServiceClass( classloader, service );
}
+ return interfaces;
+ }
- private CompositionModel getModel()
+ private Class loadServiceClass( ClassLoader classloader,
ServiceDescriptor service )
+ {
+ final String classname = service.getReference().getClassname();
+ try
+ {
+ return classloader.loadClass( classname );
+ }
+ catch( ClassNotFoundException cnfe )
{
- return m_model;
+ String type = m_class.getName();
+ throw new ServiceClassNotFoundException( type, classname );
}
}
}
Added:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/CompositionHandler.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/CompositionHandler.java
Thu Jun 30 22:52:28 2005
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.runtime;
+
+import java.io.IOException;
+import java.net.URI;
+import java.rmi.RemoteException;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Set;
+import java.util.Map;
+import java.util.Hashtable;
+import java.util.Collections;
+import java.util.HashSet;
+
+import net.dpml.composition.control.CompositionController;
+import net.dpml.composition.data.ComponentProfile;
+
+import net.dpml.part.control.DelegationException;
+import net.dpml.part.control.HandlerNotFoundException;
+import net.dpml.part.control.PartNotFoundException;
+
+import net.dpml.part.manager.Component;
+import net.dpml.part.manager.ComponentException;
+import net.dpml.part.manager.ComponentNotFoundException;
+import net.dpml.part.manager.Container;
+
+import net.dpml.part.state.NoSuchOperationException;
+import net.dpml.part.state.NoSuchTransitionException;
+import net.dpml.part.state.State;
+import net.dpml.part.part.Part;
+
+import net.dpml.logging.Logger;
+
+/**
+ * The CompositionHandler class manages the containment aspects of a
component.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class CompositionHandler extends ComponentHandler implements Container
+{
+ private final Map m_components = new Hashtable();
+
+ public CompositionHandler(
+ Logger logger, CompositionController controller, ClassLoader
classloader, URI uri,
+ ComponentProfile profile, Component parent )
+ throws ComponentException, HandlerNotFoundException,
DelegationException
+ {
+ super( logger, controller, classloader, uri, profile, parent );
+ }
+
+ /**
+ * Add a component to the collection of components managed by the
container.
+ *
+ * @param part a part uri
+ * @param key the key under which the component will be referenced
+ * @return the component
+ */
+ public Component addComponent( URI uri, String key )
+ throws IOException, ComponentException, PartNotFoundException,
DelegationException, HandlerNotFoundException
+ {
+ CompositionController controller = getController();
+ Part part = controller.loadPart( uri );
+ ClassLoader classloader = getClassLoader();
+ Component component = controller.newComponent( classloader, this,
part, key );
+ getPartsTable().addComponent( key, component );
+ return component;
+ }
+
+ /**
+ * Retrieve a component using a supplied key.
+ * @param the key
+ * @return the component
+ * @exception ComponentNotFoundException if the key is unknown
+ */
+ public Component getComponent( String key ) throws
ComponentNotFoundException
+ {
+ Component component = getPartsTable().getComponent( key );
+ if( null == component )
+ {
+ throw new ComponentNotFoundException( key );
+ }
+ else
+ {
+ return component;
+ }
+ }
+}
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextInvocationHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextInvocationHandler.java
Thu Jun 30 22:52:28 2005
@@ -22,12 +22,9 @@
import java.lang.reflect.Method;
import java.util.Observer;
-import net.dpml.part.control.LifecycleException;
-import net.dpml.part.model.ModelException;
import net.dpml.part.manager.AvailabilityListener;
import net.dpml.part.state.StateListener;
-import net.dpml.composition.model.CompositionModel;
import net.dpml.composition.control.CompositionController;
/**
@@ -45,11 +42,9 @@
//-------------------------------------------------------------------
/**
- * The component model.
+ * The component.
*/
- private final ComponentEntry m_component;
-
- private final CompositionController m_controller;
+ private final ComponentHandler m_component;
//-------------------------------------------------------------------
// constructor
@@ -58,28 +53,26 @@
/**
* Create a context invocation handler.
*
- * @param system the system context
- * @param model the component model
+ * @param controller the composition controller
+ * @param component the component
*/
- ContextInvocationHandler( CompositionController controller,
ComponentEntry component )
- throws LifecycleException, ModelException
+ ContextInvocationHandler( ComponentHandler component )
{
m_component = component;
- m_controller = controller;
}
//-------------------------------------------------------------------
// implementation
//-------------------------------------------------------------------
- ComponentEntry getComponentEntry()
+ ComponentHandler getComponentHandler()
{
return m_component;
}
- CompositionModel getModel()
+ CompositionController getController()
{
- return getComponentEntry().getCompositionModel();
+ return m_component.getController();
}
/**
@@ -108,7 +101,7 @@
if( name.startsWith( "get" ) )
{
String key = getKeyFromMethod( method );
- ComponentEntry.ContextMap map =
getComponentEntry().getContextMap();
+ ContextMap map = getComponentHandler().getContextMap();
return map.getValue( key, args );
}
else if( null != args )
@@ -118,25 +111,25 @@
if( "addAvailabilityListener".equals( name ) )
{
AvailabilityListener listener =
(AvailabilityListener) args[0];
- getComponentEntry().addAvailabilityListener(
listener );
+ getComponentHandler().addAvailabilityListener(
listener );
return null;
}
else if( "removeAvailabilityListener".equals( name ) )
{
AvailabilityListener listener =
(AvailabilityListener) args[0];
- getComponentEntry().removeAvailabilityListener(
listener );
+ getComponentHandler().removeAvailabilityListener(
listener );
return null;
}
else if( "addStateListener".equals( name ) )
{
StateListener listener = (StateListener) args[0];
- getComponentEntry().addStateListener( listener );
+ getComponentHandler().addStateListener( listener );
return null;
}
else if( "removeStateListener".equals( name ) )
{
StateListener listener = (StateListener) args[0];
- getComponentEntry().removeStateListener( listener );
+ getComponentHandler().removeStateListener( listener
);
return null;
}
else
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextManagerInvocationHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextManagerInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextManagerInvocationHandler.java
Thu Jun 30 22:52:28 2005
@@ -24,7 +24,6 @@
import net.dpml.composition.control.CompositionController;
import net.dpml.part.control.LifecycleException;
-import net.dpml.part.model.ModelException;
/**
* This makes a dynamic proxy for an object. The object can be represented
@@ -36,12 +35,6 @@
final class ContextManagerInvocationHandler extends ContextInvocationHandler
{
//-------------------------------------------------------------------
- // state
- //-------------------------------------------------------------------
-
- private final CompositionController m_controller;
-
- //-------------------------------------------------------------------
// constructor
//-------------------------------------------------------------------
@@ -51,12 +44,9 @@
* @param system the system context
* @param model the component model
*/
- ContextManagerInvocationHandler( CompositionController controller,
ComponentEntry holder )
- throws LifecycleException, ModelException
+ ContextManagerInvocationHandler( ComponentHandler component )
{
- super( controller, holder );
-
- m_controller = controller;
+ super( component );
}
//-------------------------------------------------------------------
@@ -86,7 +76,7 @@
}
else if( Map.class == source )
{
- Map map = getComponentEntry().getContextMap();
+ ContextMap map = getComponentHandler().getContextMap();
return method.invoke( map, args );
}
else if( name.startsWith( "set" ) )
@@ -102,7 +92,7 @@
throw new IllegalStateException( error );
}
Object value = args[0];
- getComponentEntry().getContextMap().put( key, value );
+ getComponentHandler().getContextMap().put( key, value );
return null;
}
else
Added:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextMap.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextMap.java
Thu Jun 30 22:52:28 2005
@@ -0,0 +1,215 @@
+/*
+ * 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.runtime;
+
+import java.net.URI;
+import java.rmi.RemoteException;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import net.dpml.part.control.Controller;
+import net.dpml.part.control.DelegationException;
+import net.dpml.part.control.HandlerNotFoundException;
+import net.dpml.part.control.DelegationException;
+import net.dpml.part.manager.Container;
+import net.dpml.part.manager.Component;
+import net.dpml.part.manager.ComponentException;
+import net.dpml.part.manager.ComponentRuntimeException;
+import net.dpml.part.manager.DuplicateKeyException;
+import net.dpml.part.manager.ComponentNotFoundException;
+import net.dpml.part.part.Part;
+
+import net.dpml.composition.control.CompositionController;
+import net.dpml.composition.data.ReferenceDirective;
+import net.dpml.composition.data.ValueDirective;
+
+/**
+ * The context map is a utility class that handles the set of components
that
+ * make up the context model for an enclosing component.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class ContextMap extends Hashtable
+{
+ private final CompositionController m_controller;
+ private final ComponentHandler m_component;
+ private final Container m_parent;
+
+ /**
+ * Creation of a new context entry table.
+ *
+ * @param component the component that is managing this context map
+ * @param parent an enclosing partent component used for lookup of part
references
+ */
+ public ContextMap( ComponentHandler component, Component parent )
+ {
+ super();
+
+ m_component = component;
+ m_controller = component.getController();
+ if( component instanceof Container )
+ {
+ m_parent = (Container) parent;
+ }
+ else
+ {
+ m_parent = null;
+ }
+ }
+
+ public void addEntry( String key, Part part )
+ throws ComponentException, HandlerNotFoundException,
DelegationException
+ {
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+ else if( null == part )
+ {
+ throw new NullPointerException( "part" );
+ }
+ else if( containsKey( key ) )
+ {
+ throw new DuplicateKeyException( key );
+ }
+ else if( part instanceof ReferenceDirective )
+ {
+ ReferenceDirective reference = (ReferenceDirective) part;
+ URI uri = reference.getURI();
+ if( null == m_parent )
+ {
+ final String error =
+ "Cannot resolve a reference to an enclosing container from
a root component."
+ + "\nComponent: " + m_component.getURI()
+ + "\nContext Key: " + key;
+ throw new ComponentException( error );
+ }
+
+ String ref = uri.getSchemeSpecificPart();
+ try
+ {
+ Component entry = m_parent.getComponent( ref );
+ addEntry( key, entry );
+ }
+ catch( ComponentNotFoundException cnfe )
+ {
+ final String error =
+ "Component not found."
+ + "\nContainer: " + m_parent.getURI()
+ + "\nComponent: " + m_component.getURI()
+ + "\nContext Key: " + key;
+ throw new ComponentException( error );
+ }
+ }
+ else
+ {
+ CompositionController controller = m_component.getController();
+ ClassLoader classloader = m_component.getClassLoader();
+ Component component = controller.newComponent( classloader,
m_component, part, key );
+ addEntry( key, component );
+ }
+ }
+
+ public void addEntry( String key, Component provider ) throws
DuplicateKeyException
+ {
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+ if( null == provider )
+ {
+ throw new NullPointerException( "provider" );
+ }
+ if( containsKey( key ) )
+ {
+ throw new DuplicateKeyException( key );
+ }
+ setEntry( key, provider );
+ }
+
+ public void setEntry( String key, Component value )
+ {
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+ put( key, value );
+ }
+
+ public Component getEntry( String key )
+ {
+ return (Component) super.get( key );
+ }
+
+ public Object getValue( String key, Object[] args ) throws
RemoteException
+ {
+ Object value = get( key );
+ if( null == value )
+ {
+ if( null == args )
+ {
+ return null;
+ }
+ else if( args.length < 1 )
+ {
+ return null;
+ }
+ else
+ {
+ return args[0];
+ }
+ }
+ else
+ {
+ return value;
+ }
+ }
+
+ public Object get( String key )
+ {
+ Object entry = super.get( key );
+ if( null == entry )
+ {
+ return null;
+ }
+ else if( entry instanceof Component )
+ {
+ Component component = (Component) entry;
+ try
+ {
+ return component.resolve();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to resolve the value of
context entry."
+ + "\nEnclosing component: " + m_component.getURI()
+ + "\nProvider Component: " + component.getURI()
+ + "\nContext Key: " + key;
+ throw new ComponentRuntimeException( error, e );
+ }
+ }
+ else
+ {
+ return entry;
+ }
+ }
+}
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LifecycleHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LifecycleHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LifecycleHandler.java
Thu Jun 30 22:52:28 2005
@@ -27,7 +27,6 @@
import net.dpml.logging.Logger;
-import net.dpml.composition.model.CompositionModel;
import net.dpml.composition.control.CompositionController;
import net.dpml.configuration.Configuration;
@@ -42,7 +41,7 @@
* A lifestyle handler provides support for the aquisition and release
* of component instances. An implementation is responsible for the
* handling of new instance creation based on lifestyle policy declared
- * in a component model.
+ * by a component.
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id: LifestyleManager.java 259 2004-10-30 07:24:40Z mcconnell $
@@ -84,20 +83,19 @@
*
* @return a new component instance
*/
- public Object incarnate( ComponentEntry holder ) throws
LifecycleException, InvocationTargetException
+ public Object incarnate( ComponentHandler component ) throws
LifecycleException, InvocationTargetException
{
if( getLogger().isDebugEnabled() )
{
final String message =
"Incarnating ["
- + holder.getURI()
+ + component.getURI()
+ "].";
getLogger().debug( message );
}
- CompositionModel model = holder.getCompositionModel();
- URI uri = holder.getURI();
- Class subject = model.getDeploymentClass();
+ URI uri = component.getURI();
+ Class subject = component.getDeploymentClass();
ClassLoader classloader = subject.getClassLoader();
Constructor constructor = getConstructor( subject );
Class parts = getInnerClass( subject, "$Parts" );
@@ -110,28 +108,28 @@
Class c = classes[i];
if( java.util.logging.Logger.class.isAssignableFrom( c ) )
{
- args[i] = getJavaLogger( model );
+ args[i] = getJavaLogger( component );
}
else if( Logger.class.isAssignableFrom( c ) )
{
- args[i] = getLoggingChannel( model );
+ args[i] = getLoggingChannel( component );
}
else if( ( null != parts ) && parts.isAssignableFrom( c ) )
{
- args[i] = newPartsInvocationHandler( holder, parts );
+ args[i] = newPartsInvocationHandler( component, parts );
}
else if( ( null != context ) && context.isAssignableFrom( c ) )
{
- args[i] = newContextInvocationHandler( holder, context );
+ args[i] = newContextInvocationHandler( component, context );
}
else if( Configuration.class.isAssignableFrom( c ) )
{
- Configuration config = model.getConfiguration();
+ Configuration config = component.getConfiguration();
args[i] = newConfigurationInvocationHandler( config );
}
else if( Parameters.class.isAssignableFrom( c ) )
{
- Parameters params = model.getParameters();
+ Parameters params = component.getParameters();
args[i] = newParametersInvocationHandler( params );
}
else
@@ -153,7 +151,7 @@
catch( Throwable e )
{
Class clazz = constructor.getDeclaringClass();
- throw new LifecycleException( model, e );
+ throw new LifecycleException( component, e );
}
}
@@ -163,53 +161,52 @@
* @return the state manager (possibly null)
*/
/*
- public Manager getManager( ComponentEntry holder ) throws
LifecycleException, InvocationTargetException
+ public Manager getManager( ComponentHandler component ) throws
LifecycleException, InvocationTargetException
{
if( getLogger().isDebugEnabled() )
{
final String message =
"Instantiating state manager for ["
- + holder.getURI()
+ + component.getURI()
+ "].";
getLogger().debug( message );
}
- CompositionModel model = holder.getCompositionModel();
- Class subject = model.getDeploymentClass();
+ Class subject = component.getDeploymentClass();
Class control = getInnerClass( subject, "Controller" );
if( null == control )
{
if( Startable.class.isAssignableFrom( subject ) )
{
- return new StartableManager( holder );
+ return new StartableManager( component );
}
else if( Executable.class.isAssignableFrom( subject ) )
{
- return new ExecutableManager( holder );
+ return new ExecutableManager( component );
}
else
{
- return new NullManager( holder );
+ return new NullManager( component );
}
}
- URI uri = holder.getURI();
+ URI uri = component.getURI();
ClassLoader classloader = subject.getClassLoader();
Constructor constructor = getConstructor( control );
Class[] classes = constructor.getParameterTypes();
Object[] args = new Object[ classes.length ];
- Object instance = holder.getValue();
+ Object instance = component.getValue();
for( int i=0; i<classes.length; i++ )
{
Class c = classes[i];
if( java.util.logging.Logger.class.isAssignableFrom( c ) )
{
- args[i] = getJavaLogger( model, "control" );
+ args[i] = getJavaLogger( component );
}
else if( Logger.class.isAssignableFrom( c ) )
{
- args[i] = getLoggingChannel( model );
+ args[i] = getLoggingChannel( component );
}
else if( subject.isAssignableFrom( c ) )
{
@@ -217,7 +214,7 @@
}
else if( ChangeListener.class.isAssignableFrom( c ) )
{
- args[i] = holder;
+ args[i] = component;
}
else
{
@@ -239,7 +236,7 @@
}
catch( Throwable e )
{
- throw new LifecycleException( model, e );
+ throw new LifecycleException( component, e );
}
}
*/
@@ -257,7 +254,6 @@
}
Class subject = object.getClass();
-
if( getLogger().isDebugEnabled() )
{
final String message =
@@ -340,12 +336,12 @@
}
private Object newContextInvocationHandler(
- ComponentEntry holder, Class clazz ) throws LifecycleRuntimeException
+ ComponentHandler component, Class clazz ) throws
LifecycleRuntimeException
{
try
{
- InvocationHandler handler = new ContextInvocationHandler(
m_controller, holder );
- ClassLoader classloader =
holder.getCompositionModel().getDeploymentClass().getClassLoader();
+ InvocationHandler handler = new ContextInvocationHandler(
component );
+ ClassLoader classloader =
component.getDeploymentClass().getClassLoader();
return Proxy.newProxyInstance( classloader, new Class[]{ clazz
}, handler );
}
catch( Throwable e )
@@ -356,12 +352,12 @@
}
}
- private Object newPartsInvocationHandler( ComponentEntry holder, Class
clazz ) throws LifecycleException
+ private Object newPartsInvocationHandler( ComponentHandler component,
Class clazz ) throws LifecycleException
{
try
{
- InvocationHandler handler = new PartsInvocationHandler(
m_controller, holder );
- ClassLoader classloader =
holder.getCompositionModel().getDeploymentClass().getClassLoader();
+ InvocationHandler handler = new PartsInvocationHandler(
component );
+ ClassLoader classloader =
component.getDeploymentClass().getClassLoader();
return Proxy.newProxyInstance( classloader, new Class[]{ clazz
}, handler );
}
catch( Throwable e )
Added:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LifestyleHandler.txt
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LifestyleHandler.txt
Thu Jun 30 22:52:28 2005
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2004 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.runtime;
+
+import java.net.URI;
+import java.rmi.RemoteException;
+
+import net.dpml.logging.Logger;
+
+import net.dpml.part.control.ControlRuntimeException;
+
+/**
+ * A lifestyle handler provides support for the aquisition and release
+ * of component instances. An implementation is responsible for the
+ * handling of new instance creation based on lifestyle policy declared
+ * in a component model.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: LifestyleManager.java 259 2004-10-30 07:24:40Z mcconnell $
+ */
+class LifestyleHandler
+{
+ private Logger m_logger;
+ private ComponentController m_controller;
+
+ LifestyleHandler( Logger logger, ComponentController controller )
+ {
+ m_logger = logger;
+ m_controller = controller;
+ }
+
+ /**
+ * Aquire a key to an instance.
+ *
+ * @param model the model from which new or existing instances will be
resolved
+ * @return the key to the resolved instance
+ */
+ public ComponentHandler aquire( ComponentHandler component,
CompositionModel model )
+ {
+ final String lifestyle = model.getLifestylePolicy();
+ if( getLogger().isDebugEnabled() )
+ {
+ URI uri = model.getURI();
+ final String message =
+ "Aquiring an object key for the model ["
+ + uri
+ + "] using the lifestyle ["
+ + lifestyle
+ + "].";
+ getLogger().debug( message );
+ }
+ if( "request".equals( lifestyle ) || "transient".equals( lifestyle )
)
+ {
+ synchronized( model )
+ {
+ ComponentHandler entry = new ComponentHandler( m_logger,
m_controller, model, null );
+ Object key = entry.getKey();
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "Established key ["
+ + entry.getURI()
+ + "].";
+ getLogger().debug( message );
+ }
+ table.add( entry );
+ return entry;
+ }
+ }
+ else if( "model".equals( lifestyle ) || "singleton".equals(
lifestyle ) )
+ {
+ synchronized( model )
+ {
+ String key = CompositionController.SELF;
+ return aquire( table, model, key );
+ }
+ }
+ else if( "thread".equals( lifestyle ) )
+ {
+ throw new UnsupportedOperationException( "thread" );
+ }
+ else
+ {
+ final String error =
+ "Lifestyle policy ["
+ + lifestyle
+ + "] is not recognized.";
+ throw new IllegalArgumentException( error );
+ }
+ }
+
+ /**
+ * Aquire a key to an instance. If the supplied key references an
+ * existing instance the same key is returned. If the key does not
+ * reference an existing instance then a new instance is created,
+ * registered with the model, and the key returned.
+ *
+ * @param model the model from which new or existing instances will be
resolved
+ * @return the key to the resolved instance
+ */
+ public ComponentHandler aquire( ComponentTable table, CompositionModel
model, Object key )
+ {
+ if( null == model )
+ {
+ throw new NullPointerException( "model" );
+ }
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+
+ ComponentHandler entry = table.get( key );
+
+ if( null == entry )
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ URI uri = model.getURI();
+ final String message =
+ "Initiating creation of identifiable instance in ["
+ + uri
+ + "].";
+ getLogger().debug( message );
+ }
+ entry = new ComponentHandler( m_logger, m_controller, model, key
);
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "Adding component entry ["
+ + entry.getURI()
+ + "].";
+ getLogger().debug( message );
+ }
+ table.add( entry );
+ }
+ else
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "Using existing component entry ["
+ + entry.getURI()
+ + "].";
+ getLogger().debug( message );
+ }
+ }
+ return entry;
+ }
+
+ public void release( ComponentTable table, CompositionModel model,
Object key )
+ {
+ final String lifestyle = model.getLifestylePolicy();
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "Releasing ["
+ + model.getURI()
+ + "#"
+ + key
+ + "].";
+ getLogger().debug( message );
+ }
+ table.remove( key );
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+
+}
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LoggingHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LoggingHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LoggingHandler.java
Thu Jun 30 22:52:28 2005
@@ -26,7 +26,6 @@
import java.net.URI;
import java.util.logging.Logger;
-import net.dpml.composition.model.CompositionModel;
import net.dpml.composition.control.CompositionController;
import net.dpml.configuration.Configuration;
@@ -35,6 +34,7 @@
import net.dpml.part.control.LifecycleException;
import net.dpml.part.control.LifecycleRuntimeException;
+import net.dpml.part.manager.Component;
/**
@@ -53,9 +53,9 @@
* @param model the composition model
* @return the logging channel
*/
- java.util.logging.Logger getJavaLogger( CompositionModel model )
+ java.util.logging.Logger getJavaLogger( Component component )
{
- return getJavaLogger( model, null );
+ return getJavaLogger( component, null );
}
/**
@@ -64,10 +64,10 @@
* @param category the logging category name
* @return the logging channel
*/
- java.util.logging.Logger getJavaLogger( CompositionModel model, String
category )
+ java.util.logging.Logger getJavaLogger( Component component, String
category )
{
- URI uri = model.getURI();
- String path = model.getURI().getSchemeSpecificPart();
+ URI uri = component.getURI();
+ String path = uri.getSchemeSpecificPart();
String channel = path.replace( '/', '.' );
if( category != null )
{
@@ -76,9 +76,9 @@
return Logger.getLogger( channel );
}
- net.dpml.logging.Logger getLoggingChannel( CompositionModel model )
+ net.dpml.logging.Logger getLoggingChannel( Component component )
{
- URI uri = model.getURI();
+ URI uri = component.getURI();
String path = uri.getSchemeSpecificPart();
if( path.endsWith( "/" ) )
{
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/Manager.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/Manager.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/Manager.java
Thu Jun 30 22:52:28 2005
@@ -19,7 +19,7 @@
package net.dpml.composition.runtime;
import net.dpml.part.control.Control;
-import net.dpml.part.model.ResourceUnavailableException;
+import net.dpml.part.manager.ResourceUnavailableException;
import net.dpml.part.manager.Component;
import net.dpml.part.state.State;
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ManagerInvocationHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ManagerInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ManagerInvocationHandler.java
Thu Jun 30 22:52:28 2005
@@ -39,7 +39,7 @@
// state
//-------------------------------------------------------------------
- private final ComponentEntry m_component;
+ private final ComponentHandler m_component;
private final Object m_manager;
private final Class m_class;
@@ -50,12 +50,12 @@
/**
* Create a new state manager invocation handler.
*
- * @param system the system context
- * @param model the component model
+ * @param component the component
+ * @param manager the component's manager
*/
- ManagerInvocationHandler( ComponentEntry holder, Object manager )
+ ManagerInvocationHandler( ComponentHandler component, Object manager )
{
- m_component = holder;
+ m_component = component;
m_manager = manager;
m_class = m_manager.getClass();
}
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/PartsInvocationHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/PartsInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/PartsInvocationHandler.java
Thu Jun 30 22:52:28 2005
@@ -26,13 +26,11 @@
import java.rmi.RemoteException;
import net.dpml.composition.info.PartDescriptor;
-import net.dpml.composition.model.CompositionModel;
import net.dpml.composition.control.CompositionController;
import net.dpml.part.control.Controller;
import net.dpml.part.control.DelegationException;
import net.dpml.part.manager.Component;
-import net.dpml.part.model.Model;
/**
* The parts invocation handler maps client request for 'get', 'create' and
@@ -59,7 +57,7 @@
/**
* The component model.
*/
- private final ComponentEntry m_holder;
+ private final ComponentHandler m_component;
private final CompositionController m_controller;
@@ -72,11 +70,11 @@
*
* @param model the component model
*/
- PartsInvocationHandler( CompositionController controller, ComponentEntry
holder )
+ PartsInvocationHandler( ComponentHandler component )
throws NullPointerException
{
- m_holder = holder;
- m_controller = controller;
+ m_component = component;
+ m_controller = component.getController();
}
//-------------------------------------------------------------------
@@ -108,11 +106,6 @@
}
}
- CompositionModel getModel()
- {
- return m_holder.getCompositionModel();
- }
-
/**
* Invoke the specified method on underlying object.
* This is called by the proxy object.
@@ -137,7 +130,17 @@
int semantic = PartDescriptor.getPartSemantic( method );
String postfix = PartDescriptor.getPartPostfix( method );
String key = PartDescriptor.getPartKey( method, semantic );
- Model provider = getModel().getPartsTable().getModel( key );
+
+ //
+ // This is the point wyhere we have a reference to the consumer (the
part proxy)
+ // and we are about to reference a component. We should be able to
resolve
+ // the component profile using the part descriptor key and then use
the
+ // lifestyle logic to establish the instance and in doing so,
register the
+ // consumer in a weak hashmap. We can then use the consumer as the
argument to
+ // the release operation or fall back to garbage collection of
consumers.
+ //
+
+ Component provider = m_component.getPartsTable().getComponent( key );
if( PartDescriptor.GET == semantic )
{
@@ -145,41 +148,39 @@
{
if( null == args )
{
- return m_controller.getComponent( provider ).resolve();
+ return provider.resolve();
+ }
+ else if( args.length == 0 )
+ {
+ return provider.resolve();
}
else if( args.length == 1 )
{
Object arg = args[0];
- if( arg.getClass() == Boolean.TYPE )
+ Class argClass = arg.getClass();
+ if( ( Boolean.TYPE == argClass ) || ( Boolean.class ==
argClass ) )
{
- boolean policy = getBooleanValue( args[1] );
- return m_controller.getComponent( provider
).resolve( policy );
+ boolean policy = getBooleanValue( arg );
+ return provider.resolve( policy );
}
else
{
- return m_controller.getComponent( provider, arg
).resolve();
+ final String error =
+ "Part accessor parameter type not supported."
+ + "\nMethod: " +
method.getDeclaringClass().getName() + "#" + method.getName()
+ + "\nParameter: " + arg.getClass();
+ throw new IllegalArgumentException( error );
}
}
- else if( args.length == 2 )
- {
- Object arg = args[0];
- boolean policy = getBooleanValue( args[1] );
- return m_controller.getComponent( provider, arg
).resolve( policy );
- }
else
{
final String error =
"Illegal number of parameters in ["
+ method.getName()
+ "].";
- throw new IllegalStateException( error );
+ throw new IllegalArgumentException( error );
}
}
- else if( PartDescriptor.MODEL_KEY.equals( postfix ) )
- {
- // TODO: wrap this is a proxy
- return provider;
- }
else if( PartDescriptor.CONTEXT_MANAGER_KEY.equals( postfix )
|| PartDescriptor.CONTEXT_MAP_KEY.equals( postfix ) )
{
@@ -190,14 +191,13 @@
"The request for the context manager for the key ["
+ key
+ "] in the component ["
- + getModel().getURI()
+ + provider.getURI()
+ "] could not be completed as the requested return
type ["
+ clazz.getName()
+ "] is not an interface.";
- throw new IllegalStateException( error );
+ throw new IllegalArgumentException( error );
}
-
- if( false == ( provider instanceof CompositionModel ) )
+ else if( false == ( provider instanceof ComponentHandler ) )
{
//
// TODO: we could construct a context manager with no
@@ -206,27 +206,22 @@
//
final String error =
- "Dynamic creation of context managers for foreign
object types is not supported."
+ "Dynamic creation of context managers for foreign
component types is not supported."
+ "\nClass: " + provider.getClass().getName()
- + "\nProvider: " + provider.getURI()
- + "Instance: " + m_holder.getURI();
+ + "\nProvider: " + provider.getURI();
throw new UnsupportedOperationException( error );
}
-
- CompositionModel model = (CompositionModel) provider;
- ComponentEntry component = getComponentEntry( model, args );
- ClassLoader classloader = model.getClassLoader();
- ContextManagerInvocationHandler handler =
- new ContextManagerInvocationHandler( m_controller,
component );
- return Proxy.newProxyInstance( classloader, new Class[]{
clazz }, handler );
- }
- else if( PartDescriptor.PROVIDER_KEY.equals( postfix ) )
- {
- return getComponent( provider, args );
+ else
+ {
+ ClassLoader classloader =
provider.getClass().getClassLoader();
+ ContextManagerInvocationHandler handler =
+ new ContextManagerInvocationHandler(
(ComponentHandler) provider );
+ return Proxy.newProxyInstance( classloader, new Class[]{
clazz }, handler );
+ }
}
else if( PartDescriptor.COMPONENT_KEY.equals( postfix ) )
{
- return getComponent( provider, args );
+ return provider; // TODO: wrap in a proxy
}
else
{
@@ -243,7 +238,7 @@
{
if( args.length == 1 )
{
- m_holder.getManager().release( args[0] );
+ provider.release( args[0] );
return null;
}
else
@@ -265,32 +260,6 @@
}
}
- private DelegationException createDelegationException( String key, Model
provider, String function, Throwable e ) throws RemoteException
- {
- URI uri = provider.getURI();
- final String error =
- "The request for the invocation of "
- + function
- + " for the key ["
- + key
- + "] in the component ["
- + getModel().getURI()
- + "] could not be completed as the provider ["
- + uri
- + "] raised an exception.";
-
- if( e instanceof InvocationTargetException )
- {
- InvocationTargetException target = (InvocationTargetException) e;
- final Throwable cause = target.getTargetException();
- return new DelegationException( uri, error, cause );
- }
- else
- {
- return new DelegationException( uri, error, e );
- }
- }
-
//-------------------------------------------------------------------
// implementation
//-------------------------------------------------------------------
@@ -308,7 +277,7 @@
{
StringBuffer buffer = new StringBuffer();
buffer.append( "[parts {" );
- PartDescriptor[] entries = getModel().getType().getPartDescriptors();
+ PartDescriptor[] entries =
m_component.getType().getPartDescriptors();
for( int i=0; i<entries.length; i++ )
{
PartDescriptor p = entries[i];
@@ -338,43 +307,4 @@
throw new IllegalArgumentException( error );
}
}
-
- private Component getComponent( Model model, Object[] args ) throws
Exception
- {
- if( null == args )
- {
- return m_controller.getComponent( model );
- }
- else if( args.length == 0 )
- {
- return m_controller.getComponent( model );
- }
- else
- {
- return m_controller.getComponent( model, args[0] );
- }
- }
-
- private ComponentEntry getComponentEntry( CompositionModel model,
Object[] args ) throws Exception
- {
- if( null == args )
- {
- return m_controller.getComponentEntry( model, null );
- }
- else if( args.length == 0 )
- {
- return m_controller.getComponentEntry( model, null );
- }
- else
- {
- return m_controller.getComponentEntry( model, args[0] );
- }
- }
-
- private Manager getManager( CompositionModel model, Object[] args )
throws Exception
- {
- ComponentEntry entry = getComponentEntry( model, args );
- return entry.getManager();
- }
-
}
Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/PartsTable.java
(from r2941,
development/main/metro/composition/control/src/main/net/dpml/composition/model/PartsTable.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/model/PartsTable.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/PartsTable.java
Thu Jun 30 22:52:28 2005
@@ -16,47 +16,47 @@
* limitations under the License.
*/
-package net.dpml.composition.model;
+package net.dpml.composition.runtime;
import java.rmi.RemoteException;
import java.util.Map;
import java.util.Hashtable;
+import net.dpml.part.control.DelegationException;
+import net.dpml.part.control.HandlerNotFoundException;
import net.dpml.part.control.ControlRuntimeException;
-import net.dpml.part.model.ModelException;
-import net.dpml.part.model.Model;
-import net.dpml.part.model.DuplicateKeyException;
+import net.dpml.part.manager.DuplicateKeyException;
+import net.dpml.part.manager.Component;
+import net.dpml.part.manager.ComponentException;
import net.dpml.part.part.Part;
import net.dpml.composition.data.ReferenceDirective;
import net.dpml.composition.control.CompositionController;
/**
- * The parts table contains the subsidiary parts of an enclosing model.
+ * The parts table contains the subsidiary parts of an enclosing component.
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
*/
public class PartsTable
{
- private final CompositionController m_controller;
+ private final ComponentHandler m_component;
- private final CompositionModel m_model;
-
- private final Hashtable m_parts = new Hashtable(); // map of Model
instances keyed by part key
+ private final Hashtable m_parts = new Hashtable(); // map of Component
instances keyed by part key
/**
* Creation of a new parts table.
*
- * @param model the enclosing composition model
+ * @param component the enclosing component
*/
- public PartsTable( CompositionController control, CompositionModel model
)
+ public PartsTable( ComponentHandler component )
{
- m_model = model;
- m_controller = control;
+ m_component = component;
}
- public void addPart( String key, Part part ) throws ModelException,
RemoteException
+ public void addPart( String key, Part part )
+ throws ComponentException, DelegationException,
HandlerNotFoundException
{
if( null == key )
{
@@ -70,20 +70,20 @@
{
final String error =
"Illegal attempt to add a part reference to a parts
collection."
- + "\nModel: " + getModel().getURI()
- + "\nParts Key: " + key;
- throw new IllegalArgumentException( error );
+ + "\nComponent: " + m_component.getURI()
+ + "\nKey: " + key;
+ throw new ComponentException( error );
}
synchronized( m_parts )
{
- CompositionModel enclosing = getModel();
- ClassLoader classloader = enclosing.getClassLoader();
- Model model = m_controller.getModel( enclosing, classloader,
part, key );
- addModel( key, model );
+ ClassLoader classloader = m_component.getClassLoader();
+ CompositionController controller = m_component.getController();
+ Component component = controller.newComponent( classloader,
m_component, part, key );
+ addComponent( key, component );
}
}
- public void addModel( String key, Model model ) throws ModelException
+ public void addComponent( String key, Component component ) throws
DuplicateKeyException
{
synchronized( m_parts )
{
@@ -91,7 +91,7 @@
{
throw new DuplicateKeyException( key );
}
- m_parts.put( key, model );
+ m_parts.put( key, component );
}
}
@@ -104,14 +104,8 @@
return m_parts.containsKey( key );
}
- public Model getModel( String key )
+ public Component getComponent( String key )
{
- return (Model) m_parts.get( key );
+ return (Component) m_parts.get( key );
}
-
- protected CompositionModel getModel()
- {
- return m_model;
- }
-
}
Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueController.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueController.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueController.java
Thu Jun 30 22:52:28 2005
@@ -70,7 +70,7 @@
*/
public Object resolve( Component entry, boolean policy )
{
- return ((ValueEntry)entry).getInstance();
+ return ((ValueHandler)entry).getInstance();
}
public void release( Object instance )
Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueHandler.java
(from r2941,
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueEntry.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueEntry.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueHandler.java
Thu Jun 30 22:52:28 2005
@@ -25,24 +25,21 @@
import net.dpml.composition.control.CompositionController;
import net.dpml.composition.data.ValueDirective;
import net.dpml.composition.data.ValueDirective.Value;
-import net.dpml.composition.model.ValueModel;
import net.dpml.logging.Logger;
import net.dpml.part.control.Controller;
import net.dpml.part.manager.Component;
-import net.dpml.part.model.Model;
-import net.dpml.part.model.ModelException;
-import net.dpml.part.model.ModelRuntimeException;
+import net.dpml.part.manager.ComponentException;
+import net.dpml.part.manager.ComponentRuntimeException;
import net.dpml.part.state.State;
/**
- * Default implementation of a the context entry constructor model.
+ * Default implementation of a value component.
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id: DefaultConstructorModel.java 1518 2005-01-17 17:13:05Z
niclas $
*/
-public class ValueEntry extends AbstractComponent implements Component
+public class ValueHandler extends AbstractHandler implements Component
{
//--------------------------------------------------------------
// state
@@ -51,12 +48,11 @@
private final URI m_uri;
private final ValueDirective m_directive;
private final ClassLoader m_classloader;
- private final ValueModel m_model;
private final Manager m_manager;
- private final Model m_parent;
+ private final Component m_parent;
private final CompositionController m_controller;
- private String m_key;
+ private Object m_key;
private Object m_value;
//--------------------------------------------------------------
@@ -64,60 +60,44 @@
//--------------------------------------------------------------
/**
- * Creation of a new context entry import model.
+ * Creation of a new value handler.
*
+ * @param controller the composition controller
* @param logger the logging channel
- * @param model the value model
- * @param name the entry name
- * @param manager the value model's manager
* @param classloader the assigned classloader
- * @param directive the value directive from which we construct the value
model
- * @param parent the parent model
- * @exception NullArgumentException if either the directive argument or
the
- * context argument is null.
+ * @param manager the value model's manager
+ * @param part the value directive
+ * @param component the enclosing component (possibly null if this is a
top-level)
+ * @exception NullPointerException if a null value is supplied for any
argument
+ * other than the enclosing component
*/
- public ValueEntry(
- CompositionController controller, Logger logger, ValueModel model,
String name, Manager manager, ClassLoader classloader,
- ValueDirective directive, Model parent )
- throws ModelException, NullPointerException
+ public ValueHandler(
+ Logger logger, CompositionController controller, ClassLoader
classloader,
+ URI uri, ValueDirective part, Component parent )
{
super( logger );
- if( directive == null )
+ if( controller == null )
{
- throw new NullPointerException( "directive" );
+ throw new NullPointerException( "controller" );
}
- if( null == model )
+ if( null == part )
{
- throw new NullPointerException( "model" );
+ throw new NullPointerException( "part" );
}
- m_directive = directive;
- m_classloader = classloader;
- m_model = model;
m_parent = parent;
- m_key = name;
- m_manager = manager;
m_controller = controller;
+ m_directive = part;
+ m_classloader = classloader;
+ m_uri = uri;
- try
- {
- URI base = m_model.getURI();
- m_uri = CompositionController.createURI( base, name );
- }
- catch( RemoteException e )
- {
- final String error =
- "Remote exception while attrempting to resolve model uri.";
- throw new RuntimeException( error, e );
- }
-
- //validate();
+ m_manager = controller.getValueController();
}
- public Model getModel()
+ public String getName()
{
- return m_model;
+ return m_directive.getKey();
}
public Manager getManager()
@@ -126,7 +106,7 @@
}
/**
- * Return the availability status of the model.
+ * Return the availability status of the component.
* @return the availability status
*/
public boolean isOperational()
@@ -134,16 +114,6 @@
return true;
}
- /**
- * Return the key identifying this instance.
- *
- * @return the key
- */
- public Object getKey()
- {
- return m_key;
- }
-
public URI getURI()
{
return m_uri;
@@ -170,15 +140,6 @@
m_manager.terminate( this );
}
- //--------------------------------------------------------------
- // EntryModel
- //--------------------------------------------------------------
-
- public Object setValue( Object value )
- {
- throw new UnsupportedOperationException( "setValue/1" );
- }
-
/**
* Return the context entry value.
*
@@ -211,12 +172,10 @@
catch( Throwable e )
{
final String error =
- "Cannot establish a constructed value in the model ["
+ "Cannot establish a constructed value ["
+ getURI()
- + "] withing the value ["
- + getKey()
+ "].";
- throw new ModelRuntimeException( error, e );
+ throw new ComponentRuntimeException( error, e );
}
}
@@ -231,7 +190,7 @@
* @return the context entry value
*/
public Object getValue( Value p )
- throws ModelException
+ throws ComponentException
{
String argument = p.getArgument();
Object object = checkForURNReference( argument );
@@ -251,10 +210,10 @@
* @param argument a single string constructor argument
* @param parameters an alternative sequence of arguments
* @return the value
- * @exception ModelException if the parameter value cannot be resolved
+ * @exception ComponentException if the parameter value cannot be
resolved
*/
public Object getValue( Class clazz, String argument, Value[] parameters
)
- throws ModelException
+ throws ComponentException
{
if( parameters.length == 0 )
{
@@ -274,7 +233,7 @@
}
private Object getMultiArgumentConstructorValue( Class clazz, Value[]
parameters )
- throws ModelException
+ throws ComponentException
{
//
// getting here means we are dealing with 0..n types parameter
constructor where the
@@ -295,7 +254,7 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
catch ( IllegalAccessException e )
{
@@ -305,7 +264,7 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
}
else
@@ -328,7 +287,7 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
}
@@ -351,7 +310,7 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
}
Constructor constructor = null;
@@ -367,7 +326,7 @@
+ "] withing the value type ["
+ getURI()
+ "] does not match the available class constructors.";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
try
@@ -382,7 +341,7 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
catch ( IllegalAccessException e )
{
@@ -392,7 +351,7 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
catch ( Throwable e )
{
@@ -402,16 +361,13 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
}
}
-
-
-
private Object getNullArgumentConstructorValue( Class clazz )
- throws ModelException
+ throws ComponentException
{
try
{
@@ -425,7 +381,7 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
catch ( IllegalAccessException e )
{
@@ -435,7 +391,7 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
catch ( Throwable e )
{
@@ -445,12 +401,12 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
}
private Object getSingleArgumentConstructorValue( Class clazz, String
argument )
- throws ModelException
+ throws ComponentException
{
Object object = checkForURNReference( argument );
if( null != object )
@@ -484,7 +440,7 @@
+ "] referenced withing the value type ["
+ getURI()
+ "] does not implement a single string argument
constructor.";
- throw new ModelException( error );
+ throw new ComponentException( error );
}
catch ( InstantiationException e )
{
@@ -496,7 +452,7 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
catch ( IllegalAccessException e )
{
@@ -506,7 +462,7 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
catch ( Throwable e )
{
@@ -516,12 +472,12 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
}
}
- private Object getPrimitiveValue( Class clazz, String argument ) throws
ModelException
+ private Object getPrimitiveValue( Class clazz, String argument ) throws
ComponentException
{
if( Integer.TYPE == clazz )
{
@@ -559,16 +515,16 @@
+ "] withing the value type ["
+ getURI()
+ "] is not supported.";
- throw new ModelException( error );
+ throw new ComponentException( error );
}
}
/**
* Return the classname of the parameter implementation to use.
* @return the parameter class
- * @exception ModelException if the parameter class cannot be resolved
+ * @exception ComponentException if the parameter class cannot be
resolved
*/
- Class getValueClass( Value value ) throws ModelException
+ Class getValueClass( Value value ) throws ComponentException
{
String v = value.getArgument();
Object object = checkForURNReference( v );
@@ -586,9 +542,9 @@
/**
* Return the classname of the parameter implementation to use.
* @return the parameter class
- * @exception ModelException if the parameter class cannot be resolved
+ * @exception ComponentException if the parameter class cannot be
resolved
*/
- Class getValueClass( String classname ) throws ModelException
+ Class getValueClass( String classname ) throws ComponentException
{
try
{
@@ -644,7 +600,7 @@
+ "] withing the value type ["
+ getURI()
+ "].";
- throw new ModelException( error, e );
+ throw new ComponentException( error, e );
}
}
}
@@ -661,10 +617,10 @@
URI urn = CompositionController.createURI( "system", arg );
return getParentResource( urn );
}
- else if ( argument.startsWith( "urn:model:" ) )
+ else if ( argument.startsWith( "urn:component:" ) )
{
- String arg = argument.substring( 10 );
- URI urn = CompositionController.createURI( "model", arg );
+ String arg = argument.substring( 14 );
+ URI urn = CompositionController.createURI( "component", arg );
return getParentResource( urn );
}
else
@@ -685,13 +641,13 @@
"Cannot resolve a parent resource urn from a non-nested
component."
+ "\nQuery URN: " + urn
+ "\nComponent URI: " + getURI();
- throw new ModelRuntimeException( error );
+ throw new ComponentRuntimeException( error );
}
}
/*
private void validate()
- throws ModelException
+ throws ComponentException
{
final String descriptorClassName = m_descriptor.getClassname();
final String directiveClassName = m_directive.getClassname();
@@ -699,7 +655,7 @@
}
private void validatePair( String descriptorClassName, String
directiveClassName )
- throws ModelException
+ throws ComponentException
{
if( "int".equals( descriptorClassName ) )
{
@@ -715,7 +671,7 @@
+ "] does not match the supplied directive class ["
+ directiveClassName
+ "].";
- throw new ModelException( error );
+ throw new ComponentException( error );
}
}
@@ -738,7 +694,7 @@
+ "] declared under the key ["
+ key
+ "] not found.";
- throw new ModelException( error );
+ throw new ComponentException( error );
}
Class source = null;
@@ -755,7 +711,7 @@
+ "] declared under the key ["
+ key
+ "] not found.";
- throw new ModelException( error );
+ throw new ComponentException( error );
}
if( !target.isAssignableFrom( source ) )
@@ -768,7 +724,7 @@
+ "] is not assignable to the context entry return type ["
+ descriptorClassName
+ "].";
- throw new ModelException( error );
+ throw new ComponentException( error );
}
}
*/
Modified:
development/main/metro/part/src/main/net/dpml/part/control/Controller.java
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/control/Controller.java
(original)
+++
development/main/metro/part/src/main/net/dpml/part/control/Controller.java
Thu Jun 30 22:52:28 2005
@@ -24,8 +24,8 @@
import java.rmi.RemoteException;
import net.dpml.part.manager.Component;
-import net.dpml.part.model.Model;
-import net.dpml.part.model.ModelException;
+import net.dpml.part.manager.Container;
+import net.dpml.part.manager.ComponentException;
import net.dpml.part.part.Part;
/**
@@ -50,20 +50,45 @@
* <li>system:domain.uri</li>
* <li>system:work.dir</li>
* <li>system:temp.dir</li>
- * <li>model:name</li>
- * <li>model:urn</li>
- * <li>model:partition</li>
+ * <li>component:name</li>
+ * <li>component:urn</li>
+ * <li>component:partition</li>
* </ol>
*
* An implementation may choose to provide support for additional urns
beyond those
* listed in the above table.
*
- * @param model the model from which any model relative urn values are to
be resolved
+ * @param component the component from which any relative urn values are
to be resolved
* @param urn the uniform resource identifier identifying the requested
resource
* @return the resource matching the supplied urn
* @exception IllegalStateException if the supplied urn is not valid
*/
- Object getResource( Model model, URI urn );
+ Object getResource( Component component, URI urn );
+
+ /**
+ * Construct a new top-level component.
+ *
+ * @param uri a uri identifying a part
+ * @return the model of the part
+ */
+ Component newComponent( URI uri ) throws
+ ComponentException, IOException, PartNotFoundException,
HandlerNotFoundException,
+ DelegationException;
+
+ /**
+ * Construct a new component under a supplied classloader and part.
+ *
+ * @param parent the parent classloader
+ * @param the enclosing component
+ * @param part component definition
+ * @param name the name to assign to the new component
+ * @return a new component
+ */
+ Component newComponent( ClassLoader parent, Component component, Part
part, String name )
+ throws ComponentException, HandlerNotFoundException,
DelegationException;
+
+
+
//===================================================================================
/**
* Return a model using a part uri and key.
@@ -72,9 +97,9 @@
* @param key the key to assign to the model
* @return the model of the part
*/
- Model getModel( URI uri, String key )
- throws IOException, DelegationException, ModelException,
PartNotFoundException,
- HandlerNotFoundException, DelegationException;
+ //Model getModel( URI uri, String key )
+ // throws IOException, DelegationException, ComponentException,
PartNotFoundException,
+ // HandlerNotFoundException;
/**
* Return a new model for a supplied part.
@@ -84,8 +109,8 @@
* @param name the name to assign to the model
* @return the model
*/
- Model getModel( ClassLoader parent, Part part, String name )
- throws ModelException, HandlerNotFoundException, DelegationException;
+ //Model getModel( ClassLoader parent, Part part, String name )
+ // throws ComponentException, HandlerNotFoundException,
DelegationException;
/**
* Return a default service provider component.
@@ -93,8 +118,8 @@
* @param model the reference model
* @return the service provider
*/
- Component getComponent( Model model )
- throws ModelException;
+ //Component getComponent( Model model )
+ // throws ComponentException;
/**
* Return an identified service provider component.
@@ -103,8 +128,8 @@
* @param identity the privider identity
* @return the service provider
*/
- Component getComponent( Model model, Object identity )
- throws ModelException;
+ //Component getComponent( Model model, Object identity )
+ // throws ComponentException;
/**
* Return a component for a supplied part.
@@ -114,7 +139,7 @@
* @param name the name to assign to the provider model
* @return the default provider
*/
- Component getComponent( ClassLoader parent, Part part, String name )
- throws ModelException, HandlerNotFoundException, DelegationException;
+ //Component getComponent( ClassLoader parent, Part part, String name )
+ // throws ComponentException, HandlerNotFoundException,
DelegationException;
}
Modified:
development/main/metro/part/src/main/net/dpml/part/control/LifecycleException.java
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/control/LifecycleException.java
(original)
+++
development/main/metro/part/src/main/net/dpml/part/control/LifecycleException.java
Thu Jun 30 22:52:28 2005
@@ -18,7 +18,7 @@
package net.dpml.part.control;
-import net.dpml.part.model.Model;
+import net.dpml.part.manager.Component;
/**
@@ -27,24 +27,24 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id: LifecycleException.java 259 2004-10-30 07:24:40Z mcconnell $
*/
-public class LifecycleException
- extends Exception
+public class LifecycleException extends Exception
{
- private Model m_model;
+ private Component m_component;
/**
* Construct a new <code>LifecycleException</code> instance.
*
* @param throwable the root cause of the exception
*/
- public LifecycleException( final Model model, final Throwable throwable )
+ public LifecycleException( final Component component, final Throwable
throwable )
{
super( null, throwable );
+ m_component = component;
}
- public Model getModel()
+ public Component getComponent()
{
- return m_model;
+ return m_component;
}
}
Modified:
development/main/metro/part/src/main/net/dpml/part/manager/Component.java
==============================================================================
--- development/main/metro/part/src/main/net/dpml/part/manager/Component.java
(original)
+++ development/main/metro/part/src/main/net/dpml/part/manager/Component.java
Thu Jun 30 22:52:28 2005
@@ -25,7 +25,6 @@
import net.dpml.part.state.StateEvent;
import net.dpml.part.state.StateListener;
import net.dpml.part.control.Identifiable;
-import net.dpml.part.model.Model;
/**
* The Component interface is implemented by objects that handle the runtime
@@ -37,19 +36,19 @@
public interface Component
{
/**
- * Returns the identity of the object implementing this interface.
- * @return a uri identifying the object
+ * Return the short name of this component.
+ * @return the component name
*/
- URI getURI();
+ String getName();
/**
- * Return the model that this compoent is based on.
- * @return the component's generic model.
+ * Returns the identity of the component.
+ * @return a uri identifying the component
*/
- Model getModel();
+ URI getURI();
/**
- * Return the operational status of the model.
+ * Return the operational status of the component.
* @return the operational status
*/
boolean isOperational();
Added:
development/main/metro/part/src/main/net/dpml/part/manager/ComponentException.java
==============================================================================
--- (empty file)
+++
development/main/metro/part/src/main/net/dpml/part/manager/ComponentException.java
Thu Jun 30 22:52:28 2005
@@ -0,0 +1,40 @@
+/*
+ * 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.part.manager;
+
+/**
+ * Exception raised by a component.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class ComponentException extends Exception
+{
+ public ComponentException( String message )
+ {
+ this( message, null );
+ }
+
+ public ComponentException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
+
Added:
development/main/metro/part/src/main/net/dpml/part/manager/ComponentNotFoundException.java
==============================================================================
--- (empty file)
+++
development/main/metro/part/src/main/net/dpml/part/manager/ComponentNotFoundException.java
Thu Jun 30 22:52:28 2005
@@ -0,0 +1,40 @@
+/*
+ * 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.part.manager;
+
+/**
+ * Exception thrown in response to an attempt to register a part model
+ * under a key that is already assigned.
+ *
+ * @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 ComponentNotFoundException extends ContainmentException
+{
+ public ComponentNotFoundException( String key )
+ {
+ super( key );
+ }
+
+ public String getKey()
+ {
+ return getMessage();
+ }
+}
+
Added:
development/main/metro/part/src/main/net/dpml/part/manager/ComponentRuntimeException.java
==============================================================================
--- (empty file)
+++
development/main/metro/part/src/main/net/dpml/part/manager/ComponentRuntimeException.java
Thu Jun 30 22:52:28 2005
@@ -0,0 +1,40 @@
+/*
+ * 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.part.manager;
+
+/**
+ * Exception raised by a component.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class ComponentRuntimeException extends RuntimeException
+{
+ public ComponentRuntimeException( String message )
+ {
+ this( message, null );
+ }
+
+ public ComponentRuntimeException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
+
Modified:
development/main/metro/part/src/main/net/dpml/part/manager/Container.java
==============================================================================
--- development/main/metro/part/src/main/net/dpml/part/manager/Container.java
(original)
+++ development/main/metro/part/src/main/net/dpml/part/manager/Container.java
Thu Jun 30 22:52:28 2005
@@ -22,48 +22,35 @@
import java.net.URI;
import net.dpml.part.control.DelegationException;
-import net.dpml.part.control.PartNotFoundException;
import net.dpml.part.control.HandlerNotFoundException;
-import net.dpml.part.model.Model;
-import net.dpml.part.model.ModelException;
-
+import net.dpml.part.control.PartNotFoundException;
/**
- * The SystemManager interface defines the a contract for a object that is
capable of
- * operational management of a set of arbitary models within the scope of a
single
- * jvm.
+ * The Container interface defines the a contract for a component that
+ * manages a collection of subsidiary components.
*
* @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 Container extends Component
{
- /**
- * Add a component to the collection of components managed by this
controller.
- *
- * @param uri a part uri
- * @param key the key under which the component will be registered
- * @return the registered component
- */
- Component addComponent( URI uri, String key )
- throws IOException, DelegationException, ModelException,
PartNotFoundException,
- HandlerNotFoundException;
-
/**
- * Add a part designated by a supplied uri to the system scope.
- * @param uri a part uri
- * @param id a component identifier
- * @param key the key under which the component will be registered
- * @return the registered component
+ * Add a component to the collection of components managed by the
container.
+ *
+ * @param part a part uri
+ * @param key the key under which the component will be referenced
+ * @return the component
*/
- Component addComponent( URI uri, Object id, String key )
- throws IOException, DelegationException, ModelException,
PartNotFoundException,
- HandlerNotFoundException;
+ Component addComponent( URI part, String key )
+ throws IOException, ComponentException, PartNotFoundException,
+ HandlerNotFoundException, DelegationException;
/**
- * Register a component with the system.
- * @param component the component to register
+ * Retrieve a component using a supplied key.
+ * @param the key
+ * @return the component
+ * @exception ComponentNotFoundException if the key is unknown
*/
- void addComponent( Component component );
+ Component getComponent( String key ) throws ComponentNotFoundException;
}
Added:
development/main/metro/part/src/main/net/dpml/part/manager/ContainmentException.java
==============================================================================
--- (empty file)
+++
development/main/metro/part/src/main/net/dpml/part/manager/ContainmentException.java
Thu Jun 30 22:52:28 2005
@@ -0,0 +1,40 @@
+/*
+ * 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.part.manager;
+
+/**
+ * Exception raised by a container.
+ *
+ * @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 ContainmentException extends Exception
+{
+ public ContainmentException( String message )
+ {
+ this( message, null );
+ }
+
+ public ContainmentException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
+
Copied:
development/main/metro/part/src/main/net/dpml/part/manager/DuplicateKeyException.java
(from r2941,
development/main/metro/part/src/main/net/dpml/part/model/DuplicateKeyException.java)
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/model/DuplicateKeyException.java
(original)
+++
development/main/metro/part/src/main/net/dpml/part/manager/DuplicateKeyException.java
Thu Jun 30 22:52:28 2005
@@ -16,15 +16,14 @@
* limitations under the License.
*/
-package net.dpml.part.model;
-
+package net.dpml.part.manager;
/**
* Exception thrown when a operation attempts to overrite an existing key.
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
*/
-public class DuplicateKeyException extends RuntimeException
+public class DuplicateKeyException extends ComponentRuntimeException
{
private String m_transition;
Copied:
development/main/metro/part/src/main/net/dpml/part/manager/PartClassNotFoundException.java
(from r2941,
development/main/metro/part/src/main/net/dpml/part/model/PartClassNotFoundException.java)
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/model/PartClassNotFoundException.java
(original)
+++
development/main/metro/part/src/main/net/dpml/part/manager/PartClassNotFoundException.java
Thu Jun 30 22:52:28 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.part.model;
+package net.dpml.part.manager;
/**
* Exception thrown when an attempt is made to locate a class declared
@@ -25,7 +25,7 @@
* @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 PartClassNotFoundException extends ModelRuntimeException
+public class PartClassNotFoundException extends ComponentRuntimeException
{
private String m_classname;
Copied:
development/main/metro/part/src/main/net/dpml/part/manager/ResourceUnavailableException.java
(from r2941,
development/main/metro/part/src/main/net/dpml/part/model/ResourceUnavailableException.java)
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/model/ResourceUnavailableException.java
(original)
+++
development/main/metro/part/src/main/net/dpml/part/manager/ResourceUnavailableException.java
Thu Jun 30 22:52:28 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.part.model;
+package net.dpml.part.manager;
/**
* Exception thrown in response to an attempt to register a part model
@@ -25,7 +25,7 @@
* @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 ResourceUnavailableException extends ModelException
+public class ResourceUnavailableException extends ComponentException
{
private String m_key;
Copied:
development/main/metro/part/src/main/net/dpml/part/manager/ServiceClassNotFoundException.java
(from r2941,
development/main/metro/part/src/main/net/dpml/part/model/ServiceClassNotFoundException.java)
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/model/ServiceClassNotFoundException.java
(original)
+++
development/main/metro/part/src/main/net/dpml/part/manager/ServiceClassNotFoundException.java
Thu Jun 30 22:52:28 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.part.model;
+package net.dpml.part.manager;
/**
* Unexpected runtime exception indicating an internal model error.
@@ -24,7 +24,7 @@
* @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 ServiceClassNotFoundException extends ModelRuntimeException
+public class ServiceClassNotFoundException extends ComponentRuntimeException
{
private String m_serviceClassname;
private String m_componentClassname;
Copied:
development/main/metro/part/src/main/net/dpml/part/manager/TypeClassNotFoundException.java
(from r2941,
development/main/metro/part/src/main/net/dpml/part/model/TypeClassNotFoundException.java)
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/model/TypeClassNotFoundException.java
(original)
+++
development/main/metro/part/src/main/net/dpml/part/manager/TypeClassNotFoundException.java
Thu Jun 30 22:52:28 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package net.dpml.part.model;
+package net.dpml.part.manager;
/**
* Unexpected runtime exception indicating an internal model error.
@@ -24,7 +24,7 @@
* @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 TypeClassNotFoundException extends ModelRuntimeException
+public class TypeClassNotFoundException extends ComponentRuntimeException
{
private String m_classname;
Modified: development/main/metro/part/src/main/net/dpml/part/part/Part.java
==============================================================================
--- development/main/metro/part/src/main/net/dpml/part/part/Part.java
(original)
+++ development/main/metro/part/src/main/net/dpml/part/part/Part.java Thu
Jun 30 22:52:28 2005
@@ -36,5 +36,4 @@
* @return the uri of the part handler
*/
URI getPartHandlerURI();
-
}
Modified:
development/main/test/components/plus/src/main/net/dpml/test/acme/plus/ConfigurableContainer.java
==============================================================================
---
development/main/test/components/plus/src/main/net/dpml/test/acme/plus/ConfigurableContainer.java
(original)
+++
development/main/test/components/plus/src/main/net/dpml/test/acme/plus/ConfigurableContainer.java
Thu Jun 30 22:52:28 2005
@@ -27,7 +27,6 @@
import net.dpml.activity.Executable;
import net.dpml.part.control.Controller;
-import net.dpml.part.model.Model;
import net.dpml.part.manager.Component;
/**
@@ -73,17 +72,17 @@
public void execute() throws Exception
{
Parts parts = getParts();
- Model model = parts.getTestModel();
- if( model instanceof Configurable )
+ Component component = parts.getTestComponent();
+ if( component instanceof Configurable )
{
Configuration conf = m_configuration.getChild( "test", false );
if( null != conf )
{
- getLogger().info( "applying configuration to " + model );
- ((Configurable)model).configure( conf );
+ getLogger().info( "applying configuration to " + component );
+ ((Configurable)component).configure( conf );
}
}
- parts.getTestComponent().resolve();
+ component.resolve();
}
private Logger getLogger()
@@ -102,7 +101,6 @@
public interface Parts
{
- Model getTestModel();
Component getTestComponent();
}
}
Modified:
development/main/test/components/simple/src/main/net/dpml/test/acme/AcmeContainer.java
==============================================================================
---
development/main/test/components/simple/src/main/net/dpml/test/acme/AcmeContainer.java
(original)
+++
development/main/test/components/simple/src/main/net/dpml/test/acme/AcmeContainer.java
Thu Jun 30 22:52:28 2005
@@ -104,15 +104,11 @@
// our parts interface
//
- debug( "getting identified gizmo" );
- Gizmo myGizmo = parts.getGizmo( "my-gizmo" );
-
debug( "getting identified non-proxied gizmo" );
- Gizmo myProxiedGizmo = parts.getGizmo( "my-gizmo", true );
+ Gizmo myProxiedGizmo = parts.getGizmo( true );
debug( "cleaning up" );
parts.releaseGizmo( gizmo );
- parts.releaseGizmo( myGizmo );
parts.releaseGizmo( myProxiedGizmo );
}
@@ -166,20 +162,12 @@
ColorContext.Manager getGizmoContextManager();
/**
- * Return an identified instance of gizmo.
- *
- * @param key the instance identifier
- * @return the gizmo service
- */
- Gizmo getGizmo( Object key );
-
- /**
- * Return an identified instance of gizmo using a supplied proxy
policy.
+ * Return an instance of gizmo using a supplied proxy policy.
*
* @param key the instance identifier
* @return the gizmo service
*/
- Gizmo getGizmo( Object key, boolean policy );
+ Gizmo getGizmo( boolean policy );
/**
* Optional release of an instance of the gizmo component.
Modified:
development/main/test/components/simple/src/main/net/dpml/test/acme/WidgetComponent.java
==============================================================================
---
development/main/test/components/simple/src/main/net/dpml/test/acme/WidgetComponent.java
(original)
+++
development/main/test/components/simple/src/main/net/dpml/test/acme/WidgetComponent.java
Thu Jun 30 22:52:28 2005
@@ -69,7 +69,6 @@
m_name = context.getName();
URI uri = context.getUri();
File work = context.getWorkingDirectory();
- URI partition = context.getPartition();
final String message =
"Widget created with a uri ["
@@ -161,7 +160,6 @@
public interface Context extends ColorContext
{
String getName();
- URI getPartition();
URI getUri();
File getWorkingDirectory();
Dimension getDimension( Dimension d );
Modified:
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/ConfigurationTestCase.java
==============================================================================
---
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/ConfigurationTestCase.java
(original)
+++
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/ConfigurationTestCase.java
Thu Jun 30 22:52:28 2005
@@ -26,7 +26,6 @@
import junit.framework.TestCase;
import net.dpml.part.control.Controller;
-import net.dpml.part.model.Model;
import net.dpml.part.manager.Component;
import net.dpml.metro.central.MetroHelper;
@@ -47,8 +46,7 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "configurable-container.part" );
- Model model = helper.getController().getModel( uri, "container" );
- Component component = helper.getController().getComponent( model );
+ Component component = helper.getController().newComponent( uri );
ConfigurableContainer container = (ConfigurableContainer)
component.resolve( false );
component.release( container );
helper.dispose();
Modified:
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/ManagementTestCase.java
==============================================================================
---
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/ManagementTestCase.java
(original)
+++
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/ManagementTestCase.java
Thu Jun 30 22:52:28 2005
@@ -29,7 +29,6 @@
import net.dpml.metro.central.MetroHelper;
import net.dpml.part.manager.Component;
-import net.dpml.part.model.Model;
import net.dpml.part.state.State;
/**
@@ -86,7 +85,6 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( path );
- Model model = helper.getController().getModel( uri, "test" );
- return helper.getController().getComponent( model, this );
+ return helper.getController().newComponent( uri );
}
}
Modified:
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/URLTestCase.java
==============================================================================
---
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/URLTestCase.java
(original)
+++
development/main/test/unit/plus/src/test/net/dpml/test/acme/plus/URLTestCase.java
Thu Jun 30 22:52:28 2005
@@ -27,7 +27,6 @@
import net.dpml.part.part.Part;
import net.dpml.part.manager.Component;
-import net.dpml.part.model.Model;
import net.dpml.test.acme.Dimension;
@@ -62,18 +61,8 @@
public void testComponentAquisition() throws Exception
{
URL url = new URL( SIMPLE_TEST_PART );
- Component provider = (Component) url.getContent( new Class[]{
Component.class } );
- Dimension d = (Dimension) provider.resolve();
- }
-
- /**
- * Test loading of a component deployment model via URL.
- */
- public void testComponentModelAquisition() throws Exception
- {
- URL url = new URL( SIMPLE_TEST_PART );
- Model model = (Model) url.getContent( new Class[]{ Model.class } );
- assertNotNull( "model", model );
+ Component component = (Component) url.getContent( new Class[]{
Component.class } );
+ Dimension d = (Dimension) component.resolve();
}
/**
Modified: development/main/test/unit/simple/build.xml
==============================================================================
--- development/main/test/unit/simple/build.xml (original)
+++ development/main/test/unit/simple/build.xml Thu Jun 30 22:52:28 2005
@@ -22,9 +22,8 @@
type="net.dpml.test.acme.WidgetComponent"
name="widget">
<context>
- <value key="name" value="urn:model:name"/>
- <value key="partition" value="urn:model:partition"/>
- <value key="uri" value="urn:model:uri"/>
+ <value key="name" value="urn:component:name"/>
+ <value key="uri" value="urn:component:uri"/>
<value key="workingDirectory">
<param class="java.io.File" value="urn:system:work.dir"/>
<param value="acme/workspace"/>
@@ -49,9 +48,8 @@
type="net.dpml.test.acme.WidgetComponent"
name="widget">
<context>
- <value key="name" value="urn:model:name"/>
- <value key="partition" value="urn:model:partition"/>
- <value key="uri" value="urn:model:uri"/>
+ <value key="name" value="urn:component:name"/>
+ <value key="uri" value="urn:component:uri"/>
<value key="workingDirectory">
<param class="java.io.File" value="urn:system:work.dir"/>
<param value="acme/workspace"/>
@@ -151,9 +149,8 @@
<param class="java.io.File" value="urn:system:work.dir"/>
<param value="acme/workspace"/>
</value>
- <value key="name" value="urn:model:name"/>
- <value key="partition" value="urn:model:partition"/>
- <value key="uri" value="urn:model:uri"/>
+ <value key="name" value="urn:component:name"/>
+ <value key="uri" value="urn:component:uri"/>
</context>
</component>
<component name="gizmo" type="net.dpml.test.acme.GizmoComponent">
Modified:
development/main/test/unit/simple/src/test/net/dpml/test/acme/CompositeTestCase.java
==============================================================================
---
development/main/test/unit/simple/src/test/net/dpml/test/acme/CompositeTestCase.java
(original)
+++
development/main/test/unit/simple/src/test/net/dpml/test/acme/CompositeTestCase.java
Thu Jun 30 22:52:28 2005
@@ -26,7 +26,6 @@
import junit.framework.TestCase;
import net.dpml.part.control.Controller;
-import net.dpml.part.model.Model;
import net.dpml.part.manager.Component;
import net.dpml.metro.central.MetroHelper;
@@ -67,8 +66,10 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "acme-bad-widget.part" );
- Component component = helper.getCompositionManager().addComponent(
uri, "acme" );
+
+ Component component = helper.getController().newComponent( uri );
AcmeContainer container = (AcmeContainer) component.resolve( false );
+
try
{
container.execute();
@@ -88,7 +89,8 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( path );
- Component component = helper.getCompositionManager().addComponent(
uri, "acme" );
+
+ Component component = helper.getController().newComponent( uri );
AcmeContainer container = (AcmeContainer) component.resolve( false );
try
{
Added:
development/main/test/unit/simple/src/test/net/dpml/test/acme/ContainerTestCase.java
==============================================================================
--- (empty file)
+++
development/main/test/unit/simple/src/test/net/dpml/test/acme/ContainerTestCase.java
Thu Jun 30 22:52:28 2005
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * 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.test.acme;
+
+import java.net.URI;
+import java.util.Hashtable;
+import java.util.Map.Entry;
+
+import junit.framework.TestCase;
+
+import net.dpml.part.control.Controller;
+import net.dpml.part.manager.Component;
+import net.dpml.part.manager.Container;
+
+import net.dpml.metro.central.MetroHelper;
+
+/**
+ * Test a simple component case.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: AbstractDescriptorTestCase.java 1556 2005-01-22 12:43:42Z
niclas $
+ */
+public class ContainerTestCase extends TestCase
+{
+ private static final String PATH = "acme-simple.part";
+
+ /**
+ * Test the construction of the widget component and the invocation of
+ * an operation on the widget service interface.
+ */
+ public void testGetValue() throws Exception
+ {
+ MetroHelper helper = new MetroHelper();
+ URI uri = helper.toURI( PATH );
+ Component component = helper.getController().newComponent( uri );
+ Widget widget = (Widget) component.resolve();
+ widget.doWidgetStuff( "green" );
+ component.release( widget );
+ }
+}
Modified:
development/main/test/unit/simple/src/test/net/dpml/test/acme/ExampleTestCase.java
==============================================================================
---
development/main/test/unit/simple/src/test/net/dpml/test/acme/ExampleTestCase.java
(original)
+++
development/main/test/unit/simple/src/test/net/dpml/test/acme/ExampleTestCase.java
Thu Jun 30 22:52:28 2005
@@ -25,7 +25,6 @@
import junit.framework.TestCase;
-import net.dpml.part.model.Model;
import net.dpml.part.manager.Component;
import net.dpml.part.control.Controller;
@@ -47,8 +46,8 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "acme-example-one.part" );
- Model model = helper.getController().getModel( uri, "example" );
- Example example = (Example) helper.getController().getComponent(
model ).resolve();
+ Component component = helper.getController().newComponent( uri );
+ Example example = (Example) component.resolve();
example.doMyStuff();
}
@@ -61,8 +60,8 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "acme-example-two.part" );
- Model model = helper.getController().getModel( uri, "example" );
- Example example = (Example) helper.getController().getComponent(
model ).resolve();
+ Component component = helper.getController().newComponent( uri );
+ Example example = (Example) component.resolve();
example.doMyStuff();
}
@@ -74,8 +73,8 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "acme-example-three.part" );
- Model model = helper.getController().getModel( uri, "example" );
- Example example = (Example) helper.getController().getComponent(
model ).resolve();
+ Component component = helper.getController().newComponent( uri );
+ Example example = (Example) component.resolve();
example.doMyStuff();
}
@@ -88,8 +87,8 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "acme-example-four.part" );
- Model model = helper.getController().getModel( uri, "example" );
- Example example = (Example) helper.getController().getComponent(
model ).resolve();
+ Component component = helper.getController().newComponent( uri );
+ Example example = (Example) component.resolve();
example.doMyStuff();
}
}
Modified:
development/main/test/unit/simple/src/test/net/dpml/test/acme/SimpleTestCase.java
==============================================================================
---
development/main/test/unit/simple/src/test/net/dpml/test/acme/SimpleTestCase.java
(original)
+++
development/main/test/unit/simple/src/test/net/dpml/test/acme/SimpleTestCase.java
Thu Jun 30 22:52:28 2005
@@ -25,7 +25,6 @@
import junit.framework.TestCase;
-import net.dpml.part.model.Model;
import net.dpml.part.control.Controller;
import net.dpml.part.manager.Component;
@@ -54,8 +53,7 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( PATH );
- Model model = helper.getController().getModel( uri, "widget" );
- Component component = helper.getController().getComponent( model );
+ Component component = helper.getController().newComponent( uri );
Widget widget = (Widget) component.resolve();
widget.doWidgetStuff( "green" );
component.release( widget );
@@ -69,8 +67,7 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "acme-widget.part" );
- Model model = helper.getController().getModel( uri, "widget" );
- Component component = helper.getController().getComponent( model );
+ Component component = helper.getController().newComponent( uri );
Widget widget = (Widget) component.resolve();
widget.doWidgetStuff( "green" );
component.release( widget );
@@ -83,8 +80,7 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( PATH );
- Model model = helper.getController().getModel( uri, "widget" );
- Component component = helper.getController().getComponent( model );
+ Component component = helper.getController().newComponent( uri );
Widget widget = (Widget) component.resolve();
try
{
@@ -109,8 +105,7 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( PATH );
- Model model = helper.getController().getModel( uri, "widget" );
- Component component = helper.getController().getComponent( model );
+ Component component = helper.getController().newComponent( uri );
WidgetComponent widget = (WidgetComponent) component.resolve( false
);
String name = widget.getName();
assertEquals( "name", "widget", name );
@@ -129,8 +124,7 @@
String id = "steve";
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( PATH );
- Model model = helper.getController().getModel( uri, "widget" );
- Component component = helper.getController().getComponent( model );
+ Component component = helper.getController().newComponent( uri );
WidgetComponent widget = (WidgetComponent) component.resolve( false
);
component.release( widget );
}
@@ -146,22 +140,13 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( PATH );
- Model model = helper.getController().getModel( uri, "widget" );
- Component c1 = helper.getController().getComponent( model,
"acme-widget-one" );
- Component c2 = helper.getController().getComponent( model,
"acme-widget-two" );
+ Component c1 = helper.getController().newComponent( uri );
+ Component c2 = helper.getController().newComponent( uri );
Widget w1 = (Widget) c1.resolve( false );
Widget w2 = (Widget) c2.resolve( false );
if( w1.equals( w2 ) )
{
fail( "Widget w1 and w2 are not unique!" );
}
- Component c3 = helper.getController().getComponent( model,
"acme-widget-one" );
- Widget w3 = (Widget) c3.resolve( false );
- if( !w1.equals( w3 ) )
- {
- System.out.println( "" + System.identityHashCode( w1 ) );
- System.out.println( "" + System.identityHashCode( w3 ) );
- fail( "Widget w1 and w3 are not the same!" );
- }
}
}
Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/util/StandardFormatter.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/util/StandardFormatter.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/util/StandardFormatter.java
Thu Jun 30 22:52:28 2005
@@ -54,9 +54,9 @@
buffer.append( lineSeparator );
if( record.getThrown() != null )
{
- boolean trace = record.getLevel().intValue() > 900;
+ //boolean trace = record.getLevel().intValue() > 900;
Throwable cause = record.getThrown();
- String error = ExceptionHelper.packException( cause, trace );
+ String error = ExceptionHelper.packException( cause, true );
buffer.append( error );
}
return buffer.toString();
Modified: development/planet/http/demo/src/main/net/dpml/http/Demo.java
==============================================================================
--- development/planet/http/demo/src/main/net/dpml/http/Demo.java
(original)
+++ development/planet/http/demo/src/main/net/dpml/http/Demo.java Thu
Jun 30 22:52:28 2005
@@ -23,7 +23,6 @@
import net.dpml.http.HttpService;
import net.dpml.http.HttpContextService;
-import net.dpml.part.model.Model;
import net.dpml.part.manager.Component;
import org.mortbay.http.HttpHandler;
Modified:
development/planet/http/demo/src/test/net/dpml/http/HttpTestCase.java
==============================================================================
--- development/planet/http/demo/src/test/net/dpml/http/HttpTestCase.java
(original)
+++ development/planet/http/demo/src/test/net/dpml/http/HttpTestCase.java
Thu Jun 30 22:52:28 2005
@@ -23,7 +23,6 @@
import junit.framework.TestCase;
-import net.dpml.part.model.Model;
import net.dpml.part.control.Controller;
import net.dpml.part.manager.Component;
@@ -45,12 +44,12 @@
*/
public void testHttp() throws Exception
{
- String id = "steve";
+ String id = "test";
MetroHelper helper = new MetroHelper();
Controller controller = helper.getController();
URI uri = helper.toURI( PATH );
- Model model = controller.getModel( uri, "demo" );
- Component component = controller.getComponent( model );
+ Component component = controller.newComponent( uri );
Demo demo = (Demo) component.resolve( false );
+ component.terminate();
}
}
Modified:
development/planet/http/impl/src/main/net/dpml/http/impl/HttpServerImpl.java
==============================================================================
---
development/planet/http/impl/src/main/net/dpml/http/impl/HttpServerImpl.java
(original)
+++
development/planet/http/impl/src/main/net/dpml/http/impl/HttpServerImpl.java
Thu Jun 30 22:52:28 2005
@@ -37,9 +37,6 @@
private Logger m_logger;
private boolean m_Graceful;
- /**
- * @metro.logger name="http"
- */
public HttpServerImpl(Logger logger, Context context )
{
m_logger = logger;
- svn commit: r2943 - in development: main/metro/central/src/main/net/dpml/metro/central main/metro/composition main/metro/composition/builder/src/main/net/dpml/composition/builder main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes main/metro/composition/control main/metro/composition/control/src/main/net/dpml/composition/control main/metro/composition/control/src/main/net/dpml/composition/data main/metro/composition/control/src/main/net/dpml/composition/info main/metro/composition/control/src/main/net/dpml/composition/model main/metro/composition/control/src/main/net/dpml/composition/runtime main/metro/composition/control/src/test/net/dpml/composition/data main/metro/composition/control/src/test/net/dpml/composition/management main/metro/part/src/main/net/dpml/part/control main/metro/part/src/main/net/dpml/part/manager main/metro/part/src/main/net/dpml/part/model main/metro/part/src/main/net/dpml/part/part main/test/components/plus/src/main/net/dpml/test/acme/plus main/test/components/simple/src/main/net/dpml/test/acme main/test/unit/plus/src/test/net/dpml/test/acme/plus main/test/unit/simple main/test/unit/simple/src/test/net/dpml/test/acme main/transit/core/handler/src/main/net/dpml/transit/util planet/http/demo/src/main/net/dpml/http planet/http/demo/src/test/net/dpml/http planet/http/impl/src/main/net/dpml/http/impl, mcconnell, 06/30/2005
Archive powered by MHonArc 2.6.24.