Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2192 - in development/main/metro/composition: builder/src/main/net/dpml/composition/builder control/src/main/net/dpml/composition/control testing/acme testing/unit testing/unit/src/test/net/dpml/composition/test

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: r2192 - in development/main/metro/composition: builder/src/main/net/dpml/composition/builder control/src/main/net/dpml/composition/control testing/acme testing/unit testing/unit/src/test/net/dpml/composition/test
  • Date: Sat, 02 Apr 2005 06:19:11 -0500

Author: mcconnell AT dpml.net
Date: Sat Apr 2 06:19:10 2005
New Revision: 2192

Added:

development/main/metro/composition/testing/unit/src/test/net/dpml/composition/test/IncludeTestCase.java
Modified:

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.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/ConsoleMonitor.java
development/main/metro/composition/testing/acme/build.xml
development/main/metro/composition/testing/unit/build.xml
Log:
Add support for the inclusion of a component part by uri and provide
testcases validating this.

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
Sat Apr 2 06:19:10 2005
@@ -57,6 +57,7 @@
import net.dpml.composition.data.Parameter;
import net.dpml.composition.data.ComponentProfile;
import net.dpml.composition.data.Mode;
+import net.dpml.composition.control.CompositionController;

import net.dpml.composition.builder.datatypes.CategoriesDataType;
import net.dpml.composition.builder.datatypes.ContextDataType;
@@ -67,6 +68,9 @@

import net.dpml.meta.info.EntryDescriptor;

+import net.dpml.control.PartNotFoundException;
+import net.dpml.control.DelegationException;
+
import net.dpml.part.Part;
import net.dpml.part.PartHolder;

@@ -107,6 +111,7 @@
*/
public class ComponentBuilderTask extends ProjectTask implements PartBuilder
{
+ private URI m_uri;
private String m_key;
private String m_name;
private String m_classname;
@@ -139,6 +144,11 @@
m_key = key;
}

