Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2198 - in development/main/metro: . automation/control/src/main/net/dpml/automation/control composition/control/src/main/net/dpml/composition/control composition/testing/system composition/testing/unit composition/testing/unit/src composition/testing/unit/src/test composition/testing/unit/src/test/net composition/testing/unit/src/test/net/dpml composition/testing/unit/src/test/net/dpml/composition composition/testing/unit/src/test/net/dpml/composition/testing composition/unit composition/unit/src composition/unit/src/test/net/dpml/composition/testing

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: r2198 - in development/main/metro: . automation/control/src/main/net/dpml/automation/control composition/control/src/main/net/dpml/composition/control composition/testing/system composition/testing/unit composition/testing/unit/src composition/testing/unit/src/test composition/testing/unit/src/test/net composition/testing/unit/src/test/net/dpml composition/testing/unit/src/test/net/dpml/composition composition/testing/unit/src/test/net/dpml/composition/testing composition/unit composition/unit/src composition/unit/src/test/net/dpml/composition/testing
  • Date: Mon, 04 Apr 2005 04:08:11 -0400

Author: mcconnell AT dpml.net
Date: Mon Apr 4 04:08:09 2005
New Revision: 2198

Added:
development/main/metro/composition/testing/unit/
development/main/metro/composition/testing/unit/build.xml
development/main/metro/composition/testing/unit/src/
development/main/metro/composition/testing/unit/src/test/
development/main/metro/composition/testing/unit/src/test/net/
development/main/metro/composition/testing/unit/src/test/net/dpml/

development/main/metro/composition/testing/unit/src/test/net/dpml/composition/

development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/
development/main/metro/composition/unit/
- copied from r2195, development/main/metro/composition/testing/system/
development/main/metro/composition/unit/build.xml
- copied unchanged from r2197,
development/main/metro/composition/testing/system/build.xml
development/main/metro/composition/unit/src/
- copied from r2197,
development/main/metro/composition/testing/system/src/
Removed:
development/main/metro/composition/testing/system/
Modified:

development/main/metro/automation/control/src/main/net/dpml/automation/control/Controller.java

development/main/metro/composition/control/src/main/net/dpml/composition/control/ApplianceInvocationHandler.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/LifestyleHandler.java

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

development/main/metro/composition/unit/src/test/net/dpml/composition/testing/CompositionManagerTestCase.java
development/main/metro/index.xml
Log:
move the unit testing utility to composition/unithouekeepingInitial
freight-train implementation.cleanup javadocInitial freight-train
implementation.houekeepingmove the unit testing utility to composition/unit

Modified:
development/main/metro/automation/control/src/main/net/dpml/automation/control/Controller.java
==============================================================================
---
development/main/metro/automation/control/src/main/net/dpml/automation/control/Controller.java
(original)
+++
development/main/metro/automation/control/src/main/net/dpml/automation/control/Controller.java
Mon Apr 4 04:08:09 2005
@@ -59,6 +59,15 @@
throws DelegationException, ModelException;

