Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2910 - in development/main: metro metro/central/src/main/net/dpml/metro/central metro/composition/control metro/composition/control/src/main/net/dpml/composition/control metro/composition/control/src/main/net/dpml/composition/event metro/composition/control/src/main/net/dpml/composition/info metro/composition/control/src/main/net/dpml/composition/model metro/composition/control/src/main/net/dpml/composition/runtime metro/part/src/main/net/dpml/part/control metro/part/src/main/net/dpml/part/manager metro/part/src/main/net/dpml/part/model metro/part/src/main/net/dpml/part/state test/components/plus/src/main/net/dpml/test/acme/plus test/unit/plus/src/test/net/dpml/test/acme/plus test/unit/simple/src/test/net/dpml/test/acme transit/core/handler transit/core/handler/src/main/net/dpml/transit/model

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2910 - in development/main: metro metro/central/src/main/net/dpml/metro/central metro/composition/control metro/composition/control/src/main/net/dpml/composition/control metro/composition/control/src/main/net/dpml/composition/event metro/composition/control/src/main/net/dpml/composition/info metro/composition/control/src/main/net/dpml/composition/model metro/composition/control/src/main/net/dpml/composition/runtime metro/part/src/main/net/dpml/part/control metro/part/src/main/net/dpml/part/manager metro/part/src/main/net/dpml/part/model metro/part/src/main/net/dpml/part/state test/components/plus/src/main/net/dpml/test/acme/plus test/unit/plus/src/test/net/dpml/test/acme/plus test/unit/simple/src/test/net/dpml/test/acme transit/core/handler transit/core/handler/src/main/net/dpml/transit/model
  • Date: Thu, 23 Jun 2005 21:30:36 -0400

Author: mcconnell AT dpml.net
Date: Thu Jun 23 21:30:35 2005
New Revision: 2910

Added:

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/AbstractComponent.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/model/AbstractComponent.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/Appliance.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/model/Appliance.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ApplianceException.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/model/ApplianceException.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentController.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/ComponentController.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentEntry.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/model/ComponentEntry.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentTable.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/model/ComponentTable.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/CompositionManager.java
- copied, changed from r2909,
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextInvocationHandler.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextInvocationHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextManagerInvocationHandler.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextManagerInvocationHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/DefaultInvocationHandler.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/DefaultInvocationHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/DefaultLogger.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/DefaultLogger.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/DelegationRuntimeException.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/DelegationRuntimeException.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LifecycleHandler.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/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/ManagerInvocationHandler.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/ManagerInvocationHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/PartsInvocationHandler.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/PartsInvocationHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueController.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/ValueController.java

development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueEntry.java
- copied, changed from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/model/ValueEntry.java
development/main/metro/part/src/main/net/dpml/part/manager/

development/main/metro/part/src/main/net/dpml/part/manager/AvailabilityEvent.java
- copied, changed from r2901,
development/main/metro/part/src/main/net/dpml/part/model/AvailabilityEvent.java

development/main/metro/part/src/main/net/dpml/part/manager/AvailabilityListener.java
- copied, changed from r2901,
development/main/metro/part/src/main/net/dpml/part/model/AvailabilityListener.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
- copied, changed from r2901,
development/main/metro/part/src/main/net/dpml/part/control/SystemManager.java
development/main/metro/part/src/main/net/dpml/part/manager/Manager.java
- copied, changed from r2901,
development/main/metro/part/src/main/net/dpml/part/control/Manager.java
Removed:

development/main/metro/composition/control/src/main/net/dpml/composition/control/ComponentController.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/ConsoleMonitor.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextInvocationHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextManagerInvocationHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/DefaultInvocationHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/DefaultLogger.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/DefaultMonitor.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/DelegationRuntimeException.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/LifecycleHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/ManagerInvocationHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/PartsInvocationHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/ValueController.java

development/main/metro/composition/control/src/main/net/dpml/composition/model/AbstractComponent.java

development/main/metro/composition/control/src/main/net/dpml/composition/model/Appliance.java

development/main/metro/composition/control/src/main/net/dpml/composition/model/ApplianceException.java

development/main/metro/composition/control/src/main/net/dpml/composition/model/ComponentEntry.java

development/main/metro/composition/control/src/main/net/dpml/composition/model/ComponentTable.java

development/main/metro/composition/control/src/main/net/dpml/composition/model/ValueEntry.java
development/main/metro/part/src/main/net/dpml/part/control/Manageable.java
development/main/metro/part/src/main/net/dpml/part/control/Manager.java
development/main/metro/part/src/main/net/dpml/part/control/Monitor.java

development/main/metro/part/src/main/net/dpml/part/control/SystemManager.java

development/main/metro/part/src/main/net/dpml/part/model/AvailabilityEvent.java

development/main/metro/part/src/main/net/dpml/part/model/AvailabilityListener.java
development/main/metro/part/src/main/net/dpml/part/model/Component.java
development/main/metro/part/src/main/net/dpml/part/model/Provider.java
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/control/build.xml

development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionClassLoader.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionControllerContext.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionPartHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/LifestyleHandler.java

development/main/metro/composition/control/src/main/net/dpml/composition/event/WeakEventProducer.java

development/main/metro/composition/control/src/main/net/dpml/composition/info/Type.java

development/main/metro/composition/control/src/main/net/dpml/composition/model/CompositionModel.java

development/main/metro/composition/control/src/main/net/dpml/composition/model/ContextTable.java

development/main/metro/composition/control/src/main/net/dpml/composition/model/PartsTable.java

development/main/metro/composition/control/src/main/net/dpml/composition/model/ReferenceEntry.java

development/main/metro/composition/control/src/main/net/dpml/composition/model/ValueModel.java
development/main/metro/index.xml
development/main/metro/part/src/main/net/dpml/part/control/Control.java
development/main/metro/part/src/main/net/dpml/part/control/Controller.java

development/main/metro/part/src/main/net/dpml/part/control/ControllerContext.java

development/main/metro/part/src/main/net/dpml/part/control/Identifiable.java
development/main/metro/part/src/main/net/dpml/part/model/Model.java
development/main/metro/part/src/main/net/dpml/part/state/Transition.java

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/ManagingContainer.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/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/build.xml

development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultModel.java
Log:
Separation of metro component instance runtime abstractions from the model
and generic controller functionality including isolation of remote interfaces
under the component model. More work will be needed here to establish an
explict per component remotely manageable model.

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 23 21:30:35 2005
@@ -27,8 +27,10 @@
import java.util.prefs.Preferences;
import java.util.Date;

-import net.dpml.composition.control.CompositionManager;
+import net.dpml.composition.control.CompositionController;
+import net.dpml.composition.runtime.CompositionManager;

+import net.dpml.part.control.Controller;
import net.dpml.part.control.ControllerContext;

import net.dpml.transit.adapter.LoggingAdapter;
@@ -64,6 +66,7 @@
//------------------------------------------------------------------

private CompositionManager m_manager;
+ private CompositionController m_controller;

//------------------------------------------------------------------
// constructor
@@ -80,9 +83,9 @@
properties.put( "work.dir", dir );
}
Logger logger = new LoggingAdapter( "metro" );
- DefaultContentModel model =
- new DefaultContentModel( logger, null, type, title, properties );
- m_manager = new CompositionManager( model );
+ 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
@@ -91,13 +94,19 @@
{
throw new NullPointerException( "model" );
}
- m_manager = new CompositionManager( model );
+ m_controller = new CompositionController( model );
+ m_manager = new CompositionManager( m_controller );
}

//------------------------------------------------------------------
// internal
//------------------------------------------------------------------

+ public Controller getController()
+ {
+ return m_controller;
+ }
+
public CompositionManager getCompositionManager()
{
return m_manager;
@@ -107,7 +116,7 @@
{
try
{
- File base = m_manager.getWorkingDirectory();
+ File base = m_controller.getWorkingDirectory();
File target = new File( base, path );
return target.toURI();
}

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 23 21:30:35 2005
@@ -31,18 +31,18 @@
import java.util.Hashtable;
import java.util.Map;

-import net.dpml.composition.control.CompositionManager;
+import net.dpml.composition.control.CompositionController;

import net.dpml.transit.repository.Repository;

+import net.dpml.part.control.Controller;
import net.dpml.part.control.ControlException;
import net.dpml.part.control.ControlRuntimeException;
import net.dpml.part.control.ControllerContext;

import net.dpml.part.part.Part;
import net.dpml.part.model.Model;
-import net.dpml.part.model.Provider;
-import net.dpml.part.model.Component;
+import net.dpml.part.manager.Component;

import net.dpml.transit.Transit;
import net.dpml.transit.model.ContentModel;
@@ -59,7 +59,7 @@
// state
//------------------------------------------------------------------

- private CompositionManager m_manager;
+ private CompositionController m_controller;

//------------------------------------------------------------------
// constructor
@@ -71,7 +71,7 @@
{
throw new NullPointerException( "model" );
}
- m_manager = new CompositionManager( model );
+ m_controller = new CompositionController( model );
}

//------------------------------------------------------------------
@@ -103,12 +103,12 @@
{
return getModel( url );
}
- else if( Provider.class.isAssignableFrom( c ) )
+ else if( Component.class.isAssignableFrom( c ) )
{
try
{
Model model = getModel( url );
- return model.getProvider();
+ return m_controller.getComponent( model );
}
catch( Throwable e )
{
@@ -127,7 +127,7 @@
Model model = getModel( url );
try
{
- return model.getProvider().resolve( false );
+ return m_controller.getComponent( model ).resolve(
false );
}
catch( Throwable e )
{
@@ -153,7 +153,7 @@
{
String path = url.toExternalForm();
URI uri = new URI( path );
- return (Part) m_manager.loadPart( uri );
+ return (Part) m_controller.loadPart( uri );
}
catch( Throwable e )
{
@@ -169,7 +169,7 @@
{
String path = url.toExternalForm();
URI uri = new URI( path );
- return m_manager.getModel( uri );
+ return m_controller.getModel( uri );
}
catch( Throwable e )
{
@@ -179,29 +179,6 @@
}
}

- //------------------------------------------------------------------
- // internal
- //------------------------------------------------------------------
-
- public CompositionManager getCompositionManager()
- {
- return m_manager;
- }
-
- public void dispose()
- {
- try
- {
- getCompositionManager().dispose();
- }
- catch( Throwable e )
- {
- }
- finally
- {
- System.gc();
- }
- }

//------------------------------------------------------------------
// static utils
@@ -209,6 +186,6 @@

static
{
- System.setProperty( "java.util.logging.config.class",
"net.dpml.depot.logging.ConfigurationHandler" );
+ System.setProperty( "java.util.logging.config.class",
"net.dpml.transit.util.ConfigurationHandler" );
}
}

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 23
21:30:35 2005
@@ -17,22 +17,13 @@
<x:path id="build.path"/>
<rmic base="${basedir}/target/classes" classpathref="build.path">
<include name="**/DefaultControllerModel.class"/>
- <include name="**/CompositionManager.class"/>
- <include name="**/CompositionControllerContext.class"/>
- <include name="**/CompositionController.class"/>
- <include name="**/CompositionPartHandler.class"/>
<include name="**/CompositionModel.class"/>
- <include name="**/ComponentEntry.class"/>
- <include name="**/ComponentController.class"/>
- <include name="**/ReferenceEntry.class"/>
- <include name="**/ValueController.class"/>
<include name="**/ValueModel.class"/>
- <include name="**/ValueEntry.class"/>
</rmic>
</target>

<target name="package" depends="standard.package">
- <x:export class="net.dpml.composition.control.CompositionManager"/>
+ <x:export class="net.dpml.composition.runtime.CompositionManager"/>
</target>

</project>

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionClassLoader.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionClassLoader.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionClassLoader.java
Thu Jun 23 21:30:35 2005
@@ -22,8 +22,9 @@
import java.net.URL;
import java.net.URLClassLoader;

+import net.dpml.logging.Logger;
+
import net.dpml.part.control.ControlRuntimeException;
-import net.dpml.part.control.Monitor;

import net.dpml.transit.repository.StandardClassLoader;

@@ -39,7 +40,7 @@
// state
//--------------------------------------------------------------------

- private final Monitor m_monitor;
+ private final Logger m_logger;
private final URI m_partition;
private final int m_index;

@@ -47,17 +48,17 @@
// constructor
//--------------------------------------------------------------------

- public CompositionClassLoader( Monitor monitor, URI partition,
ClassLoader parent )
+ public CompositionClassLoader( Logger Logger, URI partition, ClassLoader
parent )
{
- this( monitor, partition, 0, new URI[0], parent );
+ this( Logger, partition, 0, new URI[0], parent );
}

- public CompositionClassLoader( Monitor monitor, URI partition, int
index, URI[] uris, ClassLoader parent )
+ public CompositionClassLoader( Logger logger, URI partition, int index,
URI[] uris, ClassLoader parent )
{
super( partition, urisToURLs( uris ), parent );
m_partition = partition;
m_index = index;
- m_monitor = monitor;
+ m_logger = logger;
}

//--------------------------------------------------------------------
@@ -151,11 +152,11 @@

protected void finalize()
{
- if( m_monitor.isDebugEnabled() )
+ if( m_logger.isDebugEnabled() )
{
final String message =
"classloader finalization: " + m_partition;
- m_monitor.debug( message );
+ m_logger.debug( message );
}
}


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 23 21:30:35 2005
@@ -32,32 +32,34 @@
import java.util.Observable;
import java.util.Observer;
import java.util.Map.Entry;
-import java.util.logging.Logger;
-import java.util.logging.Level;
+
+import net.dpml.logging.Logger;

import net.dpml.composition.data.ClassLoaderDirective;
import net.dpml.composition.data.ClasspathDirective;
import net.dpml.composition.data.ComponentProfile;
import net.dpml.composition.data.ValueDirective;

-import net.dpml.composition.model.ComponentEntry;
+import net.dpml.composition.runtime.ComponentEntry;
+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.part.control.ControllerContext;
import net.dpml.part.control.HandlerNotFoundException;
+import net.dpml.part.control.ControlException;
import net.dpml.part.control.ControlRuntimeException;
import net.dpml.part.control.Controller;
import net.dpml.part.control.DelegationException;
import net.dpml.part.control.Disposable;
import net.dpml.part.control.LifecycleException;
-import net.dpml.part.control.Monitor;
import net.dpml.part.control.PartNotFoundException;
-import net.dpml.part.control.Manager;
import net.dpml.part.model.Model;
import net.dpml.part.model.ModelException;
-import net.dpml.part.model.Component;
-import net.dpml.part.model.Provider;
+import net.dpml.part.manager.Component;
+import net.dpml.part.manager.Manager;
import net.dpml.part.part.Part;

import net.dpml.transit.model.ContentModel;
@@ -80,39 +82,36 @@
// state
//--------------------------------------------------------------------

- private final Monitor m_monitor;
private final ControllerContext m_context;
private final LifestyleHandler m_lifestyleHandler;
private final ValueController m_valueController;
-
private final Logger m_logger;

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

- CompositionController( ContentModel context ) throws RemoteException
+ public CompositionController( ContentModel context )
+ throws ControlException
{
super();

- m_context = new CompositionControllerContext( context );
- m_logger = getLoggerForURI( m_context.getURI() );
- m_logger.info( "metro controller established" );
- m_monitor = new DefaultMonitor( m_logger );
- m_valueController = new ValueController( this );
- ComponentController manager = new ComponentController( m_monitor,
this );
- m_lifestyleHandler = new LifestyleHandler( m_monitor, manager );
- }
-
- Logger getLoggerForURI( URI uri )
- {
- String path = uri.getSchemeSpecificPart();
- if( path.endsWith( "/" ) )
+ try
{
- path = path.substring( 0, path.length() - 1 );
+ m_context = new CompositionControllerContext( context );
}
- path.replace( '/', '.' );
- return Logger.getLogger( path );
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected error while attempting to construct the compositon
context.";
+ throw new ControlException( CONTROLLER_URI, error, e );
+ }
+
+ m_logger = m_context.getLogger();
+ m_valueController = new ValueController( this );
+ m_logger.info( "metro controller established" );
+ ComponentController manager = new ComponentController( m_logger,
this );
+ m_lifestyleHandler = new LifestyleHandler( m_logger, manager );
}

Logger getLogger()
@@ -128,7 +127,7 @@
* Load the model controller.
* @return the controller
*/
- public Controller getController() throws RemoteException
+ public Controller getController()
{
return getCompositionController();
}
@@ -145,12 +144,12 @@
// Controller
//--------------------------------------------------------------------

- public File getWorkingDirectory() throws RemoteException
+ public File getWorkingDirectory()
{
return m_context.getWorkingDirectory();
}

- public File getTempDirectory() throws RemoteException
+ public File getTempDirectory()
{
return m_context.getTempDirectory();
}
@@ -171,7 +170,7 @@
* @return the resource
* @exception IllegalArgumentException if the urn is not recognized
*/
- public Object getResource( Model model, URI urn ) throws RemoteException
+ public Object getResource( Model model, URI urn )
{
String scheme = urn.getScheme();
String key = urn.getSchemeSpecificPart();
@@ -183,29 +182,11 @@
}
else if( "work.dir".equals( key ) )
{
- try
- {
- return m_context.getWorkingDirectory();
- }
- catch( RemoteException e )
- {
- final String error =
- "Unexpected remote exception while attempting to get
working directory.";
- throw new ControlRuntimeException( CONTROLLER_URI,
error, e );
- }
+ return m_context.getWorkingDirectory();
}
else if( "temp.dir".equals( key ) )
{
- try
- {
- return m_context.getTempDirectory();
- }
- catch( RemoteException e )
- {
- final String error =
- "Unexpected remote exception while attempting to get
temp directory.";
- throw new ControlRuntimeException( CONTROLLER_URI,
error, e );
- }
+ return m_context.getTempDirectory();
}
else
{
@@ -218,25 +199,34 @@
}
else if( "model".equals( scheme ) )
{
- if( "partition".equals( key ) )
- {
- return model.getPartition();
- }
- if( "name".equals( key ) )
+ try
{
- return model.getKey();
- }
- else if( "uri".equals( key ) )
- {
- return model.getURI();
+ 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 );
+ }
}
- else
+ catch( RemoteException e )
{
final String error =
- "Requested model resource urn ["
- + urn
- + "] is not recognized.";
- throw new IllegalArgumentException( error );
+ "Remote error occured while resolving modle value.";
+ throw new ControlRuntimeException( CONTROLLER_URI, error, e
);
}
}
else
@@ -249,17 +239,17 @@
}
}