+ public void setUri( URI uri )
+ {
+ m_uri = uri;
+ }
+
public void setName( String name )
{
m_name = name;
@@ -453,13 +463,57 @@
private ComponentProfile buildComponentProfile( ClassLoader classloader,
ClassLoaderDirective cld )
throws IntrospectionException, IOException, ClassNotFoundException
{
+ String name = getName();
+ if( null != m_uri )
+ {
+ log( "including component: " + m_uri );
+ CompositionController controller = new CompositionController();
+ try
+ {
+ Part part = controller.loadPart( m_uri );
+ if( part instanceof ComponentProfile )
+ {
+ ComponentProfile profile = (ComponentProfile) part;
+ return new ComponentProfile( name, profile );
+ }
+ else
+ {
+ final String error =
+ "The part ["
+ + part.getClass().getName()
+ + "] references by the uri ["
+ + m_uri
+ + "] is not assignable from "
+ + ComponentProfile.class.getName()
+ + ".";
+ throw new BuildException( error, getLocation() );
+ }
+ }
+ catch( PartNotFoundException pnfe )
+ {
+ final String error =
+ "Part not found ["
+ + m_uri
+ + "].";
+ throw new BuildException( error, getLocation() );
+ }
+ catch( DelegationException de )
+ {
+ final String error =
+ "Delegation error while attempting to load part ["
+ + m_uri
+ + "] due to: "
+ + de.getMessage();
+ throw new BuildException( error, de, getLocation() );
+ }
+ }
+
log( "building component: " + getName() );

//
// setup classname and type
//

- String name = getName();
String classname = getClassname();
Type type = loadType( classloader, classname );
String lifestyle = getLifestylePolicy( type ); // need to update
ComponentProfile to handle this

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
Sat Apr 2 06:19:10 2005
@@ -61,6 +61,11 @@
// constructor
//--------------------------------------------------------------------

+ public CompositionController()
+ {
+ this( new ConsoleMonitor() );
+ }
+
public CompositionController( Logger logger )
{
super();

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/ConsoleMonitor.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/ConsoleMonitor.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/ConsoleMonitor.java
Sat Apr 2 06:19:10 2005
@@ -32,6 +32,12 @@
private String m_category;
private boolean m_debug;

+ public ConsoleMonitor()
+ {
+ m_category = "control";
+ m_debug = false;
+ }
+
public ConsoleMonitor( String category, boolean debug )
{
m_category = category;

Modified: development/main/metro/composition/testing/acme/build.xml
==============================================================================
--- development/main/metro/composition/testing/acme/build.xml (original)
+++ development/main/metro/composition/testing/acme/build.xml Sat Apr 2
06:19:10 2005
@@ -14,21 +14,18 @@
<type class="net.dpml.composition.testing.CompositeGizmo"/>
</types>

- <!-- experimental -->
+ <!-- simple component -->
<component xmlns="plugin:dpml/composition/dpml-composition-builder"
- name="gizmo" class="net.dpml.composition.testing.CompositeGizmo">
- <parts>
- <component key="widget"
class="net.dpml.composition.testing.DefaultWidget">
- <context>
- <entry key="foo" value="bar"/>
- <entry key="width" value="12"/>
- <entry key="height" value="100"/>
- <entry key="name" value="urn:metro:name"/>
- <entry key="partition" value="urn:metro:partition"/>
- <entry key="workingDirectory" value="acme/workspace"/>
- </context>
- </component>
- </parts>
+ name="widget" class="net.dpml.composition.testing.DefaultWidget"
+ activation="true">
+ <context>
+ <entry key="foo" value="bar"/>
+ <entry key="width" value="12"/>
+ <entry key="height" value="100"/>
+ <entry key="name" value="urn:metro:name"/>
+ <entry key="partition" value="urn:metro:partition"/>
+ <entry key="workingDirectory" value="acme/workspace"/>
+ </context>
</component>

</target>

Modified: development/main/metro/composition/testing/unit/build.xml
==============================================================================
--- development/main/metro/composition/testing/unit/build.xml (original)
+++ development/main/metro/composition/testing/unit/build.xml Sat Apr 2
06:19:10 2005
@@ -35,6 +35,19 @@
</container>

<!--
+ Same as above except we include widget by a uri reference.
+ -->
+ <container xmlns="plugin:dpml/composition/dpml-composition-builder"
name="acme"
+ dest="target/test/acme-include.part">
+ <component name="widget" uri="${acme.part}"/>
+ <component name="gizmo"
class="net.dpml.composition.testing.DefaultGizmo">
+ <dependencies>
+ <dependency key="widget" source="widget"/>
+ </dependencies>
+ </component>
+ </container>
+
+ <!--
Look dad - no container!
-->
<component xmlns="plugin:dpml/composition/dpml-composition-builder"
@@ -43,8 +56,8 @@
activation="true">
<context>
<entry key="foo" value="bar"/>
- <entry key="width" value="12"/>
- <entry key="height" value="100"/>
+ <entry key="width" value="26"/>
+ <entry key="height" value="19"/>
<entry key="name" value="urn:metro:name"/>
<entry key="partition" value="urn:metro:partition"/>
<entry key="workingDirectory" value="acme/workspace"/>
@@ -59,16 +72,7 @@
class="net.dpml.composition.testing.CompositeGizmo"
dest="target/test/acme-gizmo.part">
<parts>
- <component key="widget"
class="net.dpml.composition.testing.DefaultWidget">
- <context>
- <entry key="foo" value="bar"/>
- <entry key="width" value="12"/>
- <entry key="height" value="100"/>
- <entry key="name" value="urn:metro:name"/>
- <entry key="partition" value="urn:metro:partition"/>
- <entry key="workingDirectory" value="acme/workspace"/>
- </context>
- </component>
+ <component key="widget" uri="${acme.part}"/>
</parts>
</component>


Added:
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/test/IncludeTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/test/IncludeTestCase.java
Sat Apr 2 06:19:10 2005
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.test;
+
+import java.io.File;
+import java.net.URI;
+
+import net.dpml.metro.unit.CompositionTestCase;
+
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.model.ContainmentModel;
+
+import net.dpml.exception.ExceptionHelper;
+
+/**
+ * The testcase validates the new metro container model part loading and
deployment.
+ */
+public class IncludeTestCase extends CompositionTestCase
+{
+ private static final String FILENAME = "acme-include.part";
+
+ private URI m_uri;
+
+ public void setUp() throws Exception
+ {
+ super.setupCompositionRoot();
+ File base = new File( System.getProperty( "project.test.dir" ) );
+ File file = new File( base, FILENAME );
+ m_uri = file.toURI();
+ }
+
+ public void tearDown() throws Exception
+ {
+ getRoot().decommission();
+ }
+
+ /**
+ * Validate that the hello component is deployable and resolvable.
+ * @exception if a deployment error occurs
+ */
+ public void testCompositePart() throws Throwable
+ {
+ DeploymentModel test = getRoot().addModel( m_uri );
+ test.commission();
+ Object object = test.resolve( false );
+ test.release( object );
+ }
+
+}



  • svn commit: r2192 - in development/main/metro/composition: builder/src/main/net/dpml/composition/builder control/src/main/net/dpml/composition/control testing/acme testing/unit testing/unit/src/test/net/dpml/composition/test, mcconnell, 04/01/2005

Archive powered by MHonArc 2.6.24.

Top of Page