/**
+ * Create and return a new non-proxied instance of the component
represented
+ * by the supplied model.
+ *
+ * @param model the component model
+ * @return the resolved instance
+ */
+ Object create( Model model ) throws Exception;
+
+ /**
* Create and return a new instance of the component represented
* by the supplied model.
*
@@ -68,6 +77,15 @@
Object resolve( Model model ) throws Exception;

/**
+ * Create and return a new instance of the component represented
+ * by the supplied model.
+ *
+ * @param model the component model
+ * @return the resolved instance
+ */
+ Object resolve( Model model, Object key ) throws Exception;
+
+ /**
* Return a component instance
*
* @param instance the instance to release

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/ApplianceInvocationHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/ApplianceInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/ApplianceInvocationHandler.java
Mon Apr 4 04:08:09 2005
@@ -61,6 +61,26 @@
* @param appliance the runtime appliance
* @param logger the assigned logging channel
*/
+ ApplianceInvocationHandler( LifestyleHandler handler,
StandardComponentModel model, Object key )
+ throws NullPointerException, LifecycleException
+ {
+ assertNotNull( handler, "handler" );
+ assertNotNull( model, "model" );
+
+ m_handler = handler;
+ m_model = model;
+ m_key = key;
+
+ handler.aquire( model, key );
+ m_instance = model.get( key );
+ }
+
+ /**
+ * Create a proxy invocation handler.
+ *
+ * @param appliance the runtime appliance
+ * @param logger the assigned logging channel
+ */
ApplianceInvocationHandler( LifestyleHandler handler,
StandardComponentModel model )
throws NullPointerException, LifecycleException
{

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
Mon Apr 4 04:08:09 2005
@@ -70,6 +70,7 @@

private final Monitor m_monitor;
private final SystemContext m_system;
+ private final LifecycleHandler m_factory;
private final LifestyleHandler m_handler;

//--------------------------------------------------------------------
@@ -82,8 +83,8 @@
m_monitor = monitor;
m_system = system;

- LifecycleHandler lifecycle = new LifecycleHandler( system );
- m_handler = new LifestyleHandler( lifecycle );
+ m_factory = new LifecycleHandler( system );
+ m_handler = new LifestyleHandler( m_factory );
}

//--------------------------------------------------------------------
@@ -152,18 +153,38 @@
}