- public String getName() throws RemoteException
+ public String getName()
{
return getPartition().toASCIIString();
}

public Model getPart( CompositionModel model, String key )
{
- return model.getPartsTable().getModel( key );
+ return model.getPartsTable().getModel( key );
}

- public Provider getContextEntry( CompositionModel model, String key )
+ public Component getContextEntry( CompositionModel model, String key )
{
return model.getContextTable().getEntry( key );
}
@@ -272,7 +262,7 @@
*/
public Model getModel( URI uri )
throws IOException, DelegationException, ModelException,
PartNotFoundException,
- HandlerNotFoundException, DelegationException, RemoteException
+ HandlerNotFoundException, DelegationException
{
return getModel( uri, null );
}
@@ -286,12 +276,11 @@
*/
public Model getModel( URI uri, String key )
throws IOException, DelegationException, ModelException,
PartNotFoundException,
- HandlerNotFoundException, DelegationException, RemoteException
+ HandlerNotFoundException, DelegationException
{
- m_logger.fine( "loading part " + uri );
+ m_logger.debug( "loading part " + uri );
Part part = loadPart( uri );
ClassLoader anchor = net.dpml.part.part.Part.class.getClassLoader();
- //ClassLoader anchor =
net.dpml.composition.info.Type.class.getClassLoader();
return getModel( anchor, part, key );
}

