Skip to Content.
Sympa Menu

notify-dpml - r937 - in trunk/main/metro: part/api/src/main/net/dpml/part/local runtime/src/main/net/dpml/metro/runtime test/src/main/net/dpml/test/app test/src/main/net/dpml/test/composite test/src/test/net/dpml/metro/runtime/test

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r937 - in trunk/main/metro: part/api/src/main/net/dpml/part/local runtime/src/main/net/dpml/metro/runtime test/src/main/net/dpml/test/app test/src/main/net/dpml/test/composite test/src/test/net/dpml/metro/runtime/test
  • Date: Thu, 19 Jan 2006 04:32:22 +0100

Author: mcconnell
Date: 2006-01-19 04:32:16 +0100 (Thu, 19 Jan 2006)
New Revision: 937

Added:
trunk/main/metro/part/api/src/main/net/dpml/part/local/Handler.java
trunk/main/metro/part/api/src/main/net/dpml/part/local/PartsManager.java

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
Removed:
trunk/main/metro/part/api/src/main/net/dpml/part/local/Manager.java
trunk/main/metro/part/api/src/main/net/dpml/part/local/Parts.java
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsManager.java
Modified:

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentHandler.java

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsInvocationHandler.java
trunk/main/metro/test/src/main/net/dpml/test/app/Demo.java
trunk/main/metro/test/src/main/net/dpml/test/composite/PartsComponent.java

trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/CompositeTestCase.java
Log:
Improve naming of the local component handler (renaming Manager to Handler).

Copied: trunk/main/metro/part/api/src/main/net/dpml/part/local/Handler.java
(from rev 929,
trunk/main/metro/part/api/src/main/net/dpml/part/local/Manager.java)
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/local/Manager.java
2006-01-16 19:17:05 UTC (rev 929)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/local/Handler.java
2006-01-19 03:32:16 UTC (rev 937)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part.local;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+
+import net.dpml.part.ControlException;
+
+import net.dpml.part.remote.Component;
+import net.dpml.part.remote.Provider;
+
+/**
+ * Local interface through which a component implementation may
+ * interact with subsidary parts.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface Handler
+{
+ /**
+ * Return a mutible context map.
+ *
+ * @return the context map
+ */
+ Map getContextMap();
+
+ /**
+ * Return a reference to a managed provider.
+ * @return the service provider
+ * @exception InvocationTargetException if the component instantiation
process
+ * is on demand and an target invocation error occurs
+ * @exception ControlException if the component could not be established
due to a controller
+ * related error
+ */
+ Provider getProvider() throws ControlException,
InvocationTargetException;
+}
+

Deleted: trunk/main/metro/part/api/src/main/net/dpml/part/local/Manager.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/local/Manager.java
2006-01-19 02:54:13 UTC (rev 936)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/local/Manager.java
2006-01-19 03:32:16 UTC (rev 937)
@@ -1,54 +0,0 @@
-/*
- * Copyright 2005 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.part.local;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Map;
-
-import net.dpml.part.ControlException;
-
-import net.dpml.part.remote.Provider;
-
-/**
- * Local interface through which a component implementation may
- * interact with subsidary parts.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface Manager
-{
- /**
- * Return a mutible context map.
- *
- * @return the context map
- */
- Map getContextMap();
-
- /**
- * Return a reference to a managed provider.
- * @return the service provider
- * @exception InvocationTargetException if the component instantiation
process
- * is on demand and an target invocation error occurs
- * @exception ControlException if the component could not be established
due to a controller
- * related error
- */
- Provider getProvider() throws ControlException,
InvocationTargetException;
-}
-