/**
- * Create and return a new instance of the component represented
+ * Create and return a new non-proxied instance of the component
represented
* by the supplied model.
*
* @param model the component model
* @return the resolved instance
*/
+ public Object create( Model model ) throws Exception
+ {
+ if( model instanceof StandardComponentModel )
+ {
+ StandardComponentModel componentModel = (StandardComponentModel)
model;
+ return m_factory.incarnate( componentModel );
+ }
+ else
+ {
+ return model.getController().create( model );
+ }
+ }
+
+ /**
+ * Create and return a new instance of the component represented
+ * by the supplied model using the assigned lifestyle policy.
+ *
+ * @param model the component model
+ * @return the resolved instance
+ */
public Object resolve( Model model ) throws Exception
{
if( model instanceof StandardComponentModel )
{
StandardComponentModel componentModel = (StandardComponentModel)
model;
- return resolveInstance( componentModel );
+ return resolveInstance( componentModel, null );
}
else
{
@@ -172,6 +193,27 @@
}

/**
+ * Create and return a new identifiable instance of the component
represented
+ * by the supplied model using the assigned lifestyle policy.
+ *
+ * @param model the component model
+ * @param key the object key
+ * @return the resolved instance
+ */
+ public Object resolve( Model model, Object key ) throws Exception
+ {
+ if( model instanceof StandardComponentModel )
+ {
+ StandardComponentModel componentModel = (StandardComponentModel)
model;
+ return resolveInstance( componentModel, key );
+ }
+ else
+ {
+ return model.getController().resolve( model, key );
+ }
+ }
+
+ /**
* Release an instance.
*
* @param instance the object to release
@@ -188,6 +230,10 @@
aic.dispose();
}
}
+ else
+ {
+ m_factory.etherialize( instance );
+ }
}

public Model getProvider( Model model, String path )
@@ -276,20 +322,33 @@

/**
* Create and return a new instance of the component represented
- * by the supplied model.
+ * by the supplied model using the assigned lifecycle manager.
*
* @param model the component model
+ * @param key the identifying key (may be null)
* @return the resolved instance
*/
- private Object resolveInstance( StandardComponentModel model ) throws
Exception
+ private Object resolveInstance( StandardComponentModel model, Object key
) throws Exception
{
- InvocationHandler handler = new ApplianceInvocationHandler(
m_handler, model );
+ InvocationHandler handler = createAppliance( model, key );
Class subject = model.getDeploymentClass();
ClassLoader classloader = subject.getClassLoader();
Class[] interfaces = model.getServiceClasses();
return Proxy.newProxyInstance( classloader, interfaces, handler );
}

+ private InvocationHandler createAppliance( StandardComponentModel model,
Object key ) throws LifecycleException
+ {
+ if( null == key )
+ {
+ return new ApplianceInvocationHandler( m_handler, model );
+ }
+ else
+ {
+ return new ApplianceInvocationHandler( m_handler, model, key );
+ }
+ }
+
/**
* Return a management view of a part.
*

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
Mon Apr 4 04:08:09 2005
@@ -87,6 +87,26 @@
}
}

+ /**
+ * Aquire a key to an instance. If the supplied key references an
+ * existing instance the same key is returned. If the key does not
+ * reference an existing instance then a new instance is created,
+ * registered with the model, and the key returned.
+ *
+ * @param model the model from which new or existing instances will be
resolved
+ * @return the key to the resolved instance
+ */
+ public Object aquire( StandardComponentModel model, Object key ) throws
LifecycleException
+ {
+ Object instance = model.get( key );
+ if( null == instance )
+ {
+ instance = m_handler.incarnate( model );
+ model.put( key, instance );
+ }
+ return key;
+ }
+
public void release( StandardComponentModel model, Object key )
{
final String lifestyle = model.getLifestylePolicy();

Modified:
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/control/PartsInvocationHandler.java
Mon Apr 4 04:08:09 2005
@@ -153,6 +153,7 @@
//

String key = descriptor.getKey();
+ int semantic = descriptor.getSemantic();
Model m = m_model.getPart( key );
if( null == m )
{
@@ -164,11 +165,28 @@
+ "].";
throw new IllegalStateException( error );
}
+
+ Controller controller = m.getController();
+ if( PartDescriptor.GET == semantic )
+ {
+ return controller.resolve( m );
+ }
+ else if( PartDescriptor.CREATE == semantic )
+ {
+ return controller.create( m );
+ }
+ else if( PartDescriptor.RELEASE == semantic )
+ {
+ controller.release( proxy );
+ return null;
+ }
else
{
- Controller controller = m.getController();
- Object instance = controller.resolve( m );
- return method.invoke( instance, args );
+ final String error =
+ "Unrecognized semantic ["
+ + semantic
+ + "].";
+ throw new IllegalArgumentException( error );
}
}

@@ -176,15 +194,15 @@
{
String name = method.getName();
String key = getKeyFromMethod( method );
- if( name.startsWith( "get" ) )
+ if( name.startsWith( PartDescriptor.GET_KEY ) )
{
return (PartDescriptor) m_getters.get( key );
}
- else if( name.startsWith( "create" ) )
+ else if( name.startsWith( PartDescriptor.CREATE_KEY ) )
{
return (PartDescriptor) m_creators.get( key );
}
- else if( name.startsWith( "release" ) )
+ else if( name.startsWith( PartDescriptor.RELEASE_KEY ) )
{
return (PartDescriptor) m_releasors.get( key );
}
@@ -197,15 +215,15 @@
private String getKeyFromMethod( Method method )
{
String name = method.getName();
- if( name.startsWith( "get" ) )
+ if( name.startsWith( PartDescriptor.GET_KEY ) )
{
return formatKey( name.substring( 3 ) );
}
- else if( name.startsWith( "create" ) )
+ else if( name.startsWith( PartDescriptor.CREATE_KEY ) )
{
return formatKey( name.substring( 6 ) );
}
- else if( name.startsWith( "release" ) )
+ else if( name.startsWith( PartDescriptor.RELEASE_KEY ) )
{
return formatKey( name.substring( 7 ) );
}

Added: development/main/metro/composition/testing/unit/build.xml
==============================================================================
--- (empty file)
+++ development/main/metro/composition/testing/unit/build.xml Mon Apr 4
04:08:09 2005
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-composition-testing-unit" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
xmlns:x="plugin:dpml/magic/dpml-magic-core">
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="init" depends="standard.init">
+ <x:filter key="dpml-system-impl" feature="plugin"
token="SYSTEM-PLUGIN-URI"/>
+ <x:property key="dpml-composition-testing-acme" feature="uri"
type="part" name="acme.part"/>
+ <filter token="ACME-PART-URI" value="${acme.part}"/>
+ </target>
+
+ <target name="build" depends="standard.build">
+
+ <!--
+ Setup a component dealing with experimental part handling.
+ -->
+ <component xmlns="plugin:dpml/composition/dpml-composition-builder"
+ name="gizmo"
+ class="net.dpml.composition.testing.CompositeGizmo"
+ dest="target/test/acme-gizmo.part">
+ <parts>
+ <component name="widget" uri="${acme.part}"/>
+ </parts>
+ </component>
+
+ </target>
+
+</project>

Modified:
development/main/metro/composition/unit/src/test/net/dpml/composition/testing/CompositionManagerTestCase.java
==============================================================================
---
development/main/metro/composition/testing/system/src/test/net/dpml/composition/testing/CompositionManagerTestCase.java
(original)
+++
development/main/metro/composition/unit/src/test/net/dpml/composition/testing/CompositionManagerTestCase.java
Mon Apr 4 04:08:09 2005
@@ -73,16 +73,16 @@
// test
//------------------------------------------------------------------

- public void testAcmePart() throws Exception
- {
- CompositionManager manager = getCompositionManager();
- Model model = manager.addPart( ACME_PART_URI );
- Controller controller = model.getController();
- Widget widget = (Widget) controller.resolve( model );
- widget.doWidgetTypeStuff();
- controller.release( widget );
- manager.list();
- }
+ //public void testAcmePart() throws Exception
+ //{
+ // CompositionManager manager = getCompositionManager();
+ // Model model = manager.addPart( ACME_PART_URI );
+ // Controller controller = model.getController();
+ // Widget widget = (Widget) controller.resolve( model );
+ // widget.doWidgetTypeStuff();
+ // controller.release( widget );
+ // manager.list();
+ //}

//------------------------------------------------------------------
// internal
@@ -127,7 +127,7 @@
}
}

- private static final URI ACME_PART_URI = createStaticURI(
"@ACME-PART-URI@" );
+ //private static final URI ACME_PART_URI = createStaticURI(
"@ACME-PART-URI@" );
private static final URI SYSTEM_PLUGIN_URI = createStaticURI(
"@SYSTEM-PLUGIN-URI@" );