@@ -304,7 +293,7 @@
* @return the model
*/
public Model getModel( ClassLoader classloader, Part part, String key )
- throws ModelException, HandlerNotFoundException, DelegationException,
RemoteException
+ throws ModelException, HandlerNotFoundException, DelegationException
{
if( isRecognizedPart( part ) )
{
@@ -327,37 +316,55 @@
* @return the model
*/
public Model getModel( CompositionModel model, ClassLoader classloader,
Part part, String key )
- throws ModelException, RemoteException
+ throws ModelException
{
if( part instanceof ComponentProfile )
{
final ComponentProfile profile = (ComponentProfile) part;
- getMonitor().debug( "creating nested model using " + profile );
+ getLogger().debug( "creating nested model using " + profile );
URI partition = getPartition( model );
ClassLoader parent = getClassLoader( partition, classloader,
profile );
- if( null == model )
+ try
{
- if( null == key )
+ if( null == model )
{
- return new CompositionModel( this, partition, parent,
profile );
- }
+ if( null == key )
+ {
+ return new CompositionModel( this, partition,
parent, profile );
+ }
+ else
+ {
+ return new CompositionModel( this, partition,
parent, profile, key );
+ }
+ }
else
{
- return new CompositionModel( this, partition, parent,
profile, key );
+ return new CompositionModel( this, model, partition,
parent, profile, key );
}
- }
- else
+ }
+ catch( RemoteException e )
{
- return new CompositionModel( this, model, partition, parent,
profile, key );
+ 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;
- getMonitor().debug( "creating nested value model using " +
directive );
+ getLogger().debug( "creating nested value model using " +
directive );
URI partition = getPartition( model );
- return new ValueModel(
- m_monitor, key, this, partition, m_valueController,
classloader, directive, 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
{
@@ -370,47 +377,22 @@
}

/**
- * Return a default service provider.
- *
- * @param model the reference model
- * @return the service provider
- */
- public Provider getProvider( Model model ) throws RemoteException
- {
- return getComponent( (Component) null, model );
- }
-
- /**
- * Return an identified service provider.
- *
- * @param model the reference model
- * @param identity the privider identity
- * @return the service provider
- */
- public Provider getProvider( Model model, Object identity ) throws
RemoteException
- {
- return getComponent( (Component) null, model, identity );
- }
-
- /**
* Return a nested component for a supplied part.
*
- * @param owner the owning component (not used)
* @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( Component owner, ClassLoader classloader,
Part part, String key )
- throws ModelException, HandlerNotFoundException, DelegationException,
RemoteException
+ public Component getComponent( ClassLoader classloader, Part part,
String key )
+ throws ModelException, HandlerNotFoundException, DelegationException
{
- return getComponent( owner, null, classloader, part, key );
+ return getComponent( null, classloader, part, key );
}

/**
* Return a nested component for a supplied part using enclosing model.
*
- * @param owner the owning component (not used)
* @param model the enclosing model
* @param classloader the parent classloader
* @param part the part datastructure
@@ -418,18 +400,18 @@
* @return the model
*/
public Component getComponent(
- Component owner, CompositionModel model, ClassLoader classloader, Part
part, String key )
- throws ModelException, HandlerNotFoundException, DelegationException,
RemoteException
+ CompositionModel model, ClassLoader classloader, Part part, String key
)
+ throws ModelException, HandlerNotFoundException, DelegationException
{
if( isRecognizedPart( part ) )
{
Model componentModel = getModel( model, classloader, part, key );
- return getComponent( owner, componentModel );
+ return getComponent( componentModel );
}
else
{
Controller controller = getPartHandler( part );
- return controller.getComponent( owner, classloader, part, key );
+ return controller.getComponent( classloader, part, key );
}
}

@@ -440,16 +422,25 @@
* @param model the reference model
* @return the model
*/
- public Component getComponent( Component owner, Model model ) throws
RemoteException
+ public Component getComponent( Model model )
{
if( model instanceof ValueModel )
{
ValueModel m = (ValueModel) model;
- return m.getComponent();
+ 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( owner, model, null );
+ return getComponentEntry( model, null );
}
}

@@ -461,9 +452,9 @@
* @param key the instance identity
* @return the model
*/
- public Component getComponent( Component owner, Model model, Object key
) throws RemoteException
+ public Component getComponent( Model model, Object key )
{
- return getComponentEntry( owner, model, key );
+ return getComponentEntry( model, key );
}

/**
@@ -474,7 +465,7 @@
* @param key the instance identity
* @return the model
*/
- public ComponentEntry getComponentEntry( Component owner, Model model,
Object key ) throws RemoteException
+ public ComponentEntry getComponentEntry( Model model, Object key )
{
if( null == model )
{
@@ -485,11 +476,11 @@
CompositionModel m = (CompositionModel) model;
if( null == key )
{
- return m_lifestyleHandler.aquire( m, owner );
+ return m_lifestyleHandler.aquire( m );
}
else
{
- return m_lifestyleHandler.aquire( m, key, owner );
+ return m_lifestyleHandler.aquire( m, key );
}
}
else
@@ -515,71 +506,12 @@
return this;
}

- /**
- * Return a log channel for a supplied model.
- * @param model the composition model
- * @return the logging channel
- */
- public Logger getLogChannel( CompositionModel model )
- {
- return getLogChannel( model, null );
- }
-
- /**
- * Return a named log channel for a supplied model.
- * @param model the composition model
- * @param category the logging category name
- * @return the logging channel
- */
- public Logger getLogChannel( CompositionModel model, String category )
- {
- URI uri = model.getURI();
- String path = model.getURI().getSchemeSpecificPart();
- String channel = path.replace( '/', '.' );
- if( category != null )
- {
- channel = channel + "." + category;
- }
- return Logger.getLogger( channel );
- }
-
- net.dpml.logging.Logger getLoggingChannel( CompositionModel model )
- {
- URI uri = model.getURI();
- String path = uri.getSchemeSpecificPart();
- if( path.endsWith( "/" ) )
- {
- path = path.substring( 0, path.length() - 1 );
- }
- path.replace( '/', '.' );
- return new DefaultLogger( path );
- }
-
- /**
- * Return the monitor assigned to this controller.
- *
- * @return the assigned monitor
- */
- protected Monitor getMonitor()
- {
- return m_monitor;
- }
-
private URI getPartition()
{
- try
- {
- return m_context.getURI();
- }
- catch( RemoteException e )
- {
- final String error =
- "Unexpected remote exception while attempting to resolve the
context uri.";
- throw new ControlRuntimeException( CONTROLLER_URI, error, e );
- }
+ return m_context.getURI();
}

- private URI getPartition( Model model ) throws RemoteException
+ private URI getPartition( Model model )
{
if( null == model )
{
@@ -587,7 +519,14 @@
}
else
{
- return model.getURI();
+ try
+ {
+ return model.getURI();
+ }
+ catch( RemoteException e )
+ {
+ throw new ControlRuntimeException( CONTROLLER_URI,
e.getMessage(), e.getCause() );
+ }
}
}

@@ -595,7 +534,6 @@
// private
//--------------------------------------------------------------------

-
private ClassLoader getClassLoader( URI partition, ClassLoader parent,
ComponentProfile profile )
{
final String name = profile.getName();
@@ -609,8 +547,8 @@
URI[] uris = filter( cpd.getURIs(), parent );
if( uris.length > 0 )
{
- getLogger().fine( "creating " + tag + " classloader with " +
uris.length + " entries" );
- parent = new CompositionClassLoader( m_monitor, id, i, uris,
parent );
+ getLogger().debug( "creating " + tag + " classloader with "
+ uris.length + " entries" );
+ parent = new CompositionClassLoader( m_logger, id, i, uris,
parent );
}
}
return parent;
@@ -707,7 +645,7 @@
}
}

- private boolean isRecognizedPart( Part part ) throws RemoteException
+ private boolean isRecognizedPart( Part part )
{
return getURI().equals( part.getPartHandlerURI() );
}

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionControllerContext.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionControllerContext.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionControllerContext.java
Thu Jun 23 21:30:35 2005
@@ -27,18 +27,20 @@
import java.util.EventListener;
import java.util.WeakHashMap;
import java.util.Properties;
-import java.util.prefs.Preferences;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.PreferenceChangeEvent;
+
+import net.dpml.logging.Logger;
+
+import net.dpml.composition.event.WeakEventProducer;
+import net.dpml.composition.runtime.DefaultLogger;

import net.dpml.part.control.ControllerContext;
import net.dpml.part.control.ControllerContextListener;
import net.dpml.part.control.ControllerContextEvent;
+import net.dpml.part.control.ControlRuntimeException;

import net.dpml.transit.model.DefaultModel;
import net.dpml.transit.model.ContentModel;
import net.dpml.transit.model.DefaultContentModel;
-import net.dpml.transit.model.Logger;
import net.dpml.transit.util.PropertyResolver;

/**
@@ -49,7 +51,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 CompositionControllerContext extends DefaultModel implements
ControllerContext
+public class CompositionControllerContext extends WeakEventProducer
implements ControllerContext
{

//----------------------------------------------------------------------------
// state
@@ -69,14 +71,14 @@

private URI m_uri;

+ private Logger m_logger;
+

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

//----------------------------------------------------------------------------

public CompositionControllerContext( ContentModel model ) throws
RemoteException
{
- super( "metro" );
-
m_model = model;

// TODO: add listeners to changes to the content model properties
@@ -85,24 +87,49 @@
String temp = getTempDirectoryPath();

String domain = model.getProperty( "domain.name", "local" );
-
m_uri = setupContextURI( domain );
m_work = getWorkingDirectory( work );
m_temp = getTempDirectory( temp );
+ m_logger = getLoggerForURI( m_uri );
+ }
+
+ private Logger getLoggerForURI( URI uri )
+ {
+ String path = uri.getSchemeSpecificPart();
+ if( path.endsWith( "/" ) )
+ {
+ path = path.substring( 0, path.length() - 1 );
+ }
+ path.replace( '/', '.' );
+ return new DefaultLogger( path );
}


//----------------------------------------------------------------------------
// ControllerContext

//----------------------------------------------------------------------------

+ public Logger getLogger()
+ {
+ return m_logger;
+ }
+
/**
* Return the root working directory path.
*
* @return directory path representing the root of the working directory
hierachy
*/
- public String getWorkingDirectoryPath() throws RemoteException
+ public String getWorkingDirectoryPath()
{
- return m_model.getProperty( "work.dir", "${dpml.data}/work" );
+ try
+ {
+ return m_model.getProperty( "work.dir", "${dpml.data}/work" );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Remote error while attempting to reslve working directory.";
+ throw new RuntimeException( error, e );
+ }
}

/**
@@ -110,9 +137,18 @@
*
* @return directory path representing the root of the temporary
directory hierachy.
*/
- public String getTempDirectoryPath() throws RemoteException
+ public String getTempDirectoryPath()
{
- return m_model.getProperty( "temp.dir", "${java.io.tmpdir}" );
+ try
+ {
+ return m_model.getProperty( "temp.dir", "${java.io.tmpdir}" );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Remote error while attempting to reslve temp directory.";
+ throw new RuntimeException( error, e );
+ }
}

/**
@@ -120,7 +156,7 @@
*
* @return the uri for this context.
*/
- public URI getURI() throws RemoteException
+ public URI getURI()
{
return m_uri;
}
@@ -130,7 +166,7 @@
*
* @return directory representing the root of the working directory
hierachy
*/
- public File getWorkingDirectory() throws RemoteException
+ public File getWorkingDirectory()
{
synchronized( m_lock )
{
@@ -143,7 +179,7 @@
*
* @param dir the root of the working directory hierachy
*/
- public void setWorkingDirectory( File dir ) throws RemoteException
+ public void setWorkingDirectory( File dir )
{
synchronized( m_lock )
{
@@ -156,7 +192,7 @@
*
* @return directory representing the root of the temporary directory
hierachy.
*/
- public File getTempDirectory() throws RemoteException
+ public File getTempDirectory()
{
synchronized( m_lock )
{
@@ -172,7 +208,6 @@
* @param listener the controller context listener to add
*/
public void addControllerContextlistener( ControllerContextListener
listener )
- throws RemoteException
{
addListener( listener );
}
@@ -183,13 +218,12 @@
* @param listener the controller context listener to remove
*/
public void removeControllerContextlistener( ControllerContextListener
listener )
- throws RemoteException
{
removeListener( listener );
}


//----------------------------------------------------------------------------
- // private
+ // impl

//----------------------------------------------------------------------------

protected void processEvent( EventObject event )

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionPartHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionPartHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionPartHandler.java
Thu Jun 23 21:30:35 2005
@@ -38,8 +38,11 @@
import net.dpml.part.control.HandlerNotFoundException;
import net.dpml.part.control.DelegationException;

+import net.dpml.logging.Logger;
+
import net.dpml.composition.info.Type;
import net.dpml.composition.info.TypeHolder;
+import net.dpml.composition.runtime.DefaultLogger;

import net.dpml.transit.Transit;
import net.dpml.transit.artifact.Handler;
@@ -51,7 +54,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 CompositionPartHandler extends UnicastRemoteObject implements
PartHandler
+public class CompositionPartHandler implements PartHandler
{
/**
* Map containing the foreign part handlers. The map keys
@@ -65,7 +68,7 @@
*/
private final Repository m_loader;

- public CompositionPartHandler() throws RemoteException
+ public CompositionPartHandler()
{
super();

@@ -76,7 +79,7 @@
* Returns the uri of this handler.
* @return the handler uri
*/
- public URI getURI() throws RemoteException
+ public URI getURI()
{
return PART_HANDLER_URI;
}
@@ -86,7 +89,7 @@
* @return the controller
* @exception UnsupportedOperationException allways thrown
*/
- public Controller getController() throws RemoteException
+ public Controller getController()
{
throw new UnsupportedOperationException( "getController" );
}
@@ -101,7 +104,7 @@
* @return the part estracted from the part handler referenced by the uri
*/
public Part loadPart( URI uri )
- throws PartNotFoundException, IOException, DelegationException,
RemoteException
+ throws PartNotFoundException, IOException, DelegationException
{
return loadSerializedPart( uri );
}
@@ -127,7 +130,7 @@
}

public Controller getPartHandler( Part part )
- throws HandlerNotFoundException, DelegationException, RemoteException
+ throws HandlerNotFoundException, DelegationException
{
URI uri = part.getPartHandlerURI();
PartHandler handler = loadPartHandler( uri );
@@ -139,7 +142,7 @@
* @return the part handler
*/
public PartHandler loadPartHandler( URI uri )
- throws HandlerNotFoundException, DelegationException, RemoteException
+ throws HandlerNotFoundException, DelegationException
{
if( false == getURI().equals( uri ) )
{
@@ -151,36 +154,8 @@
}
}

- public Type loadType( Class clazz )
- {
- String path = clazz.getName().replace( '.', '/' ) + ".type";
- URL url = clazz.getClassLoader().getResource( path );
- if( null == url )
- {
- return null;
- }
- try
- {
- InputStream input = url.openStream();
- ObjectInputStream stream = new ObjectInputStream( input );
- TypeHolder holder = (TypeHolder) stream.readObject();
- byte[] bytes = holder.getByteArray();
- ByteArrayInputStream byteinput = new ByteArrayInputStream( bytes
);
- ObjectInputStream bytestream = new ObjectInputStream( byteinput
);
- return (Type) bytestream.readObject();
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected error occured while attempting to load a type from
the path ["
- + path
- + "]";
- throw new PartHandlerRuntimeException( error, e );
- }
- }
-
private Part loadSerializedPart( URI uri )
- throws IOException, DelegationException, PartNotFoundException,
RemoteException
+ throws IOException, DelegationException, PartNotFoundException
{
URL url = resolveURL( uri );
InputStream input = url.openStream();
@@ -246,7 +221,7 @@
}
}

- protected PartHandler resolvePartHandler( URI uri ) throws
HandlerNotFoundException, RemoteException
+ protected PartHandler resolvePartHandler( URI uri ) throws
HandlerNotFoundException
{
if( getURI().equals( uri ) )
{
@@ -269,10 +244,10 @@
private PartHandler loadHandler( URI uri ) throws
HandlerNotFoundException
{
ClassLoader classloader = Type.class.getClassLoader();
- ConsoleMonitor monitor = new ConsoleMonitor( "manager", true );
+ DefaultLogger logger = new DefaultLogger( "handler" );
try
{
- return (PartHandler) m_loader.getPlugin( classloader, uri, new
Object[]{ this, monitor } );
+ return (PartHandler) m_loader.getPlugin( classloader, uri, new
Object[]{ this, logger } );
}
catch( IOException e )
{

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifestyleHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifestyleHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifestyleHandler.java
Thu Jun 23 21:30:35 2005
@@ -18,11 +18,16 @@

package net.dpml.composition.control;

+import java.net.URI;
import java.rmi.RemoteException;

-import net.dpml.composition.model.ComponentEntry;
+import net.dpml.logging.Logger;
+
+import net.dpml.composition.runtime.ComponentController;
+import net.dpml.composition.runtime.ComponentEntry;
import net.dpml.composition.model.CompositionModel;
-import net.dpml.part.control.Monitor;
+
+import net.dpml.part.control.ControlRuntimeException;

/**
* A lifestyle handler provides support for the aquisition and release
@@ -35,12 +40,12 @@
*/
class LifestyleHandler
{
- private Monitor m_monitor;
+ private Logger m_logger;
private ComponentController m_controller;

- LifestyleHandler( Monitor monitor, ComponentController controller )
+ LifestyleHandler( Logger logger, ComponentController controller )
{
- m_monitor = monitor;
+ m_logger = logger;
m_controller = controller;
}

@@ -50,32 +55,33 @@
* @param model the model from which new or existing instances will be
resolved
* @return the key to the resolved instance
*/
- public ComponentEntry aquire( CompositionModel model, Object owner )
throws RemoteException
+ public ComponentEntry aquire( CompositionModel model )
{
final String lifestyle = model.getLifestylePolicy();
- if( getMonitor().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
+ URI uri = model.getURI();
final String message =
"Aquiring an object key for the model ["
- + model.getURI()
+ + uri
+ "] using the lifestyle ["
+ lifestyle
+ "].";
- getMonitor().debug( message );
+ getLogger().debug( message );
}
if( "request".equals( lifestyle ) || "transient".equals( lifestyle )
)
{
synchronized( model )
{
- ComponentEntry entry = new ComponentEntry( m_monitor,
m_controller, model, null, owner );
+ ComponentEntry entry = new ComponentEntry( m_logger,
m_controller, model, null );
Object key = entry.getKey();
- if( getMonitor().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
final String message =
"Established key ["
+ entry.getURI()
+ "].";
- getMonitor().debug( message );
+ getLogger().debug( message );
}
model.getComponentTable().add( entry );
return entry;
@@ -86,7 +92,7 @@
synchronized( model )
{
String key = CompositionController.SELF;
- return aquire( model, key, owner );
+ return aquire( model, key );
}
}
else if( "thread".equals( lifestyle ) )
@@ -112,7 +118,7 @@
* @param model the model from which new or existing instances will be
resolved
* @return the key to the resolved instance
*/
- public ComponentEntry aquire( CompositionModel model, Object key, Object
owner ) throws RemoteException
+ public ComponentEntry aquire( CompositionModel model, Object key )
{
if( null == model )
{
@@ -126,34 +132,35 @@

if( null == entry )
{
- if( getMonitor().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
+ URI uri = model.getURI();
final String message =
"Initiating creation of identifiable instance in ["
- + model.getURI()
+ + uri
+ "].";
- getMonitor().debug( message );
+ getLogger().debug( message );
}
- entry = new ComponentEntry( m_monitor, m_controller, model, key,
owner );
- if( getMonitor().isDebugEnabled() )
+ entry = new ComponentEntry( m_logger, m_controller, model, key );
+ if( getLogger().isDebugEnabled() )
{
final String message =
"Adding component entry ["
+ entry.getURI()
+ "].";
- getMonitor().debug( message );
+ getLogger().debug( message );
}
model.getComponentTable().add( entry );
}
else
{
- if( getMonitor().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
final String message =
"Using existing component entry ["
+ entry.getURI()
+ "].";
- getMonitor().debug( message );
+ getLogger().debug( message );
}
}
return entry;
@@ -162,7 +169,7 @@
public void release( CompositionModel model, Object key )
{
final String lifestyle = model.getLifestylePolicy();
- if( getMonitor().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
final String message =
"Releasing ["
@@ -170,13 +177,14 @@
+ "#"
+ key
+ "].";
- getMonitor().debug( message );
+ getLogger().debug( message );
}
model.getComponentTable().remove( key );
}

- private Monitor getMonitor()
+ private Logger getLogger()
{
- return m_monitor;
+ return m_logger;
}
+
}

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/event/WeakEventProducer.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/event/WeakEventProducer.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/event/WeakEventProducer.java
Thu Jun 23 21:30:35 2005
@@ -33,7 +33,7 @@
* A abstract base class that established an event queue and handles event
dispatch
* operations for listeners declared in a class extending this base class.
*/
-public abstract class WeakEventProducer extends UnicastRemoteObject
+public abstract class WeakEventProducer
{
private Map m_listeners = new WeakHashMap();

@@ -42,9 +42,8 @@
*/
protected final Object m_lock = new Object();

- public WeakEventProducer() throws RemoteException
+ public WeakEventProducer()
{
- super();
}

/**
@@ -55,7 +54,13 @@
*
* @param event the event to process
*/
- protected abstract void processEvent( EventObject event );
+ protected void processEvent( EventObject event )
+ {
+ final String error =
+ "Event class not recognized: " + event.getClass().getName();
+ throw new IllegalArgumentException( error );
+ }
+

/**
* Add a listener to the set of listeners handled by this producer.

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 23 21:30:35 2005
@@ -20,9 +20,15 @@
package net.dpml.composition.info;

import java.io.Serializable;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ByteArrayInputStream;
+import java.net.URL;

import net.dpml.configuration.Configuration;

+import net.dpml.part.model.ModelException;
+
/**
* This class contains the meta information about a particular
* component type. It describes;
@@ -47,6 +53,33 @@
{
static final long serialVersionUID = 1L;

+ public static Type loadType( Class clazz ) throws ModelException
+ {
+ String path = clazz.getName().replace( '.', '/' ) + ".type";
+ URL url = clazz.getClassLoader().getResource( path );
+ if( null == url )
+ {
+ return null;
+ }
+ try
+ {
+ InputStream input = url.openStream();
+ ObjectInputStream stream = new ObjectInputStream( input );
+ TypeHolder holder = (TypeHolder) stream.readObject();
+ byte[] bytes = holder.getByteArray();
+ ByteArrayInputStream byteinput = new ByteArrayInputStream( bytes
);
+ ObjectInputStream bytestream = new ObjectInputStream( byteinput
);
+ return (Type) bytestream.readObject();
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected error occured while attempting to load a type."
+ + "\nResource path: " + path;
+ throw new ModelException( error, e );
+ }
+ }
+
private final InfoDescriptor m_descriptor;
private final ContextDescriptor m_context;
private final Configuration m_configuration;

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/model/CompositionModel.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/model/CompositionModel.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/model/CompositionModel.java
Thu Jun 23 21:30:35 2005
@@ -24,6 +24,8 @@
import java.util.LinkedList;
import java.util.List;

+import net.dpml.composition.runtime.ComponentTable; // ISSUE .. this should
not be in the model
+
import net.dpml.composition.control.CompositionController;

import net.dpml.composition.data.ComponentProfile;
@@ -44,8 +46,7 @@

import net.dpml.part.control.Controller;

-import net.dpml.part.model.Component;
-import net.dpml.part.model.Provider;
+import net.dpml.part.manager.Component;
import net.dpml.part.model.Model;
import net.dpml.part.model.ModelException;
import net.dpml.part.model.ModelRuntimeException;
@@ -66,7 +67,6 @@
private final List m_errors = new LinkedList();

private final String m_key;
- private final CompositionController m_controller;
private final ComponentProfile m_profile;
private final ClassLoader m_classloader;
private final URI m_partition;
@@ -78,6 +78,8 @@
private final String m_lifestyle;
private final URI m_uri;

+ private URI m_controlURI;
+ private CompositionController m_controller;
private Configuration m_configuration;
private Parameters m_parameters;

@@ -85,38 +87,35 @@
/**
* Creation of a new root component model.
*
- * @param controller the model controller
* @param partition a name defining the partition that this model exists
within
* @param classloader the classloader established for this model
* @param profile the component profile from which initial default values
are established
*/
public CompositionModel(
- CompositionController controller, URI partition, ClassLoader
classloader, ComponentProfile profile )
+ CompositionController control, URI partition, ClassLoader
classloader, ComponentProfile profile )
throws ModelException, RemoteException
{
- this( controller, null, partition, classloader, profile,
profile.getName() );
+ this( control, null, partition, classloader, profile,
profile.getName() );
}

/**
* Creation of a new root component model.
*
- * @param controller the model controller
* @param partition a name defining the partition that this model exists
within
* @param classloader the classloader established for this model
* @param profile the component profile from which initial default values
are established
* @param name the name of the model
*/
public CompositionModel(
- CompositionController controller, URI partition, ClassLoader
classloader, ComponentProfile profile, String name )
+ CompositionController control, URI partition, ClassLoader
classloader, ComponentProfile profile, String name )
throws ModelException, RemoteException
{
- this( controller, null, partition, classloader, profile, name );
+ this( control, null, partition, classloader, profile, name );
}

/**
* Creation of a new nested component model.
*
- * @param controller the model controller
* @param parent the enclosing parent model
* @param partition a name defineing the partition that this model exists
within
* @param classloader the classloader established for this model
@@ -124,14 +123,14 @@
* @param name the name of the model
*/
public CompositionModel(
- CompositionController controller, CompositionModel parent, URI
partition, ClassLoader classloader,
+ CompositionController control, CompositionModel parent, URI
partition, ClassLoader classloader,
ComponentProfile profile, String name )
throws ModelException, RemoteException
{
super();

m_key = name;
- m_controller = controller;
+ m_controlURI = control.getURI();
m_partition = partition;
m_classloader = classloader;
m_profile = profile;
@@ -140,9 +139,9 @@
m_class = loadComponentClass( classloader, profile );

m_table = new ComponentTable( this );
- m_parts = new PartsTable( this );
- m_context = new ContextTable( this, parent );
- m_type = controller.loadType( m_class );
+ m_parts = new PartsTable( control, this );
+ m_context = new ContextTable( control, this, parent );
+ m_type = Type.loadType( m_class );

//
// Construct an array of the interface classes that the component
@@ -261,17 +260,12 @@
}
}
}
-
- public Provider getProvider() throws RemoteException
- {
- return getCompositionController().getProvider( this );
- }

- public Provider getProvider( Object key ) throws RemoteException
+ public URI getControllerURI() throws RemoteException
{
- return getCompositionController().getProvider( this, key );
+ return m_controlURI;
}
-
+
/**
* Return the key identifying this model within the context is used.
* For example - a key may identify a a model relative to a collection of
@@ -284,24 +278,6 @@
return m_key;
}

- /**
- * Return the primary controller assigned to the model.
- * @return the primary controller
- */
- public Controller getController() throws RemoteException
- {
- return getCompositionController();
- }
-
- /**
- * Return the primary controller assigned to the model.
- * @return the primary controller
- */
- public CompositionController getCompositionController()
- {
- return m_controller;
- }
-
public void configure( Configuration configuration )
{
m_configuration = configuration;

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/model/ContextTable.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/model/ContextTable.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/model/ContextTable.java
Thu Jun 23 21:30:35 2005
@@ -27,8 +27,7 @@
import net.dpml.part.control.Controller;
import net.dpml.part.control.DelegationException;
import net.dpml.part.control.HandlerNotFoundException;
-import net.dpml.part.model.Component;
-import net.dpml.part.model.Provider;
+import net.dpml.part.manager.Component;
import net.dpml.part.model.Model;
import net.dpml.part.model.ModelException;
import net.dpml.part.model.ModelRuntimeException;
@@ -47,6 +46,8 @@
*/
public class ContextTable
{
+ private final CompositionController m_controller;
+
private final CompositionModel m_parent;

private final CompositionModel m_model;
@@ -61,10 +62,11 @@
* part references may be resolved
*/
public ContextTable(
- CompositionModel model, CompositionModel parent )
+ CompositionController control, CompositionModel model,
CompositionModel parent )
{
m_model = model;
m_parent = parent;
+ m_controller = control;
}

public void addEntry( String key, Part part ) throws ModelException,
RemoteException
@@ -117,18 +119,16 @@
// aware.
//

- CompositionController controller =
getModel().getCompositionController();
- ReferenceEntry entry = new ReferenceEntry( controller, key,
target, uri );
+ ReferenceEntry entry = new ReferenceEntry( m_controller, key,
target, uri );
addEntry( key, entry );
}
else
{
CompositionModel model = getModel();
ClassLoader classloader = model.getClassLoader();
- CompositionController controller =
model.getCompositionController();
try
{
- Provider provider = controller.getComponent( null, model,
classloader, part, key );
+ Component provider = m_controller.getComponent( model,
classloader, part, key );
addEntry( key, provider );
}
catch( ModelException e )
@@ -161,7 +161,7 @@
}
}

- public void addEntry( String key, Provider provider ) throws
ModelException
+ public void addEntry( String key, Component provider ) throws
ModelException
{
if( null == key )
{
@@ -178,7 +178,7 @@
setEntry( key, provider );
}

- public void setEntry( String key, Provider value )
+ public void setEntry( String key, Component value )
{
if( null == key )
{
@@ -190,9 +190,9 @@
}
}

- public Provider getEntry( String key )
+ public Component getEntry( String key )
{
- return (Provider) m_entries.get( key );
+ return (Component) m_entries.get( key );
}

public boolean containsKey( String key )
@@ -206,7 +206,7 @@

public Object getValue( String key, Object[] args ) throws
RemoteException
{
- Provider provider = getEntry( key );
+ Component provider = getEntry( key );
if( null == provider )
{
return getDefaultValueUsingArgs( args );

Modified:
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/model/PartsTable.java
Thu Jun 23 21:30:35 2005
@@ -39,6 +39,8 @@
*/
public class PartsTable
{
+ private final CompositionController m_controller;
+
private final CompositionModel m_model;

private final Hashtable m_parts = new Hashtable(); // map of Model
instances keyed by part key
@@ -48,9 +50,10 @@
*
* @param model the enclosing composition model
*/
- public PartsTable( CompositionModel model )
+ public PartsTable( CompositionController control, CompositionModel model
)
{
m_model = model;
+ m_controller = control;
}

public void addPart( String key, Part part ) throws ModelException,
RemoteException
@@ -73,10 +76,9 @@
}
synchronized( m_parts )
{
- ClassLoader classloader = getModel().getClassLoader();
CompositionModel enclosing = getModel();
- CompositionController controller =
enclosing.getCompositionController();
- Model model = controller.getModel( enclosing, classloader, part,
key );
+ ClassLoader classloader = enclosing.getClassLoader();
+ Model model = m_controller.getModel( enclosing, classloader,
part, key );
addModel( key, model );
}
}

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/model/ReferenceEntry.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/model/ReferenceEntry.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/model/ReferenceEntry.java
Thu Jun 23 21:30:35 2005
@@ -32,9 +32,8 @@
import net.dpml.part.model.Model;
import net.dpml.part.model.ModelException;
import net.dpml.part.model.ModelRuntimeException;
-import net.dpml.part.model.Component;
-import net.dpml.part.model.Provider;
-import net.dpml.part.model.AvailabilityListener;
+import net.dpml.part.manager.Component;
+import net.dpml.part.manager.AvailabilityListener;
import net.dpml.part.state.State;
import net.dpml.part.state.StateListener;

@@ -44,7 +43,7 @@
* @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 ReferenceEntry extends UnicastRemoteObject implements Provider
+public class ReferenceEntry implements Component
{
//--------------------------------------------------------------
// state
@@ -53,6 +52,7 @@
private final URI m_reference;
private final Model m_provider;
private final String m_key;
+ private final CompositionController m_controller;

//--------------------------------------------------------------
// constructor
@@ -75,10 +75,8 @@
* context argument is null.
*/
public ReferenceEntry( CompositionController controller, String key,
Model provider, URI ref )
- throws ModelException, NullPointerException, RemoteException
+ throws ModelException, NullPointerException
{
- super();
-
if( null == provider )
{
throw new NullPointerException( "model" );
@@ -90,16 +88,35 @@
m_key = key;
m_reference = ref;
m_provider = provider;
+ m_controller = controller;
}

- public URI getPartition() throws RemoteException
+ public URI getPartition()
{
- return m_provider.getPartition();
+ try
+ {
+ return m_provider.getPartition();
+ }
+ catch( RemoteException e )
+ {
+ final String error =
+ "Cannot resolve partition due to a remote exception.";
+ throw new RuntimeException( error, e );
+ }
}

- public URI getURI() throws RemoteException
+ public URI getURI()
{
- return m_provider.getURI();
+ try
+ {
+ return m_provider.getURI();
+ }
+ catch( RemoteException e )
+ {
+ final String error =
+ "Cannot resolve uri due to a remote exception.";
+ throw new RuntimeException( error, e );
+ }
}

public URI getReferenceURI()
@@ -107,68 +124,83 @@
return m_reference;
}

- public Model getProviderModel() throws RemoteException
+ public Model getModel()
{
return m_provider;
}

+ private Component getDelegate()
+ {
+ return m_controller.getComponent( m_provider, m_reference );
+ }
+
//--------------------------------------------------------------
// Provider
//--------------------------------------------------------------

- public void release( Object proxy ) throws RemoteException
+ public void initialize() throws Exception
{
- getProviderModel().getProvider().release( proxy );
+ getDelegate().initialize();
+ }
+
+ public void release( Object proxy )
+ {
+ getDelegate().release( proxy );
}

public void execute( String key ) throws Exception
{
- getProviderModel().getProvider().execute( key );
+ getDelegate().execute( key );
}

public State apply( String key ) throws Exception
{
- return getProviderModel().getProvider().apply( key );
+ return getDelegate().apply( key );
}

public Object resolve() throws Exception
{
- return getProviderModel().getProvider().resolve();
+ return getDelegate().resolve();
}

public Object resolve( boolean flag ) throws Exception
{
- return getProviderModel().getProvider().resolve( flag );
+ return getDelegate().resolve( flag );
}

- public void removeStateListener( StateListener listener ) throws
RemoteException
+ public void removeStateListener( StateListener listener )
{
- getProviderModel().getProvider().removeStateListener( listener );
+ getDelegate().removeStateListener( listener );
}

- public void removeAvailabilityListener( AvailabilityListener listener )
throws RemoteException
+ public void removeAvailabilityListener( AvailabilityListener listener )
{
- getProviderModel().getProvider().removeAvailabilityListener(
listener );
+ getDelegate().removeAvailabilityListener( listener );
}

- public void addStateListener( StateListener listener ) throws
RemoteException
+ public void addStateListener( StateListener listener )
{
- getProviderModel().getProvider().addStateListener( listener );
+ getDelegate().addStateListener( listener );
}

- public void addAvailabilityListener( AvailabilityListener listener )
throws RemoteException
+ public void addAvailabilityListener( AvailabilityListener listener )
{
- getProviderModel().getProvider().addAvailabilityListener( listener );
+ getDelegate().addAvailabilityListener( listener );
}

- public State getState() throws RemoteException
+ public State getState()
{
- return getProviderModel().getProvider().getState();
+ return getDelegate().getState();
}

- public boolean isOperational() throws RemoteException
+ public boolean isOperational()
{
- return getProviderModel().getProvider().isOperational();
+ return getDelegate().isOperational();
}

+ public void terminate()
+ {
+ getDelegate().terminate();
+ }
}
+

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/model/ValueModel.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/model/ValueModel.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/model/ValueModel.java
Thu Jun 23 21:30:35 2005
@@ -23,18 +23,20 @@
import java.lang.reflect.Constructor;
import java.net.URI;

+import net.dpml.composition.runtime.ValueEntry; // <--------------- this is
runtime
+
import net.dpml.composition.control.CompositionController;
import net.dpml.composition.data.ValueDirective;
import net.dpml.composition.data.ValueDirective.Value;

+import net.dpml.logging.Logger;
+
import net.dpml.part.control.Controller;
-import net.dpml.part.control.Monitor;
-import net.dpml.part.control.Manager;
+import net.dpml.part.manager.Manager;
+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.model.Component;
-import net.dpml.part.model.Provider;

/**
* Default implementation of a the context entry constructor model.
@@ -62,7 +64,7 @@
/**
* Creation of a new context entry import model.
*
- * @param monitor a monitor
+ * @param logger the assigned logging channel
* @param controller the value model's controller
* @param partition the assigned partition
* @param manager the models manager
@@ -73,8 +75,8 @@
* context argument is null.
*/
public ValueModel(
- Monitor monitor,
- String name, CompositionController controller, URI partition,
Manager manager, ClassLoader classloader,
+ Logger logger, String name, CompositionController controller,
+ URI partition, Manager manager, ClassLoader classloader,
ValueDirective directive, Model parent )
throws ModelException, NullPointerException, RemoteException
{
@@ -94,7 +96,7 @@
m_directive = directive;
m_uri = CompositionController.createURI( partition, name );
m_partition = partition;
- m_entry = new ValueEntry( monitor, this, name, manager, classloader,
directive, parent );
+ m_entry = new ValueEntry( m_controller, logger, this, name, manager,
classloader, directive, parent );
}

public URI getURI() throws RemoteException
@@ -129,18 +131,14 @@
return m_key;
}

- public Provider getProvider() throws RemoteException
+ public Component getComponent() throws RemoteException
{
- return getComponent();
+ return m_entry;
}

- public Provider getProvider( Object key ) throws RemoteException
+ public Component getComponent( Object key ) throws RemoteException
{
throw new UnsupportedOperationException( "getComponent/1" );
}

- public Component getComponent() throws RemoteException
- {
- return m_entry;
- }
}

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/AbstractComponent.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/model/AbstractComponent.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/model/AbstractComponent.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/AbstractComponent.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.composition.model;
+package net.dpml.composition.runtime;

import java.util.EventObject;
import java.util.EventListener;
@@ -24,11 +24,12 @@

import net.dpml.composition.event.WeakEventProducer;

-import net.dpml.part.control.Monitor;
-import net.dpml.part.control.Manager;
-import net.dpml.part.model.Component;
-import net.dpml.part.model.AvailabilityEvent;
-import net.dpml.part.model.AvailabilityListener;
+import net.dpml.logging.Logger;
+
+import net.dpml.part.manager.Manager;
+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;
@@ -46,29 +47,28 @@
{
private static final State NULL_STATE = new State( true );

- private final Monitor m_monitor;
+ private final Logger m_logger;

private boolean m_initialized = false;

- public AbstractComponent( Monitor monitor ) throws RemoteException
+ public AbstractComponent( Logger logger )
{
super();
-
- m_monitor = monitor;
+ m_logger = logger;
}

/**
* Return the availability status of the model.
* @return the availability status
*/
- public abstract boolean isOperational() throws RemoteException;
+ public abstract boolean isOperational();

- public void addAvailabilityListener( AvailabilityListener listener )
throws RemoteException
+ public void addAvailabilityListener( AvailabilityListener listener )
{
super.addListener( listener );
}

- public void removeAvailabilityListener( AvailabilityListener listener )
throws RemoteException
+ public void removeAvailabilityListener( AvailabilityListener listener )
{
super.removeListener( listener );
}
@@ -77,17 +77,17 @@
* Return the current state of the component.
* @return the current state
*/
- public State getState() throws RemoteException
+ public State getState()
{
return NULL_STATE;
}

- public void addStateListener( StateListener listener ) throws
RemoteException
+ public void addStateListener( StateListener listener )
{
super.addListener( listener );
}

- public void removeStateListener( StateListener listener ) throws
RemoteException
+ public void removeStateListener( StateListener listener )
{
super.removeListener( listener );
}
@@ -112,7 +112,7 @@
{
final String error =
"Listener raised an error duirng notification of a
availability change.";
- m_monitor.warn( error, t );
+ m_logger.warn( error, t );
}
}
}
@@ -135,7 +135,7 @@
{
final String error =
"Listener raised an error duirng notification of a
state change.";
- m_monitor.warn( error, t );
+ m_logger.warn( error, t );
}
}
}
@@ -145,11 +145,11 @@
final String error =
"Event type not supported."
+ "\nEvent Class: " + event.getClass().getName();
- m_monitor.warn( error );
+ m_logger.warn( error );
}
}

- public abstract Manager getManager() throws RemoteException;
+ public abstract Manager getManager();

/**
* Return an initialized instance of the component.
@@ -231,8 +231,8 @@
// super.enqueueEvent( event );
//}

- protected Monitor getMonitor()
+ protected Logger getLogger()
{
- return m_monitor;
+ return m_logger;
}
}

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/Appliance.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/model/Appliance.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/model/Appliance.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/Appliance.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.composition.model;
+package net.dpml.composition.runtime;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@@ -25,11 +25,9 @@
import java.net.URI;
import java.rmi.RemoteException;

-import net.dpml.composition.model.ComponentEntry;
-
import net.dpml.part.control.Disposable;
-import net.dpml.part.model.AvailabilityEvent;
-import net.dpml.part.model.AvailabilityListener;
+import net.dpml.part.manager.AvailabilityEvent;
+import net.dpml.part.manager.AvailabilityListener;
import net.dpml.part.state.ResourceUnavailableException;

/**
@@ -59,7 +57,7 @@
*
* @param component the component model
*/
- Appliance( ComponentEntry component ) throws RemoteException
+ Appliance( ComponentEntry component )
{
assertNotNull( component, "component" );
m_component = component;
@@ -99,7 +97,7 @@
final String error =
"Component is not currently available."
+ "\nComponent URI: " + m_component.getURI()
- + "\nClass: " +
m_component.getModel().getDeploymentClass().getName();
+ + "\nClass: " +
m_component.getCompositionModel().getDeploymentClass().getName();
throw new ResourceUnavailableException( error );
}

@@ -120,7 +118,7 @@
// ApplianceInvocationHandler
//-------------------------------------------------------------------

- public URI getURI() throws RemoteException
+ public URI getURI()
{
return m_component.getURI();
}
@@ -154,7 +152,7 @@
dispose();
}

- private Throwable handleInvocationThrowable( Method method, Throwable e
) throws RemoteException
+ private Throwable handleInvocationThrowable( Method method, Throwable e )
{
final String name = method.getName();
final String error =

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ApplianceException.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/model/ApplianceException.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/model/ApplianceException.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ApplianceException.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.composition.model;
+package net.dpml.composition.runtime;

/**
* Exception to indicate that there was a appliance related error.

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentController.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/ComponentController.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/ComponentController.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentController.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.composition.control;
+package net.dpml.composition.runtime;

import java.util.Map;
import java.util.Hashtable;
@@ -26,8 +26,6 @@
import java.util.LinkedList;
import java.util.Iterator;
import java.util.Vector;
-import java.util.logging.Logger;
-import java.util.logging.Level;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@@ -41,14 +39,16 @@

import javax.swing.event.ChangeEvent;

+import net.dpml.logging.Logger;
+
import net.dpml.composition.model.CompositionModel;
-import net.dpml.composition.model.ComponentEntry;
+import net.dpml.composition.control.CompositionController;

-import net.dpml.part.control.Monitor;
-import net.dpml.part.control.Manager;
+import net.dpml.part.control.ControlException;
import net.dpml.part.control.ControlRuntimeException;
import net.dpml.part.control.Disposable;
-import net.dpml.part.model.Component;
+import net.dpml.part.manager.Manager;
+import net.dpml.part.manager.Component;
import net.dpml.part.model.DuplicateKeyException;
import net.dpml.part.state.State;
import net.dpml.part.state.Transition;
@@ -68,40 +68,38 @@
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
*/
-public class ComponentController extends UnicastRemoteObject implements
Manager
+public class ComponentController extends LoggingHandler implements Manager
{
private final Map m_handlers = new Hashtable();
private final LifecycleHandler m_lifecycleHandler;

private final URI m_uri;
private final CompositionController m_controller;
- private final Monitor m_monitor;
+ private final Logger m_logger;

- public ComponentController( Monitor monitor, CompositionController
controller ) throws RemoteException
+ public ComponentController( Logger logger, CompositionController
controller )
{
- super();
-
m_controller = controller;
- m_monitor = monitor;
- m_lifecycleHandler = new LifecycleHandler( monitor );
+ m_logger = logger;
+ m_lifecycleHandler = new LifecycleHandler( logger, controller );
URI uri = controller.getURI();
String path = uri.getSchemeSpecificPart();
m_uri = CompositionController.createURI( "manager", path );
}

- public URI getURI() throws RemoteException
+ public URI getURI()
{
return m_uri;
}

- public String getName() throws RemoteException
+ public String getName()
{
return getClass().getName();
}

- public Monitor getMonitor()
+ public Logger getLogger()
{
- return m_monitor;
+ return m_logger;
}

public Object resolve( Component component ) throws Exception
@@ -113,7 +111,6 @@
{
if( component instanceof ComponentEntry )
{
-
ComponentEntry entry = (ComponentEntry) component;
if( policy )
{
@@ -145,7 +142,7 @@
*
* @param proxy the proxy to release
*/
- public void release( Object proxy ) throws RemoteException
+ public void release( Object proxy )
{
if( null == proxy )
{
@@ -213,10 +210,10 @@
return;
}

- Object instance = getInstance( component );
+ Object instance = getInstance( component );
List visited = new LinkedList();
State graph = component.getStateGraph();
- Class subject = component.getModel().getDeploymentClass();
+ Class subject = component.getCompositionModel().getDeploymentClass();
validate( subject, graph );
boolean flag = true;
while( flag )
@@ -261,7 +258,7 @@
component.setInitialized( true );
}

- private Object getInstance( ComponentEntry component ) throws
RemoteException
+ private Object getInstance( ComponentEntry component )
{
Object instance = component.getLocalInstance();
if( null == instance)
@@ -277,15 +274,15 @@
final String error =
"Unable to establish a component instance."
+ "\nComponent URI: " + component.getURI()
- + "\nComponent Model: " + component.getModel().getURI()
- + "\nClass: " + component.getModel().getDeploymentClass();
+ + "\nComponent Model: " +
component.getCompositionModel().getURI()
+ + "\nClass: " +
component.getCompositionModel().getDeploymentClass();
throw new ControlRuntimeException( uri, error, e );
}
}
return instance;
}

- private void validate( Class subject, State state ) throws
ValidationException, RemoteException
+ private void validate( Class subject, State state ) throws
ValidationException
{
if( null == state )
{
@@ -421,10 +418,13 @@
if( component instanceof ComponentEntry )
{
ComponentEntry entry = (ComponentEntry) component;
- State state = entry.getCurrentState();
- Transition transition = state.getNamedTransition( key );
+ if( false == entry.isInitialized() )
+ {
+ initialize( entry );
+ }
+ Transition transition = getNamedTransition( entry, key );
applyTransition( entry, transition );
- return entry.getState();
+ return component.getState();
}
else
{
@@ -437,6 +437,29 @@
}
}

+ private Transition getNamedTransition( ComponentEntry component, String
key )
+ {
+ State state = component.getState();
+ try
+ {
+ return state.getNamedTransition( key );
+ }
+ catch( NoSuchTransitionException e )
+ {
+ String classname =
component.getCompositionModel().getDeploymentClass().getName();
+ final String error =
+ "Invalid transition key ["
+ + key
+ + "] in component ["
+ + classname
+ + "/"
+ + state.getName()
+ + "]"
+ + "\nState: " + state.list();
+ throw new IllegalArgumentException( error );
+ }
+ }
+
/**
* Apply a transition identified by a supplied transition key. The
* implementation will attempt to locate the transition relative to the
current
@@ -470,7 +493,7 @@

if( null != handler )
{
- if( getMonitor().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
final String message =
"applying ["
@@ -478,7 +501,7 @@
+ "] to state ["
+ state.getName()
+ "]";
- getMonitor().debug( message );
+ getLogger().debug( message );
}
execution( entry, handler, state, target );
}
@@ -508,8 +531,11 @@
if( component instanceof ComponentEntry )
{
ComponentEntry entry = (ComponentEntry) component;
- State state = entry.getCurrentState();
- Operation operation = state.getNamedOperation( key );
+ if( false == entry.isInitialized() )
+ {
+ initialize( entry );
+ }
+ Operation operation = getNamedOperation( entry, key );
URI handler = operation.getHandlerURI();
if( null == handler )
{
@@ -517,14 +543,15 @@
}
else
{
- if( getMonitor().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
final String message =
"executing operation ["
+ handler.toString()
+ "]";
- getMonitor().debug( message );
+ getLogger().debug( message );
}
+ State state = entry.getCurrentState();
execution( entry, handler, state, null );
}
}
@@ -538,6 +565,29 @@
throw new IllegalArgumentException( error );
}
}
+
+ private Operation getNamedOperation( ComponentEntry component, String
key )
+ {
+ State state = component.getState();
+ try
+ {
+ return state.getNamedOperation( key );
+ }
+ catch( NoSuchOperationException e )
+ {
+ String classname =
component.getCompositionModel().getDeploymentClass().getName();
+ final String error =
+ "Invalid operation key ["
+ + key
+ + "] in component ["
+ + classname
+ + "/"
+ + state.getName()
+ + "]"
+ + "\nState: " + state.list();
+ throw new IllegalArgumentException( error );
+ }
+ }

/**
* Internal utility method that handles the resolution of a handler based
on
@@ -564,7 +614,9 @@
{
return;
}
+
String scheme = uri.getScheme();
+
if( "method".equals( scheme ) )
{
//
@@ -583,7 +635,19 @@
Method method = locateMethod( c, spec );
Class[] parameters = method.getParameterTypes();
Object[] args = resolveArguments( entry, parameters, state,
target );
- method.invoke( instance, args );
+ try
+ {
+ method.invoke( instance, args );
+ }
+ catch( InvocationTargetException e )
+ {
+ URI curi = getURI();
+ Throwable cause = e.getCause();
+ final String error =
+ "Component raised an exception while applying
transition method ["
+ + instance.getClass().getName() + "#" +
method.getName() + "]";
+ throw new ControlException( curi, error, cause );
+ }
}
}
else
@@ -607,7 +671,6 @@
* @return the populated object array
*/
private Object[] resolveArguments( ComponentEntry entry, Class[]
parameters, State state, State target )
- throws RemoteException
{
Object instance = getInstance( entry );
boolean firstStateAssigned = false;
@@ -615,10 +678,14 @@
for( int i=0; i<parameters.length; i++ )
{
Class c = parameters[i];
- if( Logger.class.isAssignableFrom( c ) )
+ if( java.util.logging.Logger.class.isAssignableFrom( c ) )
+ {
+ URI uri = entry.getURI();
+ args[i] = getJavaLoggerForURI( uri );
+ }
+ else if( Logger.class.isAssignableFrom( c ) )
{
- CompositionModel model = entry.getModel();
- args[i] = model.getCompositionController().getLogChannel(
model );
+ args[i] = entry.getLogger();
}
else if( State.class.isAssignableFrom( c ) )
{
@@ -655,6 +722,18 @@
return args;
}

+ private java.util.logging.Logger getJavaLoggerForURI( URI uri )
+ {
+ String path = uri.getSchemeSpecificPart();
+ if( path.endsWith( "/" ) )
+ {
+ path = path.substring( 0, path.length() - 1 );
+ }
+ path.replace( '/', '.' );
+ return java.util.logging.Logger.getLogger( path );
+ }
+
+
/**
* Handles a request for termination by a controller. The implementation
* will attempt to locate a transition named 'terminate' and if located,
@@ -662,7 +741,7 @@
* non-terminal state the procedure will be repeated. If the current
state
* is a terminal state the operation simply returns.
*/
- public synchronized void terminate( Component component ) throws
RemoteException
+ public synchronized void terminate( Component component )
{
if( component instanceof ComponentEntry )
{
@@ -675,7 +754,7 @@
{
// recusive termination path
String error = e.getMessage();
- getMonitor().warn( error );
+ getLogger().warn( error );
}
finally
{
@@ -720,7 +799,7 @@
catch( Exception e )
{
flag = false;
- getMonitor().warn( "Ignoring termination handler error",
e );
+ getLogger().warn( "Ignoring termination handler error",
e );
}
}
else

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentEntry.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/model/ComponentEntry.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/model/ComponentEntry.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentEntry.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.composition.model;
+package net.dpml.composition.runtime;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@@ -37,23 +37,25 @@
import net.dpml.activity.Executable;
import net.dpml.activity.Startable;

-import net.dpml.composition.control.ComponentController;
+import net.dpml.composition.model.ContextTable;
+import net.dpml.composition.model.CompositionModel;
import net.dpml.composition.control.CompositionController;
import net.dpml.composition.event.EventProducer;
import net.dpml.composition.event.WeakEventProducer;

+import net.dpml.logging.Logger;
+
import net.dpml.part.control.Identifiable;
import net.dpml.part.control.LifecycleException;
-import net.dpml.part.control.Monitor;
-
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.model.Component;
-import net.dpml.part.model.AvailabilityEvent;
-import net.dpml.part.model.AvailabilityListener;
-import net.dpml.part.control.Manager;
+import net.dpml.part.manager.Component;
+import net.dpml.part.manager.AvailabilityEvent;
+import net.dpml.part.manager.AvailabilityListener;
+import net.dpml.part.manager.Manager;
+import net.dpml.part.model.Model;

/**
*
@@ -65,7 +67,7 @@
private final Map m_proxies = new WeakHashMap();

private final Object m_key;
- private final Monitor m_monitor;
+ private final Logger m_logger;
private final CompositionModel m_model;
private final URI m_uri;
private final ContextMap m_context;
@@ -77,20 +79,16 @@

private Object m_instance;

- private final Object m_owner; // not sure if this is needed
-
private boolean m_disposed = false;

public ComponentEntry(
- Monitor monitor, ComponentController manager, CompositionModel model,
- Object key, Object owner ) throws RemoteException
+ Logger logger, ComponentController manager, CompositionModel model,
Object key )
{
super();

m_manager = manager;
- m_monitor = monitor;
+ m_logger = logger;
m_model = model;
- m_owner = owner;

if( null == key )
{
@@ -127,27 +125,27 @@
* Return the availability status of the model.
* @return the availability status
*/
- public boolean isOperational() throws RemoteException
+ public boolean isOperational()
{
return true;
}

- public void addAvailabilityListener( AvailabilityListener listener )
throws RemoteException
+ public void addAvailabilityListener( AvailabilityListener listener )
{
super.addListener( listener );
}

- public void removeAvailabilityListener( AvailabilityListener listener )
throws RemoteException
+ public void removeAvailabilityListener( AvailabilityListener listener )
{
super.removeListener( listener );
}

- public void addStateListener( StateListener listener ) throws
RemoteException
+ public void addStateListener( StateListener listener )
{
super.addListener( listener );
}

- public void removeStateListener( StateListener listener ) throws
RemoteException
+ public void removeStateListener( StateListener listener )
{
super.removeListener( listener );
}
@@ -186,7 +184,7 @@
{
final String error =
"Listener raised an exception in response to a state
change notification.";
- m_monitor.warn( error, t );
+ m_logger.warn( error, t );
}
}
}
@@ -196,11 +194,16 @@
final String error =
"Event type not supported."
+ "\nEvent Class: " + event.getClass().getName();
- m_monitor.warn( error );
+ m_logger.warn( error );
}
}

- public Manager getManager() throws RemoteException
+ public Model getModel()
+ {
+ return m_model;
+ }
+
+ public Manager getManager()
{
return m_manager;
}
@@ -211,7 +214,7 @@
*
* @return the resolved instance
*/
- public Object resolve() throws Exception, RemoteException
+ public Object resolve() throws Exception
{
return getManager().resolve( this, true );
}
@@ -223,7 +226,7 @@
* @param policy the proxy creation policy
* @return the resolved instance
*/
- public Object resolve( boolean policy ) throws Exception, RemoteException
+ public Object resolve( boolean policy ) throws Exception
{
return getManager().resolve( this, policy );
}
@@ -231,7 +234,7 @@
/**
* Initialize the component.
*/
- public void initialize() throws Exception, RemoteException
+ public void initialize() throws Exception
{
m_manager.initialize( this );
}
@@ -243,7 +246,7 @@
* @return the state resulting from the transition
* @exception if a transition error occurs
*/
- public State apply( String key ) throws Exception, RemoteException
+ public State apply( String key ) throws Exception
{
return m_manager.apply( this, key );
}
@@ -254,7 +257,7 @@
* @param key the key identifying the operation to execute
* @exception if a transition error occurs
*/
- public void execute( String key ) throws Exception, RemoteException
+ public void execute( String key ) throws Exception
{
m_manager.execute( this, key );
}
@@ -262,7 +265,7 @@
/**
* Termination of the component.
*/
- public void terminate() throws RemoteException
+ public void terminate()
{
m_manager.terminate( this );
}
@@ -301,14 +304,14 @@
{
if( false == m_state.equals( state ) )
{
- if( getMonitor().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
final String message =
"State change."
+ "\nInstance: " + getURI()
+ "\nOld State: " + m_state.getName()
+ "\nNew State: " + state.getName();
- getMonitor().debug( message );
+ getLogger().debug( message );
}

StateEvent event = new StateEvent( this, m_state, state );
@@ -356,9 +359,9 @@
}
}

- public Monitor getMonitor()
+ public Logger getLogger()
{
- return m_monitor;
+ return m_logger;
}

public Object getKey()
@@ -366,7 +369,7 @@
return m_key;
}

- public CompositionModel getModel()
+ public CompositionModel getCompositionModel()
{
return m_model;
}
@@ -392,9 +395,9 @@
*
* @return the proxy reflecting the service interfaces declared by the
component type
*/
- public Object getProxy() throws RemoteException
+ public Object getProxy()
{
- CompositionModel model = getModel();
+ CompositionModel model = getCompositionModel();
ClassLoader classloader = model.getClassLoader();
Class[] interfaces = model.getServiceClasses();
Appliance appliance = new Appliance( this );
@@ -450,7 +453,7 @@
* remove the instance for the model's instance table and trigger instance
* etherialization.
*/
- public void dispose() throws RemoteException
+ public void dispose()
{
if( m_disposed )
{
@@ -467,12 +470,12 @@
// pass
}

- getModel().getComponentTable().remove( this );
+ getCompositionModel().getComponentTable().remove( this );

//synchronized( m_proxies )
//{
// m_disposed = true;
- // CompositionModel model = getModel();
+ // CompositionModel model = getCompositionModel();
// Object[] proxies = (Object[]) m_proxies.keySet().toArray( new
Object[0] );
// for( int i=0; i<proxies.length; i++ )
// {
@@ -480,7 +483,7 @@
// m_manager.release( proxy );
// }
// m_proxies.clear();
- // getModel().getComponentTable().remove( this );
+ // getCompositionModel().getComponentTable().remove( this );
// try
// {
// Object instance = getLocalInstance();
@@ -526,7 +529,7 @@
*/
protected void finalize()
{
- m_monitor.debug( "component model finalization in " + getURI() );
+ m_logger.debug( "component model finalization in " + getURI() );
try
{
dispose();
@@ -659,7 +662,7 @@
m_model = model;
}

- public Object getValue( String key, Object[] args ) throws
RemoteException
+ public Object getValue( String key, Object[] args )
{
Object value = get( key );
if( null != value )
@@ -668,8 +671,17 @@
}
else
{
- ContextTable table = getModel().getContextTable();
- return table.getValue( key, args );
+ 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 );
+ }
}
}


Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentTable.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/model/ComponentTable.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/model/ComponentTable.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ComponentTable.java
Thu Jun 23 21:30:35 2005
@@ -16,13 +16,16 @@
* limitations under the License.
*/

-package net.dpml.composition.model;
+package net.dpml.composition.runtime;

import java.io.Serializable;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.Hashtable;

+import net.dpml.composition.model.CompositionModel;
+
+
/**
* The parts model is a model of the set of parts maintained by a parent
model.
*

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/CompositionManager.java
(from r2909,
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/CompositionManager.java
Thu Jun 23 21:30:35 2005
@@ -16,11 +16,12 @@
* limitations under the License.
*/

-package net.dpml.composition.control;
+package net.dpml.composition.runtime;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.rmi.RemoteException;
@@ -30,23 +31,31 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.logging.LogManager;

import net.dpml.activity.Startable;

+import net.dpml.composition.control.*;
+import net.dpml.composition.runtime.DefaultLogger;
+
import net.dpml.part.control.ControlRuntimeException;
import net.dpml.part.control.Controller;
import net.dpml.part.control.ControllerContext;
import net.dpml.part.control.DelegationException;
import net.dpml.part.control.HandlerNotFoundException;
import net.dpml.part.control.PartNotFoundException;
-import net.dpml.part.control.SystemManager;
+import net.dpml.part.manager.AvailabilityListener;
+import net.dpml.part.manager.Container;
+import net.dpml.part.manager.Component;
import net.dpml.part.model.Model;
-import net.dpml.part.model.Component;
import net.dpml.part.model.ModelException;
import net.dpml.part.part.Part;
+import net.dpml.part.state.State;
+import net.dpml.part.state.StateListener;
+
+import net.dpml.composition.info.Type;

import net.dpml.transit.model.ContentModel;
+import net.dpml.logging.Logger;

/**
* The CompositionManager is a top-level manager responsible for the
management
@@ -55,30 +64,37 @@
* @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 CompositionManager extends CompositionController implements
SystemManager, Startable
+public class CompositionManager implements Container, Startable
{
//--------------------------------------------------------------------
// state
//--------------------------------------------------------------------

- private final ClassLoader m_classloader;
+ private final ClassLoader m_classloader = Type.class.getClassLoader();
private final Set m_components = Collections.synchronizedSet( new
HashSet() );
private final Map m_instances = new Hashtable();

+ private final CompositionController m_controller;
+ private final Logger m_logger;
+
//--------------------------------------------------------------------
// constructor
//--------------------------------------------------------------------

- public CompositionManager( ContentModel context ) throws Exception
+ public CompositionManager( CompositionController controller ) throws
Exception
{
- super( context );
-
- m_classloader =
net.dpml.composition.info.Type.class.getClassLoader();
+ m_controller = controller;
+ m_logger = new DefaultLogger( "metro" );
setShutdownHook( this );
}

+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+
//--------------------------------------------------------------------
- // SystemManager
+ // Container
//--------------------------------------------------------------------

/**
@@ -90,10 +106,10 @@
*/
public Component addComponent( URI uri, String key )
throws IOException, DelegationException, ModelException,
PartNotFoundException,
- HandlerNotFoundException, RemoteException
+ HandlerNotFoundException
{
- Model model = getModel( uri, key );
- Component component = model.getController().getComponent(
(Component) null, model );
+ Model model = m_controller.getModel( uri, key );
+ Component component = m_controller.getComponent( model );
addComponent( component );
return component;
}
@@ -107,10 +123,10 @@
*/
public Component addComponent( URI uri, Object id, String key )
throws IOException, DelegationException, ModelException,
PartNotFoundException,
- HandlerNotFoundException, RemoteException
+ HandlerNotFoundException
{
- Model model = getModel( uri, key );
- Component component = model.getController().getComponent(
(Component) null, model, id );
+ Model model = m_controller.getModel( uri, key );
+ Component component = m_controller.getComponent( model, id );
addComponent( component );
return component;
}
@@ -119,11 +135,146 @@
* Register a component with the system.
* @param component the component to register
*/
- public void addComponent( Component component ) throws RemoteException
+ public void addComponent( Component component )
{
m_components.add( component );
}

+ //--------------------------------------------------------------------
+ // Component
+ //--------------------------------------------------------------------
+
+ public URI getURI()
+ {
+ return m_controller.getURI();
+ }
+
+ /**
+ * Return the operational status of the model.
+ * @return the operational status
+ */
+ public boolean isOperational()
+ {
+ return true;
+ }
+
+ /**
+ * Add an availability listener to the provider.
+ * @param listener the availability listener
+ */
+ public void addAvailabilityListener( AvailabilityListener listener )
+ {
+ }
+
+ /**
+ * Remove an availability listener from the provider.
+ * @param listener the availability listener
+ */
+ public void removeAvailabilityListener( AvailabilityListener listener )
+ {
+ }
+
+ /**
+ * Return the current state of the component.
+ * @return the current state
+ */
+ public State getState()
+ {
+ return null;
+ }
+
+ /**
+ * Add a state listener to the provider.
+ * @param listener the state listener
+ */
+ public void addStateListener( StateListener listener )
+ {
+ }
+
+ /**
+ * Remove a state listener from the provider.
+ * @param listener the state listener
+ */
+ public void removeStateListener( StateListener listener )
+ {
+ }
+
+ /**
+ * Return an initialized instance of the component.
+ * @return the resolved instance
+ */
+ public Object resolve() throws Exception
+ {
+ return this;
+ }
+
+ /**
+ * Return an initialized instance of the component using a supplied
isolation policy.
+ * If the isolation policy is TRUE an implementation shall make best
efforts to isolate
+ * implementation concerns under the object that is returned. Typically
isolation
+ * involves the creation of a proxy of a component implementation
instance that
+ * exposes a component's service interfaces to a client. If the
isolation policy if
+ * FALSE the implementation shall return the component implementation
instance.
+ *
+ * @param isolation the isolation policy
+ * @return the resolved instance
+ */
+ public Object resolve( boolean isolation ) throws Exception
+ {
+ return this;
+ }
+
+ /**
+ * Applies a state transition identified by a supplied transition key.
+ *
+ * @param key the key identifying the transition to apply to the
component's controller
+ * @return the state resulting from the transition
+ * @exception if a transition error occurs
+ */
+ public State apply( String key ) throws Exception
+ {
+ return null;
+ }
+
+ /**
+ * Executes an operation identified by a supplied operation key.
+ *
+ * @param key the key identifying the operation to execute
+ * @exception if a transition error occurs
+ */
+ public void execute( String key ) throws Exception
+ {
+ }
+
+ /**
+ * Release a reference to an object managed by the instance.
+ *
+ * @param instance the instance to release
+ */
+ public void release( Object instance )
+ {
+ }
+
+ /**
+ * Initialize the component.
+ */
+ public void initialize() throws Exception
+ {
+ }
+
+ public void terminate()
+ {
+ }
+
+ public Model getModel()
+ {
+ return null;
+ }
+
+ //--------------------------------------------------------------------
+ // Startable
+ //--------------------------------------------------------------------
+
public synchronized void start() throws Exception
{
getLogger().info( "initiating startup in " + getURI() );
@@ -138,7 +289,7 @@
}
}

- public synchronized void stop() throws RemoteException
+ public synchronized void stop()
{
getLogger().info( "initiating shutdown in " + getURI() );
Component[] components = (Component[]) m_instances.keySet().toArray(
new Component[0] );
@@ -175,12 +326,12 @@
*/
public void list()
{
- getMonitor().info( "listing models in the controller" );
+ getLogger().info( "listing models in the controller" );
Component[] components = getManagedComponents();
for( int i=0; i<components.length; i++ )
{
Component component = components[i];
- getMonitor().info( "component: " + component );
+ getLogger().info( "component: " + component );
}
}


Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextInvocationHandler.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextInvocationHandler.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextInvocationHandler.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.composition.control;
+package net.dpml.composition.runtime;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
@@ -24,11 +24,11 @@

import net.dpml.part.control.LifecycleException;
import net.dpml.part.model.ModelException;
-import net.dpml.part.model.AvailabilityListener;
+import net.dpml.part.manager.AvailabilityListener;
import net.dpml.part.state.StateListener;

-import net.dpml.composition.model.ComponentEntry;
import net.dpml.composition.model.CompositionModel;
+import net.dpml.composition.control.CompositionController;

/**
* This makes a dynamic proxy for an object. The object can be represented
@@ -49,6 +49,8 @@
*/
private final ComponentEntry m_component;

+ private final CompositionController m_controller;
+
//-------------------------------------------------------------------
// constructor
//-------------------------------------------------------------------
@@ -59,10 +61,11 @@
* @param system the system context
* @param model the component model
*/
- ContextInvocationHandler( ComponentEntry component )
+ ContextInvocationHandler( CompositionController controller,
ComponentEntry component )
throws LifecycleException, ModelException
{
m_component = component;
+ m_controller = controller;
}

//-------------------------------------------------------------------
@@ -76,7 +79,7 @@

CompositionModel getModel()
{
- return getComponentEntry().getModel();
+ return getComponentEntry().getCompositionModel();
}

/**

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextManagerInvocationHandler.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextManagerInvocationHandler.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextManagerInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ContextManagerInvocationHandler.java
Thu Jun 23 21:30:35 2005
@@ -16,15 +16,14 @@
* limitations under the License.
*/

-package net.dpml.composition.control;
+package net.dpml.composition.runtime;

import java.lang.reflect.Method;
import java.util.Map;

-import net.dpml.composition.model.ComponentEntry;
+import net.dpml.composition.control.CompositionController;

import net.dpml.part.control.LifecycleException;
-
import net.dpml.part.model.ModelException;

/**
@@ -37,6 +36,12 @@
final class ContextManagerInvocationHandler extends ContextInvocationHandler
{
//-------------------------------------------------------------------
+ // state
+ //-------------------------------------------------------------------
+
+ private final CompositionController m_controller;
+
+ //-------------------------------------------------------------------
// constructor
//-------------------------------------------------------------------

@@ -46,10 +51,12 @@
* @param system the system context
* @param model the component model
*/
- ContextManagerInvocationHandler( ComponentEntry holder )
+ ContextManagerInvocationHandler( CompositionController controller,
ComponentEntry holder )
throws LifecycleException, ModelException
{
- super( holder );
+ super( controller, holder );
+
+ m_controller = controller;
}

//-------------------------------------------------------------------

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/DefaultInvocationHandler.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/DefaultInvocationHandler.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/DefaultInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/DefaultInvocationHandler.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.composition.control;
+package net.dpml.composition.runtime;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/DefaultLogger.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/DefaultLogger.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/DefaultLogger.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/DefaultLogger.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.composition.control;
+package net.dpml.composition.runtime;

import java.net.URL;
import java.util.logging.Logger;

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/DelegationRuntimeException.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/DelegationRuntimeException.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/DelegationRuntimeException.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/DelegationRuntimeException.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.composition.control;
+package net.dpml.composition.runtime;

/**
* Exception thrown in response to a unexpected error in an invocation
handler.

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LifecycleHandler.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifecycleHandler.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifecycleHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LifecycleHandler.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.composition.control;
+package net.dpml.composition.runtime;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
@@ -24,10 +24,11 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URI;
-import java.util.logging.Logger;

-import net.dpml.composition.model.ComponentEntry;
+import net.dpml.logging.Logger;
+
import net.dpml.composition.model.CompositionModel;
+import net.dpml.composition.control.CompositionController;

import net.dpml.configuration.Configuration;

@@ -35,7 +36,6 @@

import net.dpml.part.control.LifecycleException;
import net.dpml.part.control.LifecycleRuntimeException;
-import net.dpml.part.control.Monitor;


/**
@@ -47,7 +47,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 $
*/
-class LifecycleHandler
+class LifecycleHandler extends LoggingHandler
{
public static Class getInnerClass( Class subject, String postfix )
{
@@ -69,11 +69,13 @@
return null;
}

- private final Monitor m_monitor;
+ private final Logger m_logger;
+ private final CompositionController m_controller;

- LifecycleHandler( Monitor monitor )
+ LifecycleHandler( Logger logger, CompositionController controller )
{
- m_monitor = monitor;
+ m_logger = logger;
+ m_controller = controller;
}

/**
@@ -84,15 +86,15 @@
*/
public Object incarnate( ComponentEntry holder ) throws
LifecycleException, InvocationTargetException
{
- if( getMonitor().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
final String message =
"Incarnating ["
+ holder.getURI()
+ "].";
- getMonitor().debug( message );
+ getLogger().debug( message );
}
- CompositionModel model = holder.getModel();
+ CompositionModel model = holder.getCompositionModel();
URI uri = holder.getURI();

Class subject = model.getDeploymentClass();
@@ -106,13 +108,13 @@
for( int i=0; i<classes.length; i++ )
{
Class c = classes[i];
- if( Logger.class.isAssignableFrom( c ) )
+ if( java.util.logging.Logger.class.isAssignableFrom( c ) )
{
- args[i] = model.getCompositionController().getLogChannel(
model );
+ args[i] = getJavaLogger( model );
}
- else if( net.dpml.logging.Logger.class.isAssignableFrom( c ) )
+ else if( Logger.class.isAssignableFrom( c ) )
{
- args[i] =
model.getCompositionController().getLoggingChannel( model );
+ args[i] = getLoggingChannel( model );
}
else if( ( null != parts ) && parts.isAssignableFrom( c ) )
{
@@ -163,16 +165,16 @@
/*
public Manager getManager( ComponentEntry holder ) throws
LifecycleException, InvocationTargetException
{
- if( getMonitor().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
final String message =
"Instantiating state manager for ["
+ holder.getURI()
+ "].";
- getMonitor().debug( message );
+ getLogger().debug( message );
}

- CompositionModel model = holder.getModel();
+ CompositionModel model = holder.getCompositionModel();
Class subject = model.getDeploymentClass();
Class control = getInnerClass( subject, "Controller" );
if( null == control )
@@ -203,11 +205,11 @@
Class c = classes[i];
if( java.util.logging.Logger.class.isAssignableFrom( c ) )
{
- args[i] = model.getCompositionController().getLogChannel(
model, "control" );
+ args[i] = getJavaLogger( model, "control" );
}
else if( Logger.class.isAssignableFrom( c ) )
{
- args[i] =
model.getCompositionController().getLoggingChannel( model );
+ args[i] = getLoggingChannel( model );
}
else if( subject.isAssignableFrom( c ) )
{
@@ -256,13 +258,13 @@

Class subject = object.getClass();

- if( getMonitor().isDebugEnabled() )
+ if( getLogger().isDebugEnabled() )
{
final String message =
"Initiating etherialization on an instance of the class ["
+ subject.getName()
+ "].";
- getMonitor().debug( message );
+ getLogger().debug( message );
}

try
@@ -337,12 +339,13 @@
}
}

- private Object newContextInvocationHandler( ComponentEntry holder, Class
clazz ) throws LifecycleRuntimeException
+ private Object newContextInvocationHandler(
+ ComponentEntry holder, Class clazz ) throws LifecycleRuntimeException
{
try
{
- InvocationHandler handler = new ContextInvocationHandler( holder
);
- ClassLoader classloader =
holder.getModel().getDeploymentClass().getClassLoader();
+ InvocationHandler handler = new ContextInvocationHandler(
m_controller, holder );
+ ClassLoader classloader =
holder.getCompositionModel().getDeploymentClass().getClassLoader();
return Proxy.newProxyInstance( classloader, new Class[]{ clazz
}, handler );
}
catch( Throwable e )
@@ -357,8 +360,8 @@
{
try
{
- InvocationHandler handler = new PartsInvocationHandler( holder );
- ClassLoader classloader =
holder.getModel().getDeploymentClass().getClassLoader();
+ InvocationHandler handler = new PartsInvocationHandler(
m_controller, holder );
+ ClassLoader classloader =
holder.getCompositionModel().getDeploymentClass().getClassLoader();
return Proxy.newProxyInstance( classloader, new Class[]{ clazz
}, handler );
}
catch( Throwable e )
@@ -369,8 +372,8 @@
}
}

- private Monitor getMonitor()
+ private Logger getLogger()
{
- return m_monitor;
+ return m_logger;
}
}

Added:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LoggingHandler.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/LoggingHandler.java
Thu Jun 23 21:30:35 2005
@@ -0,0 +1,90 @@
+/*
+ * 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.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+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;
+
+import net.dpml.parameters.Parameters;
+
+import net.dpml.part.control.LifecycleException;
+import net.dpml.part.control.LifecycleRuntimeException;
+
+
+/**
+ * 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 LoggingHandler
+{
+ /**
+ * Return a log channel for a supplied model.
+ * @param model the composition model
+ * @return the logging channel
+ */
+ java.util.logging.Logger getJavaLogger( CompositionModel model )
+ {
+ return getJavaLogger( model, null );
+ }
+
+ /**
+ * Return a named log channel for a supplied model.
+ * @param model the composition model
+ * @param category the logging category name
+ * @return the logging channel
+ */
+ java.util.logging.Logger getJavaLogger( CompositionModel model, String
category )
+ {
+ URI uri = model.getURI();
+ String path = model.getURI().getSchemeSpecificPart();
+ String channel = path.replace( '/', '.' );
+ if( category != null )
+ {
+ channel = channel + "." + category;
+ }
+ return Logger.getLogger( channel );
+ }
+
+ net.dpml.logging.Logger getLoggingChannel( CompositionModel model )
+ {
+ URI uri = model.getURI();
+ String path = uri.getSchemeSpecificPart();
+ if( path.endsWith( "/" ) )
+ {
+ path = path.substring( 0, path.length() - 1 );
+ }
+ path.replace( '/', '.' );
+ return new DefaultLogger( path );
+ }
+}

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ManagerInvocationHandler.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/ManagerInvocationHandler.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/ManagerInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ManagerInvocationHandler.java
Thu Jun 23 21:30:35 2005
@@ -16,14 +16,14 @@
* limitations under the License.
*/

-package net.dpml.composition.control;
+package net.dpml.composition.runtime;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.UndeclaredThrowableException;

-import net.dpml.composition.model.ComponentEntry;
+import net.dpml.composition.control.CompositionController;

import net.dpml.part.state.State;


Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/PartsInvocationHandler.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/PartsInvocationHandler.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/PartsInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/PartsInvocationHandler.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.composition.control;
+package net.dpml.composition.runtime;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@@ -26,14 +26,14 @@
import java.rmi.RemoteException;

import net.dpml.composition.info.PartDescriptor;
-import net.dpml.composition.model.ComponentEntry;
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.model.Component;
+import net.dpml.part.manager.Component;
+import net.dpml.part.manager.Manager;
import net.dpml.part.model.Model;
-import net.dpml.part.control.Manager;

/**
* The parts invocation handler maps client request for 'get', 'create' and
@@ -62,6 +62,8 @@
*/
private final ComponentEntry m_holder;

+ private final CompositionController m_controller;
+
//-------------------------------------------------------------------
// constructor
//-------------------------------------------------------------------
@@ -71,10 +73,11 @@
*
* @param model the component model
*/
- PartsInvocationHandler( ComponentEntry holder )
+ PartsInvocationHandler( CompositionController controller, ComponentEntry
holder )
throws NullPointerException
{
m_holder = holder;
+ m_controller = controller;
}

//-------------------------------------------------------------------
@@ -108,7 +111,7 @@

CompositionModel getModel()
{
- return m_holder.getModel();
+ return m_holder.getCompositionModel();
}

/**
@@ -141,10 +144,9 @@
{
if( null == postfix )
{
- Controller controller = provider.getController();
if( null == args )
{
- return controller.getComponent( m_holder, provider
).resolve();
+ return m_controller.getComponent( provider ).resolve();
}
else if( args.length == 1 )
{
@@ -152,18 +154,18 @@
if( arg.getClass() == Boolean.TYPE )
{
boolean policy = getBooleanValue( args[1] );
- return controller.getComponent( m_holder, provider
).resolve( policy );
+ return m_controller.getComponent( provider
).resolve( policy );
}
else
{
- return controller.getComponent( m_holder, provider,
arg ).resolve();
+ return m_controller.getComponent( provider, arg
).resolve();
}
}
else if( args.length == 2 )
{
Object arg = args[0];
boolean policy = getBooleanValue( args[1] );
- return controller.getComponent( m_holder, provider, arg
).resolve( policy );
+ return m_controller.getComponent( provider, arg
).resolve( policy );
}
else
{
@@ -213,11 +215,10 @@
}

CompositionModel model = (CompositionModel) provider;
- Controller controller = model.getController();
ComponentEntry component = getComponentEntry( model, args );
ClassLoader classloader = model.getClassLoader();
ContextManagerInvocationHandler handler =
- new ContextManagerInvocationHandler( component );
+ new ContextManagerInvocationHandler( m_controller,
component );
return Proxy.newProxyInstance( classloader, new Class[]{
clazz }, handler );
}
else if( PartDescriptor.PROVIDER_KEY.equals( postfix ) )
@@ -343,32 +344,31 @@
{
if( null == args )
{
- return model.getController().getComponent( m_holder, model );
+ return m_controller.getComponent( model );
}
else if( args.length == 0 )
{
- return model.getController().getComponent( m_holder, model );
+ return m_controller.getComponent( model );
}
else
{
- return model.getController().getComponent( m_holder, model,
args[0] );
+ return m_controller.getComponent( model, args[0] );
}
}

private ComponentEntry getComponentEntry( CompositionModel model,
Object[] args ) throws Exception
{
- CompositionController controller = model.getCompositionController();
if( null == args )
{
- return controller.getComponentEntry( m_holder, model, null );
+ return m_controller.getComponentEntry( model, null );
}
else if( args.length == 0 )
{
- return controller.getComponentEntry( m_holder, model, null );
+ return m_controller.getComponentEntry( model, null );
}
else
{
- return controller.getComponentEntry( m_holder, model, args[0] );
+ return m_controller.getComponentEntry( model, args[0] );
}
}


Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueController.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/control/ValueController.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/ValueController.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueController.java
Thu Jun 23 21:30:35 2005
@@ -16,16 +16,16 @@
* limitations under the License.
*/

-package net.dpml.composition.control;
+package net.dpml.composition.runtime;

import java.net.URI;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

-import net.dpml.composition.model.ValueEntry;
+import net.dpml.composition.control.CompositionController;

-import net.dpml.part.control.Manager;
-import net.dpml.part.model.Component;
+import net.dpml.part.manager.Manager;
+import net.dpml.part.manager.Component;
import net.dpml.part.state.NoSuchOperationException;
import net.dpml.part.state.NoSuchTransitionException;
import net.dpml.part.state.State;
@@ -35,11 +35,11 @@
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
*/
-public class ValueController extends UnicastRemoteObject implements Manager
+public class ValueController implements Manager
{
private URI m_uri;

- public ValueController( CompositionController controller ) throws
RemoteException
+ public ValueController( CompositionController controller )
{
super();

@@ -69,7 +69,7 @@
* Return the instance managed by this manager.
* @return the managed instance
*/
- public Object resolve( Component entry, boolean policy ) throws
RemoteException
+ public Object resolve( Component entry, boolean policy )
{
return ((ValueEntry)entry).getInstance();
}

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueEntry.java
(from r2901,
development/main/metro/composition/control/src/main/net/dpml/composition/model/ValueEntry.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/model/ValueEntry.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/runtime/ValueEntry.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.composition.model;
+package net.dpml.composition.runtime;

import java.lang.reflect.Constructor;
import java.net.URI;
@@ -25,14 +25,16 @@
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.control.Manager;
-import net.dpml.part.control.Monitor;
+import net.dpml.part.manager.Manager;
+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.model.Component;
import net.dpml.part.state.State;

/**
@@ -53,6 +55,7 @@
private final ValueModel m_model;
private final Manager m_manager;
private final Model m_parent;
+ private final CompositionController m_controller;

private String m_key;
private Object m_value;
@@ -64,7 +67,7 @@
/**
* Creation of a new context entry import model.
*
- * @param monitor a monitor
+ * @param logger the logging channel
* @param model the value model
* @param name the entry name
* @param manager the value model's manager
@@ -75,11 +78,11 @@
* context argument is null.
*/
public ValueEntry(
- Monitor monitor, ValueModel model, String name, Manager manager,
ClassLoader classloader,
+ CompositionController controller, Logger logger, ValueModel model,
String name, Manager manager, ClassLoader classloader,
ValueDirective directive, Model parent )
- throws ModelException, NullPointerException, RemoteException
+ throws ModelException, NullPointerException
{
- super( monitor );
+ super( logger );

if( directive == null )
{
@@ -89,20 +92,36 @@
{
throw new NullPointerException( "model" );
}
+
m_directive = directive;
m_classloader = classloader;
m_model = model;
m_parent = parent;
m_key = name;
-
- URI base = m_model.getURI();
- m_uri = CompositionController.createURI( base, name );
m_manager = manager;
+ m_controller = controller;
+
+ 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();
}

- public Manager getManager() throws RemoteException
+ public Model getModel()
+ {
+ return m_model;
+ }
+
+ public Manager getManager()
{
return m_manager;
}
@@ -111,7 +130,7 @@
* Return the availability status of the model.
* @return the availability status
*/
- public boolean isOperational() throws RemoteException
+ public boolean isOperational()
{
return true;
}
@@ -121,17 +140,17 @@
*
* @return the key
*/
- public Object getKey() throws RemoteException
+ public Object getKey()
{
return m_key;
}

- public URI getURI() throws RemoteException
+ public URI getURI()
{
return m_uri;
}

- public Object getInstance() throws RemoteException
+ public Object getInstance()
{
return getValue();
}
@@ -147,7 +166,7 @@
/**
* Termination of the component.
*/
- public void terminate() throws RemoteException
+ public void terminate()
{
m_manager.terminate( this );
}
@@ -166,7 +185,7 @@
*
* @return the context entry value
*/
- public Object getValue() throws RemoteException
+ public Object getValue()
{
if( m_value != null )
{
@@ -213,7 +232,7 @@
* @return the context entry value
*/
public Object getValue( Value p )
- throws ModelException, RemoteException
+ throws ModelException
{
String argument = p.getArgument();
Object object = checkForURNReference( argument );
@@ -236,7 +255,7 @@
* @exception ModelException if the parameter value cannot be resolved
*/
public Object getValue( Class clazz, String argument, Value[] parameters
)
- throws ModelException, RemoteException
+ throws ModelException
{
if( parameters.length == 0 )
{
@@ -256,7 +275,7 @@
}

private Object getMultiArgumentConstructorValue( Class clazz, Value[]
parameters )
- throws ModelException, RemoteException
+ throws ModelException
{
//
// getting here means we are dealing with 0..n types parameter
constructor where the
@@ -393,7 +412,7 @@


private Object getNullArgumentConstructorValue( Class clazz )
- throws ModelException, RemoteException
+ throws ModelException
{
try
{
@@ -432,7 +451,7 @@
}

private Object getSingleArgumentConstructorValue( Class clazz, String
argument )
- throws ModelException, RemoteException
+ throws ModelException
{
Object object = checkForURNReference( argument );
if( null != object )
@@ -503,7 +522,7 @@
}
}

- private Object getPrimitiveValue( Class clazz, String argument ) throws
ModelException, RemoteException
+ private Object getPrimitiveValue( Class clazz, String argument ) throws
ModelException
{
if( Integer.TYPE == clazz )
{
@@ -550,7 +569,7 @@
* @return the parameter class
* @exception ModelException if the parameter class cannot be resolved
*/
- Class getValueClass( Value value ) throws ModelException, RemoteException
+ Class getValueClass( Value value ) throws ModelException
{
String v = value.getArgument();
Object object = checkForURNReference( v );
@@ -570,7 +589,7 @@
* @return the parameter class
* @exception ModelException if the parameter class cannot be resolved
*/
- Class getValueClass( String classname ) throws ModelException,
RemoteException
+ Class getValueClass( String classname ) throws ModelException
{
try
{
@@ -631,7 +650,7 @@
}
}

- private Object checkForURNReference( String argument ) throws
RemoteException
+ private Object checkForURNReference( String argument )
{
if( null == argument )
{
@@ -655,12 +674,11 @@
}
}

- private Object getParentResource( URI urn ) throws RemoteException
+ private Object getParentResource( URI urn )
{
- Controller controller = m_model.getController();
if( null != m_parent )
{
- return controller.getResource( m_parent, urn );
+ return m_controller.getResource( m_parent, urn );
}
else
{
@@ -682,7 +700,7 @@
}

private void validatePair( String descriptorClassName, String
directiveClassName )
- throws ModelException, RemoteException
+ throws ModelException
{
if( "int".equals( descriptorClassName ) )
{

Modified: development/main/metro/index.xml
==============================================================================
--- development/main/metro/index.xml (original)
+++ development/main/metro/index.xml Thu Jun 23 21:30:35 2005
@@ -23,28 +23,31 @@
</dependencies>
</project>

- <!-- Parts -->
+ <!-- Logging -->

- <project basedir="part">
+ <project basedir="logging">
<info>
<group>dpml/metro</group>
- <name>dpml-part-api</name>
+ <name>dpml-logging-api</name>
<types>
<type>jar</type>
</types>
</info>
</project>

- <!-- Logging -->
+ <!-- Parts -->

- <project basedir="logging">
+ <project basedir="part">
<info>
<group>dpml/metro</group>
- <name>dpml-logging-api</name>
+ <name>dpml-part-api</name>
<types>
<type>jar</type>
</types>
</info>
+ <dependencies>
+ <include key="dpml-logging-api"/>
+ </dependencies>
</project>

<!-- Activity -->

Modified:
development/main/metro/part/src/main/net/dpml/part/control/Control.java
==============================================================================
--- development/main/metro/part/src/main/net/dpml/part/control/Control.java
(original)
+++ development/main/metro/part/src/main/net/dpml/part/control/Control.java
Thu Jun 23 21:30:35 2005
@@ -18,6 +18,7 @@

package net.dpml.part.control;

+import java.net.URI;
import java.rmi.RemoteException;

/**
@@ -26,12 +27,18 @@
* @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 Control extends Identifiable
+public interface Control
{
/**
+ * Returns the identity of the object implementing this interface.
+ * @return a uri identifying the object
+ */
+ URI getURI();
+
+ /**
* Return a human readable short name of the controller.
* @return the controller name
*/
- String getName() throws RemoteException;
+ String getName();

}

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 23 21:30:35 2005
@@ -19,12 +19,12 @@
package net.dpml.part.control;

import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.rmi.RemoteException;

+import net.dpml.part.manager.Component;
import net.dpml.part.model.Model;
-import net.dpml.part.model.Provider;
-import net.dpml.part.model.Component;
import net.dpml.part.model.ModelException;
import net.dpml.part.part.Part;

@@ -38,9 +38,9 @@
*/
public interface Controller extends Control
{
- File getWorkingDirectory() throws RemoteException;
+ File getWorkingDirectory();

- File getTempDirectory() throws RemoteException;
+ File getTempDirectory();

/**
* Return a resource relative to the supplied urn. Standard
@@ -63,7 +63,18 @@
* @return the resource matching the supplied urn
* @exception IllegalStateException if the supplied urn is not valid
*/
- Object getResource( Model model, URI urn ) throws RemoteException;
+ Object getResource( Model model, URI urn );
+
+ /**
+ * Return a model using a part uri and key.
+ *
+ * @param uri a uri identifying the part
+ * @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;

/**
* Return a new model for a supplied part.
@@ -74,24 +85,7 @@
* @return the model
*/
Model getModel( ClassLoader parent, Part part, String name )
- throws ModelException, HandlerNotFoundException, DelegationException,
RemoteException;
-
- /**
- * Return a default service provider.
- *
- * @param model the reference model
- * @return the service provider
- */
- Provider getProvider( Model model ) throws RemoteException;
-
- /**
- * Return an identified service provider.
- *
- * @param model the reference model
- * @param identity the privider identity
- * @return the service provider
- */
- Provider getProvider( Model model, Object identity ) throws
RemoteException;
+ throws ModelException, HandlerNotFoundException, DelegationException;

/**
* Return a default service provider component.
@@ -99,8 +93,8 @@
* @param model the reference model
* @return the service provider
*/
- Component getComponent( Component owner, Model model )
- throws ModelException, RemoteException;
+ Component getComponent( Model model )
+ throws ModelException;

/**
* Return an identified service provider component.
@@ -109,8 +103,8 @@
* @param identity the privider identity
* @return the service provider
*/
- Component getComponent( Component owner, Model model, Object identity )
- throws ModelException, RemoteException;
+ Component getComponent( Model model, Object identity )
+ throws ModelException;

/**
* Return a component for a supplied part.
@@ -120,7 +114,7 @@
* @param name the name to assign to the provider model
* @return the default provider
*/
- Component getComponent( Component owner, ClassLoader parent, Part part,
String name )
- throws ModelException, HandlerNotFoundException, DelegationException,
RemoteException;
+ Component getComponent( ClassLoader parent, Part part, String name )
+ throws ModelException, HandlerNotFoundException, DelegationException;

}

Modified:
development/main/metro/part/src/main/net/dpml/part/control/ControllerContext.java
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/control/ControllerContext.java
(original)
+++
development/main/metro/part/src/main/net/dpml/part/control/ControllerContext.java
Thu Jun 23 21:30:35 2005
@@ -18,52 +18,59 @@

package net.dpml.part.control;

-import java.rmi.Remote;
-import java.rmi.RemoteException;
import java.net.URI;
import java.io.File;

+import net.dpml.logging.Logger;
+
+
/**
* The ControllerContext is a management service supplied to a controller
instance.
*
* @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 ControllerContext extends Remote
+public interface ControllerContext
{
/**
* Return the URI identifying the controller working context.
* @return the context uri
*/
- URI getURI() throws RemoteException;
+ URI getURI();
+
+ /**
+ * Return the root logging channel.
+ * @return the logging channel
+ */
+ Logger getLogger();

/**
* Return the root working directory path.
*
* @return directory path representing the root of the working directory
hierachy
*/
- String getWorkingDirectoryPath() throws RemoteException;
+ String getWorkingDirectoryPath();

/**
* Return the root temporary directory path.
*
* @return directory path representing the root of the temporary
directory hierachy.
*/
- String getTempDirectoryPath() throws RemoteException;
+ String getTempDirectoryPath();

/**
* Return the root working directory.
*
* @return directory representing the root of the working directory
hierachy
*/
- File getWorkingDirectory() throws RemoteException;
+ File getWorkingDirectory();

/**
* Return the root temporary directory.
*
* @return directory representing the root of the temporary directory
hierachy.
*/
- File getTempDirectory() throws RemoteException;
+ File getTempDirectory();

/**
* Add the supplied controller context listener to the controller
context. A
@@ -72,13 +79,13 @@
*
* @param listener the controller context listener to add
*/
- void addControllerContextlistener( ControllerContextListener listener )
throws RemoteException;
+ void addControllerContextlistener( ControllerContextListener listener );

/**
* Remove the supplied controller context listener from the controller
context.
*
* @param listener the controller context listener to remove
*/
- void removeControllerContextlistener( ControllerContextListener listener
) throws RemoteException;
+ void removeControllerContextlistener( ControllerContextListener listener
);

}

Modified:
development/main/metro/part/src/main/net/dpml/part/control/Identifiable.java
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/control/Identifiable.java
(original)
+++
development/main/metro/part/src/main/net/dpml/part/control/Identifiable.java
Thu Jun 23 21:30:35 2005
@@ -28,7 +28,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 interface Identifiable extends Remote
+public interface Identifiable
{
/**
* Returns the identity of the object implementing this interface.

Copied:
development/main/metro/part/src/main/net/dpml/part/manager/AvailabilityEvent.java
(from r2901,
development/main/metro/part/src/main/net/dpml/part/model/AvailabilityEvent.java)
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/model/AvailabilityEvent.java
(original)
+++
development/main/metro/part/src/main/net/dpml/part/manager/AvailabilityEvent.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.part.model;
+package net.dpml.part.manager;

import java.util.EventObject;


Copied:
development/main/metro/part/src/main/net/dpml/part/manager/AvailabilityListener.java
(from r2901,
development/main/metro/part/src/main/net/dpml/part/model/AvailabilityListener.java)
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/model/AvailabilityListener.java
(original)
+++
development/main/metro/part/src/main/net/dpml/part/manager/AvailabilityListener.java
Thu Jun 23 21:30:35 2005
@@ -16,7 +16,7 @@
* limitations under the License.
*/

-package net.dpml.part.model;
+package net.dpml.part.manager;

import java.util.EventListener;


Added:
development/main/metro/part/src/main/net/dpml/part/manager/Component.java
==============================================================================
--- (empty file)
+++ development/main/metro/part/src/main/net/dpml/part/manager/Component.java
Thu Jun 23 21:30:35 2005
@@ -0,0 +1,142 @@
+/*
+ * 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;
+
+import java.net.URI;
+import java.util.Map.Entry;
+
+import net.dpml.part.state.State;
+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
+ * state of 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 interface Component
+{
+ /**
+ * Returns the identity of the object implementing this interface.
+ * @return a uri identifying the object
+ */
+ URI getURI();
+
+ /**
+ * Return the model that this compoent is based on.
+ * @return the component's generic model.
+ */
+ Model getModel();
+
+ /**
+ * Return the operational status of the model.
+ * @return the operational status
+ */
+ boolean isOperational();
+
+ /**
+ * Add an availability listener to the provider.
+ * @param listener the availability listener
+ */
+ void addAvailabilityListener( AvailabilityListener listener );
+
+ /**
+ * Remove an availability listener from the provider.
+ * @param listener the availability listener
+ */
+ void removeAvailabilityListener( AvailabilityListener listener );
+
+ /**
+ * Initialize the component.
+ * @param component the component
+ */
+ void initialize() throws Exception;
+
+ /**
+ * Return the current state of the component.
+ * @return the current state
+ */
+ State getState();
+
+ /**
+ * Add a state listener to the provider.
+ * @param listener the state listener
+ */
+ void addStateListener( StateListener listener );
+
+ /**
+ * Remove a state listener from the provider.
+ * @param listener the state listener
+ */
+ void removeStateListener( StateListener listener );
+
+ /**
+ * Return an initialized instance of the component.
+ * @return the resolved instance
+ */
+ Object resolve() throws Exception;
+
+ /**
+ * Return an initialized instance of the component using a supplied
isolation policy.
+ * If the isolation policy is TRUE an implementation shall make best
efforts to isolate
+ * implementation concerns under the object that is returned. Typically
isolation
+ * involves the creation of a proxy of a component implementation
instance that
+ * exposes a component's service interfaces to a client. If the
isolation policy if
+ * FALSE the implementation shall return the component implementation
instance.
+ *
+ * @param isolation the isolation policy
+ * @return the resolved instance
+ */
+ Object resolve( boolean isolation ) throws Exception;
+
+ /**
+ * Applies a state transition identified by a supplied transition key.
+ *
+ * @param key the key identifying the transition to apply to the
component's controller
+ * @return the state resulting from the transition
+ * @exception if a transition error occurs
+ */
+ State apply( String key ) throws Exception;
+
+ /**
+ * Executes an operation identified by a supplied operation key.
+ *
+ * @param key the key identifying the operation to execute
+ * @exception if a transition error occurs
+ */
+ void execute( String key ) throws Exception;
+
+ /**
+ * Release a reference to an object managed by the instance.
+ *
+ * @param instance the instance to release
+ */
+ void release( Object instance );
+
+ /**
+ * Terminate the component and its associated instance.
+ */
+ void terminate();
+
+}
+

Copied:
development/main/metro/part/src/main/net/dpml/part/manager/Container.java
(from r2901,
development/main/metro/part/src/main/net/dpml/part/control/SystemManager.java)
==============================================================================
---
development/main/metro/part/src/main/net/dpml/part/control/SystemManager.java
(original)
+++ development/main/metro/part/src/main/net/dpml/part/manager/Container.java
Thu Jun 23 21:30:35 2005
@@ -16,17 +16,18 @@
* limitations under the License.
*/

-package net.dpml.part.control;
+package net.dpml.part.manager;

import java.io.IOException;
import java.net.URI;
-import java.rmi.Remote;
-import java.rmi.RemoteException;

-import net.dpml.part.model.Component;
+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;

+
/**
* 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
@@ -35,7 +36,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 interface SystemManager extends Controller
+public interface Container extends Component
{
/**
* Add a component to the collection of components managed by this
controller.
@@ -46,7 +47,7 @@
*/
Component addComponent( URI uri, String key )
throws IOException, DelegationException, ModelException,
PartNotFoundException,
- HandlerNotFoundException, RemoteException;
+ HandlerNotFoundException;

/**
* Add a part designated by a supplied uri to the system scope.
@@ -57,28 +58,12 @@
*/
Component addComponent( URI uri, Object id, String key )
throws IOException, DelegationException, ModelException,
PartNotFoundException,
- HandlerNotFoundException, RemoteException;
+ HandlerNotFoundException;

/**
* Register a component with the system.
* @param component the component to register
*/
- void addComponent( Component component ) throws RemoteException;
-
- /**
- * Start the system.
- * @exception if a startup failure occurs
- */
- void start() throws Exception, RemoteException;
-
- /**
- * Stop the system.
- */
- void stop() throws RemoteException;
-
- /**
- * Dispose of the manager.
- */
- //void dispose();
+ void addComponent( Component component );

}

Copied:
development/main/metro/part/src/main/net/dpml/part/manager/Manager.java (from
r2901,
development/main/metro/part/src/main/net/dpml/part/control/Manager.java)
==============================================================================
--- development/main/metro/part/src/main/net/dpml/part/control/Manager.java
(original)
+++ development/main/metro/part/src/main/net/dpml/part/manager/Manager.java
Thu Jun 23 21:30:35 2005
@@ -16,11 +16,9 @@
* limitations under the License.
*/

-package net.dpml.part.control;
+package net.dpml.part.manager;

-import java.rmi.RemoteException;
-
-import net.dpml.part.model.Component;
+import net.dpml.part.control.Control;
import net.dpml.part.model.ResourceUnavailableException;
import net.dpml.part.state.State;

@@ -65,7 +63,7 @@
*
* @param instance the instance to release
*/
- void release( Object instance ) throws RemoteException;
+ void release( Object instance );

/**
* Initialize the component.
@@ -77,6 +75,6 @@
* Termination of the component.
* @param component the component
*/
- void terminate( Component component ) throws RemoteException;
+ void terminate( Component component );

}

Modified: development/main/metro/part/src/main/net/dpml/part/model/Model.java
==============================================================================
--- development/main/metro/part/src/main/net/dpml/part/model/Model.java
(original)
+++ development/main/metro/part/src/main/net/dpml/part/model/Model.java Thu
Jun 23 21:30:35 2005
@@ -36,10 +36,10 @@
public interface Model extends Identifiable, Remote
{
/**
- * Return the primary controller assigned to the model.
- * @return the primary controller
+ * Return the uri of the model's controller.
+ * @return the controller uri
*/
- Controller getController() throws RemoteException;
+ //URI getControllerURI() throws RemoteException;

/**
* Return the uri identifying the partition that this model is enclosed
within.
@@ -53,19 +53,4 @@
*/
Object getKey() throws RemoteException;

- /**
- * Return the default service provider.
- *
- * @return the default service provider
- */
- Provider getProvider() throws RemoteException;
-
- /**
- * Optional operation that returns an identifiable service provider.
- *
- * @param id the service provider identifier
- * @return the identfied provider
- */
- Provider getProvider( Object id ) throws RemoteException;
-
}

Modified:
development/main/metro/part/src/main/net/dpml/part/state/Transition.java
==============================================================================
--- development/main/metro/part/src/main/net/dpml/part/state/Transition.java
(original)
+++ development/main/metro/part/src/main/net/dpml/part/state/Transition.java
Thu Jun 23 21:30:35 2005
@@ -76,4 +76,16 @@
{
return m_target;
}
+
+ public String toString()
+ {
+ if( null == m_handler )
+ {
+ return "[transition target=" + m_target.getName() + "]";
+ }
+ else
+ {
+ return "[transition " + m_handler + " target=" +
m_target.getName() + "]";
+ }
+ }
}

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 23 21:30:35 2005
@@ -28,8 +28,7 @@

import net.dpml.part.control.Controller;
import net.dpml.part.model.Model;
-
-import net.dpml.part.control.Manager;
+import net.dpml.part.manager.Component;

/**
* Demonstration of a component that uses a supplied configuration to
@@ -84,7 +83,7 @@
((Configurable)model).configure( conf );
}
}
- model.getProvider().resolve();
+ parts.getTestComponent().resolve();
}

private Logger getLogger()
@@ -104,5 +103,6 @@
public interface Parts
{
Model getTestModel();
+ Component getTestComponent();
}
}

Modified:
development/main/test/components/plus/src/main/net/dpml/test/acme/plus/ManagingContainer.java
==============================================================================
---
development/main/test/components/plus/src/main/net/dpml/test/acme/plus/ManagingContainer.java
(original)
+++
development/main/test/components/plus/src/main/net/dpml/test/acme/plus/ManagingContainer.java
Thu Jun 23 21:30:35 2005
@@ -21,8 +21,7 @@
import java.net.URI;
import java.util.logging.Logger;

-import net.dpml.part.control.Manager;
-import net.dpml.part.model.Component;
+import net.dpml.part.manager.Component;
import net.dpml.part.state.State;

import net.dpml.activity.Startable;
@@ -62,17 +61,16 @@
// implementation
//------------------------------------------------------------------

- public void start() throws Exception
+ public synchronized void start() throws Exception
{
Parts parts = getParts();
Component component = parts.getTestComponent();
component.initialize();
- component.resolve();
component.apply( "start" );
component.execute( "audit" );
}

- public void stop() throws Exception
+ public synchronized void stop() throws Exception
{
Parts parts = getParts();
Component component = parts.getTestComponent();

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 23 21:30:35 2005
@@ -25,9 +25,9 @@

import junit.framework.TestCase;

-import net.dpml.part.model.Model;
import net.dpml.part.control.Controller;
-import net.dpml.part.control.Manager;
+import net.dpml.part.model.Model;
+import net.dpml.part.manager.Component;

import net.dpml.metro.central.MetroHelper;

@@ -47,9 +47,10 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "configurable-container.part" );
- Model model = helper.getCompositionManager().getModel( uri );
- ConfigurableContainer container = (ConfigurableContainer)
model.getProvider().resolve( false );
- model.getProvider().release( container );
+ Model model = helper.getController().getModel( uri, "container" );
+ Component component = helper.getController().getComponent( model );
+ 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 23 21:30:35 2005
@@ -28,8 +28,8 @@

import net.dpml.metro.central.MetroHelper;

-import net.dpml.part.control.Manager;
-import net.dpml.part.model.Component;
+import net.dpml.part.manager.Manager;
+import net.dpml.part.manager.Component;
import net.dpml.part.model.Model;
import net.dpml.part.state.State;

@@ -46,7 +46,6 @@
System.gc();
}

-
/**
* Test the construction of the example component and the invocation of
* the provided controller via </code>the
net.dpml.part.state.StateManager</code> interface
@@ -75,7 +74,7 @@
{
Component component = getComponent( "managing-container.part" );
try
- {
+ {
component.initialize();
}
finally
@@ -88,7 +87,7 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( path );
- Model model = helper.getCompositionManager().getModel( uri );
- return model.getController().getComponent( null, model, this );
+ Model model = helper.getController().getModel( uri, "test" );
+ return helper.getController().getComponent( model, this );
}
}

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 23 21:30:35 2005
@@ -26,7 +26,7 @@
import junit.framework.TestCase;

import net.dpml.part.part.Part;
-import net.dpml.part.model.Provider;
+import net.dpml.part.manager.Component;
import net.dpml.part.model.Model;

import net.dpml.test.acme.Dimension;
@@ -60,10 +60,10 @@
/**
* Test loading of a component provider model via URL.
*/
- public void testComponentProviderAquisition() throws Exception
+ public void testComponentAquisition() throws Exception
{
URL url = new URL( SIMPLE_TEST_PART );
- Provider provider = (Provider) url.getContent( new Class[]{
Provider.class } );
+ Component provider = (Component) url.getContent( new Class[]{
Component.class } );
Dimension d = (Dimension) provider.resolve();
}

@@ -74,8 +74,7 @@
{
URL url = new URL( SIMPLE_TEST_PART );
Model model = (Model) url.getContent( new Class[]{ Model.class } );
- Provider provider = model.getProvider();
- Dimension d = (Dimension) provider.resolve();
+ assertNotNull( "model", model );
}

/**
@@ -85,6 +84,7 @@
{
URL url = new URL( SIMPLE_TEST_PART );
Part part = (Part) url.getContent();
+ assertNotNull( "part", part );
}

/**

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 23 21:30:35 2005
@@ -25,10 +25,10 @@

import junit.framework.TestCase;

-import net.dpml.part.model.Model;
-import net.dpml.part.model.Component;
import net.dpml.part.control.Controller;
-import net.dpml.part.control.Manager;
+import net.dpml.part.model.Model;
+import net.dpml.part.manager.Manager;
+import net.dpml.part.manager.Component;

import net.dpml.metro.central.MetroHelper;


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 23 21:30:35 2005
@@ -26,7 +26,7 @@
import junit.framework.TestCase;

import net.dpml.part.model.Model;
-import net.dpml.part.model.Component;
+import net.dpml.part.manager.Component;
import net.dpml.part.control.Controller;

import net.dpml.metro.central.MetroHelper;
@@ -47,8 +47,8 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "acme-example-one.part" );
- Model model = helper.getCompositionManager().getModel( uri,
"example" );
- Example example = (Example) model.getProvider().resolve();
+ Model model = helper.getController().getModel( uri, "example" );
+ Example example = (Example) helper.getController().getComponent(
model ).resolve();
example.doMyStuff();
}

@@ -61,8 +61,8 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "acme-example-two.part" );
- Model model = helper.getCompositionManager().getModel( uri,
"example" );
- Example example = (Example) model.getProvider().resolve();
+ Model model = helper.getController().getModel( uri, "example" );
+ Example example = (Example) helper.getController().getComponent(
model ).resolve();
example.doMyStuff();
}

@@ -74,8 +74,8 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "acme-example-three.part" );
- Model model = helper.getCompositionManager().getModel( uri,
"example" );
- Example example = (Example) model.getProvider().resolve();
+ Model model = helper.getController().getModel( uri, "example" );
+ Example example = (Example) helper.getController().getComponent(
model ).resolve();
example.doMyStuff();
}

@@ -88,8 +88,8 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "acme-example-four.part" );
- Model model = helper.getCompositionManager().getModel( uri,
"example" );
- Example example = (Example) model.getProvider().resolve();
+ Model model = helper.getController().getModel( uri, "example" );
+ Example example = (Example) helper.getController().getComponent(
model ).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 23 21:30:35 2005
@@ -27,7 +27,7 @@

import net.dpml.part.model.Model;
import net.dpml.part.control.Controller;
-import net.dpml.part.control.Manager;
+import net.dpml.part.manager.Component;

import net.dpml.metro.central.MetroHelper;

@@ -54,10 +54,11 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( PATH );
- Model model = helper.getCompositionManager().getModel( uri, "widget"
);
- Widget widget = (Widget) model.getProvider().resolve();
+ Model model = helper.getController().getModel( uri, "widget" );
+ Component component = helper.getController().getComponent( model );
+ Widget widget = (Widget) component.resolve();
widget.doWidgetStuff( "green" );
- model.getProvider().release( widget );
+ component.release( widget );
}

/**
@@ -68,10 +69,11 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( "acme-widget.part" );
- Model model = helper.getCompositionManager().getModel( uri, "widget"
);
- Widget widget = (Widget) model.getProvider().resolve();
+ Model model = helper.getController().getModel( uri, "widget" );
+ Component component = helper.getController().getComponent( model );
+ Widget widget = (Widget) component.resolve();
widget.doWidgetStuff( "green" );
- model.getProvider().release( widget );
+ component.release( widget );
}

/**
@@ -81,8 +83,9 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( PATH );
- Model model = helper.getCompositionManager().getModel( uri, "widget"
);
- Widget widget = (Widget) model.getProvider().resolve();
+ Model model = helper.getController().getModel( uri, "widget" );
+ Component component = helper.getController().getComponent( model );
+ Widget widget = (Widget) component.resolve();
try
{
WidgetComponent w = (WidgetComponent) widget;
@@ -94,7 +97,7 @@
}
finally
{
- model.getProvider().release( widget );
+ component.release( widget );
}
}

@@ -106,14 +109,15 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( PATH );
- Model model = helper.getCompositionManager().getModel( uri, "widget"
);
- WidgetComponent widget = (WidgetComponent)
model.getProvider().resolve( false );
+ Model model = helper.getController().getModel( uri, "widget" );
+ Component component = helper.getController().getComponent( model );
+ WidgetComponent widget = (WidgetComponent) component.resolve( false
);
String name = widget.getName();
assertEquals( "name", "widget", name );
String newName = "freight";
widget.setName( newName );
assertEquals( "name", newName, widget.getName() );
- model.getProvider().release( widget );
+ component.release( widget );
}

/**
@@ -125,9 +129,10 @@
String id = "steve";
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( PATH );
- Model model = helper.getCompositionManager().getModel( uri, "widget"
);
- WidgetComponent widget = (WidgetComponent) model.getProvider( id
).resolve( false );
- model.getProvider( id ).release( widget );
+ Model model = helper.getController().getModel( uri, "widget" );
+ Component component = helper.getController().getComponent( model );
+ WidgetComponent widget = (WidgetComponent) component.resolve( false
);
+ component.release( widget );
}

/**
@@ -141,15 +146,17 @@
{
MetroHelper helper = new MetroHelper();
URI uri = helper.toURI( PATH );
- Model model = helper.getCompositionManager().getModel( uri, "widget"
);
- Controller controller = model.getController();
- Widget w1 = (Widget) model.getProvider( "acme-widget-one" ).resolve(
false );
- Widget w2 = (Widget) model.getProvider( "acme-widget-two" ).resolve(
false );
+ 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" );
+ Widget w1 = (Widget) c1.resolve( false );
+ Widget w2 = (Widget) c2.resolve( false );
if( w1.equals( w2 ) )
{
fail( "Widget w1 and w2 are not unique!" );
}
- Widget w3 = (Widget) model.getProvider( "acme-widget-one" ).resolve(
false );
+ 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 ) );

Modified: development/main/transit/core/handler/build.xml
==============================================================================
--- development/main/transit/core/handler/build.xml (original)
+++ development/main/transit/core/handler/build.xml Thu Jun 23 21:30:35
2005
@@ -49,7 +49,6 @@

<target name="build" depends="standard.build">
<rmic base="${basedir}/target/classes">
- <include name="**/DefaultModel.class"/>
<include name="**/DefaultHostModel.class"/>
<include name="**/DefaultContentModel.class"/>
<include name="**/DefaultLayoutModel.class"/>

Modified:
development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultModel.java
==============================================================================
---
development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultModel.java
(original)
+++
development/main/transit/core/handler/src/main/net/dpml/transit/model/DefaultModel.java
Thu Jun 23 21:30:35 2005
@@ -35,7 +35,7 @@
* A abstract base class that established an event queue and handles event
dispatch
* operations for listeners declared in a class extending this base class.
*/
-public abstract class DefaultModel extends UnicastRemoteObject implements
Model
+public abstract class DefaultModel extends UnicastRemoteObject
{
//
------------------------------------------------------------------------
// state



  • svn commit: r2910 - in development/main: metro metro/central/src/main/net/dpml/metro/central metro/composition/control metro/composition/control/src/main/net/dpml/composition/control metro/composition/control/src/main/net/dpml/composition/event metro/composition/control/src/main/net/dpml/composition/info metro/composition/control/src/main/net/dpml/composition/model metro/composition/control/src/main/net/dpml/composition/runtime metro/part/src/main/net/dpml/part/control metro/part/src/main/net/dpml/part/manager metro/part/src/main/net/dpml/part/model metro/part/src/main/net/dpml/part/state test/components/plus/src/main/net/dpml/test/acme/plus test/unit/plus/src/test/net/dpml/test/acme/plus test/unit/simple/src/test/net/dpml/test/acme transit/core/handler transit/core/handler/src/main/net/dpml/transit/model, mcconnell, 06/23/2005

Archive powered by MHonArc 2.6.24.

Top of Page