Deleted: trunk/main/metro/part/api/src/main/net/dpml/part/local/Parts.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/local/Parts.java
2006-01-19 02:54:13 UTC (rev 936)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/local/Parts.java
2006-01-19 03:32:16 UTC (rev 937)
@@ -1,65 +0,0 @@
-/*
- * Copyright 2005 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.part.local;
-
-import net.dpml.part.ControlException;
-
-import net.dpml.lang.UnknownKeyException;
-
-/**
- * Local interface through which a component implementation may
- * interact with subsidary parts.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface Parts
-{
- /**
- * Return the array of keys used to idenetity internal parts.
- * @return the part key array
- */
- String[] getKeys();
-
- /**
- * Return a component manager.
- * @param key the internal part key
- * @return the local component manager
- * @exception UnknownPartException the key is not recognized
- */
- Manager getManager( String key ) throws UnknownKeyException;
-
- /**
- * Return the commissioned state of the part collection.
- * @return true if commissioned else false
- */
- boolean isCommissioned();
-
- /**
- * Initiate the oprdered activation of all internal parts.
- * @exception ControlException if an activation error occurs
- */
- void commission() throws ControlException;
-
- /**
- * Initiate deactivation of all internal parts.
- */
- void decommission();
-}
-

Copied:
trunk/main/metro/part/api/src/main/net/dpml/part/local/PartsManager.java
(from rev 929,
trunk/main/metro/part/api/src/main/net/dpml/part/local/Parts.java)
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/local/Parts.java
2006-01-16 19:17:05 UTC (rev 929)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/local/PartsManager.java
2006-01-19 03:32:16 UTC (rev 937)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part.local;
+
+import net.dpml.part.ControlException;
+
+import net.dpml.lang.UnknownKeyException;
+
+/**
+ * Local interface through which a component implementation may
+ * interact with subsidary parts.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface PartsManager
+{
+ /**
+ * Return the array of keys used to idenetity internal parts.
+ * @return the part key array
+ */
+ String[] getKeys();
+
+ /**
+ * Return a local component handler.
+ * @param key the internal part key
+ * @return the local component handler
+ * @exception UnknownPartException the key is not recognized
+ */
+ Handler getComponentHandler( String key ) throws UnknownKeyException;
+
+ /**
+ * Return the commissioned state of the part collection.
+ * @return true if commissioned else false
+ */
+ boolean isCommissioned();
+
+ /**
+ * Initiate the oprdered activation of all internal parts.
+ * @exception ControlException if an activation error occurs
+ */
+ void commission() throws ControlException;
+
+ /**
+ * Initiate deactivation of all internal parts.
+ */
+ void decommission();
+}
+

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
2006-01-19 02:54:13 UTC (rev 936)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
2006-01-19 03:32:16 UTC (rev 937)
@@ -45,13 +45,13 @@

import net.dpml.parameters.Parameters;

-import net.dpml.part.local.Parts;
import net.dpml.part.Directive;
+import net.dpml.part.ControlException;
+import net.dpml.part.Version;
+import net.dpml.part.local.PartsManager;
import net.dpml.part.remote.Component;
import net.dpml.part.remote.Model;
-import net.dpml.part.ControlException;
import net.dpml.part.remote.ServiceNotFoundException;
-import net.dpml.part.Version;