private static URI createStaticURI( String path )

Modified: development/main/metro/index.xml
==============================================================================
--- development/main/metro/index.xml (original)
+++ development/main/metro/index.xml Mon Apr 4 04:08:09 2005
@@ -476,6 +476,24 @@
</dependencies>
</project>

+ <project basedir="composition/unit">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-composition-unit</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <types>
+ <type>jar</type>
+ <type>part</type>
+ </types>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-composition-control"/>
+ <include key="dpml-system-impl" runtime="false"/>
+ </dependencies>
+ </project>
+
<project basedir="composition/testing/acme">
<info>
<group>dpml/test</group>
@@ -495,22 +513,18 @@
</plugins>
</project>

- <project basedir="composition/testing/system">
+ <project basedir="composition/testing/unit">
<info>
<group>dpml/test</group>
- <name>dpml-composition-testing-system</name>
+ <name>dpml-composition-testing-unit</name>
<version>1.0.0</version>
<status>SNAPSHOT</status>
<types>
<type>jar</type>
- <type>part</type>
</types>
</info>
<dependencies>
- <include key="dpml-logging-api"/>
- <include key="dpml-composition-control"/>
- <include key="dpml-composition-testing-acme"/>
- <include key="dpml-system-impl" runtime="false"/>
+ <include key="dpml-composition-unit"/>
</dependencies>
<plugins>
<include key="dpml-composition-builder"/>



  • svn commit: r2198 - in development/main/metro: . automation/control/src/main/net/dpml/automation/control composition/control/src/main/net/dpml/composition/control composition/testing/system composition/testing/unit composition/testing/unit/src composition/testing/unit/src/test composition/testing/unit/src/test/net composition/testing/unit/src/test/net/dpml composition/testing/unit/src/test/net/dpml/composition composition/testing/unit/src/test/net/dpml/composition/testing composition/unit composition/unit/src composition/unit/src/test/net/dpml/composition/testing, mcconnell, 04/03/2005

Archive powered by MHonArc 2.6.24.

Top of Page