import net.dpml.transit.Category;
import net.dpml.transit.Value;
@@ -460,7 +460,7 @@
Class clazz = getInnerClass( subject, "$Parts" );
if( null == clazz )
{
- return Parts.class;
+ return PartsManager.class;
}
else
{
@@ -544,7 +544,7 @@
private Object createPartsInvocationHandler( ComponentHandler handler,
Class clazz )
throws ControlException
{
- PartsManager manager = handler.getPartsManager();
+ DefaultPartsManager manager = handler.getPartsManager();
try
{
InvocationHandler invocationHandler = new
PartsInvocationHandler( manager );

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentHandler.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentHandler.java
2006-01-19 02:54:13 UTC (rev 936)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentHandler.java
2006-01-19 03:32:16 UTC (rev 937)
@@ -43,14 +43,14 @@
import net.dpml.logging.Logger;

import net.dpml.part.ActivationPolicy;
-import net.dpml.part.remote.Component;
-import net.dpml.part.ControlException;
import net.dpml.part.Disposable;
+import net.dpml.part.ControlException;
+import net.dpml.part.Version;
+import net.dpml.part.local.Handler;
+import net.dpml.part.remote.Component;
import net.dpml.part.remote.Provider;
import net.dpml.part.remote.Service;
import net.dpml.part.remote.ServiceNotFoundException;
-import net.dpml.part.Version;
-import net.dpml.part.local.Manager;
import net.dpml.part.remote.ModelEvent;
import net.dpml.part.remote.ModelListener;

@@ -103,7 +103,7 @@
* @see ComponentModel
* @see Provider
*/
-public class ComponentHandler extends UnicastEventSource implements
Component, Manager, Disposable, ModelListener
+public class ComponentHandler extends UnicastEventSource implements
Component, Handler, Disposable, ModelListener
{

//--------------------------------------------------------------------------
// immutable state
@@ -125,9 +125,8 @@

private final Map m_map = new Hashtable(); // symbolic value map
private final Map m_cache = new Hashtable(); // context entry/value cache
- //private final Map m_handlers = new Hashtable(); // part handlers

- private final PartsManager m_parts;
+ private final DefaultPartsManager m_parts;


//--------------------------------------------------------------------------
// mutable state
@@ -241,7 +240,7 @@
// need to establish all of the component parts that are children of
this
// component.

- m_parts = new PartsManager( control, this, logger );
+ m_parts = new DefaultPartsManager( control, this, logger );

getLogger().debug( "component controller [" + this + "] established"
);
}
@@ -263,7 +262,7 @@
}


//--------------------------------------------------------------------------
- // Manager
+ // Handler

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

/**
@@ -280,7 +279,7 @@
* Return an <tt>Provider</tt> holder. The value returned will be a
function
* of the lifestyle policy implemented by the component.
*
- * @return the <tt>Provider</tt> manager
+ * @return the <tt>Provider</tt>
* @exception InvocationTargetException if the request triggers the
construction
* of a new provider instance and the provider raises an error during
creation
* or activation
@@ -571,7 +570,7 @@
// ComponentHandler

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

- PartsManager getPartsManager()
+ DefaultPartsManager getPartsManager()
{
return m_parts;
}
@@ -618,19 +617,19 @@
*/
Component getPartHandler( String key ) throws UnknownKeyException
{
- return (Component) m_parts.getManager( key );
-
- /*
- Component handler = (Component) m_handlers.get( key );
- if( null == handler )
+ Handler handler = m_parts.getComponentHandler( key );
+ if( handler instanceof Component )
{
- throw new UnknownKeyException( key );
+ return (Component) handler;
}
else
{
- return handler;
+ final String error =
+ "Component handler ["
+ + handler.getClass().getName()
+ + "] does not implement the component interface.";
+ throw new ControllerRuntimeException( error );
}
- */
}

Object getContextValue( String key ) throws ControlException

Copied:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
(from rev 929,
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsManager.java)
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsManager.java
2006-01-16 19:17:05 UTC (rev 929)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
2006-01-19 03:32:16 UTC (rev 937)
@@ -0,0 +1,264 @@
+/*
+ * 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.metro.runtime;
+
+import java.rmi.RemoteException;
+import java.util.Map;
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import net.dpml.logging.Logger;
+
+import net.dpml.metro.model.ComponentModel;
+
+import net.dpml.part.ControlException;
+import net.dpml.part.remote.Component;
+import net.dpml.part.local.PartsManager;
+import net.dpml.part.local.Handler;
+
+import net.dpml.lang.UnknownKeyException;
+
+/**
+ * Default implementation of the local Parts interface.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+class DefaultPartsManager implements PartsManager
+{
+ //-------------------------------------------------------------------
+ // state
+ //-------------------------------------------------------------------
+
+ /**
+ * The component handler.
+ */
+ private final ComponentHandler m_handler;
+
+ /**
+ * The logging channel.
+ */
+ private final Logger m_logger;
+
+ /**
+ * The internal map of component handlers.
+ */
+ private final Map m_handlers = new Hashtable();
+
+ private boolean m_commissioned = false;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Create a new instance handler.
+ *
+ * @param handler the component handler
+ * @param logger the logging channel
+ */
+ DefaultPartsManager( ComponentController control, ComponentHandler
handler, Logger logger )
+ throws ControlException, RemoteException
+ {
+ m_handler = handler;
+ m_logger = logger;
+
+ ClassLoader classloader = handler.getClassLoader();
+ ComponentModel model = handler.getComponentModel();
+ String[] keys = model.getPartKeys();
+ for( int i=0; i<keys.length; i++ )
+ {
+ String key = keys[i];
+ try
+ {
+ ComponentModel m = model.getComponentModel( key );
+ Component h = control.createComponentHandler( handler,
classloader, m );
+ m_handlers.put( key, h );
+ }
+ catch( UnknownKeyException e )
+ {
+ final String error =
+ "Invalid part key ["
+ + key
+ + "] in component ["
+ + handler
+ + "]";
+ throw new ControllerRuntimeException( error, e );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Internal error while attempting to create a subsidiary
part ["
+ + key
+ + "] in component ["
+ + handler
+ + "]";
+ throw new ControllerRuntimeException( error, e );
+ }
+ }
+ }
+
+ private ComponentModel getComponentModel()
+ {
+ return m_handler.getComponentModel();
+ }
+
+ //-------------------------------------------------------------------
+ // Parts
+ //-------------------------------------------------------------------
+
+ /**
+ * Return the array of keys used to idenetity internal parts.
+ * @return the part key array
+ */
+ public String[] getKeys()
+ {
+ return (String[]) m_handlers.keySet().toArray( new String[0] );
+ }
+
+ /**
+ * Return a component handler.
+ * @return the local component handler
+ */
+ public synchronized Handler getComponentHandler( String key ) throws
UnknownKeyException
+ {
+ if( m_handlers.containsKey( key ) )
+ {
+ return (Handler) m_handlers.get( key );
+ }
+ else
+ {
+ throw new UnknownKeyException( key );
+ }
+ }
+
+ public boolean isCommissioned()
+ {
+ return m_commissioned;
+ }
+
+ /**
+ * Initiate the ordered activation of all internal parts.
+ * @exception ControlException if an activation error occurs
+ * @exception InvocationTargetException if the component declares
activation on startup
+ * and a implementation source exception occured
+ * @exception RemoteException if a remote exception occurs
+ */
+ public synchronized void commission() throws ControlException
+ {
+ if( m_commissioned )
+ {
+ final String error =
+ "Illegal attempt to commission a part manager that is already
commissioned."
+ + "Component: " + m_handler;
+ throw new IllegalStateException( error );
+ }
+
+ getLogger().debug( "commissioning" );
+ ArrayList list = new ArrayList();
+ Component[] components = getComponents();
+ ControlException exception = null;
+ for( int i=0; i<components.length; i++ )
+ {
+ Component component = components[i];
+ try
+ {
+ component.activate();
+ list.add( component );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Error during the commission of the internal parts of a
component."
+ + "\nEnclosing Component: " + m_handler
+ + "\nInternal Part: " + component;
+ exception = new ControllerException( error, e );
+ break;
+ }
+ }
+
+ if( null != exception )
+ {
+ Component[] selection = (Component[]) list.toArray( new
Component[0] );
+ decommission( selection );
+ throw exception;
+ }
+ else
+ {
+ m_commissioned = true;
+ }
+ }
+
+ /**
+ * Initiate deactivation of all internal parts.
+ */
+ public synchronized void decommission()
+ {
+ if( !m_commissioned )
+ {
+ final String error =
+ "Illegal attempt to decommission a part manager that is
already decommissioned."
+ + "Component: " + m_handler;
+ throw new IllegalStateException( error );
+ }
+
+ getLogger().debug( "decommissioning" );
+ Component[] components = getComponents();
+ decommission( components );
+ }
+
+ /**
+ * Initiate deactivation of all internal parts.
+ */
+ private void decommission( Component[] components )
+ {
+ try
+ {
+ int n = components.length -1;
+ for( int i=n; i>-1; i-- )
+ {
+ Component component = components[i];
+ try
+ {
+ component.deactivate();
+ }
+ catch( RemoteException e )
+ {
+ final String message =
+ "Ignoring remote exception raised during
deactivation.";
+ getLogger().warn( message, e );
+ }
+ }
+ }
+ finally
+ {
+ m_commissioned = false;
+ }
+ }
+
+ Component[] getComponents()
+ {
+ return (Component[]) m_handlers.values().toArray( new Component[0] );
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+}

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsInvocationHandler.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsInvocationHandler.java
2006-01-19 02:54:13 UTC (rev 936)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsInvocationHandler.java
2006-01-19 03:32:16 UTC (rev 937)
@@ -22,9 +22,9 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

-import net.dpml.part.local.Manager;
+import net.dpml.part.local.Handler;
import net.dpml.part.remote.Component;
-import net.dpml.part.local.Parts;
+import net.dpml.part.local.PartsManager;

/**
* Invoication handler for the Context inner class. The invocation handler
is
@@ -43,7 +43,7 @@
/**
* The component.
*/
- private final PartsManager m_manager;
+ private final DefaultPartsManager m_manager;

//-------------------------------------------------------------------
// constructor
@@ -54,7 +54,7 @@
*
* @param handler the component handler
*/
- PartsInvocationHandler( PartsManager manager )
+ PartsInvocationHandler( DefaultPartsManager manager )
{
m_manager = manager;
}
@@ -80,7 +80,7 @@
{
return method.invoke( this, args );
}
- else if( Parts.class == source )
+ else if( PartsManager.class == source )
{
return method.invoke( m_manager, args );
}
@@ -89,7 +89,7 @@
String postfix = getPartPostfix( method );
String key = getPartKey( method, semantic );

- Manager manager = m_manager.getManager( key );
+ Handler handler = m_manager.getComponentHandler( key );

if( GET == semantic )
{
@@ -99,14 +99,14 @@
{
try
{
- return manager.getProvider().getValue( false );
+ return handler.getProvider().getValue( false );
}
catch( ClassCastException e )
{
final String error =
- "Component handler ["
- + manager
- + "] could not be cast to an approriate service
class.";
+ "Component handler ["
+ + handler
+ + "] value instance could not be cast to an
approriate service class.";
throw new IllegalStateException( error );
}
}
@@ -117,7 +117,7 @@
if( ( Boolean.TYPE == argClass ) || ( Boolean.class ==
argClass ) )
{
boolean policy = getBooleanValue( arg );
- return manager.getProvider().getValue( policy );
+ return handler.getProvider().getValue( policy );
}
else
{
@@ -139,32 +139,32 @@
}
else if( COMPONENT_KEY.equals( postfix ) )
{
- if( manager instanceof Component )
+ if( handler instanceof Component )
{
- return (Component) manager;
+ return (Component) handler;
}
else
{
final String error =
"Manager implementation ["
- + manager.getClass().getName()
+ + handler.getClass().getName()
+ "] does not implement "
+ Component.class.getName()
+ ".";
throw new IllegalStateException( error );
}
}
- else if( MANAGER_KEY.equals( postfix ) )
+ else if( HANDLER_KEY.equals( postfix ) )
{
- return manager;
+ return handler;
}
else if( MAP_KEY.equals( postfix ) )
{
- return manager.getContextMap();
+ return handler.getContextMap();
}
else if( PROVIDER_KEY.equals( postfix ) )
{
- return manager.getProvider();
+ return handler.getProvider();
}
else
{
@@ -272,9 +272,9 @@
String substring = name.substring( 0, j );
return formatKey( substring, 3 );
}
- else if( name.endsWith( MANAGER_KEY ) )
+ else if( name.endsWith( HANDLER_KEY ) )
{
- int n = MANAGER_KEY.length();
+ int n = HANDLER_KEY.length();
int j = name.length() - n;
String substring = name.substring( 0, j );
return formatKey( substring, 3 );
@@ -337,5 +337,5 @@
public static final String COMPONENT_KEY = "Component";
public static final String MAP_KEY = "Map";
public static final String PROVIDER_KEY = "Provider";
- public static final String MANAGER_KEY = "Manager";
+ public static final String HANDLER_KEY = "Handler";
}
\ No newline at end of file

Deleted:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsManager.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsManager.java
2006-01-19 02:54:13 UTC (rev 936)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/PartsManager.java
2006-01-19 03:32:16 UTC (rev 937)
@@ -1,264 +0,0 @@
-/*
- * 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.metro.runtime;
-
-import java.rmi.RemoteException;
-import java.util.Map;
-import java.util.ArrayList;
-import java.util.Hashtable;
-
-import net.dpml.logging.Logger;
-
-import net.dpml.metro.model.ComponentModel;
-
-import net.dpml.part.ControlException;
-import net.dpml.part.remote.Component;
-import net.dpml.part.local.Parts;
-import net.dpml.part.local.Manager;
-
-import net.dpml.lang.UnknownKeyException;
-
-/**
- * Default implementation of the local Parts interface.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class PartsManager implements Parts
-{
- //-------------------------------------------------------------------
- // state
- //-------------------------------------------------------------------
-
- /**
- * The component handler.
- */
- private final ComponentHandler m_handler;
-
- /**
- * The logging channel.
- */
- private final Logger m_logger;
-
- /**
- * The internal map of component handlers.
- */
- private final Map m_handlers = new Hashtable();
-
- private boolean m_commissioned = false;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- /**
- * Create a new instance handler.
- *
- * @param handler the component handler
- * @param logger the logging channel
- */
- PartsManager( ComponentController control, ComponentHandler handler,
Logger logger )
- throws ControlException, RemoteException
- {
- m_handler = handler;
- m_logger = logger;
-
- ClassLoader classloader = handler.getClassLoader();
- ComponentModel model = handler.getComponentModel();
- String[] keys = model.getPartKeys();
- for( int i=0; i<keys.length; i++ )
- {
- String key = keys[i];
- try
- {
- ComponentModel m = model.getComponentModel( key );
- Component h = control.createComponentHandler( handler,
classloader, m );
- m_handlers.put( key, h );
- }
- catch( UnknownKeyException e )
- {
- final String error =
- "Invalid part key ["
- + key
- + "] in component ["
- + handler
- + "]";
- throw new ControllerRuntimeException( error, e );
- }
- catch( Exception e )
- {
- final String error =
- "Internal error while attempting to create a subsidiary
part ["
- + key
- + "] in component ["
- + handler
- + "]";
- throw new ControllerRuntimeException( error, e );
- }
- }
- }
-
- private ComponentModel getComponentModel()
- {
- return m_handler.getComponentModel();
- }
-
- //-------------------------------------------------------------------
- // Parts
- //-------------------------------------------------------------------
-
- /**
- * Return the array of keys used to idenetity internal parts.
- * @return the part key array
- */
- public String[] getKeys()
- {
- return (String[]) m_handlers.keySet().toArray( new String[0] );
- }
-
- /**
- * Return a component manager.
- * @return the local component manager
- */
- public synchronized Manager getManager( String key ) throws
UnknownKeyException
- {
- if( m_handlers.containsKey( key ) )
- {
- return (Manager) m_handlers.get( key );
- }
- else
- {
- throw new UnknownKeyException( key );
- }
- }
-
- public boolean isCommissioned()
- {
- return m_commissioned;
- }
-
- /**
- * Initiate the ordered activation of all internal parts.
- * @exception ControlException if an activation error occurs
- * @exception InvocationTargetException if the component declares
activation on startup
- * and a implementation source exception occured
- * @exception RemoteException if a remote exception occurs
- */
- public synchronized void commission() throws ControlException
- {
- if( m_commissioned )
- {
- final String error =
- "Illegal attempt to commission a part manager that is already
commissioned."
- + "Component: " + m_handler;
- throw new IllegalStateException( error );
- }
-
- getLogger().debug( "commissioning" );
- ArrayList list = new ArrayList();
- Component[] components = getComponents();
- ControlException exception = null;
- for( int i=0; i<components.length; i++ )
- {
- Component component = components[i];
- try
- {
- component.activate();
- list.add( component );
- }
- catch( Throwable e )
- {
- final String error =
- "Error during the commission of the internal parts of a
component."
- + "\nEnclosing Component: " + m_handler
- + "\nInternal Part: " + component;
- exception = new ControllerException( error, e );
- break;
- }
- }
-
- if( null != exception )
- {
- Component[] selection = (Component[]) list.toArray( new
Component[0] );
- decommission( selection );
- throw exception;
- }
- else
- {
- m_commissioned = true;
- }
- }
-
- /**
- * Initiate deactivation of all internal parts.
- */
- public synchronized void decommission()
- {
- if( !m_commissioned )
- {
- final String error =
- "Illegal attempt to decommission a part manager that is
already decommissioned."
- + "Component: " + m_handler;
- throw new IllegalStateException( error );
- }
-
- getLogger().debug( "decommissioning" );
- Component[] components = getComponents();
- decommission( components );
- }
-
- /**
- * Initiate deactivation of all internal parts.
- */
- private void decommission( Component[] components )
- {
- try
- {
- int n = components.length -1;
- for( int i=n; i>-1; i-- )
- {
- Component component = components[i];
- try
- {
- component.deactivate();
- }
- catch( RemoteException e )
- {
- final String message =
- "Ignoring remote exception raised during
deactivation.";
- getLogger().warn( message, e );
- }
- }
- }
- finally
- {
- m_commissioned = false;
- }
- }
-
- Component[] getComponents()
- {
- return (Component[]) m_handlers.values().toArray( new Component[0] );
- }
-
- private Logger getLogger()
- {
- return m_logger;
- }
-}

Modified: trunk/main/metro/test/src/main/net/dpml/test/app/Demo.java
===================================================================
--- trunk/main/metro/test/src/main/net/dpml/test/app/Demo.java 2006-01-19
02:54:13 UTC (rev 936)
+++ trunk/main/metro/test/src/main/net/dpml/test/app/Demo.java 2006-01-19
03:32:16 UTC (rev 937)
@@ -20,8 +20,8 @@

import net.dpml.logging.Logger;

-import net.dpml.part.local.Parts;
-import net.dpml.part.local.Manager;
+import net.dpml.part.local.PartsManager;
+import net.dpml.part.local.Handler;

/**
* The demo class is used to aggregate a collection of components and
@@ -32,7 +32,7 @@
*/
public class Demo
{
- private final Parts m_parts;
+ private final PartsManager m_parts;
private final Logger m_logger;

/**
@@ -40,7 +40,7 @@
* @param logger a logging channel
* @param parts the internal parts
*/
- public Demo( Logger logger, Parts parts )
+ public Demo( Logger logger, PartsManager parts )
{
m_logger = logger;
m_parts = parts;
@@ -62,13 +62,13 @@

DefaultServer getServer() throws Exception
{
- Manager manager = m_parts.getManager( "server" );
- return (DefaultServer) manager.getProvider().getValue( false );
+ Handler handler = m_parts.getComponentHandler( "server" );
+ return (DefaultServer) handler.getProvider().getValue( false );
}

DefaultListener getListener() throws Exception
{
- Manager manager = m_parts.getManager( "listener" );
- return (DefaultListener) manager.getProvider().getValue( false );
+ Handler handler = m_parts.getComponentHandler( "listener" );
+ return (DefaultListener) handler.getProvider().getValue( false );
}
}

Modified:
trunk/main/metro/test/src/main/net/dpml/test/composite/PartsComponent.java
===================================================================
---
trunk/main/metro/test/src/main/net/dpml/test/composite/PartsComponent.java
2006-01-19 02:54:13 UTC (rev 936)
+++
trunk/main/metro/test/src/main/net/dpml/test/composite/PartsComponent.java
2006-01-19 03:32:16 UTC (rev 937)
@@ -25,8 +25,8 @@

import net.dpml.test.ColorManager;

-import net.dpml.part.local.Parts;
-import net.dpml.part.local.Manager;
+import net.dpml.part.local.PartsManager;
+import net.dpml.part.local.Handler;

import net.dpml.lang.UnknownKeyException;

@@ -74,7 +74,7 @@
/**
* The assigned part manager.
*/
- private final Parts m_parts;
+ private final PartsManager m_parts;

//------------------------------------------------------------------
// constructor
@@ -86,7 +86,7 @@
* @param context a context implementation
* @param parts the parts manager
*/
- public PartsComponent( final Logger logger, final Context context, final
Parts parts ) throws UnknownKeyException
+ public PartsComponent( final Logger logger, final Context context, final
PartsManager parts ) throws UnknownKeyException
{
logger.debug( "instantiation" );

@@ -94,8 +94,8 @@
m_logger = logger;
m_parts = parts;

- Manager manager = parts.getManager( "child" );
- Map map = manager.getContextMap();
+ Handler handler = parts.getComponentHandler( "child" );
+ Map map = handler.getContextMap();
map.put( "color", context.getColor() );
}

@@ -123,8 +123,8 @@
*/
public ChildComponent getChild() throws Exception
{
- Manager manager = m_parts.getManager( "child" );
- return (ChildComponent) manager.getProvider().getValue( false );
+ Handler handler = m_parts.getComponentHandler( "child" );
+ return (ChildComponent) handler.getProvider().getValue( false );
}

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

Modified:
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/CompositeTestCase.java
===================================================================
---
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/CompositeTestCase.java
2006-01-19 02:54:13 UTC (rev 936)
+++
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/CompositeTestCase.java
2006-01-19 03:32:16 UTC (rev 937)
@@ -27,7 +27,7 @@
import net.dpml.part.local.Controller;
import net.dpml.part.remote.Component;
import net.dpml.part.remote.Provider;
-import net.dpml.part.local.Manager;
+import net.dpml.part.local.Handler;

import net.dpml.test.composite.ChildComponent;
import net.dpml.test.composite.CompositeComponent;
@@ -80,7 +80,7 @@
public void testOverloadedComposite() throws Exception
{
Component component = CONTROLLER.createComponent( m_uri );
- Manager manager = (Manager) component;
+ Handler manager = (Handler) component;
manager.getContextMap().put( "color", Color.YELLOW );
Provider instance = component.getProvider();
CompositeComponent parent = (CompositeComponent) instance.getValue(
false );




  • r937 - in trunk/main/metro: part/api/src/main/net/dpml/part/local runtime/src/main/net/dpml/metro/runtime test/src/main/net/dpml/test/app test/src/main/net/dpml/test/composite test/src/test/net/dpml/metro/runtime/test, mcconnell at BerliOS, 01/18/2006

Archive powered by MHonArc 2.6.24.

Top of Page