Skip to Content.
Sympa Menu

notify-dpml - r1174 - in trunk/main/metro: . builder builder/etc builder/etc/test builder/etc/test/parts builder/etc/test/types builder/src builder/src/main/net/dpml/metro/builder builder/src/test builder/src/test/net builder/src/test/net/dpml builder/src/test/net/dpml/metro builder/src/test/net/dpml/metro/builder exec exec/etc/bin model model/src/main/net/dpml/metro model/src/main/net/dpml/metro/data model/src/main/net/dpml/metro/info model/src/test/net/dpml/metro/data/test model/src/test/net/dpml/metro/info/test part/api part/api/src/main/net/dpml/part part/api/src/test/net/dpml/part/test part/test runtime runtime/src/main/net/dpml/metro/runtime state state/api/src/main/net/dpml/state state/impl state/impl/etc/test state/impl/src/main/net/dpml/state/impl state/impl/src/test/net/dpml/state state/impl/src/test/net/dpml/state/test station station/console station/console/etc/bin test test/src/test/net/dpml/metro/runtime/test tools tools/src/main/net/dpml/metro/tools

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: r1174 - in trunk/main/metro: . builder builder/etc builder/etc/test builder/etc/test/parts builder/etc/test/types builder/src builder/src/main/net/dpml/metro/builder builder/src/test builder/src/test/net builder/src/test/net/dpml builder/src/test/net/dpml/metro builder/src/test/net/dpml/metro/builder exec exec/etc/bin model model/src/main/net/dpml/metro model/src/main/net/dpml/metro/data model/src/main/net/dpml/metro/info model/src/test/net/dpml/metro/data/test model/src/test/net/dpml/metro/info/test part/api part/api/src/main/net/dpml/part part/api/src/test/net/dpml/part/test part/test runtime runtime/src/main/net/dpml/metro/runtime state state/api/src/main/net/dpml/state state/impl state/impl/etc/test state/impl/src/main/net/dpml/state/impl state/impl/src/test/net/dpml/state state/impl/src/test/net/dpml/state/test station station/console station/console/etc/bin test test/src/test/net/dpml/metro/runtime/test tools tools/src/main/net/dpml/metro/tools
  • Date: Tue, 14 Mar 2006 17:11:22 +0100

Author: mcconnell
Date: 2006-03-14 17:11:04 +0100 (Tue, 14 Mar 2006)
New Revision: 1174

Added:
trunk/main/metro/builder/build.xml
trunk/main/metro/builder/etc/test/
trunk/main/metro/builder/etc/test/minimal-component.xml
trunk/main/metro/builder/etc/test/parts/
trunk/main/metro/builder/etc/test/parts/array.xml
trunk/main/metro/builder/etc/test/parts/lookup.xml
trunk/main/metro/builder/etc/test/types/
trunk/main/metro/builder/etc/test/types/example-1.xml

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentBuilder.java

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentStrategyBuilder.java

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentStrategyWriter.java

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentWriter.java
trunk/main/metro/builder/src/main/net/dpml/metro/builder/TypeBuilder.java
trunk/main/metro/builder/src/main/net/dpml/metro/builder/TypeWriter.java
trunk/main/metro/builder/src/test/
trunk/main/metro/builder/src/test/net/
trunk/main/metro/builder/src/test/net/dpml/
trunk/main/metro/builder/src/test/net/dpml/metro/
trunk/main/metro/builder/src/test/net/dpml/metro/builder/

trunk/main/metro/builder/src/test/net/dpml/metro/builder/LookupTestCase.java

trunk/main/metro/builder/src/test/net/dpml/metro/builder/MinimalTestCase.java
trunk/main/metro/builder/src/test/net/dpml/metro/builder/PartsTestCase.java
trunk/main/metro/builder/src/test/net/dpml/metro/builder/TypesTestCase.java
trunk/main/metro/model/src/main/net/dpml/metro/data/LookupDirective.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/LookupDirectiveTestCase.java
trunk/main/metro/state/impl/etc/test/empty.xml
trunk/main/metro/state/impl/etc/test/substates.xml
trunk/main/metro/state/impl/etc/test/transition.xml
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/StateBuilder.java
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/StateWriter.java
trunk/main/metro/state/impl/src/test/net/dpml/state/EmptyTestCase.java
trunk/main/metro/state/impl/src/test/net/dpml/state/TransitionTestCase.java

trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ConfigTestCase.java~

trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ParamsTestCase.java~

trunk/main/metro/tools/src/main/net/dpml/metro/tools/CategoriesDescriptorDataType.java
Removed:
trunk/main/metro/builder/etc/main/

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginFactory.java

trunk/main/metro/model/src/main/net/dpml/metro/data/CategoriesDirectiveBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/data/CategoryDirectiveBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/data/ClassLoaderDirective.java

trunk/main/metro/model/src/main/net/dpml/metro/data/ClassLoaderDirectiveBeanInfo.java
trunk/main/metro/model/src/main/net/dpml/metro/data/ClasspathDirective.java

trunk/main/metro/model/src/main/net/dpml/metro/data/ClasspathDirectiveBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirectiveBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/data/ContextDirectiveBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/data/FeatureDirectiveBeanInfo.java
trunk/main/metro/model/src/main/net/dpml/metro/data/ReferenceDirective.java

trunk/main/metro/model/src/main/net/dpml/metro/data/ReferenceDirectiveBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/data/ValueDirectiveBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/info/CategoryDescriptorBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/info/CollectionPolicyBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/info/ContextDescriptorBeanInfo.java
trunk/main/metro/model/src/main/net/dpml/metro/info/EncodingException.java

trunk/main/metro/model/src/main/net/dpml/metro/info/EntryDescriptorBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptorBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/info/LifestylePolicyBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/info/PartReferenceBeanInfo.java
trunk/main/metro/model/src/main/net/dpml/metro/info/PriorityBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/info/ServiceDescriptorBeanInfo.java

trunk/main/metro/model/src/main/net/dpml/metro/info/ThreadSafePolicyBeanInfo.java
trunk/main/metro/model/src/main/net/dpml/metro/info/TypeBeanInfo.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClassLoaderDirectiveTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClasspathDirectiveTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/ReferenceDirectiveTestCase.java
trunk/main/metro/part/api/src/main/net/dpml/part/Part.java
trunk/main/metro/part/api/src/main/net/dpml/part/PartBeanInfo.java
trunk/main/metro/part/api/src/main/net/dpml/part/PartBuilder.java
trunk/main/metro/part/api/src/main/net/dpml/part/PartHeader.java
trunk/main/metro/part/api/src/main/net/dpml/part/PartHeaderBeanInfo.java
trunk/main/metro/part/api/src/main/net/dpml/part/Version.java
trunk/main/metro/part/api/src/main/net/dpml/part/VersionBeanInfo.java
trunk/main/metro/part/api/src/test/net/dpml/part/test/PartTestCase.java
trunk/main/metro/state/api/src/main/net/dpml/state/StateBuilder.java
trunk/main/metro/state/build.xml

trunk/main/metro/state/impl/src/main/net/dpml/state/impl/ApplyActionBeanInfo.java

trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultInterfaceBeanInfo.java

trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultOperationBeanInfo.java

trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateBeanInfo.java

trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultTransitionBeanInfo.java

trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultTriggerBeanInfo.java

trunk/main/metro/state/impl/src/main/net/dpml/state/impl/ExecActionBeanInfo.java
trunk/main/metro/station/build.xml

trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ConfigTestCase.java

trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ParamsTestCase.java

trunk/main/metro/tools/src/main/net/dpml/metro/tools/ClassLoaderBuilderTask.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ReferenceDataType.java

trunk/main/metro/tools/src/main/net/dpml/metro/tools/SerializableObjectHelper.java
Modified:
trunk/main/metro/exec/build.xml
trunk/main/metro/exec/etc/bin/metro.lap
trunk/main/metro/model/build.xml
trunk/main/metro/model/src/main/net/dpml/metro/ComponentModel.java
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirective.java

trunk/main/metro/model/src/main/net/dpml/metro/data/DeploymentDirective.java
trunk/main/metro/model/src/main/net/dpml/metro/info/CategoryDescriptor.java
trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptor.java
trunk/main/metro/model/src/main/net/dpml/metro/info/ServiceDescriptor.java
trunk/main/metro/model/src/main/net/dpml/metro/info/Type.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/AbstractEncodingTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/CategoriesDirectiveTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/CategoryDirectiveTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/ContextDirectiveTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/FeatureDirectiveTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/PartReferenceTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/info/test/AbstractEncodingTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/info/test/EntryDescriptorTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java
trunk/main/metro/module.xml
trunk/main/metro/part/api/build.xml
trunk/main/metro/part/api/src/main/net/dpml/part/Controller.java
trunk/main/metro/part/api/src/main/net/dpml/part/Service.java
trunk/main/metro/part/test/build.xml
trunk/main/metro/runtime/build.xml

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

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

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

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

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

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

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultService.java
trunk/main/metro/state/api/src/main/net/dpml/state/Trigger.java
trunk/main/metro/state/impl/build.xml
trunk/main/metro/state/impl/etc/test/example.xgraph
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultState.java

trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateMachine.java

trunk/main/metro/state/impl/src/test/net/dpml/state/test/AbstractEncodingTestCase.java

trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultOperationTestCase.java

trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateMachineTestCase.java

trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateTestCase.java

trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTransitionTestCase.java

trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTriggerTestCase.java
trunk/main/metro/station/console/build.xml
trunk/main/metro/station/console/etc/bin/station.lap
trunk/main/metro/test/build.xml
trunk/main/metro/tools/build.xml
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java

trunk/main/metro/tools/src/main/net/dpml/metro/tools/CategoriesDataType.java

trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/EntryDataType.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/PartsDataType.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServiceDataType.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateDataType.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateTask.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/TypeBuilderTask.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/TypesTask.java
Log:
update metro part management to integrate with a generic part solution
implemented within transit

Added: trunk/main/metro/builder/build.xml
===================================================================
--- trunk/main/metro/builder/build.xml 2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/builder/build.xml 2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ 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.
+-->
+
+<project xmlns:transit="antlib:net.dpml.transit" xmlns:x="dpml:depot"
+ default="install">
+
+ <transit:import uri="local:template:dpml/tools/standard"/>
+
+ <target name="init" depends="standard.init">
+ <filter token="STATE-XSD-URI"
value="artifact:xsd:dpml/lang/dpml-state#1.0"/>
+ <filter token="PART-XSD-URI"
value="artifact:xsd:dpml/lang/dpml-part#1.0"/>
+ <filter token="STATE-XSD-URI"
value="artifact:xsd:dpml/lang/dpml-state#1.0"/>
+ <filter token="TYPE-XSD-URI"
value="artifact:xsd:dpml/lang/dpml-type#1.0"/>
+ <filter token="COMPONENT-XSD-URI"
value="artifact:xsd:dpml/lang/dpml-component#1.0"/>
+ <x:filter token="CONTROLLER-URI" ref="dpml/metro/dpml-metro-runtime"
type="part" feature="uri"/>
+ <x:filter token="BUILDER-URI" type="part" feature="uri"/>
+ </target>
+
+</project>
+
+

Added: trunk/main/metro/builder/etc/test/minimal-component.xml
===================================================================
--- trunk/main/metro/builder/etc/test/minimal-component.xml 2006-03-14
16:05:36 UTC (rev 1173)
+++ trunk/main/metro/builder/etc/test/minimal-component.xml 2006-03-14
16:11:04 UTC (rev 1174)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<component xmlns="@COMPONENT-XSD-URI@" name="widget" class="acme.Widget"/>

Added: trunk/main/metro/builder/etc/test/parts/array.xml
===================================================================
--- trunk/main/metro/builder/etc/test/parts/array.xml 2006-03-14 16:05:36
UTC (rev 1173)
+++ trunk/main/metro/builder/etc/test/parts/array.xml 2006-03-14 16:11:04
UTC (rev 1174)
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+
+<component xmlns="@COMPONENT-XSD-URI@"
+ class="net.dpml.test.array.ArrayTestComponent"
+ name="array"
+ lifestyle="thread"
+ collection="system"
+ activation="system">
+ <context>
+ <entry key="values" class="[Ljava.lang.String;">
+ <param class="Hello"/>
+ <param class="World"/>
+ </entry>
+ </context>
+</component>
+

Added: trunk/main/metro/builder/etc/test/parts/lookup.xml
===================================================================
--- trunk/main/metro/builder/etc/test/parts/lookup.xml 2006-03-14 16:05:36
UTC (rev 1173)
+++ trunk/main/metro/builder/etc/test/parts/lookup.xml 2006-03-14 16:11:04
UTC (rev 1174)
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+
+<component xmlns="@COMPONENT-XSD-URI@"
+ class="net.dpml.test.array.ArrayTestComponent">
+ <context>
+ <entry key="test" lookup="acme.Widget"/>
+ </context>
+</component>
+

Added: trunk/main/metro/builder/etc/test/types/example-1.xml
===================================================================
--- trunk/main/metro/builder/etc/test/types/example-1.xml 2006-03-14
16:05:36 UTC (rev 1173)
+++ trunk/main/metro/builder/etc/test/types/example-1.xml 2006-03-14
16:11:04 UTC (rev 1174)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+
+<type xmlns="artifact:xsd:dpml/lang/dpml-type#1.0"
+ xmlns:state="artifact:xsd:dpml/lang/dpml-state#1.0">
+
+ <info name="test"
+ class="net.dpml.test.part.ExampleComponent"
+ version="0.0.0"
+ lifestyle="thread"
+ collection="system"
+ threadsafe="unknown"/>
+
+ <services>
+ <service class="net.dpml.test.part.ColorManager" version="1.0.0"/>
+ </services>
+
+ <context>
+ <entry key="color" class="java.awt.Color" optional="false"/>
+ </context>
+
+ <!-- ISSUE need to add support for declarations such as <state:state ...>
-->
+ <state xmlns="artifact:xsd:dpml/lang/dpml-state#1.0"/>
+
+ <parts/>
+
+</type>

Added:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentBuilder.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentBuilder.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentBuilder.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,328 @@
+/*
+ * Copyright 2006 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.builder;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.io.OutputStreamWriter;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import javax.xml.XMLConstants;
+
+import net.dpml.state.State;
+import net.dpml.state.Action;
+import net.dpml.state.Trigger.TriggerEvent;
+import net.dpml.state.StateBuilderRuntimeException;
+
+import net.dpml.part.DOM3DocumentBuilder;
+import net.dpml.lang.BuilderException;
+import net.dpml.part.PartDirective;
+import net.dpml.part.ActivationPolicy;
+
+import net.dpml.metro.data.ContextDirective;
+import net.dpml.metro.data.CategoryDirective;
+import net.dpml.metro.data.CategoriesDirective;
+import net.dpml.metro.data.ComponentDirective;
+import net.dpml.metro.data.ValueDirective;
+import net.dpml.metro.data.LookupDirective;
+import net.dpml.metro.info.LifestylePolicy;
+import net.dpml.metro.info.CollectionPolicy;
+import net.dpml.metro.info.PartReference;
+import net.dpml.metro.info.Priority;
+import net.dpml.metro.info.Type;
+
+import net.dpml.transit.util.ElementHelper;
+import net.dpml.transit.Value;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.Attr;
+import org.w3c.dom.TypeInfo;
+
+/**
+ * Construct a state graph.
+ */
+public class ComponentBuilder extends ComponentWriter
+{
+ private static final String STATE_SCHEMA_URN = "@STATE-XSD-URI@";
+
+ private static final String SCHEMA_URN = "@COMPONENT-XSD-URI@";
+
+ private static DOM3DocumentBuilder BUILDER = new DOM3DocumentBuilder();
+
+ private static TypeBuilder TYPE_BUILDER = new TypeBuilder();
+
+ public ComponentDirective loadComponentDirective( URI uri ) throws
IOException
+ {
+ if( null == uri )
+ {
+ throw new NullPointerException( "uri" );
+ }
+ try
+ {
+ final Document document = BUILDER.parse( uri );
+ final Element root = document.getDocumentElement();
+ return buildComponent( root );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "An error while attempting to load a component directive."
+ + "\nURI: " + uri;
+ IOException exception = new IOException( error );
+ exception.initCause( e );
+ throw exception;
+ }
+ }
+
+ public ComponentDirective buildComponent( Element root ) throws Exception
+ {
+ if( null == root )
+ {
+ throw new NullPointerException( "root" );
+ }
+
+ return createComponentDirective( root );
+ }
+
+ private ComponentDirective createComponentDirective( Element element )
throws BuilderException
+ {
+ String classname = buildComponentClassname( element );
+ String name = buildComponentName( element );
+ ActivationPolicy activation = buildActivationPolicy( element );
+ CollectionPolicy collection = buildCollectionPolicy( element );
+ LifestylePolicy lifestyle = buildLifestylePolicy( element );
+ CategoriesDirective categories = getNestedCategoriesDirective(
element );
+ ContextDirective context = getNestedContextDirective( element );
+ PartReference[] parts = getNestedParts( element );
+
+ return new ComponentDirective(
+ name, activation, collection, lifestyle, classname,
+ categories, context, null, null, parts );
+ }
+
+ private String buildComponentClassname( Element element ) throws
BuilderException
+ {
+ String classname = ElementHelper.getAttribute( element, "class" );
+ if( null == classname )
+ {
+ final String error =
+ "Missing component 'class' attribute.";
+ throw new BuilderException( element, error );
+ }
+ else
+ {
+ return classname;
+ }
+ }
+
+ private ActivationPolicy buildActivationPolicy( Element element ) throws
BuilderException
+ {
+ String defaultValue = ActivationPolicy.SYSTEM.getName();
+ String policy = ElementHelper.getAttribute( element, "activation",
defaultValue );
+ return ActivationPolicy.parse( policy );
+ }
+
+ private LifestylePolicy buildLifestylePolicy( Element element ) throws
BuilderException
+ {
+ String defaultValue = LifestylePolicy.TRANSIENT.getName();
+ String policy = ElementHelper.getAttribute( element, "lifestyle",
defaultValue );
+ return LifestylePolicy.parse( policy );
+ }
+
+ private CollectionPolicy buildCollectionPolicy( Element element ) throws
BuilderException
+ {
+ String defaultValue = CollectionPolicy.SYSTEM.getName();
+ String policy = ElementHelper.getAttribute( element, "collection",
defaultValue );
+ return CollectionPolicy.parse( policy );
+ }
+
+ private String buildComponentName( Element element )
+ {
+ return ElementHelper.getAttribute( element, "name" );
+ }
+
+ private CategoriesDirective getNestedCategoriesDirective( Element root )
+ {
+ Element element = ElementHelper.getChild( root, "categories" );
+ if( null == element )
+ {
+ return null;
+ }
+ else
+ {
+ return createCategoriesDirective( element );
+ }
+ }
+
+ private CategoriesDirective createCategoriesDirective( Element element )
+ {
+ if( null == element )
+ {
+ return null;
+ }
+ else
+ {
+ String name = ElementHelper.getAttribute( element, "name" );
+ Priority priority = createPriority( element );
+ String target = ElementHelper.getAttribute( element, "target" );
+ CategoryDirective[] categories = createCategoryDirectiveArray(
element );
+ return new CategoriesDirective( name, priority, target,
categories );
+ }
+ }
+
+ private CategoryDirective createCategoryDirective( Element element )
+ {
+ String name = ElementHelper.getAttribute( element, "name" );
+ Priority priority = createPriority( element );
+ String target = ElementHelper.getAttribute( element, "target" );
+ return new CategoryDirective( name, priority, target );
+ }
+
+ private CategoryDirective[] createCategoryDirectiveArray( Element
element )
+ {
+ Element[] children = ElementHelper.getChildren( element );
+ CategoryDirective[] categories = new CategoryDirective[
children.length ];
+ for( int i=0; i<categories.length; i++ )
+ {
+ Element elem = children[i];
+ if( "category".equals( elem.getTagName() ) )
+ {
+ categories[i] = createCategoryDirective( elem );
+ }
+ else
+ {
+ categories[i] = createCategoriesDirective( elem );
+ }
+ }
+ return categories;
+ }
+
+ private Priority createPriority( Element element )
+ {
+ String priority = ElementHelper.getAttribute( element, "priority" );
+ if( null == priority )
+ {
+ return null;
+ }
+ else
+ {
+ return Priority.parse( priority );
+ }
+ }
+
+ private ContextDirective getNestedContextDirective( Element root )
+ {
+ Element context = ElementHelper.getChild( root, "context" );
+ if( null == context )
+ {
+ return null;
+ }
+ else
+ {
+ return createContextDirective( context );
+ }
+ }
+
+ private ContextDirective createContextDirective( Element element )
+ {
+ String classname = ElementHelper.getAttribute( element, "class" );
+ Element[] children = ElementHelper.getChildren( element );
+ PartReference[] entries = new PartReference[ children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element elem = children[i];
+ entries[i] = createContextEntryPartReference( elem );
+ }
+ return new ContextDirective( classname, entries );
+ }
+
+ private PartReference createContextEntryPartReference( Element element )
+ {
+ String key = ElementHelper.getAttribute( element, "key" );
+ String spec = ElementHelper.getAttribute( element, "lookup" );
+ if( null != spec )
+ {
+ LookupDirective directive = new LookupDirective( spec );
+ return new PartReference( key, directive );
+ }
+ else
+ {
+ ValueDirective directive = buildValueDirective( element );
+ return new PartReference( key, directive );
+ }
+ }
+
+ protected ValueDirective buildValueDirective( Element element )
+ {
+ String classname = ElementHelper.getAttribute( element, "class" );
+ String method = ElementHelper.getAttribute( element, "method" );
+ Element[] elements = ElementHelper.getChildren( element, "param" );
+ if( elements.length > 0 )
+ {
+ Value[] values = buildValues( elements );
+ return new ValueDirective( classname, method, values );
+ }
+ else
+ {
+ String value = ElementHelper.getAttribute( element, "value" );
+ return new ValueDirective( classname, method, value );
+ }
+ }
+
+ private PartReference[] getNestedParts( Element root )
+ {
+ Element parts = ElementHelper.getChild( root, "parts" );
+ if( null == parts )
+ {
+ return null;
+ }
+ else
+ {
+ return createParts( parts );
+ }
+ }
+
+ private PartReference[] createParts( Element element )
+ {
+ Element[] children = ElementHelper.getChildren( element );
+ PartReference[] parts = new PartReference[ children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element elem = children[i];
+ parts[i] = createPartReference( elem );
+ }
+ return parts;
+ }
+
+ private PartReference createPartReference( Element element )
+ {
+ String key = ElementHelper.getAttribute( element, "key" );
+ ComponentDirective directive = createComponentDirective( element );
+ return new PartReference( key, directive );
+ }
+}

Deleted:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginFactory.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginFactory.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginFactory.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,53 +0,0 @@
-/*
- * Copyright 2006 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.builder;
-
-import java.net.URI;
-
-import net.dpml.lang.Plugin;
-import net.dpml.lang.Strategy;
-import net.dpml.lang.Classpath;
-import net.dpml.lang.PluginFactory;
-
-import net.dpml.transit.DefaultPluginFactory;
-
-/**
- * Default plugin factory.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ComponentPluginFactory extends DefaultPluginFactory
-{
- /**
- * Construct a new plugin description instance using a supplied arguments
- *
- * @param uri the uri identifying the plugin
- * @param element the root element definining the plugin
- * @exception Exception if an error occurs
- */
- public Plugin newPlugin(
- String title, String description, URI uri, Strategy strategy,
Classpath classpath )
- throws Exception
- {
- System.out.println( "# NEW: " + getClass().getName() );
- return super.newPlugin( title, description, uri, strategy, classpath
);
- }
-}
-

Added:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentStrategyBuilder.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentStrategyBuilder.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentStrategyBuilder.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2006 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.builder;
+
+import java.net.URI;
+import java.io.Writer;
+import java.io.IOException;
+import java.util.Map;
+
+import net.dpml.metro.data.ComponentDirective;
+
+import net.dpml.transit.Value;
+import net.dpml.transit.Construct;
+import net.dpml.transit.util.ElementHelper;
+
+import net.dpml.part.Strategy;
+import net.dpml.part.StrategyBuilder;
+import net.dpml.part.PartDirective;
+
+import net.dpml.lang.Builder;
+import net.dpml.lang.BuilderException;
+import net.dpml.lang.Type;
+import net.dpml.lang.DefaultType;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.TypeInfo;
+
+/**
+ * Component part handler.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ComponentStrategyBuilder extends ComponentStrategyWriter
implements StrategyBuilder, Builder
+{
+ public ComponentStrategyBuilder()
+ {
+ super( null );
+ }
+
+ public ComponentStrategyBuilder( Map map )
+ {
+ super( map );
+ }
+
+ /**
+ * Constructs a component deployment strategy.
+ *
+ * @return the deployment strategy
+ * @exception Exception if an error occurs
+ */
+ public Object build( ClassLoader classloader, Element element ) throws
Exception
+ {
+ return buildStrategy( classloader, element );
+ }
+
+ /**
+ * Constructs a component deployment strategy.
+ *
+ * @return the deployment strategy
+ * @exception Exception if an error occurs
+ */
+ public Type buildType( ClassLoader classloader, Element element ) throws
Exception
+ {
+ boolean alias = ElementHelper.getBooleanAttribute( element, "alias",
false );
+ Strategy strategy = buildStrategy( classloader, element );
+ return new DefaultType( "part", alias, strategy );
+ }
+
+ /**
+ * Constructs a component deployment strategy.
+ *
+ * @return the deployment strategy
+ * @exception Exception if an error occurs
+ */
+ public Strategy buildStrategy( ClassLoader classloader, Element element
) throws Exception
+ {
+ TypeInfo info = element.getSchemaTypeInfo();
+ String namespace = info.getTypeNamespace();
+ String name = info.getTypeName();
+
+ URI uri = new URI( BUILDER_URI );
+ boolean alias = ElementHelper.getBooleanAttribute( element, "alias",
false );
+
+ if( "component".equals( name ) )
+ {
+ PartDirective control = createControllerDirective( null );
+ ComponentDirective component = createComponentDirective( element
);
+ return new Strategy( uri, control, component, alias );
+ }
+ else if( "strategy".equals( name ) )
+ {
+ Element controller = ElementHelper.getChild( element,
"controller" );
+ PartDirective control = createControllerDirective( controller );
+ Element directive = ElementHelper.getChild( element, "component"
);
+ ComponentDirective component = createComponentDirective(
directive );
+ return new Strategy( uri, control, component, alias );
+ }
+ else
+ {
+ final String error =
+ "Strategy element name ["
+ + name
+ + "] is not recognized (expecting either 'component' or
'strategy').";
+ throw new BuilderException( element, error );
+ }
+ }
+
+ private ComponentDirective createComponentDirective( Element element )
throws Exception
+ {
+ return BUILDER.buildComponent( element );
+ }
+
+ private PartDirective createControllerDirective( Element element )
throws Exception
+ {
+ if( null == element )
+ {
+ try
+ {
+ URI uri = new URI( CONTROLLER_URI );
+ return new PartDirective( uri, null );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected error during part directive creation.";
+ throw new RuntimeException( error, e );
+ }
+ }
+ else
+ {
+ String spec = ElementHelper.getAttribute( element, "uri" );
+ URI uri = new URI( spec );
+ Element[] elements = ElementHelper.getChildren( element, "param"
);
+ Value[] values = buildValues( elements );
+ return new PartDirective( uri, values );
+ }
+ }
+}

Added:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentStrategyWriter.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentStrategyWriter.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentStrategyWriter.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2006 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.builder;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+
+import javax.xml.XMLConstants;
+
+import net.dpml.metro.data.ContextDirective;
+import net.dpml.metro.data.CategoryDirective;
+import net.dpml.metro.data.CategoriesDirective;
+import net.dpml.metro.data.ComponentDirective;
+import net.dpml.metro.info.LifestylePolicy;
+import net.dpml.metro.info.CollectionPolicy;
+import net.dpml.metro.info.PartReference;
+
+import net.dpml.transit.Value;
+import net.dpml.transit.Construct;
+import net.dpml.transit.util.ElementHelper;
+
+import net.dpml.part.Strategy;
+import net.dpml.part.StrategyBuilder;
+import net.dpml.part.PartDirective;
+import net.dpml.lang.BuilderException;
+import net.dpml.part.ValueBuilder;
+import net.dpml.lang.Type;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.TypeInfo;
+
+/**
+ * Component part handler.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ComponentStrategyWriter extends ValueBuilder
+{
+ final String CONTROLLER_URI = "@CONTROLLER-URI@";
+ final String BUILDER_URI = "@BUILDER-URI@";
+ final String COMPONENT_XSD_URI = "@COMPONENT-XSD-URI@";
+
+ private static final String XML_HEADER =
+ "<?xml version=\"1.0\"?>";
+
+ private static final String TYPE_SCHEMA_URN = "@TYPE-XSD-URI@";
+ private static final String STATE_SCHEMA_URN = "@STATE-XSD-URI@";
+ private static final String PART_SCHEMA_URN = "@PART-XSD-URI@";
+ private static final String COMPONENT_SCHEMA_URN = "@COMPONENT-XSD-URI@";
+
+ private static final String PARTIAL_COMPONENT_HEADER =
+ "<component xmlns=\""
+ + COMPONENT_SCHEMA_URN
+ + "\""
+ + "\n xmlns:xsi=\""
+ + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI
+ + "\"\n xmlns:part=\""
+ + PART_SCHEMA_URN
+ + "\"\n xmlns:type=\""
+ + TYPE_SCHEMA_URN
+ + "\"\n xmlns:component=\""
+ + COMPONENT_SCHEMA_URN
+ + "\"";
+
+ final ComponentBuilder BUILDER = new ComponentBuilder();
+
+ public ComponentStrategyWriter( Map map )
+ {
+ super( map );
+ }
+
+ public void writeStrategy(
+ Writer writer, Strategy strategy, String pad ) throws IOException
+ {
+ Object data = strategy.getDeploymentData();
+ if( data instanceof ComponentDirective )
+ {
+ ComponentDirective directive = (ComponentDirective) data;
+ writer.write( "\n" + pad + "<component xmlns=\"" +
COMPONENT_SCHEMA_URN + "\"" );
+ writer.write( "\n" + pad + " " );
+ BUILDER.writeAttributes( writer, directive, pad + " " );
+ BUILDER.writeBody( writer, directive, pad + " " );
+ writer.write( "\n" + pad + "</component>" );
+ }
+ else
+ {
+ final String error =
+ "Strategy argument ["
+ + data.getClass().getName()
+ + "] is not an instance of "
+ + ComponentDirective.class.getName()
+ + ".";
+ throw new IllegalArgumentException( error );
+ }
+ }
+}

Added:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentWriter.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentWriter.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentWriter.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,438 @@
+/*
+ * Copyright 2006 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.builder;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.XMLConstants;
+
+import net.dpml.metro.data.ContextDirective;
+import net.dpml.metro.data.CategoryDirective;
+import net.dpml.metro.data.CategoriesDirective;
+import net.dpml.metro.data.ComponentDirective;
+import net.dpml.metro.data.ValueDirective;
+import net.dpml.metro.data.LookupDirective;
+import net.dpml.metro.data.ValueDirective;
+import net.dpml.metro.info.LifestylePolicy;
+import net.dpml.metro.info.CollectionPolicy;
+import net.dpml.metro.info.PartReference;
+import net.dpml.metro.info.Priority;
+
+import net.dpml.transit.Value;
+import net.dpml.transit.Construct;
+import net.dpml.transit.util.ElementHelper;
+
+import net.dpml.part.Strategy;
+import net.dpml.part.StrategyBuilder;
+import net.dpml.part.PartDirective;
+import net.dpml.lang.BuilderException;
+import net.dpml.part.PartBuilder;
+import net.dpml.lang.Type;
+
+import net.dpml.part.ActivationPolicy;
+import net.dpml.part.Directive;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.TypeInfo;
+
+/**
+ * Component part handler.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ComponentWriter extends PartBuilder
+{
+ private final String CONTROLLER_URI = "@CONTROLLER-URI@";
+ private final String BUILDER_URI = "@BUILDER-URI@";
+
+ private static final String XML_HEADER =
+ "<?xml version=\"1.0\"?>";
+
+ private static final String TYPE_SCHEMA_URN = "@TYPE-XSD-URI@";
+ private static final String STATE_SCHEMA_URN = "@STATE-XSD-URI@";
+ private static final String PART_SCHEMA_URN = "@PART-XSD-URI@";
+ private static final String COMPONENT_SCHEMA_URN = "@COMPONENT-XSD-URI@";
+
+ private static final String PARTIAL_COMPONENT_HEADER =
+ "<component xmlns=\""
+ + COMPONENT_SCHEMA_URN
+ + "\""
+ + "\n xmlns:xsi=\""
+ + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI
+ + "\"\n xmlns:part=\""
+ + PART_SCHEMA_URN
+ + "\"\n xmlns:type=\""
+ + TYPE_SCHEMA_URN
+ + "\"\n xmlns:component=\""
+ + COMPONENT_SCHEMA_URN
+ + "\"";
+
+ public void export( ComponentDirective directive, OutputStream output )
throws IOException
+ {
+ final Writer writer = new OutputStreamWriter( output );
+
+ writer.write( XML_HEADER );
+ writer.write( "\n\n" );
+ writer.write( PARTIAL_COMPONENT_HEADER );
+ writeAttributes( writer, directive, "" );
+ writeBody( writer, directive, " " );
+ writer.write( "\n" );
+ writer.write( "</component>" );
+ writer.write( "\n" );
+ writer.flush();
+ output.close();
+ }
+
+ public void writeComponent(
+ Writer writer, ComponentDirective directive, String pad ) throws
IOException
+ {
+ writeTaggedComponent( writer, directive, null, pad );
+ }
+
+ public void writeTaggedComponent(
+ Writer writer, ComponentDirective directive, String key, String pad )
throws IOException
+ {
+ writer.write( "\n" + pad + "<component xmlns=\"" +
COMPONENT_SCHEMA_URN + "\"" );
+ if( null != key )
+ {
+ writer.write( " key=\"" + key + "\"" );
+ }
+ writer.write( "\n" + pad + " " );
+ writeAttributes( writer, directive, pad + " " );
+ writeBody( writer, directive, pad + " " );
+ writer.write( "\n" + pad + "</component>" );
+ }
+
+ void writeAttributes(
+ Writer writer, ComponentDirective directive, String pad ) throws
IOException
+ {
+ String classname = directive.getClassname();
+ writer.write( " class=\"" + classname + "\"" );
+ String name = directive.getName();
+ if( null != name )
+ {
+ writer.write( "\n" + pad + " name=\"" + name + "\"" );
+ }
+ LifestylePolicy lifestyle = directive.getLifestylePolicy();
+ if( null != lifestyle )
+ {
+ writer.write( "\n" + pad + " lifestyle=\"" + lifestyle.getName()
+ "\"" );
+ }
+ CollectionPolicy collection = directive.getCollectionPolicy();
+ if( null != collection )
+ {
+ writer.write( "\n" + pad + " collection=\"" +
collection.getName() + "\"" );
+ }
+ ActivationPolicy activation = directive.getActivationPolicy();
+ if( null != activation )
+ {
+ writer.write( "\n" + pad + " activation=\"" +
activation.getName() + "\"" );
+ }
+ writer.write( ">" );
+ }
+
+ void writeBody(
+ Writer writer, ComponentDirective directive, String pad ) throws
IOException
+ {
+ CategoriesDirective categories = directive.getCategoriesDirective();
+ ContextDirective context = directive.getContextDirective();
+ PartReference[] parts = directive.getPartReferences();
+ writeCategoriesDirective( writer, categories, pad );
+ writeContextDirective( writer, context, pad );
+ writeParts( writer, parts, pad );
+ }
+
+ private void writeCategoriesDirective(
+ Writer writer, CategoriesDirective categories, String pad ) throws
IOException
+ {
+ String name = categories.getName();
+ Priority priority = categories.getPriority();
+ String target = categories.getTarget();
+ CategoryDirective[] subCategories = categories.getCategories();
+
+ if( isaNullValue( name ) && isaNullPriority( priority ) &&
isaNullValue( target )
+ && ( subCategories.length == 0 ) )
+ {
+ return;
+ }
+
+ writer.write( "\n" + pad + "<categories" );
+ if( !isaNullValue( name ) )
+ {
+ writer.write( " name=\"" + name + "\"" );
+ }
+ if( !isaNullPriority( priority ) )
+ {
+ writer.write( " priority=\"" + priority.getName() + "\"" );
+ }
+ if( !isaNullValue( target ) )
+ {
+ writer.write( " target=\"" + target + "\"" );
+ }
+ if( subCategories.length == 0 )
+ {
+ writer.write( "/>" );
+ }
+ else
+ {
+ writer.write( ">" );
+ for( int i=0; i<subCategories.length; i++ )
+ {
+ CategoryDirective directive = subCategories[i];
+ if( directive instanceof CategoriesDirective )
+ {
+ CategoriesDirective c = (CategoriesDirective) directive;
+ writeCategoriesDirective( writer, c, pad + " " );
+ }
+ else
+ {
+ writeCategoryDirective( writer, directive, pad + " " );
+ }
+ }
+ writer.write( "\n" + pad + "</categories>" );
+ }
+ }
+
+ private boolean isaNullPriority( Priority priority )
+ {
+ if( null == priority )
+ {
+ return true;
+ }
+ else
+ {
+ return Priority.DEBUG.equals( priority );
+ }
+ }
+
+ private boolean isaNullValue( String value )
+ {
+ if( null == value )
+ {
+ return true;
+ }
+ else if( "".equals( value ) )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ private void writeCategoryDirective(
+ Writer writer, CategoryDirective category, String pad ) throws
IOException
+ {
+ String name = category.getName();
+ Priority priority = category.getPriority();
+ String target = category.getTarget();
+
+ writer.write( "\n" + pad + "<category" );
+ if( null != name )
+ {
+ writer.write( " name=\"" + name + "\"" );
+ }
+ if( null != priority )
+ {
+ writer.write( " priority=\"" + priority.getName() + "\"" );
+ }
+ if( null != target )
+ {
+ writer.write( " target=\"" + target + "\"" );
+ }
+ writer.write( "/>" );
+ }
+
+ private void writeContextDirective(
+ Writer writer, ContextDirective context, String pad ) throws
IOException
+ {
+ String classname = context.getClassname();
+ PartReference[] parts = context.getDirectives();
+
+ if( ( null == classname ) && ( parts.length == 0 ) )
+ {
+ return;
+ }
+
+ writer.write( "\n" + pad + "<context" );
+ if( null != classname )
+ {
+ writer.write( " class=\"" + classname + "\"" );
+ }
+ if( parts.length == 0 )
+ {
+ writer.write( "/>" );
+ }
+ else
+ {
+ writer.write( ">" );
+ writeContextEntries( writer, parts, pad + " " );
+ writer.write( "\n" + pad + "</context>" );
+ }
+ }
+
+ protected void writeParts(
+ Writer writer, PartReference[] parts, String pad ) throws IOException
+ {
+ if( parts.length == 0 )
+ {
+ return;
+ }
+ else
+ {
+ writer.write( "\n" + pad + "<parts>" );
+ writePartReferences( writer, parts, pad + " " );
+ writer.write( "\n" + pad + "</parts>" );
+ }
+ }
+
+ private void writePartReferences(
+ Writer writer, PartReference[] parts, String pad ) throws IOException
+ {
+ for( int i=0; i<parts.length; i++ )
+ {
+ PartReference ref = parts[i];
+ writePartReference( writer, ref, pad );
+ }
+ }
+
+ private void writeContextEntries(
+ Writer writer, PartReference[] parts, String pad ) throws IOException
+ {
+ for( int i=0; i<parts.length; i++ )
+ {
+ PartReference ref = parts[i];
+ writeContextEntry( writer, ref, pad );
+ }
+ }
+
+ private void writeContextEntry(
+ Writer writer, PartReference part, String pad ) throws IOException
+ {
+ String key = part.getKey();
+ if( null == key )
+ {
+ throw new IllegalStateException( "key" );
+ }
+ Directive directive = part.getDirective();
+ if( null == directive )
+ {
+ throw new IllegalStateException( "directive" );
+ }
+ if( directive instanceof ValueDirective )
+ {
+ ValueDirective value = (ValueDirective) directive;
+ writeEntry( writer, key, value, pad );
+ }
+ else if( directive instanceof LookupDirective )
+ {
+ LookupDirective value = (LookupDirective) directive;
+ writeLookupEntry( writer, key, value, pad );
+ }
+ else
+ {
+ String classname = directive.getClass().getName();
+ final String message = "WARNING: UNRECOGNIZED ENTRY: "+
classname;
+ System.out.println( "# " + message );
+ System.out.println( "# key: " + key );
+ System.out.println( "# class: " + classname );
+ writer.write( "\n" + pad + "<!-- " + message + " -->" );
+ writer.write( "\n" + pad + "<!-- " );
+ writer.write( "\n" + pad + "key: " + key );
+ writer.write( "\n" + pad + "class: " +
directive.getClass().getName() );
+ writer.write( "\n" + pad + "-->" );
+ }
+ }
+
+ private void writeLookupEntry(
+ Writer writer, String key, LookupDirective directive, String pad )
throws IOException
+ {
+ String classname = directive.getServiceClassname();
+ writer.write( "\n" + pad + "<entry key=\"" + key + "\" lookup=\"" +
classname + "\"/>" );
+ }
+
+ private void writePartReference(
+ Writer writer, PartReference part, String pad ) throws IOException
+ {
+ String key = part.getKey();
+ if( null == key )
+ {
+ throw new IllegalStateException( "key" );
+ }
+
+ Directive directive = part.getDirective();
+ if( null == directive )
+ {
+ throw new IllegalStateException( "directive" );
+ }
+ if( directive instanceof ComponentDirective )
+ {
+ ComponentDirective component = (ComponentDirective) directive;
+ writeTaggedComponent( writer, component, key, pad );
+ }
+ else
+ {
+ String classname = directive.getClass().getName();
+ final String error =
+ "Part reference class not recognized."
+ + "\nClass: " + classname;
+ throw new IllegalArgumentException( error );
+ }
+ }
+
+ protected void writeEntry( Writer writer, String key, ValueDirective
value, String pad ) throws IOException
+ {
+ String target = value.getTargetExpression();
+ String method = value.getMethodName();
+
+ writer.write( "\n" + pad + "<entry key=\"" + key + "\"" );
+ if( null != target )
+ {
+ writer.write( " class=\"" + target + "\"" );
+ }
+ if( null != method )
+ {
+ writer.write( " method=\"" + method + "\"" );
+ }
+ Value[] values = value.getValues();
+ if( values.length > 0 )
+ {
+ writer.write( ">" );
+ writeValues( writer, values, pad + " " );
+ writer.write( "\n" + pad + "</entry>" );
+ }
+ else
+ {
+ String v = value.getBaseValue();
+ if( null != v )
+ {
+ writer.write( " value=\"" + v + "\"" );
+ }
+ writer.write( "/>" );
+ }
+ }
+}

Added:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/TypeBuilder.java
===================================================================
--- trunk/main/metro/builder/src/main/net/dpml/metro/builder/TypeBuilder.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/builder/src/main/net/dpml/metro/builder/TypeBuilder.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,302 @@
+/*
+ * 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.builder;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Properties;
+
+import javax.xml.XMLConstants;
+
+import net.dpml.metro.info.Type;
+import net.dpml.metro.info.InfoDescriptor;
+import net.dpml.metro.info.ContextDescriptor;
+import net.dpml.metro.info.CategoryDescriptor;
+import net.dpml.metro.info.ServiceDescriptor;
+import net.dpml.metro.info.EntryDescriptor;
+import net.dpml.metro.info.PartReference;
+import net.dpml.metro.info.Descriptor;
+import net.dpml.metro.info.CollectionPolicy;
+import net.dpml.metro.info.LifestylePolicy;
+import net.dpml.metro.info.ThreadSafePolicy;
+import net.dpml.metro.info.Priority;
+import net.dpml.metro.data.ComponentDirective;
+
+import net.dpml.lang.Version;
+
+import net.dpml.lang.BuilderException;
+import net.dpml.part.DOM3DocumentBuilder;
+import net.dpml.part.ValueBuilder;
+
+import net.dpml.state.State;
+import net.dpml.state.impl.StateBuilder;
+import net.dpml.state.impl.DefaultState;
+
+import net.dpml.transit.util.ElementHelper;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.Document;
+
+
+/**
+ * Type builder.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class TypeBuilder extends TypeWriter
+{
+ private static final StateBuilder STATE_BUILDER = new StateBuilder();
+
+ private static DOM3DocumentBuilder BUILDER = new DOM3DocumentBuilder();
+
+ public Type loadType( Class subject ) throws IOException
+ {
+ String classname = subject.getName();
+ String path = classname.replace( '.', '/' );
+ String target = path + ".type";
+ ClassLoader classloader = subject.getClassLoader();
+ URL url = classloader.getResource( target );
+ if( null == url )
+ {
+ return Type.createType( subject );
+ }
+ else
+ {
+ try
+ {
+ URI uri = new URI( url.toString() );
+ return loadType( uri );
+ }
+ catch( URISyntaxException e )
+ {
+ final String error =
+ "Bad uri value."
+ + "\nURI: " + url;
+ IOException exception = new IOException( error );
+ exception.initCause( e );
+ throw exception;
+ }
+ }
+ }
+
+ public Type loadType( URI uri ) throws IOException
+ {
+ try
+ {
+ final Document document = BUILDER.parse( uri );
+ final Element root = document.getDocumentElement();
+ return buildType( root );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "An error while attempting to load a type."
+ + "\nType URI: " + uri;
+ IOException exception = new IOException( error );
+ exception.initCause( e );
+ throw exception;
+ }
+ }
+
+ private Type buildType( Element root ) throws Exception
+ {
+ InfoDescriptor info = buildNestedInfoDescriptor( root );
+ ServiceDescriptor[] services = buildNestedServices( root );
+ ContextDescriptor context = buildNestedContext( root );
+ CategoryDescriptor[] categories = buildNestedCategories( root );
+ State state = buildNestedState( root );
+ PartReference[] parts = buildNestedParts( root );
+ return new Type( info, categories, context, services, parts, state );
+ }
+
+ private InfoDescriptor buildNestedInfoDescriptor( Element root )
+ {
+ Element info = ElementHelper.getChild( root, "info" );
+ if( null == info )
+ {
+ final String error =
+ "Definition of <type> is missing the required <info> element.";
+ throw new BuilderException( root, error );
+ }
+
+ String name = ElementHelper.getAttribute( info, "name" );
+ String classname = ElementHelper.getAttribute( info, "class" );
+ String version = ElementHelper.getAttribute( info, "version" );
+ String collection = ElementHelper.getAttribute( info, "collection",
"system" );
+ String lifestyle = ElementHelper.getAttribute( info, "lifestyle",
"system" );
+ String threadsafe = ElementHelper.getAttribute( info, "threadsafe",
"unknown" );
+ Properties properties = buildNestedProperties( info );
+
+ return new InfoDescriptor(
+ name,
+ classname,
+ Version.getVersion( version ),
+ LifestylePolicy.parse( lifestyle ),
+ CollectionPolicy.parse( collection ),
+ ThreadSafePolicy.parse( threadsafe ),
+ properties );
+ }
+
+ private ServiceDescriptor[] buildNestedServices( Element root )
+ {
+ Element element = ElementHelper.getChild( root, "services" );
+ if( null == element )
+ {
+ return new ServiceDescriptor[0];
+ }
+ else
+ {
+ Element[] children = ElementHelper.getChildren( element,
"service" );
+ ServiceDescriptor[] services = new ServiceDescriptor[
children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ String classname = ElementHelper.getAttribute( child,
"class" );
+ String version = ElementHelper.getAttribute( child,
"version", "1.0.0" );
+ services[i] = new ServiceDescriptor( classname,
Version.getVersion( version ) );
+ }
+ return services;
+ }
+ }
+
+ private ContextDescriptor buildNestedContext( Element root )
+ {
+ Element context = ElementHelper.getChild( root, "context" );
+ if( null == context )
+ {
+ return new ContextDescriptor( new EntryDescriptor[0] );
+ }
+ else
+ {
+ Element[] children = ElementHelper.getChildren( context, "entry"
);
+ EntryDescriptor[] entries = new EntryDescriptor[ children.length
];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ String key = ElementHelper.getAttribute( child, "key" );
+ String classname = ElementHelper.getAttribute( child,
"class" );
+ boolean optional = ElementHelper.getBooleanAttribute( child,
"optional", false );
+ boolean isVolatile = ElementHelper.getBooleanAttribute(
child, "volatile", false );
+ entries[i] = new EntryDescriptor( key, classname, optional,
isVolatile );
+ }
+ return new ContextDescriptor( entries );
+ }
+ }
+
+ private CategoryDescriptor[] buildNestedCategories( Element root )
+ {
+ Element element = ElementHelper.getChild( root, "categories" );
+ if( null == element )
+ {
+ return new CategoryDescriptor[0];
+ }
+ else
+ {
+ Element[] children = ElementHelper.getChildren( element,
"category" );
+ CategoryDescriptor[] categories = new CategoryDescriptor[
children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element elem = children[i];
+ String name = ElementHelper.getAttribute( elem, "name" );
+ String priority = ElementHelper.getAttribute( elem,
"priority" );
+ Properties properties = buildNestedProperties( elem );
+ categories[i] = new CategoryDescriptor( name,
Priority.parse( priority ), properties );
+ }
+ return categories;
+ }
+ }
+
+ private State buildNestedState( Element root )
+ {
+ // ISSUE: selection does not support namespace resolution
+ // and will fail with something like <acme:state>
+
+ Element element = ElementHelper.getChild( root, "state" );
+ if( null == element )
+ {
+ return new DefaultState();
+ }
+ else
+ {
+ return STATE_BUILDER.buildStateGraph( element );
+ }
+ }
+
+ private PartReference[] buildNestedParts( Element root ) throws Exception
+ {
+ Element element = ElementHelper.getChild( root, "parts" );
+ if( null == element )
+ {
+ return new PartReference[0];
+ }
+ else
+ {
+ Element[] children = ElementHelper.getChildren( element );
+ if( children.length == 0 )
+ {
+ return new PartReference[0];
+ }
+ else
+ {
+ PartReference[] refs = new PartReference[ children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ refs[i] = buildPartReference( child );
+ }
+ return refs;
+ }
+ }
+ }
+
+ private PartReference buildPartReference( Element element ) throws
Exception
+ {
+ String key = ElementHelper.getAttribute( element, "key" );
+ ComponentDirective definition = COMPONENT_BUILDER.buildComponent(
element );
+ return new PartReference( key, definition );
+ }
+
+ private Properties buildNestedProperties( Element element )
+ {
+ Element[] entries = ElementHelper.getChildren( element, "property" );
+ if( entries.length == 0 )
+ {
+ return null;
+ }
+ else
+ {
+ Properties properties = new Properties();
+ for( int i=0; i<entries.length; i++ )
+ {
+ Element elem = entries[i];
+ String name = ElementHelper.getAttribute( elem, "name" );
+ String value = ElementHelper.getAttribute( elem, "value" );
+ properties.setProperty( name, value );
+ }
+ return properties;
+ }
+ }
+
+}
+

Added:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/TypeWriter.java
===================================================================
--- trunk/main/metro/builder/src/main/net/dpml/metro/builder/TypeWriter.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/builder/src/main/net/dpml/metro/builder/TypeWriter.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,248 @@
+/*
+ * 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.builder;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.XMLConstants;
+
+import net.dpml.metro.info.Type;
+import net.dpml.metro.info.InfoDescriptor;
+import net.dpml.metro.info.ContextDescriptor;
+import net.dpml.metro.info.CategoryDescriptor;
+import net.dpml.metro.info.ServiceDescriptor;
+import net.dpml.metro.info.EntryDescriptor;
+import net.dpml.metro.info.PartReference;
+import net.dpml.metro.info.Descriptor;
+
+import net.dpml.state.State;
+import net.dpml.state.impl.StateBuilder;
+
+import net.dpml.part.DOM3DocumentBuilder;
+import net.dpml.part.ValueWriter;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.Document;
+
+
+/**
+ * Type builder.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+//public class TypeWriter extends ComponentBuilder
+public class TypeWriter extends ValueWriter
+{
+ private static final String XML_HEADER =
+ "<?xml version=\"1.0\"?>";
+
+ private static final String PART_SCHEMA_URN = "@PART-XSD-URI@";
+ private static final String COMPONENT_SCHEMA_URN = "@COMPONENT-XSD-URI@";
+ private static final String TYPE_SCHEMA_URN = "@TYPE-XSD-URI@";
+
+ private static final StateBuilder STATE_BUILDER = new StateBuilder();
+
+ static final ComponentBuilder COMPONENT_BUILDER = new ComponentBuilder();
+
+ private static final String HEADER =
+ "<type xmlns=\""
+ + TYPE_SCHEMA_URN
+ + "\""
+ + "\n xmlns:xsi=\""
+ + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI
+ + "\"\n xmlns:part=\""
+ + PART_SCHEMA_URN
+ + "\"\n xmlns:type=\""
+ + TYPE_SCHEMA_URN
+ + "\"\n xmlns:component=\""
+ + COMPONENT_SCHEMA_URN
+ + "\">";
+
+ private static final String FOOTER = "</type>";
+
+ public void export( Type type, OutputStream output ) throws IOException
+ {
+ final Writer writer = new OutputStreamWriter( output );
+ writer.write( XML_HEADER );
+ writer.write( "\n\n" );
+ writer.write( HEADER );
+ writer.write( "\n" );
+ writeBody( writer, type, " " );
+ writer.write( "\n" );
+ writer.write( FOOTER );
+ writer.write( "\n" );
+ writer.flush();
+ output.close();
+ }
+
+ private void writeBody( Writer writer, Type type, String pad ) throws
IOException
+ {
+ writeTypeInfo( writer, type.getInfo(), pad );
+ writeTypeServices( writer, type.getServiceDescriptors(), pad );
+ writeTypeContext( writer, type.getContextDescriptor(), pad );
+ writeTypeCategories( writer, type.getCategoryDescriptors(), pad );
+ writeTypeState( writer, type.getStateGraph(), pad );
+ writeTypeParts( writer, type.getPartReferences(), pad );
+ }
+
+ private void writeTypeInfo( Writer writer, InfoDescriptor info, String
pad ) throws IOException
+ {
+ writer.write( "\n" + pad + "<info" );
+ writer.write( " name=\"" + info.getName() );
+ writer.write( "\"\n" + pad + " class=\"" + info.getClassname() );
+ writer.write( "\"\n" + pad + " version=\"" + info.getVersion() );
+ writer.write( "\"\n" + pad + " lifestyle=\"" +
info.getLifestyle().getName().toLowerCase() );
+ writer.write( "\"\n" + pad + " collection=\"" +
info.getCollectionPolicy().getName().toLowerCase() );
+ writer.write( "\"\n" + pad + " threadsafe=\"" +
info.getThreadSafePolicy().getName().toLowerCase() );
+ writer.write( "\"" );
+ if( info.getAttributeNames().length > 0 )
+ {
+ writer.write( ">" );
+ writeAttributes( writer, info, pad + " " );
+ writer.write( "\n" + pad + "</info>" );
+ }
+ else
+ {
+ writer.write( "/>" );
+ }
+ }
+
+ private void writeTypeServices( Writer writer, ServiceDescriptor[]
services, String pad ) throws IOException
+ {
+ if( services.length == 0 )
+ {
+ return;
+ }
+ else
+ {
+ writer.write( "\n" + pad + "<services>" );
+ for( int i=0; i<services.length; i++ )
+ {
+ ServiceDescriptor service = services[i];
+ writer.write( "\n" + pad + " <service" );
+ writer.write( " class=\"" + service.getClassname() );
+ writer.write( "\" version=\"" + service.getVersion() );
+ writer.write( "\"/>" );
+ }
+ writer.write( "\n" + pad + "</services>" );
+ }
+ }
+
+ private void writeTypeContext( Writer writer, ContextDescriptor context,
String pad ) throws IOException
+ {
+ EntryDescriptor[] entries = context.getEntryDescriptors();
+ if( entries.length > 0 )
+ {
+ writer.write( "\n" + pad + "<context>" );
+ for( int i=0; i<entries.length; i++ )
+ {
+ EntryDescriptor entry = entries[i];
+ writer.write( "\n" + pad + " <entry" );
+ writer.write( " key=\"" + entry.getKey() );
+ writer.write( "\" class=\"" + entry.getClassname() );
+ if( entry.isOptional() )
+ {
+ writer.write( "\" optional=\"true\"" );
+ }
+ else
+ {
+ writer.write( "\" optional=\"false\"" );
+ }
+ if( entry.isVolatile() )
+ {
+ writer.write( "\" volatile=\"true\"" );
+ }
+ writer.write( "/>" );
+ }
+ writer.write( "\n" + pad + "</context>" );
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void writeTypeCategories( Writer writer, CategoryDescriptor[]
categories, String pad ) throws IOException
+ {
+ if( categories.length > 0 )
+ {
+ writer.write( "\n" + pad + "<categories>" );
+ for( int i=0; i<categories.length; i++ )
+ {
+ CategoryDescriptor category = categories[i];
+ writer.write( "\n" + pad + " <category" );
+ writer.write( " name=\"" + category.getName() );
+ writer.write(
+ "\" priority=\""
+ + category.getDefaultPriority().getName().toLowerCase() );
+ writer.write( "\"" );
+
+ if( category.getAttributeNames().length > 0 )
+ {
+ writer.write( ">" );
+ writeAttributes( writer, category, pad + " " );
+ writer.write( "\n" + pad + " </category>" );
+ }
+ else
+ {
+ writer.write( "/>" );
+ }
+ }
+ writer.write( "\n" + pad + "</categories>" );
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ private void writeTypeState( Writer writer, State state, String pad )
throws IOException
+ {
+ STATE_BUILDER.writeState( writer, state, pad );
+ writer.write( "\n" );
+ }
+
+ private void writeTypeParts( Writer writer, PartReference[] parts,
String pad ) throws IOException
+ {
+ COMPONENT_BUILDER.writeParts( writer, parts, pad );
+ }
+
+ private void writeAttributes( Writer writer, Descriptor descriptor,
String pad ) throws IOException
+ {
+ String[] names = descriptor.getAttributeNames();
+ for( int i=0; i<names.length; i++ )
+ {
+ String name = names[i];
+ String value = descriptor.getAttribute( name, "" );
+ writer.write( "\n" + pad + "<property" );
+ writer.write( " name=\"" + name );
+ writer.write( "\" value=\"" + value );
+ writer.write( "\"/>" );
+ }
+ }
+}
+

Added:
trunk/main/metro/builder/src/test/net/dpml/metro/builder/LookupTestCase.java
===================================================================
---
trunk/main/metro/builder/src/test/net/dpml/metro/builder/LookupTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/builder/src/test/net/dpml/metro/builder/LookupTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,94 @@
+/*
+ * 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.metro.builder;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.BufferedInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.net.URI;
+
+import net.dpml.part.Directive;
+import net.dpml.transit.Value;
+
+import net.dpml.metro.info.PartReference;
+import net.dpml.metro.data.ContextDirective;
+import net.dpml.metro.data.ComponentDirective;
+import net.dpml.metro.data.LookupDirective;
+
+import junit.framework.TestCase;
+
+/**
+ * Default state machine test-case.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public class LookupTestCase extends TestCase
+{
+ private ComponentBuilder m_builder;
+
+ /**
+ * Testcase setup.
+ * @exception Exception if a setup error occurs
+ */
+ public void setUp() throws Exception
+ {
+ m_builder = new ComponentBuilder();
+ }
+
+ /**
+ * List the state graph.
+ * @exception Exception if an error occurs
+ */
+ public void testLookup() throws Exception
+ {
+ String testPath = System.getProperty( "project.test.dir" );
+ File test = new File( testPath );
+ File example = new File( test, "parts/lookup.xml" );
+ URI uri = example.toURI();
+ ComponentDirective component = m_builder.loadComponentDirective( uri
);
+ ContextDirective context = component.getContextDirective();
+ PartReference[] entries = context.getDirectives();
+ if( entries.length != 1 )
+ {
+ fail( "Invalid entries length - expected 1, found " +
entries.length );
+ }
+ else
+ {
+ PartReference entry = entries[0];
+ String key = entry.getKey();
+ Directive directive = entry.getDirective();
+ if( directive instanceof LookupDirective )
+ {
+ LookupDirective value = (LookupDirective) directive;
+ String classname = value.getServiceClassname();
+ assertNotNull( "classname", classname );
+ assertEquals( "classname", "acme.Widget", classname );
+ }
+ else
+ {
+ fail( "Expected LookupDirective, found " +
directive.getClass().getName() );
+ }
+ }
+ }
+}
+
+
+

Added:
trunk/main/metro/builder/src/test/net/dpml/metro/builder/MinimalTestCase.java
===================================================================
---
trunk/main/metro/builder/src/test/net/dpml/metro/builder/MinimalTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/builder/src/test/net/dpml/metro/builder/MinimalTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,71 @@
+/*
+ * 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.metro.builder;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.BufferedInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.net.URI;
+
+import net.dpml.part.Strategy;
+
+import net.dpml.metro.data.ComponentDirective;
+
+import junit.framework.TestCase;
+
+/**
+ * Default state machine test-case.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public class MinimalTestCase extends TestCase
+{
+ private ComponentBuilder m_builder;
+
+ /**
+ * Testcase setup.
+ * @exception Exception if a setup error occurs
+ */
+ public void setUp() throws Exception
+ {
+ m_builder = new ComponentBuilder();
+ }
+
+ public void testNothing()
+ {
+ }
+
+ /**
+ * List the state graph.
+ * @exception Exception if an error occurs
+ */
+ public void testComponentLoading() throws Exception
+ {
+ String testPath = System.getProperty( "project.test.dir" );
+ File test = new File( testPath );
+ File example = new File( test, "minimal-component.xml" );
+ URI uri = example.toURI();
+ ComponentDirective directive = m_builder.loadComponentDirective( uri
);
+ }
+}
+
+
+

Added:
trunk/main/metro/builder/src/test/net/dpml/metro/builder/PartsTestCase.java
===================================================================
---
trunk/main/metro/builder/src/test/net/dpml/metro/builder/PartsTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/builder/src/test/net/dpml/metro/builder/PartsTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,99 @@
+/*
+ * 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.metro.builder;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.BufferedInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.net.URI;
+
+import net.dpml.part.Directive;
+import net.dpml.transit.Value;
+
+import net.dpml.metro.info.PartReference;
+import net.dpml.metro.data.ContextDirective;
+import net.dpml.metro.data.ComponentDirective;
+import net.dpml.metro.data.ValueDirective;
+
+import junit.framework.TestCase;
+
+/**
+ * Default state machine test-case.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public class PartsTestCase extends TestCase
+{
+ private ComponentBuilder m_builder;
+
+ /**
+ * Testcase setup.
+ * @exception Exception if a setup error occurs
+ */
+ public void setUp() throws Exception
+ {
+ m_builder = new ComponentBuilder();
+ }
+
+ /**
+ * List the state graph.
+ * @exception Exception if an error occurs
+ */
+ public void testExampleOne() throws Exception
+ {
+ String testPath = System.getProperty( "project.test.dir" );
+ File test = new File( testPath );
+ File example = new File( test, "parts/array.xml" );
+ URI uri = example.toURI();
+ ComponentDirective component = m_builder.loadComponentDirective( uri
);
+ ContextDirective context = component.getContextDirective();
+ PartReference[] entries = context.getDirectives();
+ if( entries.length != 1 )
+ {
+ fail( "Invalid entries length - expected 1, found " +
entries.length );
+ }
+ else
+ {
+ PartReference entry = entries[0];
+ String key = entry.getKey();
+ Directive directive = entry.getDirective();
+ if( directive instanceof ValueDirective )
+ {
+ ValueDirective value = (ValueDirective) directive;
+ String base = value.getBaseValue();
+ String method = value.getMethodName();
+ String target = value.getTargetExpression();
+ Value[] values = value.getValues();
+ System.out.println( "# TARGET: " + target );
+ System.out.println( "# METHOD: " + method );
+ System.out.println( "# BASE: " + base );
+ System.out.println( "# VALUES: " + values.length );
+ }
+ else
+ {
+ fail( "Expected ValueDirective, found " +
directive.getClass().getName() );
+ }
+ }
+ }
+}
+
+
+

Added:
trunk/main/metro/builder/src/test/net/dpml/metro/builder/TypesTestCase.java
===================================================================
---
trunk/main/metro/builder/src/test/net/dpml/metro/builder/TypesTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/builder/src/test/net/dpml/metro/builder/TypesTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,86 @@
+/*
+ * 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.metro.builder;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.BufferedInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.net.URI;
+
+import net.dpml.part.Strategy;
+
+import net.dpml.metro.info.Type;
+import net.dpml.metro.info.ContextDescriptor;
+import net.dpml.metro.info.EntryDescriptor;
+import net.dpml.metro.info.PartReference;
+
+import junit.framework.TestCase;
+
+/**
+ * Default state machine test-case.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public class TypesTestCase extends TestCase
+{
+ private TypeBuilder m_builder;
+
+ /**
+ * Testcase setup.
+ * @exception Exception if a setup error occurs
+ */
+ public void setUp() throws Exception
+ {
+ m_builder = new TypeBuilder();
+ }
+
+ /**
+ * List the state graph.
+ * @exception Exception if an error occurs
+ */
+ public void testExampleOne() throws Exception
+ {
+ String testPath = System.getProperty( "project.test.dir" );
+ File test = new File( testPath );
+ File example = new File( test, "types/example-1.xml" );
+ URI uri = example.toURI();
+ Type type = m_builder.loadType( uri );
+ ContextDescriptor context = type.getContextDescriptor();
+ EntryDescriptor[] entries = context.getEntryDescriptors();
+ if( entries.length != 1 )
+ {
+ fail( "Invalid entries length - expected 1, found " +
entries.length );
+ }
+ else
+ {
+ EntryDescriptor entry = entries[0];
+ String key = entry.getKey();
+ String classname = entry.getClassname();
+ boolean optional = entry.isOptional();
+ assertEquals( "key", "color", key );
+ assertEquals( "classname", "java.awt.Color", classname );
+ assertFalse( "optional", optional );
+ }
+ }
+}
+
+
+

Modified: trunk/main/metro/exec/build.xml
===================================================================
--- trunk/main/metro/exec/build.xml 2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/exec/build.xml 2006-03-14 16:11:04 UTC (rev 1174)
@@ -9,7 +9,7 @@
<available property="metro.exe.available"
file="${dpml.system}/bin/metro.exe"/>

<target name="init" depends="standard.init">
- <x:filter feature="uri" type="plugin" token="COMPOSITION-CONTROLLER-URI"
+ <x:filter feature="uri" type="part" token="COMPOSITION-CONTROLLER-URI"
ref="dpml/metro/dpml-metro-runtime"/>
</target>


Modified: trunk/main/metro/exec/etc/bin/metro.lap
===================================================================
--- trunk/main/metro/exec/etc/bin/metro.lap 2006-03-14 16:05:36 UTC (rev
1173)
+++ trunk/main/metro/exec/etc/bin/metro.lap 2006-03-14 16:11:04 UTC (rev
1174)
@@ -4,6 +4,7 @@

-Djava.system.class.loader=net.dpml.transit.SystemClassLoader
-Djava.security.policy=${env.DPML_HOME}\share\bin\security.policy
+-Djava.endorsed.dirs=${env.DPML_HOME}\share\lib\endorsed
-Ddpml.depot.application=dpml.metro
-Djava.protocol.handler.pkgs=net.dpml.transit
-Djava.rmi.server.RMIClassLoaderSpi=net.dpml.depot.DepotRMIClassLoaderSpi

Modified: trunk/main/metro/model/build.xml
===================================================================
--- trunk/main/metro/model/build.xml 2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/model/build.xml 2006-03-14 16:11:04 UTC (rev 1174)
@@ -28,7 +28,7 @@
<x:filter feature="name" token="NAME"/>
<x:filter feature="version" token="VERSION"/>
<x:filter feature="group" token="GROUP"/>
- <x:filter key="dpml-metro-runtime" feature="uri" type="plugin"
token="PART-HANDLER-URI" />
+ <x:filter key="dpml-metro-runtime" feature="uri" type="part"
token="PART-HANDLER-URI" />
</target>

</project>

Modified: trunk/main/metro/model/src/main/net/dpml/metro/ComponentModel.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/ComponentModel.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/model/src/main/net/dpml/metro/ComponentModel.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -24,13 +24,14 @@

import net.dpml.metro.info.LifestylePolicy;
import net.dpml.metro.info.CollectionPolicy;
-import net.dpml.metro.data.ClassLoaderDirective;
import net.dpml.metro.data.CategoryDirective;

import net.dpml.configuration.Configuration;

import net.dpml.parameters.Parameters;

+import net.dpml.lang.Classpath;
+
/**
* The ComponentModel interface defines the remotely accessible aspects of a
component
* configuration.
@@ -64,12 +65,12 @@
String getImplementationClassName() throws RemoteException;

/**
- * Return the component classloader directive.
+ * Return the component classpath directive.
*
- * @return the classloader directive for the component
+ * @return the classpath directive for the component
* @exception RemoteException if a remote exception occurs
*/
- ClassLoaderDirective getClassLoaderDirective() throws RemoteException;
+ Classpath getClasspath() throws RemoteException;

/**
* Return the component lifestyle policy.

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/data/CategoriesDirectiveBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/CategoriesDirectiveBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/CategoriesDirectiveBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,50 +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.metro.data;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the CategoriesDirective class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class CategoriesDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a new bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
CategoriesDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"name", "priority",
"target", "categories"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/data/CategoryDirectiveBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/CategoryDirectiveBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/CategoryDirectiveBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,50 +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.metro.data;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the CategoryDirective class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class CategoryDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a new bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
CategoryDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"name", "priority",
"target"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/data/ClassLoaderDirective.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ClassLoaderDirective.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ClassLoaderDirective.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,143 +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.data;
-
-import java.io.Serializable;
-
-/**
- * Description of classloader.
- *
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ClassLoaderDirective implements Serializable
-{
- /**
- * Serial version identifier.
- */
- static final long serialVersionUID = 1L;
-
- private static final ClasspathDirective[] EMPTY_CLASSPATH_ARRAY = new
ClasspathDirective[0];
-
- /**
- * The classpath directives
- */
- private final ClasspathDirective[] m_classpaths;
-
- /**
- * Create a empty ClasspathDirective.
- */
- public ClassLoaderDirective()
- {
- this( EMPTY_CLASSPATH_ARRAY );
- }
-
- /**
- * Create a ClassLoaderDirective instance.
- *
- * @param classpaths an array of classpath directives
- */
- public ClassLoaderDirective( final ClasspathDirective[] classpaths )
- {
- if( classpaths == null )
- {
- m_classpaths = EMPTY_CLASSPATH_ARRAY;
- }
- else
- {
- for( int i=0; i<classpaths.length; i++ )
- {
- ClasspathDirective d = classpaths[i];
- if( null == d )
- {
- throw new NullPointerException( "classpaths (" + i + ")"
);
- }
- }
- m_classpaths = classpaths;
- }
- }
-
- /**
- * Return the set of classpath directives.
- *
- * @return the classpath directive array
- */
- public ClasspathDirective[] getClasspathDirectives()
- {
- return m_classpaths;
- }
-
- /**
- * Test this object for equality with the supplied object.
- * @param other the other object
- * @return true if the objects are equal
- */
- public boolean equals( Object other )
- {
- if( null == other )
- {
- return false;
- }
- else
- {
- if( other instanceof ClassLoaderDirective )
- {
- ClassLoaderDirective directive = (ClassLoaderDirective)
other;
- if( getClasspathDirectives().length !=
directive.getClasspathDirectives().length )
- {
- return false;
- }
- else
- {
- ClasspathDirective[] mine = getClasspathDirectives();
- ClasspathDirective[] yours =
directive.getClasspathDirectives();
- for( int i=0; i<mine.length; i++ )
- {
- ClasspathDirective m = mine[i];
- ClasspathDirective n = yours[i];
- if( !m.equals( n ) )
- {
- return false;
- }
- }
- return true;
- }
- }
- else
- {
- return false;
- }
- }
- }
-
- /**
- * Return the hashcode for the instance.
- * @return the instance hashcode
- */
- public int hashCode()
- {
- int hash = 633987582;
- for( int i=0; i<m_classpaths.length; i++ )
- {
- hash ^= m_classpaths[i].hashCode();
- }
- return hash;
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/data/ClassLoaderDirectiveBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ClassLoaderDirectiveBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ClassLoaderDirectiveBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,50 +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.metro.data;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the ClassLoaderDirective class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ClassLoaderDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a new bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
ClassLoaderDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new
String[]{"classpathDirectives"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/data/ClasspathDirective.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ClasspathDirective.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ClasspathDirective.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,161 +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.data;
-
-import java.io.Serializable;
-import java.net.URI;
-
-import net.dpml.lang.Category;
-
-/**
- * Description of classpath.
- *
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ClasspathDirective implements Serializable
-{
- /**
- * Serial version identifier.
- */
- static final long serialVersionUID = 1L;
-
- private static final URI[] EMPTY_URIS = new URI[0];
-
- /**
- * The resource references
- */
- private final URI[] m_uris;
-
- /**
- * The resource references
- */
- private final Category m_category;
-
- /**
- * Create a ClasspathDirective instance.
- * @param category the classpath category
- * @param uris the set of artifact uris
- */
- public ClasspathDirective( final Category category, final URI[] uris )
- {
- m_category = category;
- if( uris == null )
- {
- m_uris = EMPTY_URIS;
- }
- else
- {
- m_uris = uris;
- }
- }
-
- /**
- * Return the category name.
- * @return the category name
- */
- public Category getCategory()
- {
- return m_category;
- }
-
- /**
- * Return the default status of this directive. If TRUE
- * the enclosed repository and fileset directives are empty.
- * @return true if the classpath directive is empty
- */
- public boolean isEmpty()
- {
- final int n = m_uris.length;
- return n == 0;
- }
-
- /**
- * Return the set of artifact directives.
- *
- * @return the artifact directive set
- */
- public URI[] getURIs()
- {
- return m_uris;
- }
-
- /**
- * Test this object for equality with the supplied object.
- * @param other the other object
- * @return true if the objects are equal
- */
- public boolean equals( Object other )
- {
- if( null == other )
- {
- return false;
- }
- else
- {
- if( other instanceof ClasspathDirective )
- {
- ClasspathDirective directive = (ClasspathDirective) other;
- if( !getCategory().equals( directive.getCategory() ) )
- {
- return false;
- }
- else if( getURIs().length != directive.getURIs().length )
- {
- return false;
- }
- else
- {
- URI[] myUris = getURIs();
- URI[] yourURIs = directive.getURIs();
- for( int i=0; i<myUris.length; i++ )
- {
- URI m = myUris [i];
- URI n = yourURIs[i];
- if( !m.equals( n ) )
- {
- return false;
- }
- }
- return true;
- }
- }
- else
- {
- return false;
- }
- }
- }
-
- /**
- * Return the hashcode for the instance.
- * @return the instance hashcode
- */
- public int hashCode()
- {
- int hash = m_category.hashCode();
- for( int i=0; i<m_uris.length; i++ )
- {
- hash ^= m_uris[i].hashCode();
- }
- return hash;
- }
-
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/data/ClasspathDirectiveBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ClasspathDirectiveBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ClasspathDirectiveBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,50 +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.metro.data;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the ClasspathDirective class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ClasspathDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a new bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
ClasspathDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"category", "URIs"} )
);
- return descriptor;
- }
-}

Modified:
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirective.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirective.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirective.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -166,7 +166,7 @@
CollectionPolicy.SYSTEM,
LifestylePolicy.TRANSIENT,
classname,
- null, null, null, null, null, null );
+ null, null, null, null, null );
}

/**
@@ -186,7 +186,6 @@
template.getContextDirective(),
template.getParameters(),
template.getConfiguration(),
- template.getClassLoaderDirective(),
template.getPartReferences() );
}

@@ -214,10 +213,9 @@
final ContextDirective context,
final Parameters parameters,
final Configuration config,
- final ClassLoaderDirective classloader,
final PartReference[] parts )
{
- super( name, activation, categories, classloader, parts );
+ super( name, activation, categories, parts );

if( null == classname )
{

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirectiveBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirectiveBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ComponentDirectiveBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,82 +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.metro.data;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.Encoder;
-import java.beans.Expression;
-
-/**
- * BeanInfo for the ContextDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ComponentDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a new bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
ComponentDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new ComponentDirectivePersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * The persistence delegate.
- */
- private static class ComponentDirectivePersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return the expression.
- * @param old the old instance
- * @param encoder the XML encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- ComponentDirective directive = (ComponentDirective) old;
- Object[] args = new Object[11];
- args[0] = directive.getName();
- args[1] = directive.getActivationPolicy();
- args[2] = directive.getCollectionPolicy();
- args[3] = directive.getLifestylePolicy();
- args[4] = directive.getClassname();
- args[5] = directive.getCategoriesDirective();
- args[6] = directive.getContextDirective();
- args[7] = directive.getParameters();
- args[8] = directive.getConfiguration();
- args[9] = directive.getClassLoaderDirective();
- args[10] = directive.getPartReferences();
- return new Expression( old, old.getClass(), "new", args );
- }
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/data/ContextDirectiveBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ContextDirectiveBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ContextDirectiveBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,50 +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.metro.data;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the ContextDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ContextDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a new bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
ContextDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"classname",
"directives"} ) );
- return descriptor;
- }
-}

Modified:
trunk/main/metro/model/src/main/net/dpml/metro/data/DeploymentDirective.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/DeploymentDirective.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/DeploymentDirective.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -42,9 +42,6 @@
private static final CategoriesDirective EMPTY_CATEGORIES =
new CategoriesDirective();

- private static final ClassLoaderDirective EMPTY_CLASSLOADER_DIRECTIVE =
- new ClassLoaderDirective();
-

//--------------------------------------------------------------------------
// state

//--------------------------------------------------------------------------
@@ -65,11 +62,6 @@
*/
private final CategoriesDirective m_categories;

- /**
- * The classpath directive.
- */
- private final ClassLoaderDirective m_classloader;
-

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

//--------------------------------------------------------------------------
@@ -79,12 +71,10 @@
* @param name the profile name
* @param activation the activation policy
* @param categories logging category directives
- * @param classloader the classloader directive
* @param parts the internal component parts
*/
public DeploymentDirective(
- final String name, ActivationPolicy activation, CategoriesDirective
categories,
- ClassLoaderDirective classloader, PartReference[] parts )
+ final String name, ActivationPolicy activation, CategoriesDirective
categories, PartReference[] parts )
{
super( parts );

@@ -99,38 +89,32 @@
m_categories = categories;
}

- if( name == null )
+ if( null != name )
{
- m_name = "untitled";
+ if( name.indexOf( " " ) > 0 || name.indexOf( "." ) > 0 ||
name.indexOf( "," ) > 0
+ || name.indexOf( "/" ) > 0 )
+ {
+ final String error =
+ "Directive name ["
+ + name
+ + "] contains an illegal character (' ', ',', or '.')";
+ throw new IllegalArgumentException( error );
+ }
+ else if( name.length() == 0 )
+ {
+ final String error =
+ "Directive name [] is not sufficiently descriptor.";
+ throw new IllegalArgumentException( error );
+ }
+ else
+ {
+ m_name = name;
+ }
}
- else if( name.indexOf( " " ) > 0 || name.indexOf( "." ) > 0 ||
name.indexOf( "," ) > 0
- || name.indexOf( "/" ) > 0 )
- {
- final String error =
- "Directive name ["
- + name
- + "] contains an illegal character (' ', ',', or '.')";
- throw new IllegalArgumentException( error );
- }
- else if( name.length() == 0 )
- {
- final String error =
- "Directive name [] is not sufficiently descriptor.";
- throw new IllegalArgumentException( error );
- }
else
{
- m_name = name;
+ m_name = null;
}
-
- if( null == classloader )
- {
- m_classloader = EMPTY_CLASSLOADER_DIRECTIVE;
- }
- else
- {
- m_classloader = classloader;
- }
}


//--------------------------------------------------------------------------
@@ -171,17 +155,6 @@
}

/**
- * Return the classloader directive that describes the creation
- * arguments for the classloader required by this profile.
- *
- * @return the classloader directive
- */
- public ClassLoaderDirective getClassLoaderDirective()
- {
- return m_classloader;
- }
-
- /**
* Returns a string representation of the profile.
* @return a string representation
*/
@@ -226,13 +199,9 @@
{
return false;
}
- else if( !m_categories.equals(
profile.getCategoriesDirective() ) )
- {
- return false;
- }
else
{
- return m_classloader.equals(
profile.getClassLoaderDirective() );
+ return m_categories.equals(
profile.getCategoriesDirective() ) ;
}
}
else
@@ -252,7 +221,6 @@
hash ^= m_name.hashCode();
hash ^= m_activation.hashCode();
hash ^= m_categories.hashCode();
- hash ^= m_classloader.hashCode();
return hash;
}
}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/data/FeatureDirectiveBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/FeatureDirectiveBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/FeatureDirectiveBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,50 +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.metro.data;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the ContextDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class FeatureDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
FeatureDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"key", "feature"} ) );
- return descriptor;
- }
-}

Copied:
trunk/main/metro/model/src/main/net/dpml/metro/data/LookupDirective.java
(from rev 1167,
trunk/main/metro/model/src/main/net/dpml/metro/data/ReferenceDirective.java)
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ReferenceDirective.java
2006-03-05 11:48:22 UTC (rev 1167)
+++ trunk/main/metro/model/src/main/net/dpml/metro/data/LookupDirective.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,102 @@
+/*
+ * 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.data;
+
+import java.net.URI;
+
+import net.dpml.part.Directive;
+
+/**
+ * A reference directive is a reference to a part within the enclosing part's
+ * context or parts.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class LookupDirective extends AbstractDirective implements
Directive
+{
+ /**
+ * Serial version identifier.
+ */
+ static final long serialVersionUID = 1L;
+
+ /**
+ * The container scoped key.
+ */
+ private final String m_classname;
+
+ /**
+ * Creation of a new lookup directive.
+ * @param spec the lookup reference
+ * @exception NullPointerException if the uri argument is null.
+ */
+ public LookupDirective( final String classname )
+ throws NullPointerException
+ {
+ if( null == classname )
+ {
+ throw new NullPointerException( "classname" );
+ }
+ m_classname = classname;
+ }
+
+ /**
+ * Return the service classname.
+ *
+ * @return the classname
+ */
+ public String getServiceClassname()
+ {
+ return m_classname;
+ }
+
+ /**
+ * Test if the supplied object is equal to this object.
+ * @param other the object to compare with this instance
+ * @return TRUE if the supplied object is equal to this object
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ if( other instanceof LookupDirective )
+ {
+ LookupDirective directive = (LookupDirective) other;
+ return m_classname.equals( directive.m_classname );
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ return m_classname.hashCode();
+ }
+}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/data/ReferenceDirective.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ReferenceDirective.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ReferenceDirective.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,107 +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.data;
-
-import java.net.URI;
-
-import net.dpml.part.Directive;
-
-/**
- * A reference directive is a reference to a part within the enclosing part's
- * context or parts.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ReferenceDirective extends AbstractDirective implements
Directive
-{
- /**
- * Serial version identifier.
- */
- static final long serialVersionUID = 1L;
-
- /**
- * The container scoped key.
- */
- private final URI m_uri;
-
- /**
- * Creation of a new entry directive.
- * @param uri a uri referencing a a part in an enclosing container
- * @exception NullPointerException if the uri argument is null.
- */
- public ReferenceDirective( final URI uri )
- throws NullPointerException
- {
- if( null == uri )
- {
- throw new NullPointerException( "uri" );
- }
- m_uri = uri;
- }
-
-
//--------------------------------------------------------------------------
- // ImportDirective
-
//--------------------------------------------------------------------------
-
- /**
- * Return the uri reference.
- *
- * @return the uri
- */
- public URI getURI()
- {
- return m_uri;
- }
-
- /**
- * Test if the supplied object is equal to this object.
- * @param other the object to compare with this instance
- * @return TRUE if the supplied object is equal to this object
- */
- public boolean equals( Object other )
- {
- if( null == other )
- {
- return false;
- }
- else
- {
- if( other instanceof ReferenceDirective )
- {
- ReferenceDirective directive = (ReferenceDirective) other;
- return m_uri.equals( directive.getURI() );
- }
- else
- {
- return false;
- }
- }
- }
-
- /**
- * Return the hashcode for the instance.
- * @return the instance hashcode
- */
- public int hashCode()
- {
- int hash = m_uri.hashCode();
- return hash;
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/data/ReferenceDirectiveBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ReferenceDirectiveBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ReferenceDirectiveBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,50 +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.metro.data;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the ContextDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ReferenceDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
ReferenceDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"URI"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/data/ValueDirectiveBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/data/ValueDirectiveBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/data/ValueDirectiveBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,82 +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.metro.data;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.Encoder;
-import java.beans.Expression;
-
-/**
- * BeanInfo for the ContextDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ValueDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( ValueDirective.class
);
- descriptor.setValue(
- "persistenceDelegate",
- //new DefaultPersistenceDelegate( new String[]{ "construct" } ) );
- new ValueDirectivePersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate implementation.
- */
- private static class ValueDirectivePersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return the expression value.
- * @param old the old instance
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- ValueDirective construct = (ValueDirective) old;
- Object[] args = new Object[3];
- args[0] = construct.getTargetExpression();
- args[1] = construct.getMethodName();
- if( construct.isCompound() )
- {
- args[2] = construct.getValues();
- }
- else
- {
- args[2] = construct.getBaseValue();
- }
- return new Expression( old, old.getClass(), "new", args );
- }
- }
-}

Modified:
trunk/main/metro/model/src/main/net/dpml/metro/info/CategoryDescriptor.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/CategoryDescriptor.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/CategoryDescriptor.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -44,7 +44,7 @@
/**
* Default priority value.
*/
- public static final Priority PRIORITY = Priority.INFO;
+ public static final Priority PRIORITY = Priority.DEBUG;


private final String m_name;
@@ -68,13 +68,15 @@
{
throw new NullPointerException( "name" );
}
+ m_name = name;
if( null == priority )
{
- throw new NullPointerException( "priority" );
+ m_priority = PRIORITY;
}
-
- m_name = name;
- m_priority = priority;
+ else
+ {
+ m_priority = priority;
+ }
}

/**

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/info/CategoryDescriptorBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/CategoryDescriptorBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/CategoryDescriptorBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,50 +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.metro.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the CategoryDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class CategoryDescriptorBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
CategoryDescriptor.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"name",
"defaultPriority", "properties"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/info/CollectionPolicyBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/CollectionPolicyBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/CollectionPolicyBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,73 +0,0 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 1999-2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.metro.info;
-
-import java.beans.Expression;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.SimpleBeanInfo;
-import java.beans.Encoder;
-
-/**
- * BeanInfo that declares a specialized persistence delegate for the
collection policy class.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class CollectionPolicyBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
CollectionPolicy.class );
- descriptor.setValue(
- "persistenceDelegate",
- new CollectionPolicyPersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate implementation.
- */
- private static class CollectionPolicyPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return the expression value.
- * @param old the old instance
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- CollectionPolicy policy = (CollectionPolicy) old;
- return new Expression( policy, CollectionPolicy.class, "parse",
new Object[]{policy.getName()} );
- }
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/info/ContextDescriptorBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/ContextDescriptorBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/ContextDescriptorBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,50 +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.metro.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the ContextDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ContextDescriptorBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
ContextDescriptor.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"entryDescriptors"} )
);
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/info/EncodingException.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/EncodingException.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/EncodingException.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,48 +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.metro.info;
-
-/**
- * Exception throw if an error occurs during the encoding of a component
type.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class EncodingException extends Exception
-{
- private final Exception[] m_errors;
-
- /**
- * Creation of a new encoding exception.
- * @param message the exception message
- * @param errors an array of errors
- */
- public EncodingException( String message, Exception[] errors )
- {
- super( message );
-
- m_errors = errors;
- }
-
- /**
- * Return the array of errors.
- * @return the error array
- */
- public Exception[] getExceptions()
- {
- return m_errors;
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/info/EntryDescriptorBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/EntryDescriptorBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/EntryDescriptorBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,50 +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.metro.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the EntryDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class EntryDescriptorBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
EntryDescriptor.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"key", "classname",
"optional", "volatile"} ) );
- return descriptor;
- }
-}

Modified:
trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptor.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptor.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptor.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -21,7 +21,7 @@

import java.util.Properties;

-import net.dpml.part.Version;
+import net.dpml.lang.Version;

/**
* This class is used to provide explicit information to assembler

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptorBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptorBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptorBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,77 +0,0 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 1999-2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.dpml.metro.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.Expression;
-import java.beans.Encoder;
-
-/**
- * Bean info for the InfoDescriptor class.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class InfoDescriptorBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( InfoDescriptor.class
);
- descriptor.setValue( "persistenceDelegate", new
InfoDescriptorPersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate implementation.
- */
- private static class InfoDescriptorPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return the expression value.
- * @param old the old instance
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- InfoDescriptor info = (InfoDescriptor) old;
-
- Object[] args = new Object[ 7 ];
- args[0] = info.getName();
- args[1] = info.getClassname();
- args[2] = info.getVersion();
- args[3] = info.getLifestyle();
- args[4] = info.getCollectionPolicy();
- args[5] = info.getThreadSafePolicy();
- args[6] = info.getProperties();
- return new Expression( old, old.getClass(), "new", args );
- }
- }
-
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/info/LifestylePolicyBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/LifestylePolicyBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/LifestylePolicyBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,73 +0,0 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 1999-2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.metro.info;
-
-import java.beans.Expression;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.SimpleBeanInfo;
-import java.beans.Encoder;
-
-/**
- * Bean info for state encoding of the Lifestyle policy enumeration.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class LifestylePolicyBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
LifestylePolicy.class );
- descriptor.setValue(
- "persistenceDelegate",
- new LifestylePolicyPersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate implementation.
- */
- private static class LifestylePolicyPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return the expression value.
- * @param old the old instance
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- LifestylePolicy policy = (LifestylePolicy) old;
- return new Expression( policy, LifestylePolicy.class, "parse",
new Object[]{policy.getName()} );
- }
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/info/PartReferenceBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/PartReferenceBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/PartReferenceBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,49 +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.metro.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the Partreference class that declares a persistence delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class PartReferenceBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( PartReference.class
);
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"key", "directive"} )
);
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/info/PriorityBeanInfo.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/info/PriorityBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/model/src/main/net/dpml/metro/info/PriorityBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,73 +0,0 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 1999-2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.metro.info;
-
-import java.beans.Expression;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.SimpleBeanInfo;
-import java.beans.Encoder;
-
-/**
- * Bean info for state encoding of the logging priority enumeration.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class PriorityBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( Priority.class );
- descriptor.setValue(
- "persistenceDelegate",
- new PriorityPersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate implementation.
- */
- private static class PriorityPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return the expression value.
- * @param old the old instance
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- Priority priority = (Priority) old;
- return new Expression( priority, Priority.class, "parse", new
Object[]{priority.getName()} );
- }
- }
-}

Modified:
trunk/main/metro/model/src/main/net/dpml/metro/info/ServiceDescriptor.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/ServiceDescriptor.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/ServiceDescriptor.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -20,7 +20,7 @@

import java.io.Serializable;

-import net.dpml.part.Version;
+import net.dpml.lang.Version;

/**
* This ServiceDescriptor defines the interface and service version

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/info/ServiceDescriptorBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/ServiceDescriptorBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/ServiceDescriptorBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,50 +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.metro.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the ServiceDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ServiceDescriptorBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
ServiceDescriptor.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"classname",
"version"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/model/src/main/net/dpml/metro/info/ThreadSafePolicyBeanInfo.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/ThreadSafePolicyBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/ThreadSafePolicyBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,73 +0,0 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 1999-2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.metro.info;
-
-import java.beans.Expression;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.SimpleBeanInfo;
-import java.beans.Encoder;
-
-/**
- * BeanInfo that declares a specialized persistence delegate for the
collection policy class.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ThreadSafePolicyBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
ThreadSafePolicy.class );
- descriptor.setValue(
- "persistenceDelegate",
- new ThreadSafePolicyPersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate implementation.
- */
- private static class ThreadSafePolicyPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return the expression value.
- * @param old the old instance
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- ThreadSafePolicy policy = (ThreadSafePolicy) old;
- return new Expression( policy, ThreadSafePolicy.class, "parse",
new Object[]{policy.getName()} );
- }
- }
-}

Modified: trunk/main/metro/model/src/main/net/dpml/metro/info/Type.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/info/Type.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/model/src/main/net/dpml/metro/info/Type.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -56,214 +56,7 @@
public class Type extends Composite implements Serializable
{
static final long serialVersionUID = 1L;
-
- private static final Type OBJECT_TYPE = createObjectType();

- /**
- * Encode a type to an output stream.
- * @param type the type instance
- * @param output the output stream
- * @exception IOException if an I/O error occurs
- * @exception EncodingException if an encododing error occurs
- */
- public static void encode( final Type type, final OutputStream output )
- throws IOException, EncodingException
- {
- XMLEncoder encoder = new XMLEncoder( output );
- encoder.setExceptionListener( new TypeEncoderListener( type ) );
- encoder.setPersistenceDelegate( URI.class, new
URIPersistenceDelegate() );
- try
- {
- encoder.writeObject( type );
- }
- finally
- {
- encoder.close();
- }
- }
-
- /**
- * Encoding exception listener.
- */
- private static final class TypeEncoderListener implements
ExceptionListener
- {
- private Type m_type;
-
- /**
- * Creation of a new encoding listener.
- * @param type the type instance that is being encoded
- */
- private TypeEncoderListener( Type type )
- {
- m_type = type;
- }
-
- /**
- * Catch an encoding exception.
- * @param e the encoding exception
- */
- public void exceptionThrown( Exception e )
- {
- Throwable cause = e.getCause();
- if( null != cause )
- {
- if( cause instanceof EncodingRuntimeException )
- {
- EncodingRuntimeException ere =
(EncodingRuntimeException) cause;
- throw ere;
- }
- else
- {
- final String error =
- "An error occured while attempting to encode the type
["
- + m_type.getInfo().getClassname()
- + "]\nCause: " + cause.toString();
- throw new EncodingRuntimeException( error, cause );
- }
- }
- else
- {
- final String error =
- "An unexpected error occured while attempting to encode
the type ["
- + m_type.getInfo().getClassname()
- + "] due to: " + e.toString();
- throw new EncodingRuntimeException( error, e );
- }
- }
- }
-
- /**
- * EncodingRuntimeException.
- */
- private static class EncodingRuntimeException extends RuntimeException
- {
- /**
- * Creation of a new <tt>EncodingRuntimeException</tt>.
- * @param message the exception message
- * @param cause the causal exception
- */
- public EncodingRuntimeException( String message, Throwable cause )
- {
- super( message, cause );
- }
- }
-
- /**
- * Decode a type corresponding to the supplied class.
- * @param clazz the class from which to load the type definition
- * @return the decoded type
- * @exception IOException if an I/O error occurs
- */
- public static Type decode( Class clazz ) throws IOException
- {
- ClassLoader context = Type.class.getClassLoader();
- return decode( context, clazz );
- }
-
- /**
- * Decode a type.
- * @param context the context classloader
- * @param clazz the class
- * @return the decoded type
- * @exception IOException if an I/O error occurs
- */
- public static Type decode( ClassLoader context, Class clazz ) throws
IOException
- {
- String path = clazz.getName().replace( '.', '/' ) + ".type";
- URL url = clazz.getClassLoader().getResource( path );
- if( null == url )
- {
- // no component type defined ..
- // create a default type definition
- return createType( clazz );
- }
- else
- {
- try
- {
- InputStream input = url.openStream();
- return decode( context, input );
- }
- catch( IOException e )
- {
- throw e;
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error occured while attempting to load an
encoded type."
- + "\nResource path: " + path;
- IOException ioe = new IOException( error );
- ioe.initCause( e );
- throw ioe;
- }
- }
- }
-
- /**
- * Decode a type from an input stream.
- * @param input the input stream
- * @return the decoded type
- * @exception IOException if an I/O error occurs
- */
- public static Type decode( InputStream input ) throws IOException
- {
- ClassLoader context = Type.class.getClassLoader();
- return decode( context, input );
- }
-
- /**
- * Decode a type from an input stream.
- * @param context the context classloader
- * @param input the input stream
- * @return the decoded type
- * @exception IOException if an I/O error occurs
- */
- public static Type decode( ClassLoader context, InputStream input )
throws IOException
- {
- final ClassLoader loader =
Thread.currentThread().getContextClassLoader();
-
- try
- {
- Thread.currentThread().setContextClassLoader( context );
- XMLDecoder decoder = new XMLDecoder( new BufferedInputStream(
input ) );
- return (Type) decoder.readObject();
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error occured while attempting to load an encoded
type.";
- IOException ioe = new IOException( error );
- ioe.initCause( e );
- throw ioe;
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( loader );
- input.close();
- }
- }
-
- /**
- * Persistence delegate for a URI.
- */
- private static class URIPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return the expression value.
- * @param old the old instance
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- URI uri = (URI) old;
- String spec = uri.toString();
- Object[] args = new Object[]{spec};
- return new Expression( old, old.getClass(), "new", args );
- }
- }
-
private final InfoDescriptor m_info;
private final CategoryDescriptor[] m_categories;
private final ContextDescriptor m_context;
@@ -434,16 +227,6 @@
}

/**
- * Returns the default configuration supplied with the type.
- *
- * @return the default configuration or null if no packaged defaults
- */
- //public Configuration getConfiguration()
- //{
- // return m_configuration;
- //}
-
- /**
* Return a string representation of the type.
* @return the stringified type
*/
@@ -520,13 +303,8 @@
return hash;
}

- private static Type createObjectType()
+ public static Type createType( Class clazz )
{
- return createType( Object.class );
- }
-
- private static Type createType( Class clazz )
- {
final InfoDescriptor info = new InfoDescriptor( "object",
clazz.getName() );
final CategoryDescriptor[] loggers = new CategoryDescriptor[0];
final ContextDescriptor context = new ContextDescriptor( new
EntryDescriptor[0] );

Deleted: trunk/main/metro/model/src/main/net/dpml/metro/info/TypeBeanInfo.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/info/TypeBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/model/src/main/net/dpml/metro/info/TypeBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,53 +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.metro.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the CategoryDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class TypeBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( Type.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate(
- new String[]{
- "info", "categoryDescriptors", "contextDescriptor",
- "serviceDescriptors", "partReferences", "stateGraph"} ) );
- return descriptor;
- }
-}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/AbstractEncodingTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/AbstractEncodingTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/AbstractEncodingTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -19,6 +19,10 @@
package net.dpml.metro.data.test;

import java.io.File;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
@@ -46,72 +50,22 @@
/**
* Execution of an encoding test.
* @param object the object encode/decode
- * @param filename the filename to use when encoding the object
* @return the decoded object
* @exception Exception if an error occurs
*/
- public Object executeEncodingTest( Object object, String filename )
throws Exception
+ public Object executeEncodingTest( Object object ) throws Exception
{
- String base = System.getProperty( "project.test.dir" );
- File test = new File( base );
- File destination = new File( test, filename );
- FileOutputStream output = new FileOutputStream( destination );
- BufferedOutputStream buffer = new BufferedOutputStream( output );
- ClassLoader current = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(
ComponentDirective.class.getClassLoader() );
- XMLEncoder encoder = new XMLEncoder( buffer );
- encoder.setPersistenceDelegate( URI.class, new
URIPersistenceDelegate() );
- encoder.setExceptionListener(
- new ExceptionListener()
- {
- public void exceptionThrown( Exception e )
- {
- e.printStackTrace();
- fail( "encoding exception: " + e.toString() );
- }
- }
- );
- try
- {
- encoder.writeObject( object );
- }
- finally
- {
- encoder.close();
- }
-
- FileInputStream input = new FileInputStream( destination );
- try
- {
- XMLDecoder decoder = new XMLDecoder( new BufferedInputStream(
input ) );
- Object result = decoder.readObject();
- assertEquals( "encoding-equality", object, result );
- return result;
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( current );
- }
+ ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
+ ObjectOutputStream output = new ObjectOutputStream( byteOutputStream
);
+ output.writeObject( object );
+ output.close();
+ ByteArrayInputStream byteInputStream = new ByteArrayInputStream(
byteOutputStream.toByteArray() );
+ ObjectInputStream input = new ObjectInputStream( byteInputStream );
+ Object serialized = input.readObject();
+ input.close();
+ assertTrue( "!=", object != serialized ); // Ensure this is not the
same instance
+ assertEquals( "equals", object, serialized );
+ assertEquals( "hash", object.hashCode(), serialized.hashCode() );
+ return serialized;
}
-
- /**
- * Utility class that handles uri encoding.
- */
- public static class URIPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return an expression supporting creation of a uri.
- * @param old the old instance
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- URI uri = (URI) old;
- String spec = uri.toString();
- Object[] args = new Object[]{spec};
- return new Expression( old, old.getClass(), "new", args );
- }
- }
-
}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/CategoriesDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/CategoriesDirectiveTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/CategoriesDirectiveTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -124,7 +124,7 @@
public void testEncoding() throws Exception
{
CategoryDirective result =
- (CategoryDirective) executeEncodingTest( m_directive,
"categories-directive.xml" );
+ (CategoryDirective) executeEncodingTest( m_directive );
assertEquals( "encoded-equality", m_directive, result );
}
}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/CategoryDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/CategoryDirectiveTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/CategoryDirectiveTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -116,7 +116,7 @@
public void testEncoding() throws Exception
{
CategoryDirective result =
- (CategoryDirective) executeEncodingTest( m_directive,
"category-directive.xml" );
+ (CategoryDirective) executeEncodingTest( m_directive );
assertEquals( "encoded-equality", m_directive, result );
}
}

Deleted:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClassLoaderDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClassLoaderDirectiveTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClassLoaderDirectiveTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,74 +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.data.test;
-
-import java.net.URI;
-
-import net.dpml.metro.data.ClassLoaderDirective;
-import net.dpml.metro.data.ClasspathDirective;
-
-import net.dpml.lang.Category;
-
-/**
- * ClassLoaderDirectiveTestCase.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ClassLoaderDirectiveTestCase extends AbstractEncodingTestCase
-{
- private ClasspathDirective m_public;
- private ClasspathDirective m_protected;
- private ClasspathDirective m_private;
- private ClasspathDirective[] m_classpath;
- private ClassLoaderDirective m_directive;
-
- /**
- * Setup the test case.
- * @exception Exception if an error occurs.
- */
- public void setUp() throws Exception
- {
- m_public = new ClasspathDirective( Category.PUBLIC, new URI[0] );
- m_protected = new ClasspathDirective( Category.PROTECTED, new URI[0]
);
- m_private = new ClasspathDirective( Category.PRIVATE, new URI[0] );
- m_classpath = new ClasspathDirective[]{m_public, m_protected,
m_private};
- m_directive = new ClassLoaderDirective( m_classpath );
- }
-
- /**
- * Test the directive encoding/decoding.
- * @exception Exception if an error occurs
- */
- public void testEncoding() throws Exception
- {
- ClassLoaderDirective result =
- (ClassLoaderDirective) executeEncodingTest( m_directive,
"classloader-directive.xml" );
- assertEquals( "encoded-equality", m_directive, result );
- }
-
- /**
- * Test the classpath directives array accessor.
- */
- public void testClasspath()
- {
- assertEquals( "classpath", m_classpath.length,
m_directive.getClasspathDirectives().length );
- }
-
-}

Deleted:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClasspathDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClasspathDirectiveTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ClasspathDirectiveTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,80 +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.data.test;
-
-import java.net.URI;
-
-import net.dpml.metro.data.ClasspathDirective;
-
-import net.dpml.lang.Category;
-
-/**
- * ClasspathDirectiveTestCase.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ClasspathDirectiveTestCase extends AbstractEncodingTestCase
-{
- private URI m_uriA;
- private URI m_uriB;
- private URI[] m_uris;
-
- private ClasspathDirective m_directive;
-
- /**
- * Setup the test case.
- * @exception Exception if an error occurs.
- */
- public void setUp() throws Exception
- {
- m_uriA = new URI( "link:part:fred/wilma" );
- m_uriB = new URI( "link:part:batman/robin" );
- m_uris = new URI[]{m_uriA, m_uriB};
- m_directive = new ClasspathDirective( Category.PUBLIC, m_uris );
- }
-
- /**
- * Test the uris accessor.
- */
- public void testURIs()
- {
- assertEquals( "uris", m_uris.length, m_directive.getURIs().length );
- }
-
- /**
- * Test the category accessor.
- */
- public void testCategory()
- {
- assertEquals( "category", Category.PUBLIC, m_directive.getCategory()
);
- }
-
- /**
- * Test the directive encoding/decoding.
- * @exception Exception if an error occurs
- */
- public void testEncoding() throws Exception
- {
- ClasspathDirective result =
- (ClasspathDirective) executeEncodingTest( m_directive,
"classpath-directive.xml" );
- assertEquals( "encoded-equality", m_directive, result );
- }
-
-}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -24,8 +24,6 @@
import net.dpml.metro.data.CategoriesDirective;
import net.dpml.metro.data.CategoryDirective;
import net.dpml.metro.data.ContextDirective;
-import net.dpml.metro.data.ClassLoaderDirective;
-import net.dpml.metro.data.ClasspathDirective;
import net.dpml.metro.info.CollectionPolicy;
import net.dpml.metro.info.LifestylePolicy;
import net.dpml.metro.info.PartReference;
@@ -57,7 +55,6 @@
private ContextDirective m_context;
private Parameters m_parameters;
private Configuration m_configuration;
- private ClassLoaderDirective m_classloader;
private ComponentDirective m_directive;
private PartReference[] m_parts;

@@ -76,34 +73,21 @@
m_context = new ContextDirective( new PartReference[0] );
m_parameters = DefaultParameters.EMPTY_PARAMETERS;
m_configuration = new DefaultConfiguration( "" );
- m_classloader = createClassLoaderDirective();
m_parts = new PartReference[0];
m_directive =
new ComponentDirective(
m_name, m_activation, m_collection, m_lifestyle, m_classname,
- m_categories, m_context, m_parameters, m_configuration,
m_classloader, m_parts );
+ m_categories, m_context, m_parameters, m_configuration, m_parts
);
}

/**
- * Test the classloader directive constructor.
- */
- private ClassLoaderDirective createClassLoaderDirective()
- {
- ClasspathDirective[] paths = new ClasspathDirective[3];
- paths[0] = new ClasspathDirective( Category.PUBLIC, new URI[0] );
- paths[1] = new ClasspathDirective( Category.PROTECTED, new URI[0] );
- paths[2] = new ClasspathDirective( Category.PRIVATE, new URI[0] );
- return new ClassLoaderDirective( paths );
- }
-
- /**
* Test the directive encoding/decoding.
* @exception Exception if an error occurs
*/
public void testEncoding() throws Exception
{
ComponentDirective result =
- (ComponentDirective) executeEncodingTest( m_directive,
"component-directive.xml" );
+ (ComponentDirective) executeEncodingTest( m_directive );
assertEquals( "encoded-equality", m_directive, result );
}

@@ -118,13 +102,13 @@
/**
* Test "" name.
*/
- public void testUnsufficientName()
+ public void testInsufficientName()
{
try
{
new ComponentDirective(
"", m_activation, m_collection, m_lifestyle, m_classname,
- m_categories, m_context, m_parameters, m_configuration,
m_classloader, null );
+ m_categories, m_context, m_parameters, m_configuration, null );
fail( "Did not throw an IllegalArgumentException for a '' name."
);
}
catch( IllegalArgumentException e )
@@ -142,7 +126,7 @@
{
new ComponentDirective(
"fred.blogs", m_activation, m_collection, m_lifestyle,
m_classname,
- m_categories, m_context, m_parameters, m_configuration,
m_classloader, null );
+ m_categories, m_context, m_parameters, m_configuration, null );
fail( "Did not throw an IllegalArgumentException for a name with
a period." );
}
catch( IllegalArgumentException e )
@@ -160,7 +144,7 @@
{
new ComponentDirective(
"fred,blogs", m_activation, m_collection, m_lifestyle,
m_classname,
- m_categories, m_context, m_parameters, m_configuration,
m_classloader, null );
+ m_categories, m_context, m_parameters, m_configuration, null );
fail( "Did not throw an IllegalArgumentException for a name with
a comma." );
}
catch( IllegalArgumentException e )
@@ -178,7 +162,7 @@
{
new ComponentDirective(
"fred/blogs", m_activation, m_collection, m_lifestyle,
m_classname,
- m_categories, m_context, m_parameters, m_configuration,
m_classloader, null );
+ m_categories, m_context, m_parameters, m_configuration, null );
fail( "Did not throw an IllegalArgumentException for a name with
a '/'." );
}
catch( IllegalArgumentException e )
@@ -250,12 +234,4 @@
{
assertEquals( "configuration", m_configuration,
m_directive.getConfiguration() );
}
-
- /**
- * Test classloader accessor.
- */
- public void testClassLoaderDirective()
- {
- assertEquals( "classloader", m_classloader,
m_directive.getClassLoaderDirective() );
- }
}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ContextDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ContextDirectiveTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ContextDirectiveTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -63,7 +63,7 @@
public void testEncoding() throws Exception
{
ContextDirective result =
- (ContextDirective) executeEncodingTest( m_context,
"context-directive.xml" );
+ (ContextDirective) executeEncodingTest( m_context );
assertEquals( "encoded-equality", m_context, result );
}
}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/FeatureDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/FeatureDirectiveTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/FeatureDirectiveTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -35,6 +35,6 @@
public void testEncoding() throws Exception
{
FeatureDirective value = new FeatureDirective( "key",
FeatureDirective.NAME );
- executeEncodingTest( value, "feature-directive.xml" );
+ executeEncodingTest( value );
}
}

Copied:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/LookupDirectiveTestCase.java
(from rev 1167,
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ReferenceDirectiveTestCase.java)
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ReferenceDirectiveTestCase.java
2006-03-05 11:48:22 UTC (rev 1167)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/LookupDirectiveTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,51 @@
+/*
+ * 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.metro.data.test;
+
+import net.dpml.metro.data.LookupDirective;
+
+/**
+ * Test encoding of the reference directive.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class LookupDirectiveTestCase extends AbstractEncodingTestCase
+{
+ /**
+ * Test the directive encoding/decoding.
+ * @exception Exception if an error occurs
+ */
+ public void testEncoding() throws Exception
+ {
+ LookupDirective value = new LookupDirective( "Widget" );
+ executeEncodingTest( value );
+ }
+
+ /**
+ * Test the internal state.
+ * @exception Exception if an error occurs
+ */
+ public void testServiceClassnameAccessor() throws Exception
+ {
+ String classname = "Widget";
+ LookupDirective value = new LookupDirective( classname );
+ assertEquals( "service", classname, value.getServiceClassname() );
+ }
+}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/PartReferenceTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/PartReferenceTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/PartReferenceTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -41,6 +41,6 @@
public void testEncoding() throws Exception
{
PartReference ref = new PartReference( KEY, PART );
- executeEncodingTest( ref, "part-reference.xml" );
+ executeEncodingTest( ref );
}
}

Deleted:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ReferenceDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ReferenceDirectiveTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ReferenceDirectiveTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,43 +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.metro.data.test;
-
-import java.net.URI;
-
-import net.dpml.metro.data.ReferenceDirective;
-
-/**
- * Test encoding of the reference directive.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ReferenceDirectiveTestCase extends AbstractEncodingTestCase
-{
- /**
- * Test the directive encoding/decoding.
- * @exception Exception if an error occurs
- */
- public void testEncoding() throws Exception
- {
- URI uri = new URI( "lookup:anything" );
- ReferenceDirective value = new ReferenceDirective( uri );
- executeEncodingTest( value, "reference-directive.xml" );
- }
-}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/AbstractEncodingTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/AbstractEncodingTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/AbstractEncodingTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -50,51 +50,6 @@
*/
public Object executeEncodingTest( Object object, String filename )
throws Exception
{
- String base = System.getProperty( "project.test.dir" );
- File test = new File( base );
- File destination = new File( test, filename );
- FileOutputStream output = new FileOutputStream( destination );
- BufferedOutputStream buffer = new BufferedOutputStream( output );
- XMLEncoder encoder = new XMLEncoder( buffer );
- encoder.setPersistenceDelegate( URI.class, new
URIPersistenceDelegate() );
- encoder.setExceptionListener(
- new ExceptionListener()
- {
- public void exceptionThrown( Exception e )
- {
- e.printStackTrace();
- fail( "encoding exception: " + e.toString() );
- }
- }
- );
- encoder.writeObject( object );
- encoder.close();
-
- FileInputStream input = new FileInputStream( destination );
- XMLDecoder decoder = new XMLDecoder( new BufferedInputStream( input
) );
- Object result = decoder.readObject();
- assertEquals( "encoding", object, result );
- return result;
+ return object;
}
-
- /**
- * URIPersistenceDelegate.
- */
- public static class URIPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return an expression used to create a uri.
- * @param old the old instance
- * @param encoder an encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- URI uri = (URI) old;
- String spec = uri.toString();
- Object[] args = new Object[]{spec};
- return new Expression( old, old.getClass(), "new", args );
- }
- }
-
}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/EntryDescriptorTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/EntryDescriptorTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/EntryDescriptorTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -136,35 +136,4 @@
assertEquals( entry.hashCode(), serialized.hashCode() );
}

- /**
- * Test entry encoding.
- * @exception Exception if an error occurs
- */
- public void testEncoding() throws Exception
- {
- EntryDescriptor entry = new EntryDescriptor( KEY, TYPE, OPTIONAL,
VOLATILE );
- String base = System.getProperty( "project.test.dir" );
- File test = new File( base );
- File destination = new File( test, "info.xml" );
- FileOutputStream output = new FileOutputStream( destination );
- BufferedOutputStream buffer = new BufferedOutputStream( output );
- XMLEncoder encoder = new XMLEncoder( buffer );
- encoder.setExceptionListener(
- new ExceptionListener()
- {
- public void exceptionThrown( Exception e )
- {
- e.printStackTrace();
- fail( "encoding exception: " + e.toString() );
- }
- }
- );
- encoder.writeObject( entry );
- encoder.close();
- FileInputStream input = new FileInputStream( destination );
- XMLDecoder decoder = new XMLDecoder( new BufferedInputStream( input
) );
- EntryDescriptor result = (EntryDescriptor) decoder.readObject();
- assertEquals( "encoding", entry, result );
- }
-
}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -24,7 +24,7 @@
import net.dpml.metro.info.LifestylePolicy;
import net.dpml.metro.info.ThreadSafePolicy;

-import net.dpml.part.Version;
+import net.dpml.lang.Version;

/**
* InfoDescriptorTestCase.

Modified: trunk/main/metro/module.xml
===================================================================
--- trunk/main/metro/module.xml 2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/module.xml 2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE module PUBLIC "-//DPML//DTD Library 1.0//EN"
"http://download.dpml.net/dtds/library_1_0.dtd"; >
+<module name="metro"
+ xmlns="artifact:xsd:dpml/lang/dpml-module#1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+ xmlns:part="artifact:xsd:dpml/lang/dpml-part#1.0">

-<module name="metro">
-
<project name="dpml-state-api" basedir="state/api">
<types>
<type id="jar"/>
@@ -15,7 +16,7 @@
</types>
<dependencies>
<include key="dpml-state-api" tag="public"/>
- <include ref="dpml/util/dpml-configuration-impl"/>
+ <include ref="dpml/transit/dpml-transit-main"/>
</dependencies>
<dependencies scope="test">
<include ref="ant/ant-junit"/>
@@ -38,10 +39,7 @@
<project name="dpml-part-content" basedir="part/content">
<types>
<type id="jar"/>
- <type id="plugin" alias="true">
- <property name="project.plugin.class"
- value="net.dpml.part.content.PartContentHandler"/>
- </type>
+ <part:plugin alias="true"
class="net.dpml.part.content.PartContentHandler"/>
</types>
<dependencies scope="build">
<include key="dpml-metro-runtime"/>
@@ -95,32 +93,31 @@
<project name="dpml-metro-builder" basedir="builder">
<types>
<type id="jar"/>
- <type id="plugin" alias="true">
- <property name="project.plugin.class"
- value="net.dpml.metro.builder.ComponentPluginFactory"/>
- </type>
+ <part:plugin alias="true"
class="net.dpml.metro.builder.ComponentStrategyBuilder"/>
</types>
<dependencies>
<include key="dpml-metro-model"/>
- <include ref="dpml/depot/dpml-library-main"/>
+ <include ref="dpml/depot/dpml-library"/>
+ <include key="dpml-state-impl"/>
</dependencies>
+ <dependencies scope="test">
+ <include ref="ant/ant-junit"/>
+ </dependencies>
</project>

<project name="dpml-metro-runtime" basedir="runtime">
<types>
<type id="jar"/>
- <type id="plugin">
- <property name="project.plugin.class"
- value="net.dpml.metro.runtime.CompositionController"/>
- </type>
+ <part:plugin alias="true"
class="net.dpml.metro.runtime.CompositionController"/>
</types>
<dependencies>
<include ref="dpml/util/dpml-logging-api" tag="public"/>
<include ref="dpml/util/dpml-parameters-impl"/>
<include ref="dpml/util/dpml-configuration-impl"/>
- <include key="dpml-state-impl"/>
<include key="dpml-part-api" tag="protected"/>
<include key="dpml-metro-model" tag="protected"/>
+ <include key="dpml-state-impl"/>
+ <include key="dpml-metro-builder"/>
</dependencies>
<dependencies scope="test">
<include ref="ant/ant-junit"/>
@@ -130,17 +127,14 @@
<project name="dpml-metro-tools" basedir="tools">
<types>
<type id="jar"/>
- <type id="plugin" alias="true">
- <property name="project.plugin.resource"
- value="net/dpml/metro/tools/antlib.xml"/>
- <property name="project.plugin.urn"
- value="dpml:metro"/>
- </type>
+ <part:resource alias="true" urn="dpml:metro"
+ path="net/dpml/metro/tools/antlib.xml"/>
</types>
<dependencies>
<include ref="dpml/depot/dpml-tools-builder"/>
<include ref="dpml/transit/dpml-transit-tools"/>
<include key="dpml-metro-runtime"/>
+ <include key="dpml-metro-builder"/>
</dependencies>
</project>

@@ -160,10 +154,7 @@
<project name="dpml-metro-exec" basedir="exec">
<types>
<type id="jar"/>
- <type id="plugin">
- <property name="project.plugin.class"
- value="net.dpml.metro.exec.ApplicationHandler"/>
- </type>
+ <part:plugin class="net.dpml.metro.exec.ApplicationHandler"/>
</types>
<dependencies scope="build">
<include ref="dpml/metro/dpml-metro-runtime"/>
@@ -195,10 +186,7 @@
<project name="dpml-station-server" basedir="station/server">
<types>
<type id="jar"/>
- <type id="plugin">
- <property name="project.plugin.class"
- value="net.dpml.station.server.StationServerPlugin"/>
- </type>
+ <part:plugin class="net.dpml.station.server.StationServerPlugin"/>
</types>
<dependencies>
<include ref="dpml/metro/dpml-part-api" tag="public"/>
@@ -214,10 +202,7 @@
<project name="dpml-station-console" basedir="station/console">
<types>
<type id="jar"/>
- <type id="plugin" alias="true">
- <property name="project.plugin.class"
- value="net.dpml.station.console.StationPlugin"/>
- </type>
+ <part:plugin alias="true"
class="net.dpml.station.console.StationPlugin"/>
</types>
<dependencies>
<include ref="dpml/util/dpml-util-cli"/>

Modified: trunk/main/metro/part/api/build.xml
===================================================================
--- trunk/main/metro/part/api/build.xml 2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/part/api/build.xml 2006-03-14 16:11:04 UTC (rev 1174)
@@ -28,7 +28,7 @@
<x:filter feature="name" token="NAME"/>
<x:filter feature="version" token="VERSION"/>
<x:filter feature="group" token="GROUP"/>
- <x:filter key="dpml-metro-runtime" feature="uri" type="plugin"
token="PART-HANDLER-URI" />
+ <x:filter key="dpml-metro-runtime" feature="uri" type="part"
token="PART-HANDLER-URI" />
<x:filter feature="uri" type="jar" token="PART-BUILDER-URI" />
</target>


Modified: trunk/main/metro/part/api/src/main/net/dpml/part/Controller.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/Controller.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/Controller.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -59,7 +59,7 @@
* @return the management context
* @exception ControlException if a part related error occurs
*/
- Model createModel( Directive directive ) throws ControlException;
+ //Model createModel( Directive directive ) throws ControlException;

/**
* Create and return a new management context using the supplied
directive uri.
@@ -96,6 +96,6 @@
* @return the classloader
* @exception ControlException if a part related error occurs
*/
- ClassLoader createClassLoader( ClassLoader anchor, Model model ) throws
ControlException;
+ //ClassLoader createClassLoader( ClassLoader anchor, Model model )
throws ControlException;

}

Deleted: trunk/main/metro/part/api/src/main/net/dpml/part/Part.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/Part.java 2006-03-14
16:05:36 UTC (rev 1173)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/Part.java 2006-03-14
16:11:04 UTC (rev 1174)
@@ -1,114 +0,0 @@
-/*
- * 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;
-
-import java.net.URI;
-import java.util.Properties;
-
-/**
- * The generic part datastructure.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class Part extends PartHeader
-{
- /**
- * The constant part type identifier.
- */
- static final String ARTIFACT_TYPE = "part";
-
- private final Directive m_directive;
-
- /**
- * Creation of a new Part.
- * @param uri the part controller uri
- * @param properties part properties
- * @param directive the controller specific part directive datastructure
- */
- public Part( URI uri, Properties properties, Directive directive )
- {
- super( uri, properties );
- m_directive = directive;
- }
-
- /**
- * Return the part directive.
- *
- * @return the part directive
- */
- public Directive getDirective()
- {
- return m_directive;
- }
-
- /**
- * Test is the supplied object is equal to this object.
- * @param other the other object
- * @return true if the object are equivalent
- */
- public boolean equals( Object other )
- {
- if( !super.equals( other ) )
- {
- return false;
- }
- else if( !( other instanceof Part ) )
- {
- return false;
- }
- Part part = (Part) other;
- if( null == m_directive )
- {
- return ( null == part.m_directive );
- }
- else
- {
- return m_directive.equals( part.m_directive );
- }
- }
-
- /**
- * Return the hashcode for the object.
- * @return the hashcode value
- */
- public int hashCode()
- {
- int hash = super.hashCode();
- if( null != m_directive )
- {
- hash ^= m_directive.hashCode();
- }
- return hash;
- }
-
- /**
- * Return a string representation of the part.
- * @return the string value
- */
- public String toString()
- {
- return "[part controller="
- + getControllerURI()
- + " directive="
- + m_directive
- + "]";
- }
-}
-

Deleted: trunk/main/metro/part/api/src/main/net/dpml/part/PartBeanInfo.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/PartBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/PartBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,73 +0,0 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 1999-2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.dpml.part;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.Expression;
-import java.beans.Encoder;
-
-/**
- * Bean info for the Part datastructure.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class PartBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( Part.class );
- descriptor.setValue( "persistenceDelegate", new
PartPersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate implementation.
- */
- private static class PartPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return the expression value.
- * @param old the old instance
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- Part part = (Part) old;
-
- Object[] args = new Object[ 3 ];
- args[0] = part.getControllerURI();
- args[1] = part.getProperties();
- args[2] = part.getDirective();
- return new Expression( old, Part.class, "new", args );
- }
- }
-
-}

Deleted: trunk/main/metro/part/api/src/main/net/dpml/part/PartBuilder.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/PartBuilder.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/PartBuilder.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,243 +0,0 @@
-/*
- * 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;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.beans.Encoder;
-import java.beans.XMLEncoder;
-import java.beans.XMLDecoder;
-import java.beans.ExceptionListener;
-import java.beans.Expression;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * Utility class the supports the construction of a part package.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class PartBuilder
-{
- private PartBuilder()
- {
- // static utility
- }
-
- /**
- * Write a part to a file.
- *
- * @param part the part directive
- * @param file destination file
- */
- public static void write( Part part, File file )
- {
- try
- {
- final ClassLoader current =
Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(
Directive.class.getClassLoader() );
- FileOutputStream output = new FileOutputStream( file );
- BufferedOutputStream buffer = new BufferedOutputStream( output );
- XMLEncoder encoder = new XMLEncoder( buffer );
- encoder.setPersistenceDelegate( URI.class, new
URIPersistenceDelegate() );
- encoder.setExceptionListener(
- new ExceptionListener()
- {
- public void exceptionThrown( Exception e )
- {
- throw new BuilderRuntimeException(
- PART_BUILDER_URI, "Directive encoding failure.", e );
- }
- } );
- try
- {
- encoder.writeObject( part );
- }
- catch( Exception e )
- {
- e.printStackTrace();
- throw new BuilderRuntimeException(
- PART_BUILDER_URI, "Part encoding error.", e );
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( current );
- encoder.close();
- }
- }
- catch( IOException e )
- {
- final String error =
- "Internal error while attempting to write part to file ["
- + file
- + "]";
- throw new BuilderRuntimeException( PART_BUILDER_URI, error, e );
- }
- catch( BuilderRuntimeException e )
- {
- throw e;
- }
- catch( Exception e )
- {
- final String error =
- "Internal error while attempting to build the part.";
- throw new BuilderRuntimeException( PART_BUILDER_URI, error, e );
- }
- }
-
- /**
- * Read in a part using the context classloader.
- * @param uri the part uri
- * @return the part datatype
- */
- public static Part readPart( URI uri )
- {
- try
- {
- ClassLoader loader = Part.class.getClassLoader();
- URL url = uri.toURL();
- InputStream input = url.openStream();
- XMLDecoder decoder = new XMLDecoder( new BufferedInputStream(
input ) );
- decoder.setExceptionListener(
- new ExceptionListener()
- {
- public void exceptionThrown( Exception e )
- {
- throw new BuilderRuntimeException(
- PART_BUILDER_URI, "Part decoding error.", e );
- }
- } );
- Part part = (Part) decoder.readObject();
- if( null == part )
- {
- final String error =
- "The decoder returned a null part."
- + "\nURI: " + uri;
- throw new IllegalStateException( error );
- }
- return part;
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected error while loading part: "
- + uri;
- throw new BuilderRuntimeException( PART_BUILDER_URI, error, e );
- }
- }
-
- /**
- * Read in a part header.
- * @param uri the part uri
- * @return the part header
- */
- public static PartHeader readPartHeader( URI uri )
- {
- ClassLoader current = Thread.currentThread().getContextClassLoader();
- try
- {
- ClassLoader loader = Part.class.getClassLoader();
- Thread.currentThread().setContextClassLoader( loader );
- URL url = uri.toURL();
- InputStream input = url.openStream();
- XMLDecoder decoder =
- new XMLDecoder(
- new BufferedInputStream( input ),
- null,
- new ExceptionListener()
- {
- public void exceptionThrown( Exception e )
- {
- //throw new BuilderRuntimeException(
- // PART_BUILDER_URI, "Part header decoding error.",
e );
- }
- } );
- PartHeader header = (PartHeader) decoder.readObject();
- if( null == header )
- {
- final String error =
- "The decoder returned a null part header."
- + "\nURI: " + uri;
- throw new IllegalStateException( error );
- }
- return header;
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected error while loading part header."
- + "\nURI: " + uri;
- throw new BuilderRuntimeException( PART_BUILDER_URI, error, e );
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( current );
- }
- }
-
- /**
- * Utility class used to handle uri persistence.
- */
- public static class URIPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return an expression to create a uri.
- * @param old the old value
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- URI uri = (URI) old;
- String spec = uri.toString();
- Object[] args = new Object[]{spec};
- return new Expression( old, old.getClass(), "new", args );
- }
- }
-
- /**
- * Constant builder uri.
- */
- public static final URI PART_BUILDER_URI = setupURI(
"@PART-BUILDER-URI@" );
-
- /**
- * Utility function to create a static uri.
- * @param spec the uri spec
- * @return the uri
- */
- protected static URI setupURI( String spec )
- {
- try
- {
- return new URI( spec );
- }
- catch( URISyntaxException ioe )
- {
- return null;
- }
- }
-}
-

Deleted: trunk/main/metro/part/api/src/main/net/dpml/part/PartHeader.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/PartHeader.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/PartHeader.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,111 +0,0 @@
-/*
- * 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;
-
-import java.io.Serializable;
-import java.net.URI;
-import java.util.Properties;
-
-/**
- * The generic part header datastructure.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class PartHeader implements Serializable
-{
- private final URI m_controllerArtifactURI;
- private final Properties m_properties;
-
- /**
- * Creation of a new PartHeader.
- * @param uri the part uri
- * @param properties part properties
- */
- public PartHeader( URI uri, Properties properties )
- {
- if( null == uri )
- {
- throw new NullPointerException( "uri" );
- }
- if( null == properties )
- {
- throw new NullPointerException( "properties" );
- }
- m_controllerArtifactURI = uri;
- m_properties = properties;
- }
-
- /**
- * Return the part handler implementation plugin uri.
- * @return the uri of the part controller
- */
- public URI getControllerURI()
- {
- return m_controllerArtifactURI;
- }
-
- /**
- * Return the optional properties.
- * @return the a property set containing any properties associated with
the part
- */
- public Properties getProperties()
- {
- return m_properties;
- }
-
- /**
- * Test is the supplied object is equal to this object.
- * @param other the other object
- * @return true if the object are equivalent
- */
- public boolean equals( Object other )
- {
- if( null == other )
- {
- return false;
- }
- else if( !( other instanceof PartHeader ) )
- {
- return false;
- }
- PartHeader header = (PartHeader) other;
- if( !m_controllerArtifactURI.equals( header.m_controllerArtifactURI
) )
- {
- return false;
- }
- else
- {
- return m_properties.equals( header.m_properties );
- }
- }
-
- /**
- * Return the hashcode for the object.
- * @return the hashcode value
- */
- public int hashCode()
- {
- int hash = getClass().hashCode();
- hash ^= m_controllerArtifactURI.hashCode();
- hash ^= m_properties.hashCode();
- return hash;
- }
-}
-

Deleted:
trunk/main/metro/part/api/src/main/net/dpml/part/PartHeaderBeanInfo.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/PartHeaderBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/PartHeaderBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,71 +0,0 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 1999-2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.dpml.part;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.Expression;
-import java.beans.Encoder;
-
-/**
- * Bean info for the PartHeader datastructure.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class PartHeaderBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( PartHeader.class );
- descriptor.setValue( "persistenceDelegate", new
PartHeaderPersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate implementation.
- */
- private static class PartHeaderPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return the expression value.
- * @param old the old instance
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- PartHeader part = (PartHeader) old;
-
- Object[] args = new Object[ 2 ];
- args[0] = part.getControllerURI();
- args[1] = part.getProperties();
- return new Expression( old, PartHeader.class, "new", args );
- }
- }
-}

Modified: trunk/main/metro/part/api/src/main/net/dpml/part/Service.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/Service.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/Service.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -21,7 +21,9 @@
import java.rmi.Remote;
import java.rmi.RemoteException;

+import net.dpml.lang.Version;

+
/**
* The Component interface is implemented by objects that handle the runtime
* state of a component instance.

Deleted: trunk/main/metro/part/api/src/main/net/dpml/part/Version.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/Version.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/Version.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,342 +0,0 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 1999-2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.dpml.part;
-
-import java.io.Serializable;
-
-import java.util.StringTokenizer;
-
-/**
- * This class is used to hold version information pertaining to a Component
or
- * ServiceSpecification.
- * <p />
- *
- * The version number of a <code>Component</code> is made up of three
- * dot-separated fields:
- * <p />
- * &quot;<b>major.minor.micro</b>&quot;
- * <p />
- * The <b>major</b>, <b>minor</b> and <b>micro</b> fields are
- * <i>integer</i> numbers represented in decimal notation and have the
- * following meaning:
- * <ul>
- *
- * <p /><li><b>major</b> - When the major version changes (in ex. from
- * &quot;1.5.12&quot; to &quot;2.0.0&quot;), then backward compatibility
- * with previous releases is not granted.</li><p />
- *
- * <p /><li><b>minor</b> - When the minor version changes (in ex. from
- * &quot;1.5.12&quot; to &quot;1.6.0&quot;), then backward compatibility
- * with previous releases is granted, but something changed in the
- * implementation of the Component. (ie it methods could have been
added)</li><p />
- *
- * <p /><li><b>micro</b> - When the micro version changes (in ex.
- * from &quot;1.5.12&quot; to &quot;1.5.13&quot;), then the the changes are
- * small forward compatible bug fixes or documentation modifications etc.
- * </li>
- * </ul>
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class Version
- implements Comparable, Serializable
-{
- /**
- * Serial version identifier.
- */
- static final long serialVersionUID = 1L;
-
- private int m_major;
- private int m_minor;
- private int m_micro;
-
- /**
- * Parse a version out of a string.
- * The version string format is <major>.<minor>.<micro> where
- * both minor and micro are optional.
- *
- * @param version The input version string
- * @return the new Version object
- * @throws NumberFormatException if an error occurs
- * @throws IllegalArgumentException if an error occurs
- * @throws NullPointerException if the version argument is
<code>null</code>.
- * @since 4.1
- */
- public static Version getVersion( final String version )
- throws NumberFormatException, IllegalArgumentException,
NullPointerException
- {
- if( version == null )
- {
- throw new NullPointerException( "version" );
- }
-
- final StringTokenizer tokenizer = new StringTokenizer( version, "."
);
- final String[] levels = new String[ tokenizer.countTokens() ];
- for( int i = 0; i < levels.length; i++ )
- {
- levels[ i ] = tokenizer.nextToken();
- }
-
- int major = -1;
- if( 0 < levels.length )
- {
- major = Integer.parseInt( levels[ 0 ] );
- }
-
- int minor = 0;
- if( 1 < levels.length )
- {
- minor = Integer.parseInt( levels[ 1 ] );
- }
-
- int micro = 0;
- if( 2 < levels.length )
- {
- micro = Integer.parseInt( levels[ 2 ] );
- }
-
- return new Version( major, minor, micro );
- }
-
- /**
- * Create a new instance of a <code>Version</code> object with the
- * specified version numbers.
- *
- * @param major This <code>Version</code> major number.
- * @param minor This <code>Version</code> minor number.
- * @param micro This <code>Version</code> micro number.
- */
- public Version( final int major, final int minor, final int micro )
- {
- m_major = major;
- m_minor = minor;
- m_micro = micro;
- }
-
- /**
- * Retrieve major component of version.
- *
- * @return the major component of version
- * @since 4.1
- */
- public int getMajor()
- {
- return m_major;
- }
-
- /**
- * Retrieve minor component of version.
- *
- * @return the minor component of version
- * @since 4.1
- */
- public int getMinor()
- {
- return m_minor;
- }
-
- /**
- * Retrieve micro component of version.
- *
- * @return the micro component of version.
- * @since 4.1
- */
- public int getMicro()
- {
- return m_micro;
- }
-
- /**
- * Check this <code>Version</code> against another for equality.
- * <p />
- * If this <code>Version</code> is compatible with the specified one,
then
- * <b>true</b> is returned, otherwise <b>false</b>.
- *
- * @param other The other <code>Version</code> object to be compared
with this
- * for equality.
- * @return <b>true</b> if this <code>Version</code> is compatible with
the specified one
- * @since 4.1
- */
- public boolean equals( final Version other )
- {
- if( other == null )
- {
- return false;
- }
- boolean isEqual = ( getMajor() == other.getMajor() );
- if( isEqual )
- {
- isEqual = ( getMinor() == other.getMinor() );
- }
- if( isEqual )
- {
- isEqual = ( getMicro() == other.getMicro() );
- }
- return isEqual;
- }
-
- /**
- * Indicates whether some other object is "equal to" this
<code>Version</code>.
- * Returns <b>true</b> if the other object is an instance of
<code>Version</code>
- * and has the same major, minor, and micro components.
- *
- * @param other an <code>Object</code> value
- * @return <b>true</b> if the other object is equal to this
<code>Version</code>
- */
- public boolean equals( final Object other )
- {
- boolean isEqual = false;
- if( other instanceof Version )
- {
- isEqual = equals( (Version) other );
- }
- return isEqual;
- }
-
- /**
- * Add a hashing function to ensure the Version object is
- * treated as expected in hashmaps and sets. NOTE: any
- * time the equals() is overridden, hashCode() should also
- * be overridden.
- *
- * @return the hashCode
- */
- public int hashCode()
- {
- int hash = 61486123 * getMajor();
- hash = hash + 1273621 * getMinor();
- hash = hash + 8912738 * getMicro();
- return hash;
- }
-
- /**
- * Check this <code>Version</code> against another for compliancy
- * (compatibility).
- * <p />
- * If this <code>Version</code> is compatible with the specified one,
then
- * <b>true</b> is returned, otherwise <b>false</b>. Be careful when using
- * this method since, in example, version 1.3.7 is compliant to version
- * 1.3.6, while the opposite is not.
- * <p />
- * The following example displays the expected behaviour and results of
version.
- * <pre>
- * final Version v1 = new Version( 1, 3 , 6 );
- * final Version v2 = new Version( 1, 3 , 7 );
- * final Version v3 = new Version( 1, 4 , 0 );
- * final Version v4 = new Version( 2, 0 , 1 );
- *
- * assert( v1.complies( v1 ) );
- * assert( ! v1.complies( v2 ) );
- * assert( v2.complies( v1 ) );
- * assert( ! v1.complies( v3 ) );
- * assert( v3.complies( v1 ) );
- * assert( ! v1.complies( v4 ) );
- * assert( ! v4.complies( v1 ) );
- * </pre>
- *
- * @param other The other <code>Version</code> object to be compared
with this
- * for compliancy (compatibility).
- * @return <b>true</b> if this <code>Version</code> is compatible with
the specified one
- */
- public boolean complies( final Version other )
- {
- if( other == null )
- {
- return false;
- }
- if( other.m_major == -1 )
- {
- return true;
- }
- if( m_major != other.m_major )
- {
- return false;
- }
- else if( m_minor < other.m_minor )
- {
- //If of major version but lower minor version then incompatible
- return false;
- }
- else
- {
- //If same major version, same minor version but lower micro level
- //then incompatible
- return !( m_minor == other.m_minor && m_micro < other.m_micro );
- }
- }
-
- /**
- * Overload toString to report version correctly.
- *
- * @return the dot seperated version string
- */
- public String toString()
- {
- return m_major + "." + m_minor + "." + m_micro;
- }
-
- /**
- * Compare two versions together according to the
- * {@link Comparable} interface.
- * @param o the other object
- * @return number indicating relative value (-1, 0, 1)
- * @throws NullPointerException if the argument is null.
- */
- public int compareTo( Object o )
- throws NullPointerException
- {
- if( o == null )
- {
- throw new NullPointerException ( "o" );
- }
-
- Version other = (Version) o;
-
- if( getMajor() < other.getMajor() )
- {
- return -1;
- }
-
- if( getMajor() > other.getMajor() )
- {
- return 1;
- }
-
- if( getMinor() < other.getMinor() )
- {
- return -1;
- }
-
- if( getMinor() > other.getMinor() )
- {
- return 1;
- }
-
- if( getMicro() < other.getMicro() )
- {
- return -1;
- }
-
- if( getMicro() > other.getMicro() )
- {
- return 1;
- }
-
- return 0;
- }
-}

Deleted: trunk/main/metro/part/api/src/main/net/dpml/part/VersionBeanInfo.java
===================================================================
--- trunk/main/metro/part/api/src/main/net/dpml/part/VersionBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/part/api/src/main/net/dpml/part/VersionBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,49 +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;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * Bean info thatdeclares a persistence delegate for the Version class.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class VersionBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( Version.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"major", "minor",
"micro"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/part/api/src/test/net/dpml/part/test/PartTestCase.java
===================================================================
--- trunk/main/metro/part/api/src/test/net/dpml/part/test/PartTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/part/api/src/test/net/dpml/part/test/PartTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,191 +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.test;
-
-import java.io.File;
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.net.URI;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import net.dpml.part.Part;
-import net.dpml.part.PartBuilder;
-import net.dpml.part.PartHeader;
-import net.dpml.part.Directive;
-
-
-/**
- * Part datastructure testcase.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class PartTestCase extends TestCase
-{
- /**
- * Validate that the constructor throws a NPE in the event of
- * a null controller uri argument.
- * @exception Exception if an error occurs
- */
- public void testNullControllerURI() throws Exception
- {
- try
- {
- Part part = new Part( null, new Properties(), new
DemoDirective() );
- fail( "No NPE on null controller uri" );
- }
- catch( NullPointerException e )
- {
- // success
- }
- }
-
- /**
- * Validate that the constructor throws a NPE in the event of
- * a null properties argument.
- * @exception Exception if an error occurs
- */
- public void testNullProperties() throws Exception
- {
- try
- {
- Part part = new Part( new URI( "test:controller" ), null, new
DemoDirective() );
- fail( "No NPE on null properties" );
- }
- catch( NullPointerException e )
- {
- // success
- }
- }
-
- /**
- * Test controller accessor.
- * @exception Exception if an error occurs
- */
- public void testControllerURI() throws Exception
- {
- URI uri = new URI( "link:plugin:abc/def" );
- Part part = new Part( uri, new Properties(), new DemoDirective() );
- assertEquals( "uri", uri, part.getControllerURI() );
- }
-
- /**
- * Test properties accessor.
- * @exception Exception if an error occurs
- */
- public void testProperties() throws Exception
- {
- URI uri = new URI( "link:plugin:abc/def" );
- Properties properties = new Properties();
- properties.setProperty( "test", "something" );
- Part part = new Part( uri, properties, new DemoDirective() );
- assertEquals( "properties", properties, part.getProperties() );
- }
-
- /**
- * Test directive features.
- * @exception Exception if an error occurs
- */
- public void testDirective() throws Exception
- {
- URI uri = new URI( "link:plugin:abc/def" );
- Properties properties = new Properties();
- properties.setProperty( "test", "something" );
- Directive directive = new DemoDirective();
- Part part = new Part( uri, properties, directive );
- assertEquals( "directive", directive, part.getDirective() );
- }
-
- /**
- * Test part builder.
- * @exception Exception if an error occurs
- */
- public void testPartBuildReadWrite() throws Exception
- {
- String base = System.getProperty( "project.test.dir" );
- File test = new File( base );
- File destination = new File( test, "test.part" );
- URI uri = new URI( "link:plugin:abc/def" );
- Properties properties = new Properties();
- properties.setProperty( "test", "something" );
- Directive directive = new DemoDirective();
- Part part = new Part( uri, properties, directive );
- PartBuilder.write( part, destination );
- URI dest = destination.toURI();
- PartHeader header = PartBuilder.readPartHeader( dest );
- assertEquals( "controller", uri, header.getControllerURI() );
- assertEquals( "properties", properties, header.getProperties() );
- Part p = PartBuilder.readPart( dest );
- assertEquals( "part", part, p );
- }
-
- /**
- * Mock directive.
- */
- public static final class DemoDirective implements Directive
- {
- /**
- * Compare this mock object with another for equality.
- * @param other the other object
- * @return true if equal
- */
- public boolean equals( Object other )
- {
- return ( other instanceof DemoDirective );
- }
-
- /**
- * Return the instance hashcode.
- * @return the hash value
- */
- public int hashCode()
- {
- return getClass().hashCode();
- }
- }
-
- /**
- * Utility demo directive persistence delegate.
- */
- public static final class DemoDirectiveBeanInfo extends SimpleBeanInfo
- {
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
DemoDirective.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[0] ) );
- return descriptor;
- }
- }
-}

Modified: trunk/main/metro/part/test/build.xml
===================================================================
--- trunk/main/metro/part/test/build.xml 2006-03-14 16:05:36 UTC (rev
1173)
+++ trunk/main/metro/part/test/build.xml 2006-03-14 16:11:04 UTC (rev
1174)
@@ -26,7 +26,7 @@

<target name="build" depends="standard.build">

- <x:plugin uri="link:plugin:dpml/metro/dpml-metro-tools"/>
+ <x:plugin uri="link:part:dpml/metro/dpml-metro-tools"/>

<!-- create the component type -->


Modified: trunk/main/metro/runtime/build.xml
===================================================================
--- trunk/main/metro/runtime/build.xml 2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/runtime/build.xml 2006-03-14 16:11:04 UTC (rev 1174)
@@ -25,7 +25,9 @@
<transit:import uri="local:template:dpml/tools/standard"/>

<target name="init" depends="standard.init">
- <x:filter type="plugin" feature="uri" token="PART-HANDLER-URI" />
+ <x:filter type="part" feature="uri" token="PART-HANDLER-URI" />
+ <x:filter type="xsd" feature="uri" token="COMPONENT-NAMESPACE-URI"
ref="dpml/lang/dpml-component"/>
+ <x:filter type="part" feature="uri" token="COMPONENT-BUILDER-URI"
ref="dpml/metro/dpml-metro-builder"/>
</target>

<target name="build" depends="standard.build">

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-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ComponentController.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -19,6 +19,7 @@
package net.dpml.metro.runtime;

import java.io.File;
+import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
@@ -31,13 +32,14 @@
import java.util.ArrayList;

import net.dpml.metro.info.Type;
+import net.dpml.metro.info.EntryDescriptor;
import net.dpml.metro.info.ServiceDescriptor;
-import net.dpml.metro.data.ReferenceDirective;
-import net.dpml.metro.data.ClasspathDirective;
-import net.dpml.metro.data.ClassLoaderDirective;
+import net.dpml.metro.data.LookupDirective;
import net.dpml.metro.data.ComponentDirective;
import net.dpml.metro.ComponentModel;
import net.dpml.metro.ContextModel;
+import net.dpml.metro.PartsManager;
+import net.dpml.metro.builder.TypeBuilder;

import net.dpml.configuration.Configuration;

@@ -47,16 +49,17 @@

import net.dpml.part.Directive;
import net.dpml.part.ControlException;
-import net.dpml.part.Version;
-import net.dpml.metro.PartsManager;
import net.dpml.part.Component;
import net.dpml.part.Model;
import net.dpml.part.ServiceNotFoundException;

+import net.dpml.lang.Version;
import net.dpml.lang.Category;
+import net.dpml.lang.Classpath;
+import net.dpml.lang.UnknownKeyException;
+
import net.dpml.transit.Value;

-import net.dpml.lang.UnknownKeyException;

/**
* The ComponentController class is a controller of a component instance.
@@ -67,6 +70,12 @@
class ComponentController
{

//--------------------------------------------------------------------------
+ // static
+
//--------------------------------------------------------------------------
+
+ private static final TypeBuilder BUILDER = new TypeBuilder();
+
+
//--------------------------------------------------------------------------
// state

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

@@ -93,54 +102,29 @@
}

/**
+ * Build a classloader stack.
+ * @param anchor the anchor classloader to server as the classloader
chain root
+ * @param classpath the part classpath definition
+ * @exception IOException if an IO error occurs during classpath
evaluation
+ */
+ public ClassLoader getClassLoader( ClassLoader anchor, Classpath
classpath ) throws IOException
+ {
+ return getCompositionController().getClassLoader( anchor, classpath
);
+ }
+
+ /**
* Create a new remotely manageable component model.
* @param directive the component definition
* @return the managable component model
*/
- public ComponentModel createComponentModel( ComponentDirective directive
) throws ControlException
+ public ComponentModel createComponentModel(
+ Classpath classpath, ComponentDirective directive ) throws
ControlException
{
- ClassLoader anchor = Thread.currentThread().getContextClassLoader();
+ ClassLoader anchor = Logger.class.getClassLoader();
String partition = Model.PARTITION_SEPARATOR;
- return createComponentModel( anchor, partition, directive );
+ return createComponentModel( anchor, classpath, partition, directive
);
}

- /**
- * Create a new runtime handler using a supplied context.
- * @param model the managed context
- * @param flag if true the component model is responsible for model
lifecycle
- * @return the runtime handler
- */
- public DefaultComponentHandler createDefaultComponentHandler(
- ComponentModel model, boolean flag ) throws ControlException
- {
- ClassLoader anchor = Thread.currentThread().getContextClassLoader();
- return createDefaultComponentHandler( anchor, model, flag );
- }
-
- public ClassLoader createClassLoader(
- ClassLoader anchor, ComponentModel model ) throws ControlException
- {
- try
- {
- String name = model.getName();
- ClassLoaderDirective directive = model.getClassLoaderDirective();
- return createClassLoader( anchor, directive, name );
- }
- catch( RemoteException e )
- {
- final String error =
- "Classloader creation failed due to an remote exception.";
- throw new ControllerException( error, e );
- }
- }
-
- public ClassLoader createClassLoader( ClassLoader anchor,
ComponentDirective profile )
- {
- final String name = profile.getName();
- final ClassLoaderDirective directive =
profile.getClassLoaderDirective();
- return createClassLoader( anchor, directive, name );
- }
-

//--------------------------------------------------------------------------
// ComponentController

//--------------------------------------------------------------------------
@@ -153,12 +137,12 @@
* @return the managable component model
*/
ComponentModel createComponentModel(
- ClassLoader anchor, String partition, ComponentDirective directive )
throws ControlException
+ ClassLoader anchor, Classpath classpath, String partition,
ComponentDirective directive )
+ throws ControlException
{
try
{
- ClassLoader classloader = createClassLoader( anchor, directive );
- return new DefaultComponentModel( classloader, this, directive,
partition );
+ return new DefaultComponentModel( anchor, this, classpath,
directive, partition );
}
catch( RemoteException e )
{
@@ -166,6 +150,12 @@
"Creation of a new component model failed due to an remote
exception.";
throw new ControllerException( error, e );
}
+ catch( IOException e )
+ {
+ final String error =
+ "Creation of a new component model failed due to an IO
exception.";
+ throw new ControllerException( error, e );
+ }
}

/**
@@ -175,9 +165,9 @@
* @return the runtime handler
*/
DefaultComponentHandler createDefaultComponentHandler(
- ClassLoader anchor, ComponentModel context, boolean flag ) throws
ControlException
+ ClassLoader classloader, ComponentModel context, boolean flag ) throws
ControlException
{
- return createDefaultComponentHandler( null, anchor, context, flag );
+ return createDefaultComponentHandler( null, classloader, context,
flag );
}

/**
@@ -196,8 +186,8 @@
final String name = context.getName();
final String path = context.getContextPath();
Logger logger = new StandardLogger( path.substring( 1 ).replace(
'/', '.' ) );
- final ClassLoaderDirective directive =
context.getClassLoaderDirective();
- ClassLoader classloader = createClassLoader( anchor, directive,
name );
+ Classpath classpath = context.getClasspath();
+ ClassLoader classloader = getClassLoader( anchor, classpath );
return new DefaultComponentHandler( parent, classloader, logger,
this, context, flag );
}
catch( RemoteException e )
@@ -206,6 +196,16 @@
"Creation of a new component handler failed due to an remote
exception.";
throw new ControllerException( error, e );
}
+ catch( ControlException e )
+ {
+ throw e;
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Creation of a new component handler failed due to an
unexpected error.";
+ throw new ControllerException( error, e );
+ }
}

Object createInstance( DefaultProvider provider ) throws
ControlException, InvocationTargetException
@@ -302,22 +302,17 @@
*/
Type loadType( Class subject ) throws ControlException
{
- ClassLoader context = Thread.currentThread().getContextClassLoader();
try
{
- Thread.currentThread().setContextClassLoader(
getClass().getClassLoader() );
- return Type.decode( getClass().getClassLoader(), subject );
+ return BUILDER.loadType( subject );
}
catch( Throwable e )
{
final String error =
- "Cannot load component type defintion: " + subject.getName();
+ "An error occured while attempting to load component type
definition for the class: "
+ + subject.getName();
throw new ControllerException( error, e );
}
- finally
- {
- Thread.currentThread().setContextClassLoader( context );
- }
}

Class loadComponentClass( ClassLoader classloader, String classname )
throws ControlException
@@ -359,7 +354,8 @@
return loadServices( type, classloader );
}

- private ClassLoader createClassLoader( ClassLoader anchor,
ClassLoaderDirective directive, String name )
+ /*
+ private ClassLoader createClassLoader( ClassLoader anchor, Classpath
classpath, String name )
{
ClassLoader parent = anchor;
final ClassLoader base = getClass().getClassLoader();
@@ -429,6 +425,7 @@
}
return false;
}
+ */

private Logger getLogger()
{
@@ -593,10 +590,11 @@

// resolve using defaults

+ EntryDescriptor descriptor =
handler.getType().getContextDescriptor().getEntryDescriptor( key );
Directive directive = context.getEntryDirective( key );
if( null == directive )
{
- if(
handler.getType().getContextDescriptor().getEntryDescriptor( key
).isOptional() )
+ if( descriptor.isOptional() )
{
return null;
}
@@ -621,10 +619,11 @@
ClassLoader classloader = handler.getClassLoader();
Value value = (Value) directive;
ClassLoader loader =
Thread.currentThread().getContextClassLoader();
+ String defaultTarget = descriptor.getClassname();
try
{
Thread.currentThread().setContextClassLoader(
classloader );
- return value.resolve( symbols, false );
+ return value.resolve( defaultTarget, symbols, false
);
}
catch( Exception ve )
{
@@ -643,9 +642,30 @@
Thread.currentThread().setContextClassLoader( loader
);
}
}
- else if( directive instanceof ReferenceDirective )
+ else if( directive instanceof LookupDirective )
{
- ReferenceDirective ref = (ReferenceDirective) directive;
+ LookupDirective ref = (LookupDirective) directive;
+ String spec = ref.getServiceClassname();
+ ServiceDescriptor request = new ServiceDescriptor( spec
);
+ DefaultService service = loadService( handler, request );
+ try
+ {
+ return executeLookup( handler, service );
+ }
+ catch( Exception ee )
+ {
+ final String error =
+ "Unable to resolve a service provider for the
class ["
+ + request.getClassname()
+ + "] requested in component ["
+ + handler.getPath()
+ + "] under the context key ["
+ + key
+ + "].";
+ throw new ControllerException( error, ee );
+ }
+
+ /*
URI uri = ref.getURI();
String scheme = uri.getScheme();
if( "service".equals( scheme ) || "lookup".equals(
scheme ) )
@@ -693,6 +713,7 @@
"Service lookup scheme [" + scheme + "] not
recognized.";
throw new ControllerException( error );
}
+ */
}
else
{

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/CompositionController.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/CompositionController.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/CompositionController.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -25,6 +25,8 @@
import java.util.EventObject;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.Hashtable;
import java.lang.reflect.InvocationTargetException;

import net.dpml.logging.Logger;
@@ -38,7 +40,6 @@
import net.dpml.part.Directive;
import net.dpml.part.Part;
import net.dpml.part.PartBuilder;
-import net.dpml.part.PartHeader;
import net.dpml.part.ControllerContext;
import net.dpml.part.ControllerContextListener;
import net.dpml.part.ControllerContextEvent;
@@ -47,7 +48,10 @@

import net.dpml.part.PartHandler;
import net.dpml.part.StandardPartHandler;
+import net.dpml.part.Strategy;

+import net.dpml.lang.Classpath;
+
import net.dpml.transit.Repository;
import net.dpml.transit.Transit;

@@ -61,6 +65,30 @@
public class CompositionController extends StandardPartHandler implements
Controller
{
//--------------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------------
+
+ private static final String COMPONENT_NAMESPACE_URI =
"@COMPONENT-NAMESPACE-URI@";
+ private static final String COMPONENT_BUILDER_URI =
"@COMPONENT-BUILDER-URI@";
+
+ static final PartBuilder BUILDER = createPartBuilder();
+
+ private static PartBuilder createPartBuilder()
+ {
+ Map map = new Hashtable();
+ try
+ {
+ map.put( COMPONENT_NAMESPACE_URI, new URI( COMPONENT_BUILDER_URI
) );
+ return new PartBuilder( map );
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ return new PartBuilder();
+ }
+ }
+
+ //--------------------------------------------------------------------
// immutable state
//--------------------------------------------------------------------

@@ -99,6 +127,7 @@
m_loader = Transit.getInstance().getRepository();
m_logger.debug( "controller: " + CONTROLLER_URI );
m_controller = new ComponentController( m_logger, this );
+
startEventDispatchThread();
}

@@ -106,36 +135,47 @@
// PartHandler
//--------------------------------------------------------------------

- //--------------------------------------------------------------------
- // Controller
- //--------------------------------------------------------------------
-
/**
- * Create a classloader using the supplied anchor classloader and
- * component directive.
- *
- * @param anchor the anchor classloader
- * @param model a component model
- * @return the new classloader
- * @exception ControlException if a classloader creation error occurs
+ * Build a classloader stack.
+ * @param anchor the anchor classloader to server as the classloader
chain root
+ * @param classpath the part classpath definition
+ * @exception IOException if an IO error occurs during classpath
evaluation
*/
- public ClassLoader createClassLoader( ClassLoader anchor, Model model )
throws ControlException
+ public ClassLoader getClassLoader( ClassLoader anchor, Classpath
classpath ) throws IOException
{
- if( model instanceof ComponentModel )
+ return super.getClassLoader( anchor, classpath );
+ }
+
+ /**
+ * Instantiate a value.
+ * @param classloader the implementation classloader established for the
part
+ * @param data the part deployment data
+ * @param args supplimentary arguments
+ * @exception Exception if a deployment error occurs
+ */
+ public Object getInstance(
+ ClassLoader anchor, Classpath classpath, Object data, Object[] args )
throws Exception
+ {
+ if( data instanceof ComponentDirective )
{
- ComponentModel componentModel = (ComponentModel) model;
- return m_controller.createClassLoader( anchor, componentModel );
+ ComponentDirective directive = (ComponentDirective) data;
+ ComponentModel model = m_controller.createComponentModel(
classpath, directive );
+ ClassLoader classloader = getClassLoader( anchor, classpath );
+ return m_controller.createDefaultComponentHandler( classloader,
model, true );
}
else
{
- final String error =
- "Construction of a classloader from the context model class ["
- + model.getClass().getName()
- + "] is not supported.";
- throw new ControllerException( error );
+ final String datatype = data.getClass().getName();
+ final String error =
+ "Unsupported datatype [" + datatype + "].";
+ throw new IllegalArgumentException( error );
}
}

+ //--------------------------------------------------------------------
+ // Controller
+ //--------------------------------------------------------------------
+
/**
* Returns the uri of this controller.
* @return the controller uri
@@ -155,8 +195,25 @@
*/
public Model createModel( URI uri ) throws ControlException, IOException
{
- Directive directive = loadDirective( uri );
- return createModel( directive );
+ Part part = BUILDER.loadPart( uri );
+ Strategy strategy = part.getStrategy();
+ Object data = strategy.getDeploymentData();
+ if( data instanceof ComponentDirective )
+ {
+ Classpath classpath = part.getClasspath();
+ ComponentDirective directive = (ComponentDirective) data;
+ return m_controller.createComponentModel( classpath, directive );
+ }
+ else
+ {
+ final String error =
+ "Part datatype ["
+ + data.getClass().getName()
+ + "] referenced in the part ["
+ + part
+ + "] is not recognized.";
+ throw new ControllerException( error );
+ }
}

/**
@@ -167,6 +224,7 @@
* @return the management context model
* @exception ControlException if an error occurs during model
construction
*/
+ /*
public Model createModel( Directive directive ) throws ControlException
{
if( directive instanceof ComponentDirective )
@@ -183,6 +241,7 @@
throw new ControllerException( error );
}
}
+ */

/**
* Create and return a remote reference to a component handler.
@@ -192,8 +251,26 @@
*/
public Component createComponent( URI uri ) throws Exception
{
- Model model = createModel( uri );
- return createComponent( model, true );
+ Part part = BUILDER.loadPart( uri );
+ Strategy strategy = part.getStrategy();
+ Object data = strategy.getDeploymentData();
+ if( data instanceof ComponentDirective )
+ {
+ Classpath classpath = part.getClasspath();
+ ComponentDirective directive = (ComponentDirective) data;
+ Model model = m_controller.createComponentModel( classpath,
directive );
+ return createComponent( model, true );
+ }
+ else
+ {
+ final String error =
+ "Part datatype ["
+ + data.getClass().getName()
+ + "] referenced in the part ["
+ + part
+ + "] is not recognized.";
+ throw new ControllerException( error );
+ }
}

/**
@@ -218,8 +295,11 @@
{
if( model instanceof ComponentModel )
{
+ ClassLoader anchor = Logger.class.getClassLoader();
ComponentModel componentModel = (ComponentModel) model;
- return m_controller.createDefaultComponentHandler(
componentModel, flag );
+ Classpath classpath = componentModel.getClasspath();
+ ClassLoader classloader = getClassLoader( anchor, classpath );
+ return m_controller.createDefaultComponentHandler( classloader,
componentModel, flag );
}
else
{
@@ -269,21 +349,28 @@
ClassLoader current = Thread.currentThread().getContextClassLoader();
try
{
- PartHeader header = PartBuilder.readPartHeader( uri );
- URI controllerURI = header.getControllerURI();
- if( CONTROLLER_URI.equals( controllerURI ) )
+ Part part = BUILDER.loadPart( uri );
+ Strategy strategy = part.getStrategy();
+ Object data = strategy.getDeploymentData();
+ if( data instanceof Directive )
{
- ClassLoader loader =
ComponentDirective.class.getClassLoader();
- Thread.currentThread().setContextClassLoader( loader );
- Part part = PartBuilder.readPart( uri );
- return part.getDirective();
+ return (Directive) data;
}
else
{
- Controller controller = getPrimaryController( controllerURI
);
- return controller.loadDirective( uri );
+ final String error =
+ "Part datatype ["
+ + data.getClass().getName()
+ + "] referenced in the part ["
+ + uri
+ + "] is not recognized.";
+ throw new ControllerException( error );
}
}
+ catch( ControllerException e )
+ {
+ throw e;
+ }
catch( Exception e )
{
final String error =
@@ -304,6 +391,7 @@
* @exception ControllerNotFoundException if the controller could not be
found
* @exception DelegationException if an error occured in the foreign
controller
*/
+ /*
public Controller getPrimaryController( URI uri )
throws ControllerNotFoundException, DelegationException
{
@@ -361,6 +449,7 @@
throw new ControllerRuntimeException( error );
}
}
+ */

void dispose()
{

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ContextInvocationHandler.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ContextInvocationHandler.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/ContextInvocationHandler.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -106,7 +106,7 @@
{
return value;
}
- else if( args.length > 0 )
+ else if( ( null != args ) && args.length > 0 )
{
return args[0];
}

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -51,7 +51,7 @@
import net.dpml.part.ActivationPolicy;
import net.dpml.part.Disposable;
import net.dpml.part.ControlException;
-import net.dpml.part.Version;
+import net.dpml.lang.Version;
import net.dpml.part.ServiceNotFoundException;
import net.dpml.part.Component;
import net.dpml.part.Provider;
@@ -59,6 +59,7 @@
import net.dpml.part.ModelEvent;
import net.dpml.part.ModelListener;

+import net.dpml.lang.Classpath;
import net.dpml.lang.UnknownKeyException;

import net.dpml.state.State;
@@ -277,8 +278,9 @@
{
ComponentDirective cd = (ComponentDirective) directive;
String partition = getPath() + "/";
+ Classpath classpath = m_model.getClasspath();
ComponentModel model =
- m_controller.createComponentModel( anchor, partition, cd );
+ m_controller.createComponentModel( anchor, classpath,
partition, cd );
return m_controller.createDefaultComponentHandler(
this, anchor, model, true );
}

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentModel.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentModel.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentModel.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -18,6 +18,7 @@

package net.dpml.metro.runtime;

+import java.io.IOException;
import java.rmi.RemoteException;
import java.util.HashMap;
import java.util.EventObject;
@@ -25,7 +26,6 @@
import java.util.Map;

import net.dpml.metro.data.ComponentDirective;
-import net.dpml.metro.data.ClassLoaderDirective;
import net.dpml.metro.data.ContextDirective;
import net.dpml.metro.data.CategoriesDirective;
import net.dpml.metro.data.CategoryDirective;
@@ -55,6 +55,7 @@
import net.dpml.parameters.Parameters;
import net.dpml.parameters.impl.DefaultParameters;

+import net.dpml.lang.Classpath;
import net.dpml.lang.UnknownKeyException;

/**
@@ -75,7 +76,8 @@
private final Type m_type;
private final ComponentDirective m_directive;
private final ClassLoader m_classloader;
- //private final String[] m_partKeys;
+ private final Classpath m_classpath;
+
private final HashMap m_parts = new HashMap();
private final DefaultContextModel m_context;
private final String m_path;
@@ -94,17 +96,18 @@
//
------------------------------------------------------------------------

public DefaultComponentModel(
- ClassLoader classloader, ComponentController controller,
+ ClassLoader anchor, ComponentController controller, Classpath
classpath,
ComponentDirective directive, String partition )
- throws ControlException, RemoteException
+ throws ControlException, IOException, RemoteException
{
super( new StandardLogger( partition.substring( 1 ).replace( '/',
'.' ) ) );

+ m_classpath = classpath;
m_controller = controller;
m_path = partition + directive.getName();
+ m_directive = directive;

- m_directive = directive;
- m_classloader = classloader;
+ m_classloader = m_controller.getClassLoader( anchor, classpath );
m_classname = directive.getClassname();
m_class = m_controller.loadComponentClass( m_classloader,
m_classname );
m_type = m_controller.loadType( m_class );
@@ -120,8 +123,8 @@
m_context = new DefaultContextModel( this, logger, m_classloader,
m_type, context );

final String base = m_path + PARTITION_SEPARATOR;
- processParts( controller, classloader, m_type, m_parts, base );
- processParts( controller, classloader, m_directive, m_parts, base );
+ processParts( controller, m_classloader, m_type, m_parts, base );
+ processParts( controller, m_classloader, m_directive, m_parts, base
);
}

private void processParts(
@@ -136,9 +139,10 @@
Directive part = composite.getDirective( key );
if( part instanceof ComponentDirective )
{
+ Classpath classpath = new Classpath();
ComponentDirective component = (ComponentDirective) part;
ComponentModel model =
- controller.createComponentModel( classloader, base,
component );
+ controller.createComponentModel( classloader, classpath,
base, component );
map.put( key, model );
}
else
@@ -152,6 +156,11 @@
}
}

+ public Classpath getClasspath()
+ {
+ return m_classpath;
+ }
+
protected void processEvent( EventObject event )
{
EventListener[] listeners = super.listeners();
@@ -234,7 +243,15 @@
*/
public String getName()
{
- return m_directive.getName();
+ String name = m_directive.getName();
+ if( null != name )
+ {
+ return name;
+ }
+ else
+ {
+ return m_type.getInfo().getName();
+ }
}

/**
@@ -368,11 +385,6 @@
}
}

- public ClassLoaderDirective getClassLoaderDirective()
- {
- return m_directive.getClassLoaderDirective();
- }
-
public Configuration getConfiguration()
{
if( null == m_configuration )

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -35,7 +35,7 @@
import net.dpml.part.Component;
import net.dpml.part.Model;
import net.dpml.part.Service;
-import net.dpml.part.Version;
+import net.dpml.lang.Version;

import net.dpml.lang.UnknownKeyException;


Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultService.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultService.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultService.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -19,7 +19,7 @@
package net.dpml.metro.runtime;

import net.dpml.part.Service;
-import net.dpml.part.Version;
+import net.dpml.lang.Version;

/**
* Default service implementation.

Deleted: trunk/main/metro/state/api/src/main/net/dpml/state/StateBuilder.java
===================================================================
--- trunk/main/metro/state/api/src/main/net/dpml/state/StateBuilder.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/state/api/src/main/net/dpml/state/StateBuilder.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,168 +0,0 @@
-/*
- * 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.state;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
-import java.beans.Encoder;
-import java.beans.XMLEncoder;
-import java.beans.XMLDecoder;
-import java.beans.ExceptionListener;
-import java.beans.Expression;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * Utility class the supports the construction of a state graph.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class StateBuilder
-{
- private StateBuilder()
- {
- // static utility
- }
-
- /**
- * Write a graph to a file. For correct operation the context
classloader
- * must contain both the api classes for the state package together with
- * any implementation classes using in the state graph implementation.
- *
- * @param graph the state graph
- * @param file destination file
- */
- public static void write( State graph, File file )
- {
- try
- {
- FileOutputStream output = new FileOutputStream( file );
- BufferedOutputStream buffer = new BufferedOutputStream( output );
- XMLEncoder encoder = new XMLEncoder( buffer );
- encoder.setPersistenceDelegate( URI.class, new
URIPersistenceDelegate() );
- encoder.setExceptionListener(
- new ExceptionListener()
- {
- public void exceptionThrown( Exception e )
- {
- throw new StateBuilderRuntimeException(
- "State graph encoding failure.", e );
- }
- } );
- try
- {
- encoder.writeObject( graph );
- }
- catch( Exception e )
- {
- throw new StateBuilderRuntimeException(
- "Part encoding error.", e );
- }
- finally
- {
- encoder.close();
- }
- }
- catch( IOException e )
- {
- final String error =
- "Internal error while attempting to write state graph to file
["
- + file
- + "]";
- throw new StateBuilderRuntimeException( error, e );
- }
- catch( StateBuilderRuntimeException e )
- {
- throw e;
- }
- catch( Exception e )
- {
- final String error =
- "Internal error while attempting to build the part.";
- throw new StateBuilderRuntimeException( error, e );
- }
- }
-
- /**
- * Read in a graph using the context classloader.
- * @param uri the graph uri
- * @return the state graph
- */
- public static State readGraph( URI uri )
- {
- try
- {
- URL url = uri.toURL();
- InputStream input = url.openStream();
- XMLDecoder decoder = new XMLDecoder( new BufferedInputStream(
input ) );
- decoder.setExceptionListener(
- new ExceptionListener()
- {
- public void exceptionThrown( Exception e )
- {
- throw new StateBuilderRuntimeException(
- "State graph decoding error.", e );
- }
- } );
- State graph = (State) decoder.readObject();
- if( null == graph )
- {
- final String error =
- "The decoder returned a null graph."
- + "\nURI: " + uri;
- throw new IllegalStateException( error );
- }
- return graph;
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected error while loading graph: "
- + uri;
- throw new StateBuilderRuntimeException( error, e );
- }
- }
-
- /**
- * Utility class used to handle uri persistence.
- */
- public static class URIPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return an expression to create a uri.
- * @param old the old value
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- URI uri = (URI) old;
- String spec = uri.toString();
- Object[] args = new Object[]{spec};
- return new Expression( old, old.getClass(), "new", args );
- }
- }
-}
-

Modified: trunk/main/metro/state/api/src/main/net/dpml/state/Trigger.java
===================================================================
--- trunk/main/metro/state/api/src/main/net/dpml/state/Trigger.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/state/api/src/main/net/dpml/state/Trigger.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -110,48 +110,4 @@
super( label );
}
}
-
- /**
- * Internal BeanInfo class that exposes an persistence delegate.
- */
- public static final class TriggerEventBeanInfo extends SimpleBeanInfo
- {
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
TriggerEvent.class );
- descriptor.setValue(
- "persistenceDelegate",
- new TriggerEventPersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate.
- */
- private static class TriggerEventPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Create an expression.
- * @paran old the old instance
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- TriggerEvent event = (TriggerEvent) old;
- return new Expression( TriggerEvent.class, "parse", new
Object[]{event.getName()} );
- }
- }
- }
}

Deleted: trunk/main/metro/state/build.xml
===================================================================
--- trunk/main/metro/state/build.xml 2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/state/build.xml 2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-state" default="install" basedir="."
- xmlns:transit="antlib:net.dpml.transit" >
-
- <transit:import uri="local:template:dpml/tools/reactor"/>
-
-</project>

Modified: trunk/main/metro/state/impl/build.xml
===================================================================
--- trunk/main/metro/state/impl/build.xml 2006-03-14 16:05:36 UTC (rev
1173)
+++ trunk/main/metro/state/impl/build.xml 2006-03-14 16:11:04 UTC (rev
1174)
@@ -23,6 +23,10 @@

<transit:import uri="local:template:dpml/tools/standard"/>

+ <target name="init" depends="standard.init">
+ <filter token="STATE-XSD-URI"
value="artifact:xsd:dpml/lang/dpml-state#1.0"/>
+ </target>
+
<target name="build" depends="standard.build">
<rmic base="${project.target.classes.main.dir}"
classpathref="project.compile.path">
<include name="**/DefaultStateListener.class"/>

Added: trunk/main/metro/state/impl/etc/test/empty.xml
===================================================================
--- trunk/main/metro/state/impl/etc/test/empty.xml 2006-03-14 16:05:36
UTC (rev 1173)
+++ trunk/main/metro/state/impl/etc/test/empty.xml 2006-03-14 16:11:04
UTC (rev 1174)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<state xmlns="@STATE-XSD-URI@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

Modified: trunk/main/metro/state/impl/etc/test/example.xgraph
===================================================================
--- trunk/main/metro/state/impl/etc/test/example.xgraph 2006-03-14 16:05:36
UTC (rev 1173)
+++ trunk/main/metro/state/impl/etc/test/example.xgraph 2006-03-14 16:11:04
UTC (rev 1174)
@@ -1,16 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
+<state xmlns="@STATE-XSD-URI@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>

-<state>
<trigger event="initialization">
<transition name="init" target="available/started">
<operation name="startup" method="start"/>
</transition>
</trigger>
+
<state name="available">
+
<operation name="audit" method="audit"/>
<trigger event="termination">
<transition name="terminate" target="../terminated"/>
</trigger>
+
<state name="started">
<interface class="org.acme.ManagementInterface"/>
<transition name="stop" target="../stopped">
@@ -20,12 +23,16 @@
<apply id="stop"/>
</trigger>
</state>
+
<state name="stopped">
<transition name="start" target="../started">
<operation name="start" method="start"/>
</transition>
</state>
+
</state>
+
<state name="terminated" terminal="true"/>
+
</state>


Added: trunk/main/metro/state/impl/etc/test/substates.xml
===================================================================
--- trunk/main/metro/state/impl/etc/test/substates.xml 2006-03-14 16:05:36
UTC (rev 1173)
+++ trunk/main/metro/state/impl/etc/test/substates.xml 2006-03-14 16:11:04
UTC (rev 1174)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<state xmlns="@STATE-XSD-URI@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+ <state name="foo">
+ <transition name="fred" target="wilma"/>
+ <state name="xxx"/>
+ </state>
+ <state name="bar">
+ </state>
+</state>

Added: trunk/main/metro/state/impl/etc/test/transition.xml
===================================================================
--- trunk/main/metro/state/impl/etc/test/transition.xml 2006-03-14 16:05:36
UTC (rev 1173)
+++ trunk/main/metro/state/impl/etc/test/transition.xml 2006-03-14 16:11:04
UTC (rev 1174)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<state xmlns="@STATE-XSD-URI@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+ <transition name="foo" target="bar"/>
+ <transition name="pink" target="floyd"/>
+ <transition name="barry" target="manalow"/>
+</state>

Deleted:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/ApplyActionBeanInfo.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/ApplyActionBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/ApplyActionBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -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.state.impl;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the DefaltTermination class that declares a persistence
delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ApplyActionBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- /**
- * Internal persistence delagate.
- * @return the bean descriptor
- */
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( ApplyAction.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"ID"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultInterfaceBeanInfo.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultInterfaceBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultInterfaceBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -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.state.impl;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the DefaultInterface class that declares a persistence
delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class DefaultInterfaceBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- /**
- * Internal persistence delagate.
- * @return the bean descriptor
- */
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
DefaultInterface.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"classname"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultOperationBeanInfo.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultOperationBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultOperationBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -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.state.impl;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the DefaltOperation class that declares a persistence
delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class DefaultOperationBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- /**
- * Internal persistence delagate.
- * @return the bean descriptor
- */
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
DefaultOperation.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"name", "methodName"}
) );
- return descriptor;
- }
-}

Modified:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultState.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultState.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultState.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -50,6 +50,15 @@
* Creation of a new state.
* @param name the state name
*/
+ public DefaultState()
+ {
+ this( "root" );
+ }
+
+ /**
+ * Creation of a new state.
+ * @param name the state name
+ */
public DefaultState( final String name )
{
this( name, new Trigger[0], new Transition[0], new Interface[0], new
Operation[0], new State[0], true );

Deleted:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateBeanInfo.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,67 +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.state.impl;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.PropertyDescriptor;
-
-/**
- * BeanInfo for the DefaltState class that declares a persistence delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class DefaultStateBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- /**
- * Return the property descriptors.
- * @return the descriptors
- */
- public PropertyDescriptor[] getPropertyDescriptors()
- {
- return new PropertyDescriptor[0];
- }
-
- /**
- * Internal persistence delagate.
- * @return the bean descriptor
- */
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( DefaultState.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate(
- new String[]{
- "name", "triggers", "transitions", "interfaces", "operations",
- "states", "terminal"} ) );
- return descriptor;
- }
-}

Modified:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateMachine.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateMachine.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultStateMachine.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -30,10 +30,6 @@
import java.util.Hashtable;
import java.util.List;

-import net.dpml.configuration.Configuration;
-import net.dpml.configuration.impl.DefaultConfigurationBuilder;
-import net.dpml.configuration.impl.ConfigurationUtil;
-
import net.dpml.state.State;
import net.dpml.state.Transition;
import net.dpml.state.Operation;
@@ -60,31 +56,7 @@
*/
public static final String PROPERTY_NAME = "state";

- private static final DefaultConfigurationBuilder BUILDER = new
DefaultConfigurationBuilder();
-
/**
- * Load a state descriptor from an input stream.
- * @param input the input stream
- * @return the state graph
- * @exception StateBuilderRuntimeException if an error occurs during
loading
- */
- public static State load( InputStream input ) throws
StateBuilderRuntimeException
- {
- State graph = null;
- try
- {
- Configuration config = BUILDER.build( input );
- return buildState( config, true );
- }
- catch( Throwable e )
- {
- final String error =
- "Internal error while attempting to build state graph.";
- throw new StateBuilderRuntimeException( error, e );
- }
- }
-
- /**
* Validate the state integrity.
* @param state the state to validate
*/
@@ -108,16 +80,6 @@

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

/**
- * Creation of a new state machine using a supplied input stream of
- * the source for the state graph.
- * @param input the input stream to a state graph
- */
- public DefaultStateMachine( InputStream input )
- {
- this( load( input ) );
- }
-
- /**
* Creation of a new state machine using a state graph.
* @param state the state graph
*/
@@ -949,241 +911,6 @@
}
}

-
//-------------------------------------------------------------------------------
- // static internals used top build a state graph from a supplied
configuration
-
//-------------------------------------------------------------------------------
-
- private static DefaultState buildState( Configuration config, boolean
root ) throws Exception
- {
- String stateName = null;
- boolean terminal = false;
- String[] names = config.getAttributeNames();
- for( int i=0; i<names.length; i++ )
- {
- String name = names[i];
- if( name.equals( "name" ) )
- {
- if( root )
- {
- final String error =
- "Root state elements is declaring a name.";
- throw new StateBuilderRuntimeException( error );
- }
- else
- {
- stateName = config.getAttribute( "name" );
- }
- }
- else if( name.equals( "terminal" ) )
- {
- terminal = config.getAttributeAsBoolean( "terminal", false );
- }
- else
- {
- final String error =
- "State element attribute name ["
- + name
- + "] is not recognized.";
- throw new StateBuilderRuntimeException( error );
- }
- }
-
- if( null == stateName )
- {
- if( !root )
- {
- final String error =
- "State element does not declare a 'name'.";
- throw new StateBuilderRuntimeException( error );
- }
- else
- {
- stateName = "";
- }
- }
- ArrayList transitionList = new ArrayList();
- ArrayList operationList = new ArrayList();
- ArrayList interfaceList = new ArrayList();
- ArrayList stateList = new ArrayList();
- ArrayList triggerList = new ArrayList();
- Configuration[] children = config.getChildren();
- for( int i=0; i<children.length; i++ )
- {
- Configuration child = children[i];
- String name = child.getName();
- if( name.equals( "transition" ) )
- {
- Transition transition = buildTransition( child );
- transitionList.add( transition );
- }
- else if( name.equals( "operation" ) )
- {
- Operation operation = buildOperation( child );
- operationList.add( operation );
- }
- else if( name.equals( "interface" ) )
- {
- Interface data = buildInterface( child );
- interfaceList.add( data );
- }
- else if( name.equals( "state" ) )
- {
- DefaultState state = buildState( child, false );
- stateList.add( state );
- }
- else if( name.equals( "trigger" ) )
- {
- Trigger trigger = buildTrigger( child );
- triggerList.add( trigger );
- }
- else
- {
- final String error =
- "A subsidiary element named ["
- + name
- + "] with the state element ["
- + stateName
- + "] is not recognized."
- + ConfigurationUtil.list( child );
- throw new StateBuilderRuntimeException( error );
- }
- }
- DefaultTransition[] transitions = (DefaultTransition[])
transitionList.toArray( new DefaultTransition[0] );
- DefaultOperation[] operations = (DefaultOperation[])
operationList.toArray( new DefaultOperation[0] );
- DefaultInterface[] interfaces = (DefaultInterface[])
interfaceList.toArray( new DefaultInterface[0] );
- DefaultState[] states = (DefaultState[]) stateList.toArray( new
DefaultState[0] );
- DefaultTrigger[] triggers = (DefaultTrigger[]) triggerList.toArray(
new DefaultTrigger[0] );
- return new DefaultState( stateName, triggers, transitions,
interfaces, operations, states, terminal );
- }
-
- private static Trigger buildTrigger( Configuration config ) throws
Exception
- {
- String name = config.getName();
- if( name.equals( "trigger" ) )
- {
- String eventName = config.getAttribute( "event",
Trigger.INITIALIZATION.getName() );
- TriggerEvent event = TriggerEvent.parse( eventName );
- if( config.getChildren().length == 1 )
- {
- Configuration c = config.getChildren()[0];
- Action action = buildAction( c );
- return new DefaultTrigger( event, action );
- }
- else
- {
- final String error =
- "Trigger element does not contain a nested action
element.";
- throw new StateBuilderRuntimeException( error );
- }
- }
- else
- {
- final String error =
- "Illegal element name ["
- + name
- + "] supplied to trigger builder.";
- throw new StateBuilderRuntimeException( error );
- }
- }
-
- private static Action buildAction( Configuration config ) throws
Exception
- {
- String name = config.getName();
- if( name.equals( "transition" ) )
- {
- return buildTransition( config );
- }
- else if( name.equals( "operation" ) )
- {
- return buildOperation( config );
- }
- else if( name.equals( "apply" ) )
- {
- String id = config.getAttribute( "id" );
- return new ApplyAction( id );
- }
- else if( name.equals( "exec" ) )
- {
- String id = config.getAttribute( "id" );
- return new ExecAction( id );
- }
- else
- {
- final String error =
- "Illegal element name ["
- + name
- + "] supplied to action builder."
- + ConfigurationUtil.list( config );
- throw new StateBuilderRuntimeException( error );
- }
- }
-
- private static DefaultOperation buildOperation( Configuration config )
throws Exception
- {
- if( null == config )
- {
- return null;
- }
- String name = config.getName();
- if( name.equals( "operation" ) )
- {
- String operationName = config.getAttribute( "name" );
- String methodName = config.getAttribute( "method", null );
- return new DefaultOperation( operationName, methodName );
- }
- else
- {
- final String error =
- "Illegal element name ["
- + name
- + "] supplied to operation builder.";
- throw new StateBuilderRuntimeException( error );
- }
- }
-
- private static DefaultInterface buildInterface( Configuration config )
throws Exception
- {
- if( null == config )
- {
- return null;
- }
- String name = config.getName();
- if( name.equals( "interface" ) )
- {
- String className = config.getAttribute( "class", null );
- return new DefaultInterface( className );
- }
- else
- {
- final String error =
- "Illegal element name ["
- + name
- + "] supplied to operation builder.";
- throw new StateBuilderRuntimeException( error );
- }
- }
-
- private static DefaultTransition buildTransition( Configuration config )
throws Exception
- {
- String name = config.getName();
-
- if( name.equals( "transition" ) )
- {
- String transitionName = config.getAttribute( "name" );
- String target = config.getAttribute( "target", "." );
- DefaultOperation operation = buildOperation( config.getChild(
"operation", false ) );
- return new DefaultTransition( transitionName, target, operation
);
- }
- else
- {
- final String error =
- "Illegal element name ["
- + name
- + "] supplied to transition builder.";
- throw new StateBuilderRuntimeException( error );
- }
- }
-
private static URI createURI( String path ) throws Exception
{
if( null == path )

Deleted:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultTransitionBeanInfo.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultTransitionBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultTransitionBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,64 +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.state.impl;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.PropertyDescriptor;
-
-/**
- * BeanInfo for the DefaltTransition class that declares a persistence
delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class DefaultTransitionBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- /**
- * Return the property descriptors.
- * @return the descriptors
- */
- public PropertyDescriptor[] getPropertyDescriptors()
- {
- return new PropertyDescriptor[0];
- }
-
- /**
- * Internal persistence delagate.
- * @return the bean descriptor
- */
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor(
DefaultTransition.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"name", "targetName",
"operation"} ) );
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultTriggerBeanInfo.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultTriggerBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/DefaultTriggerBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -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.state.impl;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the DefaltTermination class that declares a persistence
delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class DefaultTriggerBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- /**
- * Internal persistence delagate.
- * @return the bean descriptor
- */
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( DefaultTrigger.class
);
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"event", "action"} )
);
- return descriptor;
- }
-}

Deleted:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/ExecActionBeanInfo.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/ExecActionBeanInfo.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/ExecActionBeanInfo.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -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.state.impl;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the DefaltTermination class that declares a persistence
delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ExecActionBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Return the bean descriptor.
- * @return the descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- /**
- * Internal persistence delagate.
- * @return the bean descriptor
- */
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( ExecAction.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate( new String[]{"ID"} ) );
- return descriptor;
- }
-}

Added:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/StateBuilder.java
===================================================================
---
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/StateBuilder.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/StateBuilder.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,272 @@
+/*
+ * Copyright 2006 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.state.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.io.OutputStreamWriter;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import javax.xml.XMLConstants;
+
+import net.dpml.state.State;
+import net.dpml.state.Action;
+import net.dpml.state.Trigger.TriggerEvent;
+import net.dpml.state.StateBuilderRuntimeException;
+
+import net.dpml.part.DOM3DocumentBuilder;
+
+import net.dpml.transit.util.ElementHelper;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.Attr;
+import org.w3c.dom.TypeInfo;
+
+/**
+ * Construct a state graph.
+ */
+public class StateBuilder extends StateWriter
+{
+ private static final String XML_HEADER =
+ "<?xml version=\"1.0\"?>";
+
+ private static final String STATE_SCHEMA_URN = "@STATE-XSD-URI@";
+
+ private static final String STATE_HEADER =
+ "<state xmlns=\""
+ + STATE_SCHEMA_URN
+ + "\""
+ + "\n xmlns:xsi=\""
+ + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI
+ + "\">";
+
+ private static final String STATE_FOOTER = "</state>";
+
+ private static DOM3DocumentBuilder BUILDER = new DOM3DocumentBuilder();
+
+ public State loadState( URI uri ) throws IOException
+ {
+ if( null == uri )
+ {
+ throw new NullPointerException( "uri" );
+ }
+ try
+ {
+ final Document document = BUILDER.parse( uri );
+ final Element root = document.getDocumentElement();
+ return buildStateGraph( root );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "An error while attempting to load a state graph."
+ + "\nURI: " + uri;
+ IOException exception = new IOException( error );
+ exception.initCause( e );
+ throw exception;
+ }
+ }
+
+ public State buildStateGraph( Element element )
+ {
+ if( null == element )
+ {
+ throw new NullPointerException( "element" );
+ }
+
+ boolean terminal = ElementHelper.getBooleanAttribute( element,
"terminal" );
+ DefaultTransition[] transitions = buildNestedTransitions( element );
+ DefaultOperation[] operations = buildNestedOperations( element );
+ DefaultInterface[] interfaces = buildNestedInterfaces( element );
+ DefaultState[] states = buildNestedStates( 1, element );
+ DefaultTrigger[] triggers = buildNestedTriggers( element );
+ return new DefaultState(
+ "root", triggers, transitions, interfaces, operations, states,
terminal );
+ }
+
+ private DefaultTransition[] buildNestedTransitions( Element element )
+ {
+ Element[] children = ElementHelper.getChildren( element,
"transition" );
+ DefaultTransition[] transitions = new DefaultTransition[
children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ transitions[i] = buildTransition( child );
+ }
+ return transitions;
+ }
+
+ private DefaultOperation[] buildNestedOperations( Element element )
+ {
+ Element[] children = ElementHelper.getChildren( element, "operation"
);
+ DefaultOperation[] operations = new DefaultOperation[
children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ operations[i] = buildOperation( child );
+ }
+ return operations;
+ }
+
+ private DefaultInterface[] buildNestedInterfaces( Element element )
+ {
+ Element[] children = ElementHelper.getChildren( element, "interface"
);
+ DefaultInterface[] interfaces = new DefaultInterface[
children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ interfaces[i] = buildInterface( child );
+ }
+ return interfaces;
+ }
+
+ private DefaultState[] buildNestedStates( int n, Element element )
+ {
+ Element[] children = ElementHelper.getChildren( element, "state" );
+ DefaultState[] states = new DefaultState[ children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ states[i] = buildState( n, child );
+ }
+ return states;
+ }
+
+ private DefaultTrigger[] buildNestedTriggers( Element element )
+ {
+ Element[] children = ElementHelper.getChildren( element, "trigger" );
+ DefaultTrigger[] triggers = new DefaultTrigger[ children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ triggers[i] = buildTrigger( child );
+ }
+ return triggers;
+ }
+
+ private DefaultTransition buildTransition( Element element )
+ {
+ String name = ElementHelper.getAttribute( element, "name" );
+ String target = ElementHelper.getAttribute( element, "target" );
+ Element child = ElementHelper.getChild( element, "operation" );
+ DefaultOperation operation = buildOperation( child );
+ return new DefaultTransition( name, target, operation );
+ }
+
+ private DefaultOperation buildOperation( Element element )
+ {
+ if( null == element )
+ {
+ return null;
+ }
+ String name = ElementHelper.getAttribute( element, "name" );
+ String method = ElementHelper.getAttribute( element, "method" );
+ return new DefaultOperation( name, method );
+ }
+
+ private DefaultInterface buildInterface( Element element )
+ {
+ String classname = ElementHelper.getAttribute( element, "class" );
+ return new DefaultInterface( classname );
+ }
+
+ private DefaultState buildState( int n, Element element )
+ {
+ String name = ElementHelper.getAttribute( element, "name" );
+ boolean terminal = ElementHelper.getBooleanAttribute( element,
"terminal" );
+ DefaultTransition[] transitions = buildNestedTransitions( element );
+ DefaultOperation[] operations = buildNestedOperations( element );
+ DefaultInterface[] interfaces = buildNestedInterfaces( element );
+ DefaultState[] states = buildNestedStates( n+1, element );
+ DefaultTrigger[] triggers = buildNestedTriggers( element );
+ return new DefaultState(
+ name, triggers, transitions, interfaces, operations, states,
terminal );
+ }
+
+ private DefaultTrigger buildTrigger( Element element )
+ {
+ String type = ElementHelper.getAttribute( element, "event" );
+ TriggerEvent event = TriggerEvent.parse( type );
+ Element child = getSingleNestedElement( element );
+ Action action = buildAction( child );
+ return new DefaultTrigger( event, action );
+ }
+
+ private Action buildAction( Element element )
+ {
+ String name = element.getTagName();
+ if( name.equals( "transition" ) )
+ {
+ return buildTransition( element );
+ }
+ else if( name.equals( "operation" ) )
+ {
+ return buildOperation( element );
+ }
+ else if( name.equals( "apply" ) )
+ {
+ String id = ElementHelper.getAttribute( element, "id" );
+ return new ApplyAction( id );
+ }
+ else if( name.equals( "exec" ) )
+ {
+ String id = ElementHelper.getAttribute( element, "id" );
+ return new ExecAction( id );
+ }
+ else
+ {
+ final String error =
+ "Illegal element name ["
+ + name
+ + "] supplied to action builder.";
+ throw new StateBuilderRuntimeException( error );
+ }
+ }
+
+ private Element getSingleNestedElement( Element parent )
+ {
+ if( null == parent )
+ {
+ throw new NullPointerException( "parent" );
+ }
+ else
+ {
+ Element[] children = ElementHelper.getChildren( parent );
+ if( children.length == 1 )
+ {
+ return children[0];
+ }
+ else
+ {
+ final String error =
+ "Parent element does not contain a single child.";
+ throw new IllegalArgumentException( error );
+ }
+ }
+ }
+}

Added:
trunk/main/metro/state/impl/src/main/net/dpml/state/impl/StateWriter.java
===================================================================
--- trunk/main/metro/state/impl/src/main/net/dpml/state/impl/StateWriter.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/state/impl/src/main/net/dpml/state/impl/StateWriter.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,350 @@
+/*
+ * Copyright 2006 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.state.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.io.OutputStreamWriter;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import javax.xml.XMLConstants;
+
+import net.dpml.state.State;
+import net.dpml.state.Action;
+import net.dpml.state.Trigger.TriggerEvent;
+import net.dpml.state.StateBuilderRuntimeException;
+
+import net.dpml.part.DOM3DocumentBuilder;
+
+import net.dpml.transit.util.ElementHelper;
+
+import net.dpml.state.Trigger;
+import net.dpml.state.State;
+import net.dpml.state.Transition;
+import net.dpml.state.Operation;
+import net.dpml.state.Interface;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.Attr;
+import org.w3c.dom.TypeInfo;
+
+/**
+ * Construct a state graph.
+ */
+public class StateWriter
+{
+ private static final String XML_HEADER =
+ "<?xml version=\"1.0\"?>";
+
+ private static final String STATE_SCHEMA_URN = "@STATE-XSD-URI@";
+
+ /**
+ * Externalize the part to XML.
+ * @param part the part to externalize
+ * @param output the output stream
+ * @exception IOException if an IO error occurs
+ */
+ public void export( State state, OutputStream output ) throws IOException
+ {
+ final Writer writer = new OutputStreamWriter( output );
+
+ writer.write( XML_HEADER );
+ writer.write( "\n\n" );
+ writer.write( "<state xmlns=\""
+ + STATE_SCHEMA_URN
+ + "\""
+ + "\n xmlns:xsi=\""
+ + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI
+ + "\"" );
+ if( state.isTerminal() )
+ {
+ writer.write( " terminal=\"true\">" );
+ }
+ else
+ {
+ writer.write( ">" );
+ }
+ writer.write( "\n" );
+ writeBody( writer, state, "" );
+ writer.write( "\n" );
+ writer.write( "\n</state>" );
+ writer.write( "\n" );
+ writer.flush();
+ output.close();
+ }
+
+ public void writeState( Writer writer, State state, String pad ) throws
IOException
+ {
+ if( isEmpty( state ) )
+ {
+ return;
+ }
+ else
+ {
+ writer.write( "\n" + pad + "<state xmlns=\"" + STATE_SCHEMA_URN
+ "\"" );
+ if( state.isTerminal() )
+ {
+ writer.write( " terminal=\"true\"" );
+ }
+ writer.write( ">" );
+ writeBody( writer, state, pad + " " );
+ writer.write( "\n" + pad + "</state>" );
+ }
+ }
+
+ private void writeBody( Writer writer, State state, String pad ) throws
IOException
+ {
+ Trigger[] triggers = state.getTriggers();
+ Transition[] transitions = state.getTransitions();
+ Operation[] operations = state.getOperations();
+ Interface[] interfaces = state.getInterfaces();
+ State[] states = state.getStates();
+
+ writeTriggers( writer, triggers, pad );
+ writeTransitions( writer, transitions, pad );
+ writeOperations( writer, operations, pad );
+ writeInterfaces( writer, interfaces, pad );
+ writeStates( writer, states, pad );
+ }
+
+ private void writeTriggers( Writer writer, Trigger[] triggers, String
pad ) throws IOException
+ {
+ if( triggers.length == 0 )
+ {
+ return;
+ }
+ else
+ {
+ for( int i=0; i<triggers.length; i++ )
+ {
+ Trigger trigger = triggers[i];
+ writeTrigger( writer, trigger, pad );
+ }
+ }
+ }
+
+ private void writeTrigger( Writer writer, Trigger trigger, String pad )
throws IOException
+ {
+ TriggerEvent event = trigger.getEvent();
+ writer.write( "\n" + pad + "<trigger event=\"" );
+ writer.write( event.getName() );
+ writer.write( "\">" );
+ Action action = trigger.getAction();
+ writeAction( writer, action, pad + " " );
+ writer.write( "\n" + pad + "</trigger>" );
+ }
+
+ private void writeTransitions( Writer writer, Transition[] transitions,
String pad ) throws IOException
+ {
+ if( transitions.length == 0 )
+ {
+ return;
+ }
+ else
+ {
+ for( int i=0; i<transitions.length; i++ )
+ {
+ Transition transition = transitions[i];
+ writeTransition( writer, transition, pad );
+ }
+ }
+ }
+
+ private void writeOperations( Writer writer, Operation[] operations,
String pad ) throws IOException
+ {
+ if( operations.length == 0 )
+ {
+ return;
+ }
+ else
+ {
+ for( int i=0; i<operations.length; i++ )
+ {
+ Operation operation = operations[i];
+ writeOperation( writer, operation, pad );
+ }
+ }
+ }
+
+ private void writeInterfaces( Writer writer, Interface[] interfaces,
String pad ) throws IOException
+ {
+ if( interfaces.length == 0 )
+ {
+ return;
+ }
+ else
+ {
+ for( int i=0; i<interfaces.length; i++ )
+ {
+ Interface spec = interfaces[i];
+ writeInterface( writer, spec, pad );
+ }
+ }
+ }
+
+ private void writeStates( Writer writer, State[] states, String pad )
throws IOException
+ {
+ if( states.length == 0 )
+ {
+ return;
+ }
+ else
+ {
+ for( int i=0; i<states.length; i++ )
+ {
+ State state = states[i];
+ writeNestedState( writer, state, pad );
+ }
+ }
+ }
+
+ private void writeTransition( Writer writer, Transition transition,
String pad ) throws IOException
+ {
+ String name = transition.getName();
+ String target = transition.getTargetName();
+ writer.write( "\n" + pad + "<transition name=\"" + name + "\"
target=\"" + target + "\"" );
+ Operation operation = transition.getOperation();
+ if( null == operation )
+ {
+ writer.write( "/>" );
+ }
+ else
+ {
+ writer.write( ">" );
+ writeOperation( writer, operation, pad + " " );
+ writer.write( "\n" + pad + "</transition>" );
+ }
+ }
+
+ private void writeOperation( Writer writer, Operation operation, String
pad ) throws IOException
+ {
+ String name = operation.getName();
+ String method = operation.getMethodName();
+ writer.write( "\n" + pad + "<operation name=\"" + name + "\"" );
+ if( null != method )
+ {
+ writer.write( " method=\"" + method + "\"" );
+ }
+ writer.write( "/>" );
+ }
+
+ private void writeInterface( Writer writer, Interface spec, String pad )
throws IOException
+ {
+ String classname = spec.getClassname();
+ writer.write( "\n" + pad + "<interface class=\"" + classname +
"\"/>" );
+ }
+
+ private void writeAction( Writer writer, Action action, String pad )
throws IOException
+ {
+ if( action instanceof Transition )
+ {
+ Transition transition = (Transition) action;
+ writeTransition( writer, transition, pad );
+ }
+ else if( action instanceof Operation )
+ {
+ Operation operation = (Operation) action;
+ writeOperation( writer, operation, pad );
+ }
+ else if( action instanceof Interface )
+ {
+ Interface spec = (Interface) action;
+ writeInterface( writer, spec, pad );
+ }
+ else if( action instanceof ExecAction )
+ {
+ ExecAction exec = (ExecAction) action;
+ writeExecAction( writer, exec, pad );
+ }
+ else if( action instanceof ApplyAction )
+ {
+ ApplyAction apply = (ApplyAction) action;
+ writeApplyAction( writer, apply, pad );
+ }
+ else
+ {
+ final String error =
+ "Unrecognized action class ["
+ + action.getClass().getName()
+ + "].";
+ throw new IOException( error );
+ }
+ }
+ private void writeExecAction( Writer writer, ExecAction action, String
pad ) throws IOException
+ {
+ String id = action.getID();
+ writer.write( "\n" + pad + "<exec id=\"" + id + "\"/>" );
+ }
+
+ private void writeApplyAction( Writer writer, ApplyAction action, String
pad ) throws IOException
+ {
+ String id = action.getID();
+ writer.write( "\n" + pad + "<apply id=\"" + id + "\"/>" );
+ }
+
+ private void writeNestedState( Writer writer, State state, String pad )
throws IOException
+ {
+ String name = state.getName();
+ writer.write( "\n" + pad + "<state name=\"" + name + "\"" );
+ if( state.isTerminal() )
+ {
+ writer.write( " terminal=\"true\">" );
+ }
+ else
+ {
+ writer.write( ">" );
+ }
+ writeBody( writer, state, pad + " " );
+ writer.write( "\n" + pad + "</state>" );
+ }
+
+ private boolean isEmpty( State state )
+ {
+ if( state.getTriggers().length > 0 )
+ {
+ return false;
+ }
+ if( state.getTransitions().length > 0 )
+ {
+ return false;
+ }
+ if( state.getOperations().length > 0 )
+ {
+ return false;
+ }
+ if( state.getInterfaces().length > 0 )
+ {
+ return false;
+ }
+ if( state.getStates().length > 0 )
+ {
+ return false;
+ }
+ return true;
+ }
+}

Added: trunk/main/metro/state/impl/src/test/net/dpml/state/EmptyTestCase.java
===================================================================
--- trunk/main/metro/state/impl/src/test/net/dpml/state/EmptyTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/state/impl/src/test/net/dpml/state/EmptyTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,75 @@
+/*
+ * 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.state;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.BufferedInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.net.URI;
+
+import net.dpml.state.State;
+import net.dpml.state.Transition;
+import net.dpml.state.Operation;
+import net.dpml.state.Interface;
+import net.dpml.state.Trigger;
+import net.dpml.state.Action;
+
+import junit.framework.TestCase;
+
+import net.dpml.state.impl.StateBuilder;
+
+/**
+ * Default state machine test-case.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public class EmptyTestCase extends TestCase
+{
+ private StateBuilder m_builder;
+
+ /**
+ * Testcase setup.
+ * @exception Exception if a setup error occurs
+ */
+ public void setUp() throws Exception
+ {
+ m_builder = new StateBuilder();
+ }
+
+ /**
+ * List the state graph.
+ * @exception Exception if an error occurs
+ */
+ public void testStateLoading() throws Exception
+ {
+ String testPath = System.getProperty( "project.test.dir" );
+ File test = new File( testPath );
+ File example = new File( test, "empty.xml" );
+ URI uri = example.toURI();
+ State state = m_builder.loadState( uri );
+ assertEquals( "substates", 0, state.getStates().length );
+ assertEquals( "transitions", 0, state.getTransitions().length );
+ assertEquals( "triggers", 0, state.getTriggers().length );
+ }
+}
+
+
+

Added:
trunk/main/metro/state/impl/src/test/net/dpml/state/TransitionTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/TransitionTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/TransitionTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,75 @@
+/*
+ * 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.state;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.BufferedInputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.net.URI;
+
+import net.dpml.state.State;
+import net.dpml.state.Transition;
+import net.dpml.state.Operation;
+import net.dpml.state.Interface;
+import net.dpml.state.Trigger;
+import net.dpml.state.Action;
+
+import junit.framework.TestCase;
+
+import net.dpml.state.impl.StateBuilder;
+
+/**
+ * Default state machine test-case.
+ *
+ * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+ */
+public class TransitionTestCase extends TestCase
+{
+ private StateBuilder m_builder;
+
+ /**
+ * Testcase setup.
+ * @exception Exception if a setup error occurs
+ */
+ public void setUp() throws Exception
+ {
+ m_builder = new StateBuilder();
+ }
+
+ /**
+ * List the state graph.
+ * @exception Exception if an error occurs
+ */
+ public void testStateLoading() throws Exception
+ {
+ String testPath = System.getProperty( "project.test.dir" );
+ File test = new File( testPath );
+ File example = new File( test, "transition.xml" );
+ URI uri = example.toURI();
+ State state = m_builder.loadState( uri );
+ assertEquals( "substates", 0, state.getStates().length );
+ assertEquals( "transitions", 3, state.getTransitions().length );
+ assertEquals( "triggers", 0, state.getTriggers().length );
+ }
+}
+
+
+

Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/AbstractEncodingTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/AbstractEncodingTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/AbstractEncodingTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -21,8 +21,10 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
import java.beans.Encoder;
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
@@ -43,59 +45,27 @@
{
/**
* Utility operation to validate encoding and decoding of a supplied
object.
- * @param object the enject to encode and decode
- * @param filename a file path relative to the test directory to which
- * interim encoded data will be written to
- * @return the object resulting from the decode of the interim file
+ * @param object the object to encode and decode
+ * @return the object resulting from deserialization
* @exception Exception if an error occurs
*/
- public Object executeEncodingTest( Object object, String filename )
throws Exception
+ public Object executeEncodingTest( Object object ) throws Exception
{
- String base = System.getProperty( "project.test.dir" );
- File test = new File( base );
- File destination = new File( test, filename );
- FileOutputStream output = new FileOutputStream( destination );
- BufferedOutputStream buffer = new BufferedOutputStream( output );
- XMLEncoder encoder = new XMLEncoder( buffer );
- encoder.setPersistenceDelegate( URI.class, new
URIPersistenceDelegate() );
- encoder.setExceptionListener(
- new ExceptionListener()
- {
- public void exceptionThrown( Exception e )
- {
- e.printStackTrace();
- fail( "encoding exception: " + e.toString() );
- }
- }
- );
- encoder.writeObject( object );
- encoder.close();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream( baos );
+ oos.writeObject( object );
+ oos.close();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(
baos.toByteArray() );
+ ObjectInputStream ois = new ObjectInputStream( bais );
+ Object serialized = ois.readObject();
+ ois.close();
+
+ assertTrue( object != serialized ); // Ensure this is not the same
instance
+ assertEquals( object, serialized );
+ assertEquals( object.hashCode(), serialized.hashCode() );

- FileInputStream input = new FileInputStream( destination );
- XMLDecoder decoder = new XMLDecoder( new BufferedInputStream( input
) );
- Object result = decoder.readObject();
- assertEquals( "encoding", object, result );
- return result;
+ return serialized;
}

- /**
- * Utility persistence delegate used to handle uri encoding.
- */
- public static class URIPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Create an expression instance for a supplied uri.
- * @param old the old uri
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- URI uri = (URI) old;
- String spec = uri.toString();
- Object[] args = new Object[]{spec};
- return new Expression( old, old.getClass(), "new", args );
- }
- }
-
}

Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultOperationTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultOperationTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultOperationTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -73,7 +73,7 @@
*/
public void testEncoding() throws Exception
{
- Operation operation = (Operation) executeEncodingTest( m_operation,
"simple-operation-encoded.xml" );
+ Operation operation = (Operation) executeEncodingTest( m_operation );
assertEquals( "original-equals-encoded", m_operation, operation );
}
}

Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateMachineTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateMachineTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateMachineTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -31,6 +31,7 @@
import net.dpml.state.Trigger;
import net.dpml.state.Action;
import net.dpml.state.impl.DefaultStateMachine;
+import net.dpml.state.impl.StateBuilder;

/**
* Default state machine test-case.
@@ -51,11 +52,10 @@
String testPath = System.getProperty( "project.test.dir" );
File test = new File( testPath );
File example = new File( test, "example.xgraph" );
- FileInputStream input = new FileInputStream( example );
- BufferedInputStream buffer = new BufferedInputStream( input );
try
{
- m_state = DefaultStateMachine.load( buffer );
+ StateBuilder builder = new StateBuilder();
+ m_state = builder.loadState( example.toURI() );
m_machine = new DefaultStateMachine( m_state );
}
catch( Throwable e )
@@ -63,10 +63,6 @@
e.printStackTrace();
fail( e.toString() );
}
- finally
- {
- input.close();
- }
}

/**
@@ -215,7 +211,7 @@
*/
public void testEncoding() throws Exception
{
- Object state = executeEncodingTest( m_state, "state-encoded.xml" );
+ Object state = executeEncodingTest( m_state );
}

private void audit( State state )

Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -140,7 +140,7 @@
*/
public void testEncoding() throws Exception
{
- State state = (State) executeEncodingTest( m_state,
"simple-state-encoded.xml" );
+ State state = (State) executeEncodingTest( m_state );
assertEquals( "origin-equals-encoded", m_state, state );
}


Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTransitionTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTransitionTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTransitionTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -80,7 +80,7 @@
*/
public void testEncoding() throws Exception
{
- Transition transition = (Transition) executeEncodingTest(
m_transition, "simple-transition-encoded.xml" );
+ Transition transition = (Transition) executeEncodingTest(
m_transition );
assertEquals( "original-equals-encoded", m_transition, transition );
}


Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTriggerTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTriggerTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTriggerTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -70,7 +70,7 @@
*/
public void testEncoding() throws Exception
{
- Trigger trigger = (Trigger) executeEncodingTest( m_trigger,
"simple-trigger-encoded.xml" );
+ Trigger trigger = (Trigger) executeEncodingTest( m_trigger );
assertEquals( "original-equals-encoded", m_trigger, trigger );
}


Deleted: trunk/main/metro/station/build.xml
===================================================================
--- trunk/main/metro/station/build.xml 2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/station/build.xml 2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- 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.
--->
-
-<project name="dpml-station" default="install" basedir="."
- xmlns:transit="antlib:net.dpml.transit">
-
- <transit:import uri="local:template:dpml/tools/reactor"/>
-
-</project>

Modified: trunk/main/metro/station/console/build.xml
===================================================================
--- trunk/main/metro/station/console/build.xml 2006-03-14 16:05:36 UTC (rev
1173)
+++ trunk/main/metro/station/console/build.xml 2006-03-14 16:11:04 UTC (rev
1174)
@@ -9,7 +9,7 @@
<available property="station.exe.available"
file="${dpml.system}/bin/station.exe"/>

<target name="init" depends="standard.init">
- <x:filter token="DEPOT-STATION-PLUGIN-URI" key="dpml-station-server"
feature="uri" type="plugin"/>
+ <x:filter token="DEPOT-STATION-PLUGIN-URI" key="dpml-station-server"
feature="uri" type="part"/>
</target>

<target name="install" depends="bin,standard.install">

Modified: trunk/main/metro/station/console/etc/bin/station.lap
===================================================================
--- trunk/main/metro/station/console/etc/bin/station.lap 2006-03-14
16:05:36 UTC (rev 1173)
+++ trunk/main/metro/station/console/etc/bin/station.lap 2006-03-14
16:11:04 UTC (rev 1174)
@@ -4,6 +4,7 @@

-Djava.system.class.loader=net.dpml.transit.SystemClassLoader
-Djava.security.policy=${env.DPML_HOME}\share\bin\security.policy
+-Djava.endorsed.dirs=${env.DPML_HOME}\share\lib\endorsed
-Ddpml.depot.application=dpml.station
-Djava.protocol.handler.pkgs=net.dpml.transit
-Djava.rmi.server.RMIClassLoaderSpi=net.dpml.depot.DepotRMIClassLoaderSpi

Modified: trunk/main/metro/test/build.xml
===================================================================
--- trunk/main/metro/test/build.xml 2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/test/build.xml 2006-03-14 16:11:04 UTC (rev 1174)
@@ -25,7 +25,7 @@
<transit:import uri="local:template:dpml/tools/standard"/>

<target name="prepare" depends="standard.prepare">
- <x:plugin uri="link:plugin:dpml/depot/dpml-depot-convert">
+ <x:plugin uri="link:part:dpml/depot/dpml-depot-convert">
<task name="convert" class="de.java2html.anttasks.Java2HtmlTask"/>
</x:plugin>
<convert srcdir="target/build/main" destdir="target/reports/src"/>
@@ -38,7 +38,7 @@
<include name="**/ManagedComponent#DefaultMonitor.class"/>
</rmic>

- <x:plugin uri="link:plugin:dpml/metro/dpml-metro-tools"/>
+ <x:plugin uri="link:part:dpml/metro/dpml-metro-tools"/>

<!-- create the test component types -->

@@ -201,7 +201,13 @@

<!-- categories component -->

- <c:type class="net.dpml.test.categories.CategoriesComponent"
name="categories" lifestyle="thread"/>
+ <c:type class="net.dpml.test.categories.CategoriesComponent"
name="categories" lifestyle="thread">
+ <categories>
+ <category name="alpha"/>
+ <category name="beta"/>
+ </categories>
+ </c:type>
+
<c:component dest="target/test/categories.part" test="true"
activation="STARTUP"
type="net.dpml.test.categories.CategoriesComponent"
collection="hard">
<categories>
@@ -211,7 +217,7 @@
</c:component>

<!-- configuration component -->
-
+ <!--
<c:type class="net.dpml.test.config.ConfigurableComponent" name="config"
lifestyle="thread"/>
<c:component dest="target/test/config.part" test="true"
activation="STARTUP"
type="net.dpml.test.config.ConfigurableComponent" collection="hard">
@@ -222,9 +228,10 @@
<item name="dinner" value="Margret de Canard"/>
</configuration>
</c:component>
-
+ -->
+
<!-- parameterizable component -->
-
+ <!--
<c:type class="net.dpml.test.params.ParameterizableComponent"
name="params" lifestyle="thread"/>
<c:component dest="target/test/params.part" test="true"
activation="STARTUP"
type="net.dpml.test.params.ParameterizableComponent"
collection="hard">
@@ -233,6 +240,7 @@
<param name="size" value="1024"/>
</parameters>
</c:component>
+ -->

<!-- composite app-->


Deleted:
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ConfigTestCase.java
===================================================================
---
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ConfigTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ConfigTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,79 +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.metro.runtime.test;
-
-import java.io.File;
-import java.net.URI;
-
-import junit.framework.TestCase;
-
-import net.dpml.part.Controller;
-import net.dpml.part.Component;
-import net.dpml.part.Provider;
-
-import net.dpml.test.config.ConfigurableComponent;
-
-/**
- * Validation of component configuration aspects.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ConfigTestCase extends TestCase
-{
- private static final Controller CONTROLLER = Controller.STANDARD;
-
- private URI m_uri;
-
- /**
- * Testcase setup during which the part definition 'config.part'
- * is established as a file uri.
- * @exception Exception if an unexpected error occurs
- */
- public void setUp() throws Exception
- {
- final String path = "config.part";
- final File test = new File( System.getProperty( "project.test.dir" )
);
- m_uri = new File( test, path ).toURI();
- }
-
- /**
- * Test the the component properly exposed the configuration
- * declared within the part defintion.
- * @exception Exception if an unexpected error occurs
- */
- public void testCategories() throws Exception
- {
- Component component = CONTROLLER.createComponent( m_uri );
- Provider instance = component.getProvider();
- ConfigurableComponent object = (ConfigurableComponent)
instance.getValue( false );
- assertEquals( "name", "fred", object.getName() );
- assertEquals( "count", 3, object.getItemCount() );
- component.deactivate();
- }
-
- static
- {
- System.setProperty(
- "java.util.logging.config.class",
- System.getProperty(
- "java.util.logging.config.class",
- "net.dpml.transit.util.ConfigurationHandler" ) );
- }
-}

Copied:
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ConfigTestCase.java~
(from rev 1168,
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ConfigTestCase.java)

Deleted:
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ParamsTestCase.java
===================================================================
---
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ParamsTestCase.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ParamsTestCase.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,77 +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.metro.runtime.test;
-
-import java.io.File;
-import java.net.URI;
-
-import junit.framework.TestCase;
-
-import net.dpml.part.Controller;
-import net.dpml.part.Component;
-import net.dpml.part.Provider;
-
-import net.dpml.test.params.ParameterizableComponent;
-
-/**
- * Contains a series of tests dealing with dynamic component lifecycles.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ParamsTestCase extends TestCase
-{
- private static final Controller CONTROLLER = Controller.STANDARD;
-
- private URI m_uri;
-
- /**
- * Test case setup.
- * @exception Exception if an error occurs
- */
- public void setUp() throws Exception
- {
- final String path = "params.part";
- final File test = new File( System.getProperty( "project.test.dir" )
);
- m_uri = new File( test, path ).toURI();
- }
-
- /**
- * Test that the component initial state is inactive.
- * @exception Exception if an error occurs
- */
- public void testCategories() throws Exception
- {
- Component component = CONTROLLER.createComponent( m_uri );
- Provider instance = component.getProvider();
- ParameterizableComponent object = (ParameterizableComponent)
instance.getValue( false );
- assertEquals( "name", "fred", object.getName() );
- assertEquals( "count", ParameterizableComponent.TEST_VALUE,
object.getSize() );
- component.deactivate();
- }
-
- static
- {
- System.setProperty(
- "java.util.logging.config.class",
- System.getProperty(
- "java.util.logging.config.class",
- "net.dpml.transit.util.ConfigurationHandler" ) );
- }
-}

Copied:
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ParamsTestCase.java~
(from rev 1168,
trunk/main/metro/test/src/test/net/dpml/metro/runtime/test/ParamsTestCase.java)

Modified: trunk/main/metro/tools/build.xml
===================================================================
--- trunk/main/metro/tools/build.xml 2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/tools/build.xml 2006-03-14 16:11:04 UTC (rev 1174)
@@ -25,8 +25,10 @@
<transit:import uri="local:template:dpml/tools/standard"/>

<target name="init" depends="standard.init">
- <x:filter feature="uri" type="plugin" token="PART-BUILDER-URI" />
- <x:filter key="dpml-metro-runtime" feature="uri" type="plugin"
token="PART-HANDLER-URI" />
+ <x:filter feature="uri" type="part" token="PART-BUILDER-URI" />
+ <x:filter key="dpml-metro-runtime" feature="uri" type="part"
token="PART-HANDLER-URI" />
+ <x:filter ref="dpml/lang/dpml-component" feature="uri" type="xsd"
token="COMPONENT-XSD-URI" />
+ <x:filter key="dpml-metro-builder" feature="uri" type="part"
token="STRATEGY-BUILDER-URI" />
</target>

<target name="install" depends="standard.install">

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -24,6 +24,7 @@
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.IOException;
+import java.net.URI;
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -56,6 +57,9 @@
*/
public class CatalogTask extends Task
{
+ private static final net.dpml.metro.builder.TypeBuilder TYPE_BUILDER =
+ new net.dpml.metro.builder.TypeBuilder();
+
private File m_work;
private File m_destination;
private String m_style;
@@ -732,12 +736,11 @@

private void processType( File reports, File source )
{
- //File htmls = new File( reports, "html" );
File htmls = reports;
try
{
- InputStream input = new FileInputStream( source );
- Type type = Type.decode( getClass().getClassLoader(), input );
+ URI uri = source.toURI();
+ Type type = TYPE_BUILDER.loadType( uri );
createTypePage( htmls, type );
}
catch( Exception e )

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CategoriesDataType.java
===================================================================
---
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CategoriesDataType.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CategoriesDataType.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -57,14 +57,14 @@
*/
public CategoriesDirective getCategoriesDirective()
{
- CategoryDataType[] types = (CategoryDataType[]) m_list.toArray( new
CategoryDataType[0] );
- CategoryDirective[] directives = new CategoryDirective[
types.length ];
- for( int i=0; i<types.length; i++ )
- {
- CategoryDataType type = types[i];
- directives[i] = type.getCategoryDirective();
- }
- return new CategoriesDirective( directives );
+ CategoryDataType[] types = (CategoryDataType[]) m_list.toArray( new
CategoryDataType[0] );
+ CategoryDirective[] directives = new CategoryDirective[ types.length
];
+ for( int i=0; i<types.length; i++ )
+ {
+ CategoryDataType type = types[i];
+ directives[i] = type.getCategoryDirective();
+ }
+ return new CategoriesDirective( directives );
}

/**

Added:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CategoriesDescriptorDataType.java
===================================================================
---
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CategoriesDescriptorDataType.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CategoriesDescriptorDataType.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -0,0 +1,107 @@
+/*
+ * 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.metro.tools;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.dpml.metro.info.CategoryDescriptor;
+
+import net.dpml.metro.info.Priority;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Datatype supporting the declaration of a logging channel at the level of
a component type.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class CategoriesDescriptorDataType
+{
+ private List m_categories = new ArrayList();
+
+ /**
+ * Create a new services datatype.
+ * @return a new services datatype
+ */
+ public CategoryDescriptorDataType createCategory()
+ {
+ CategoryDescriptorDataType data = new CategoryDescriptorDataType();
+ m_categories.add( data );
+ return data;
+ }
+
+ CategoryDescriptor[] getCategoryDescriptors()
+ {
+ CategoryDescriptorDataType[] entries =
+ (CategoryDescriptorDataType[]) m_categories.toArray( new
CategoryDescriptorDataType[0] );
+ CategoryDescriptor[] categories = new CategoryDescriptor[
entries.length ];
+ for( int i=0; i<entries.length; i++ )
+ {
+ CategoryDescriptorDataType data = entries[i];
+ categories[i] = data.getCategoryDescriptor();
+ }
+ return categories;
+ }
+
+ public class CategoryDescriptorDataType
+ {
+ private String m_name;
+ private Priority m_priority;
+
+ /**
+ * Set the service classname.
+ * @param classname the name of the service interface class
+ */
+ public void setName( final String name )
+ {
+ if( null == name )
+ {
+ throw new NullPointerException( "name" );
+ }
+ m_name = name;
+ }
+
+ /**
+ * Set the service version.
+ * @param spec the version value
+ */
+ public void setPriority( final String spec )
+ {
+ if( null == spec )
+ {
+ throw new NullPointerException( "spec" );
+ }
+ m_priority = Priority.parse( spec );
+ }
+
+ CategoryDescriptor getCategoryDescriptor()
+ {
+ if( null == m_name )
+ {
+ throw new BuildException( "Missing category 'name'
attribute." );
+ }
+ else
+ {
+ return new CategoryDescriptor( m_name, m_priority, null );
+ }
+ }
+ }
+}

Deleted:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ClassLoaderBuilderTask.java
===================================================================
---
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ClassLoaderBuilderTask.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ClassLoaderBuilderTask.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,207 +0,0 @@
-/*
- * 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.metro.tools;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import net.dpml.metro.data.ClassLoaderDirective;
-import net.dpml.metro.data.ClasspathDirective;
-
-import net.dpml.tools.tasks.GenericTask;
-
-import net.dpml.library.info.Scope;
-import net.dpml.library.model.Resource;
-
-import net.dpml.part.Controller;
-
-import net.dpml.lang.Category;
-
-import org.apache.tools.ant.AntClassLoader;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.Path;
-
-/**
- * Task that handles the construction of a serialized container part.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public abstract class ClassLoaderBuilderTask extends GenericTask
-{
- private boolean m_test = false;
-
- /**
- * Set the test build policy. The default is to include
- * the project artifact in the classpath of a created part, however - in
a
- * test scenario we don't want to do this. Setting test to true will
result
- * in the association of a local file uri to the project resource.
- *
- * @param test true if this is a local test part
- */
- public void setTest( boolean test )
- {
- m_test = test;
- }
-
- /**
- * Get the composition controller.
- * @return the controller
- */
- protected Controller getController()
- {
- try
- {
- return Controller.STANDARD;
- //Logger logger = new AntAdapter( this );
- //return new CompositionController( logger );
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error while creating controller.";
- throw new BuildException( error, e );
- }
- }
-
- /**
- * Return the runtime classloader.
- * @return the classloader
- */
- protected ClassLoader createClassLoader()
- {
- Project project = getProject();
- Path path = getContext().getPath( Scope.RUNTIME );
- File classes = getContext().getTargetClassesMainDirectory();
- path.createPathElement().setLocation( classes );
- ClassLoader parentClassLoader =
ClassLoaderBuilderTask.class.getClassLoader();
- return new AntClassLoader( parentClassLoader, project, path, true );
- }
-
- /**
- * Create the classloader directive.
- * @return the classloader directive
- */
- protected ClassLoaderDirective constructClassLoaderDirective()
- {
- ClasspathDirective sys = createClasspathDirective( Category.SYSTEM );
- ClasspathDirective pub = createClasspathDirective( Category.PUBLIC );
- ClasspathDirective pro = createClasspathDirective(
Category.PROTECTED );
- ClasspathDirective pri = createClasspathDirective( Category.PRIVATE
);
- ClasspathDirective[] cps = new ClasspathDirective[]{sys, pub, pro,
pri};
- return new ClassLoaderDirective( cps );
- }
-
- private ClasspathDirective createClasspathDirective( Category category )
- {
- try
- {
- Resource resource = getResource();
- Resource[] resources = resource.getClasspathProviders( category
);
- if( category.equals( category.PRIVATE ) && resource.isa( "jar" )
)
- {
- Resource[] res = new Resource[ resources.length + 1 ];
- for( int i=0; i<resources.length; i++ )
- {
- res[i] = resources[i];
- }
- res[ resources.length ] = resource;
- resources = res;
- }
- URI[] uris = new URI[ resources.length ];
- for( int i=0; i<uris.length; i++ )
- {
- uris[i] = toURI( resources[i] );
- }
- return new ClasspathDirective( category, uris );
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected error occured while building a classpath
directive.";
- throw new RuntimeException( error, e );
- }
- }
-
- private URI toURI( Resource resource ) throws Exception
- {
- if( m_test && resource.equals( getResource() ) )
- {
- File deliverable = getContext().getTargetDeliverable( "jar" );
- return deliverable.toURI();
- }
- else
- {
- return resource.getArtifact( "jar" ).toURI();
- }
- }
-
- /**
- * Create and return the part output file.
- * @return the part output file
- */
- protected File getPartOutputFile()
- {
- File deliverables = getContext().getTargetDeliverablesDirectory();
- String type = "part"; // Part.ARTIFACT_TYPE
- String types = type + "s";
- File dir = new File( deliverables, types );
- String filename = getContext().getLayoutPath( type );
- return new File( dir, filename );
- }
-
- /**
- * Return a urn identitifying the part handler for this builder.
- *
- * @return a strategy uri
- */
- public URI getPartHandlerURI()
- {
- return PART_HANDLER_URI;
- }
-
- /**
- * Constant controller uri.
- */
- public static final URI PART_HANDLER_URI = setupURI(
"@PART-HANDLER-URI@" );
-
- /**
- * Constant builder uri.
- */
- public static final URI PART_BUILDER_URI = setupURI(
"@PART-BUILDER-URI@" );
-
- /**
- * Utility function to create a static uri.
- * @param spec the uri spec
- * @return the uri
- */
- protected static URI setupURI( String spec )
- {
- try
- {
- return new URI( spec );
- }
- catch( URISyntaxException ioe )
- {
- return null;
- }
- }
-}

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
===================================================================
---
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -25,19 +25,21 @@
import java.io.File;
import java.io.IOException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Properties;

-import net.dpml.metro.data.ClassLoaderDirective;
+import net.dpml.part.Directive;
import net.dpml.metro.data.ComponentDirective;
import net.dpml.metro.data.ContextDirective;
import net.dpml.metro.data.CategoriesDirective;
-import net.dpml.part.Directive;
import net.dpml.metro.info.LifestylePolicy;
import net.dpml.metro.info.CollectionPolicy;
import net.dpml.metro.info.PartReference;
import net.dpml.metro.info.Type;
import net.dpml.metro.info.EntryDescriptor;

+import net.dpml.library.info.Scope;
+
import net.dpml.configuration.Configuration;

import net.dpml.parameters.Parameters;
@@ -45,9 +47,16 @@
import net.dpml.part.ActivationPolicy;
import net.dpml.part.Part;
import net.dpml.part.PartBuilder;
+import net.dpml.part.Strategy;
+import net.dpml.part.PartDirective;

+import net.dpml.tools.tasks.GenericTask;
+import net.dpml.tools.tasks.PartTask;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.types.Path;

/**
* Task that handles the construction of a serialized container part.
@@ -55,12 +64,17 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public class ComponentBuilderTask extends ClassLoaderBuilderTask implements
PartReferenceBuilder
+public class ComponentBuilderTask extends PartTask implements
PartReferenceBuilder
{
+ private static final String NAMESPACE = "@COMPONENT-XSD-URI@";
+
+ private static final net.dpml.metro.builder.TypeBuilder TYPE_BUILDER =
+ new net.dpml.metro.builder.TypeBuilder();
+
private URI m_uri;
private String m_key;
private boolean m_embedded = false;
- private URI m_extends;
+ //private URI m_extends;
private String m_name;
private String m_classname;
private LifestylePolicy m_lifestyle;
@@ -74,18 +88,9 @@
private File m_output;
private Type m_type;
private ComponentDirective m_profile;
+ private boolean m_alias = false;

/**
- * Override the default output destination.
- *
- * @param file the overriding destination
- */
- public void setDest( File file )
- {
- m_output = file;
- }
-
- /**
* Set the part key.
* @param key the key
*/
@@ -94,23 +99,28 @@
m_key = key;
}

+ public void setAlias( boolean alias )
+ {
+ m_alias = alias;
+ }
+
/**
* Set the extends uri feature.
* @param uri the uri from which the component extends
*/
- public void setExtends( URI uri )
- {
- m_extends = uri;
- }
+ //public void setExtends( URI uri )
+ //{
+ // m_extends = uri;
+ //}

/**
* Set the embedded component flag.
* @param flag true if embedded
*/
- public void setEmbedded( boolean flag )
- {
- m_embedded = flag;
- }
+ //public void setEmbedded( boolean flag )
+ //{
+ // m_embedded = flag;
+ //}

/**
* Set the component name.
@@ -260,81 +270,27 @@
public void execute()
{
ClassLoader classloader = createClassLoader();
- ClassLoaderDirective cld = constructClassLoaderDirective();
- File file = getOutputFile();
- File parent = file.getParentFile();
- if( !parent.exists() )
- {
- parent.mkdirs();
- }
- createComponent( classloader, cld, file );
+ Thread.currentThread().setContextClassLoader( classloader );
+ Strategy strategy = createStrategy( classloader );
+ setStrategy( strategy );
+ super.execute();
}

/**
- * Local exception listener implementation.
- */
- private class LocalExceptionListener implements
java.beans.ExceptionListener
- {
- /**
- * Catch an encoding exception.
- * @param e the exception
- */
- public void exceptionThrown( Exception e )
- {
- e.printStackTrace();
- }
- }
-
- /**
* Create a component directive.
* @param classloader the classloader
* @param cld the classloader directive
* @param file the output file
* @return the component directive
*/
- public ComponentDirective createComponent( ClassLoader classloader,
ClassLoaderDirective cld, File file )
+ public Strategy createStrategy( ClassLoader classloader )
{
try
{
- final ClassLoader current =
Thread.currentThread().getContextClassLoader();
- ComponentDirective profile = buildComponentDirective(
classloader, cld );
- Thread.currentThread().setContextClassLoader(
ComponentDirective.class.getClassLoader() );
- try
- {
- Part part = new Part( PART_HANDLER_URI, new Properties(),
profile );
- PartBuilder.write( part, file );
- }
- catch( Exception e )
- {
- throw new BuildException( "Part encoding error.", e );
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( current );
- }
-
- return profile;
-
+ PartDirective directive = new PartDirective( PART_HANDLER_URI );
+ ComponentDirective profile = buildComponentDirective(
classloader );
+ return new Strategy( STRATEGY_BUILDER_URI, directive, profile,
m_alias );
}
- catch( ConstructionException e )
- {
- throw e;
- }
- catch( IntrospectionException e )
- {
- final String error =
- "Introspection error. "
- + e.getMessage();
- throw new BuildException( error, e, getLocation() );
- }
- catch( IOException e )
- {
- final String error =
- "Internal error while attempting to write component part to
file ["
- + file
- + "]";
- throw new BuildException( error, e, getLocation() );
- }
catch( BuildException e )
{
throw e;
@@ -346,7 +302,22 @@
throw new BuildException( error, e, getLocation() );
}
}
-
+
+ /**
+ * Return the runtime classloader.
+ * @return the classloader
+ */
+ protected ClassLoader createClassLoader()
+ {
+ Project project = getProject();
+ Path path = getContext().getPath( Scope.RUNTIME );
+ File classes = getContext().getTargetClassesMainDirectory();
+ path.createPathElement().setLocation( classes );
+ ClassLoader parentClassLoader = getClass().getClassLoader();
+ return new AntClassLoader( parentClassLoader, project, path, true );
+ }
+
+ /*
private File getOutputFile()
{
if( null != m_output )
@@ -372,30 +343,35 @@
return getPartOutputFile();
}
}
+ */

/**
* Return the embedded reosurce path.
* @param classname the component classname
* @return the resource path
*/
+ /*
public String getEmbeddedResourcePath( String classname )
{
String path = classname.replace( '.', '/' );
String filename = path + ".xprofile";
return filename;
}
+ */

/**
* Return the embedded output file.
* @param filename the filename
* @return the embedded output file
*/
+ /*
public File getEmbeddedOutputFile( String filename )
{
File classes = getContext().getTargetClassesMainDirectory();
File destination = new File( classes, filename );
return destination;
}
+ */

//---------------------------------------------------------------------
// Builder
@@ -440,7 +416,7 @@
Type type = loadType( classloader, classname );
return buildComponentDirective( type, classloader );
}
-
+
//---------------------------------------------------------------------
// PartReferenceBuilder
//---------------------------------------------------------------------
@@ -488,48 +464,48 @@
private ComponentDirective buildComponentDirective( Type type,
ClassLoader classloader )
throws IntrospectionException, IOException, ClassNotFoundException
{
- return buildComponentDirective( classloader, null );
+ return buildComponentDirective( classloader );
}

- private ComponentDirective buildComponentDirective( ClassLoader
classloader, ClassLoaderDirective cld )
+ private ComponentDirective buildComponentDirective( ClassLoader
classloader )
throws IntrospectionException, IOException, ClassNotFoundException
{
String classname = getClassname();
Type type = loadType( classloader, classname );
String id = getName( type.getInfo().getName() );
log( "creating [" + id + "] using [" + classname + "]" );
-
- if( null == m_extends )
- {
+
+ //if( null == m_extends )
+ //{
m_profile = new ComponentDirective( id, classname );
- }
- else
- {
- try
- {
- Directive part = getController().loadDirective( m_extends );
- if( part instanceof ComponentDirective )
- {
- m_profile = (ComponentDirective) part;
- }
- else
- {
- final String error =
- "Super-part is not an instance of "
- + ComponentDirective.class.getName();
- throw new BuildException( error );
- }
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to resolve component super-part ["
- + m_extends
- + "] due to: "
- + e.getMessage();
- throw new BuildException( error, e, getLocation() );
- }
- }
+ //}
+ //else
+ //{
+ // try
+ // {
+ // Directive part = getController().loadDirective( m_extends
);
+ // if( part instanceof ComponentDirective )
+ // {
+ // m_profile = (ComponentDirective) part;
+ // }
+ // else
+ // {
+ // final String error =
+ // "Super-part is not an instance of "
+ // + ComponentDirective.class.getName();
+ // throw new BuildException( error );
+ // }
+ // }
+ // catch( Throwable e )
+ // {
+ // final String error =
+ // "Unable to resolve component super-part ["
+ // + m_extends
+ // + "] due to: "
+ // + e.getMessage();
+ // throw new BuildException( error, e, getLocation() );
+ // }
+ //}

LifestylePolicy lifestyle = getLifestylePolicy( type );
CollectionPolicy collection = getCollectionPolicy( type );
@@ -546,7 +522,7 @@

return new ComponentDirective(
id, activation, collection, lifestyle, classname, categories,
context,
- parameters, configuration, cld, parts );
+ parameters, configuration, parts );
}

private Type loadType( ClassLoader classloader, String classname )
@@ -562,17 +538,7 @@
try
{
Class c = classloader.loadClass( classname );
- Type type = Type.decode( getClass().getClassLoader(), c );
- if( null != type )
- {
- return type;
- }
- else
- {
- final String error =
- "Component type [" + classname + "] is unknown or
undefined.";
- throw new BuildException( error );
- }
+ return TYPE_BUILDER.loadType( c );
}
catch( Throwable e )
{
@@ -821,4 +787,36 @@
return new Expression( old, old.getClass(), "new", args );
}
}
+
+ /**
+ * Constant controller uri.
+ */
+ public static final URI PART_HANDLER_URI = setupURI(
"@PART-HANDLER-URI@" );
+
+ /**
+ * Constant builder uri.
+ */
+ public static final URI PART_BUILDER_URI = setupURI(
"@PART-BUILDER-URI@" );
+
+ /**
+ * Constant strategy builder uri.
+ */
+ public static final URI STRATEGY_BUILDER_URI = setupURI(
"@STRATEGY-BUILDER-URI@" );
+
+ /**
+ * Utility function to create a static uri.
+ * @param spec the uri spec
+ * @return the uri
+ */
+ protected static URI setupURI( String spec )
+ {
+ try
+ {
+ return new URI( spec );
+ }
+ catch( URISyntaxException ioe )
+ {
+ return null;
+ }
+ }
}

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/EntryDataType.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/EntryDataType.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/EntryDataType.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -24,7 +24,7 @@
import net.dpml.metro.info.PartReference;
import net.dpml.metro.data.ValueDirective;
import net.dpml.part.Directive;
-import net.dpml.metro.data.ReferenceDirective;
+import net.dpml.metro.data.LookupDirective;
import net.dpml.metro.data.NullDirective;
import net.dpml.metro.data.FeatureDirective;
import net.dpml.metro.info.EntryDescriptor;
@@ -44,7 +44,7 @@
{
private String m_key;
private ClassLoader m_classloader;
- private URI m_uri;
+ private String m_spec;
private int m_feature = -1;
private boolean m_validate = true;

@@ -61,9 +61,9 @@
* Set the uri that this directive references.
* @param uri the uri
*/
- public void setURI( final URI uri )
+ public void setLookup( final String spec )
{
- m_uri = uri;
+ m_spec = spec;
}

/**
@@ -76,41 +76,15 @@
}

/**
- * Set the interface classname to locate with the enclosing component.
- * @param service the service classname
- */
- public void setLookup( final String service )
- {
- if( null != m_uri )
- {
- final String error =
- "Attributes 'feature', 'lookup' and 'uri' are mutually
exlusive.";
- throw new BuildException( error );
- }
- try
- {
- m_uri = new URI( "lookup:" + service );
- }
- catch( Exception e )
- {
- final String error =
- "Failed to set ["
- + service
- + "] lookup reference.";
- throw new BuildException( error, e );
- }
- }
-
- /**
* Set the feature that this directive references.
* @param feature the component feature
*/
public void setFeature( String feature )
{
- if( null != m_uri )
+ if( null != m_spec )
{
final String error =
- "Attributes 'feature', 'lookup' and 'uri' are mutually
exlusive.";
+ "Attributes 'feature' and 'lookup' are mutually exlusive.";
throw new BuildException( error );
}
try
@@ -158,12 +132,12 @@
}

/**
- * Return the uri reference.
- * @return the uri
+ * Return the lookup service classname.
+ * @return the classname
*/
- public URI getURI()
+ private String getLookupAttribute()
{
- return m_uri;
+ return m_spec;
}

/**
@@ -182,10 +156,10 @@
}
else
{
- URI uri = getURI();
- if( null != uri )
+ String spec = getLookupAttribute();
+ if( null != spec )
{
- Directive directive = new ReferenceDirective( m_uri );
+ Directive directive = new LookupDirective( spec );
return new PartReference( key, directive );
}
else if( m_feature > -1 )

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/PartsDataType.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/PartsDataType.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/PartsDataType.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -26,6 +26,8 @@
import net.dpml.metro.info.Type;
import net.dpml.metro.info.PartReference;

+import net.dpml.tools.tasks.GenericTask;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DynamicElementNS;
import org.apache.tools.ant.Location;
@@ -38,7 +40,7 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public class PartsDataType extends ClassLoaderBuilderTask implements
DynamicElementNS
+public class PartsDataType extends GenericTask implements DynamicElementNS
{
private List m_builders = new LinkedList();
private Task m_owner;

Deleted:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ReferenceDataType.java
===================================================================
---
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ReferenceDataType.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ReferenceDataType.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,154 +0,0 @@
-/*
- * 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.metro.tools;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import net.dpml.metro.info.Type;
-import net.dpml.metro.info.PartReference;
-import net.dpml.metro.data.ReferenceDirective;
-
-import net.dpml.part.Directive;
-
-/**
- * part reference datatype.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ReferenceDataType implements PartReferenceBuilder
-{
- private String m_key;
- private ClassLoader m_classloader;
- private URI m_uri;
-
- /**
- * Set the key that this directive qualifies.
- * @param key the context entry key
- */
- public void setKey( final String key )
- {
- m_key = key;
- }
-
- /**
- * Set the uri that this directive references.
- * @param uri the uri
- */
- public void setURI( final URI uri )
- {
- m_uri = uri;
- }
-
- /**
- * Return the uri reference.
- * @return the uri
- */
- public URI getURI()
- {
- return m_uri;
- }
-
- //---------------------------------------------------------------------
- // Builder
- //---------------------------------------------------------------------
-
- /**
- * Return a uri identitifying the builder.
- *
- * @return the builder uri
- */
- public URI getBuilderURI()
- {
- return PART_BUILDER_URI;
- }
-
- //---------------------------------------------------------------------
- // PartReferenceBuilder
- //---------------------------------------------------------------------
-
- /**
- * Return the key identifying the part that this builder is building.
- * @return the key
- */
- public String getKey()
- {
- if( null == m_key )
- {
- final String error =
- "Missing 'key' attribute declaration.";
- throw new ConstructionException( error );
- }
- return m_key;
- }
-
- /**
- * Build a part reference.
- * @param classloader the classloader
- * @param type the underlying component type
- * @return the part reference
- */
- public PartReference buildPartReference( ClassLoader classloader, Type
type )
- {
- String key = getKey();
- URI uri = getURI();
- Directive part = new ReferenceDirective( m_uri );
- return new PartReference( key, part );
- }
-
- //---------------------------------------------------------------------
- // PartBuilder
- //---------------------------------------------------------------------
-
- /**
- * Return a urn identitifying the part handler for this builder.
- *
- * @return a strategy uri
- */
- public URI getPartHandlerURI()
- {
- return PART_HANDLER_URI;
- }
-
- //---------------------------------------------------------------------
- // static utilities
- //---------------------------------------------------------------------
-
- private static final URI PART_HANDLER_URI = setupURI(
"@PART-HANDLER-URI@" );
- private static final URI PART_BUILDER_URI = setupURI(
"@PART-BUILDER-URI@" );
-
- /**
- * Internal utility to create a static uri.
- * @param spec the uri spec
- * @return the uri
- */
- protected static URI setupURI( String spec )
- {
- try
- {
- return new URI( spec );
- }
- catch( URISyntaxException ioe )
- {
- return null;
- }
- }
-}
-

Deleted:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/SerializableObjectHelper.java
===================================================================
---
trunk/main/metro/tools/src/main/net/dpml/metro/tools/SerializableObjectHelper.java
2006-03-14 16:05:36 UTC (rev 1173)
+++
trunk/main/metro/tools/src/main/net/dpml/metro/tools/SerializableObjectHelper.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -1,128 +0,0 @@
-/*
- * 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.metro.tools;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-
-import net.dpml.part.BuilderRuntimeException;
-
-/**
- * A datatype that enables custom part builders.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class SerializableObjectHelper
-{
- private SerializableObjectHelper()
- {
- // static
- }
-
- /**
- * Write a serialized object to file.
- * @param object the object to write to file
- * @param file the destination file
- * @exception IOException if an I/O exception occurs
- */
- public static void write( Serializable object, File file ) throws
IOException
- {
- ObjectOutputStream output = null;
- FileOutputStream stream = null;
- try
- {
- file.getParentFile().mkdirs();
- stream = new FileOutputStream( file );
- output = new ObjectOutputStream( stream );
- output.writeObject( object );
- }
- catch( IOException ioe )
- {
- throw ioe;
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error while attempting to write an object."
- + "\ndestination: " + file
- + "\nclass: " + object.getClass().getName()
- + "\nreason: " + e.toString();
- throw new BuilderRuntimeException(
ComponentBuilderTask.PART_BUILDER_URI, error, e );
- }
- finally
- {
- closeStream( output );
- }
- }
-
- /**
- * Write a serializable object to a byte array.
- * @param object the serializable object
- * @return the byte array
- * @exception IOException if an I/O exception occurs
- */
- public static byte[] writeToByteArray( Serializable object ) throws
IOException
- {
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- ObjectOutputStream output = null;
- try
- {
- output = new ObjectOutputStream( stream );
- output.writeObject( object );
- return stream.toByteArray();
- }
- catch( IOException ioe )
- {
- throw ioe;
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error while attempting to write object to a byte
array."
- + "\nclass: " + object.getClass().getName()
- + "\nreason: " + e.toString();
- throw new BuilderRuntimeException(
ComponentBuilderTask.PART_BUILDER_URI, error, e );
- }
- finally
- {
- closeStream( output );
- }
- }
-
- private static void closeStream( OutputStream out )
- {
- if( null != out )
- {
- try
- {
- out.close();
- }
- catch( IOException ioe )
- {
- boolean ignoreMe = true;
- }
- }
- }
-}

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServiceDataType.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServiceDataType.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServiceDataType.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -20,7 +20,7 @@

import net.dpml.metro.info.ServiceDescriptor;

-import net.dpml.part.Version;
+import net.dpml.lang.Version;

import org.apache.tools.ant.BuildException;


Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateDataType.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateDataType.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateDataType.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -34,7 +34,7 @@
import net.dpml.state.Operation;
import net.dpml.state.Interface;
import net.dpml.state.Transition;
-import net.dpml.state.StateBuilder;
+import net.dpml.state.impl.StateBuilder;
import net.dpml.state.impl.DefaultState;
import net.dpml.state.impl.DefaultStateMachine;

@@ -51,6 +51,8 @@
*/
public class StateDataType
{
+ private static final StateBuilder BUILDER = new StateBuilder();
+
private final boolean m_root;
private final GenericTask m_task;

@@ -270,7 +272,18 @@
if( null != m_uri )
{
m_task.log( "importing state graph: " + m_uri );
- return StateBuilder.readGraph( m_uri );
+ try
+ {
+ return BUILDER.loadState( m_uri );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to load an external state graph"
+ + "\nURI: "
+ + m_uri;
+ throw new BuildException( error, e );
+ }
}
else if( null != m_classname )
{
@@ -383,7 +396,7 @@
Path path = m_task.getContext().getPath( Scope.RUNTIME );
File classes = m_task.getContext().getTargetClassesMainDirectory();
path.createPathElement().setLocation( classes );
- ClassLoader parentClassLoader =
ClassLoaderBuilderTask.class.getClassLoader();
+ ClassLoader parentClassLoader = getClass().getClassLoader();
return new AntClassLoader( parentClassLoader, project, path, true );
}

@@ -399,8 +412,7 @@
}
else
{
- InputStream input = url.openConnection().getInputStream();
- return DefaultStateMachine.load( input );
+ return BUILDER.loadState( url.toURI() );
}
}
catch( Throwable e )

Modified: trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateTask.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateTask.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/StateTask.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -19,11 +19,14 @@
package net.dpml.metro.tools;

import java.io.File;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;

import net.dpml.tools.tasks.GenericTask;

import net.dpml.state.State;
-import net.dpml.state.StateBuilder;
+import net.dpml.state.impl.StateBuilder;
import net.dpml.state.impl.DefaultState;

import org.apache.tools.ant.BuildException;
@@ -36,6 +39,8 @@
*/
public class StateTask extends GenericTask
{
+ private static final StateBuilder BUILDER = new StateBuilder();
+
private File m_output;
private StateDataType m_data;

@@ -143,12 +148,11 @@
{
try
{
- final ClassLoader current =
Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(
DefaultState.class.getClassLoader() );
+ FileOutputStream output = new FileOutputStream( file );
try
{
State graph = getData().getState();
- StateBuilder.write( graph, file );
+ BUILDER.export( graph, output );
}
catch( Exception e )
{
@@ -156,7 +160,14 @@
}
finally
{
- Thread.currentThread().setContextClassLoader( current );
+ try
+ {
+ output.close();
+ }
+ catch( IOException ioe )
+ {
+ ioe.printStackTrace();
+ }
}
}
catch( BuildException e )

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/TypeBuilderTask.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/TypeBuilderTask.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/TypeBuilderTask.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -24,6 +24,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
+import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.URL;
@@ -39,7 +40,6 @@
import net.dpml.metro.info.LifestylePolicy;
import net.dpml.metro.info.CollectionPolicy;
import net.dpml.metro.info.Type;
-import net.dpml.metro.info.EncodingException;
import net.dpml.metro.info.PartReference;
import net.dpml.metro.info.EntryDescriptor;
import net.dpml.metro.info.ServiceDescriptor;
@@ -48,6 +48,7 @@
import net.dpml.state.State;
import net.dpml.state.impl.DefaultState;
import net.dpml.state.impl.DefaultStateMachine;
+import net.dpml.state.impl.StateBuilder;

import net.dpml.library.info.Scope;
import net.dpml.tools.tasks.GenericTask;
@@ -66,6 +67,10 @@
*/
public class TypeBuilderTask extends GenericTask implements TypeBuilder
{
+ private static final StateBuilder STATE_BUILDER = new StateBuilder();
+ private static final net.dpml.metro.builder.TypeBuilder TYPE_BUILDER =
+ new net.dpml.metro.builder.TypeBuilder();
+
//---------------------------------------------------------------
// state
//---------------------------------------------------------------
@@ -79,7 +84,8 @@
private PartsDataType m_parts;
private StateDataType m_state;
private ServicesDataType m_services;
-
+ private CategoriesDescriptorDataType m_categories;
+
//---------------------------------------------------------------
// setters
//---------------------------------------------------------------
@@ -175,6 +181,25 @@
}

/**
+ * Create a new services datatype.
+ * @return a new services datatype
+ */
+ public CategoriesDescriptorDataType createCategories()
+ {
+ if( m_categories == null )
+ {
+ m_categories = new CategoriesDescriptorDataType();
+ return m_categories;
+ }
+ else
+ {
+ final String error =
+ "Illegal attempt to create a duplicate categories element.";
+ throw new BuildException( error, getLocation() );
+ }
+ }
+
+ /**
* Create a state descriptor for the component.
* @return a state graph descriptor
*/
@@ -250,7 +275,7 @@

InfoDescriptor info = createInfoDescriptor( subject );
ServiceDescriptor[] services = createServiceDescriptors( subject );
- CategoryDescriptor[] categories = new CategoryDescriptor[0];
+ CategoryDescriptor[] categories = createCategoryDescriptors();
ContextDescriptor context = createContextDescriptor( subject );
PartReference[] parts = getPartReferences( subject.getClassLoader()
);
State graph = getStateGraph( subject );
@@ -284,25 +309,28 @@
try
{
final Type type = buildType( classloader );
- final String classname = type.getInfo().getClassname();
- final String resource = getEmbeddedResourcePath( classname );
- final File file = getEmbeddedOutputFile( resource );
- file.getParentFile().mkdirs();
- final FileOutputStream output = new FileOutputStream( file );
- final BufferedOutputStream buffer = new BufferedOutputStream(
output );
- Thread.currentThread().setContextClassLoader(
getClass().getClassLoader() );
- Type.encode( type, output );
+ OutputStream output = getOutputStream( type );
+ try
+ {
+ TYPE_BUILDER.export( type, output );
+ }
+ finally
+ {
+ try
+ {
+ output.close();
+ }
+ catch( IOException ioe )
+ {
+ ioe.printStackTrace();
+ }
+ }
}
catch( IntrospectionException e )
{
final String error = e.getMessage();
throw new BuildException( error, e, getLocation() );
}
- catch( EncodingException e )
- {
- final String error = e.getMessage();
- throw new BuildException( error, e, getLocation() );
- }
catch( BuildException e )
{
throw e;
@@ -315,12 +343,17 @@
+ "\nMessage: " + e.getMessage();
throw new BuildException( error, e, getLocation() );
}
- finally
- {
- Thread.currentThread().setContextClassLoader( current );
- }
}

+ private OutputStream getOutputStream( Type type ) throws IOException
+ {
+ final String classname = type.getInfo().getClassname();
+ final String resource = getEmbeddedResourcePath( classname );
+ final File file = getEmbeddedOutputFile( resource );
+ file.getParentFile().mkdirs();
+ return new FileOutputStream( file );
+ }
+
private String getEmbeddedResourcePath( String classname )
{
String path = classname.replace( '.', '/' );
@@ -418,7 +451,7 @@
}
}
}
-
+
private ServiceDescriptor[] createServiceDescriptors( Class subject )
{
if( null == m_services )
@@ -431,7 +464,19 @@
return m_services.getServiceDescriptors();
}
}
-
+
+ private CategoryDescriptor[] createCategoryDescriptors()
+ {
+ if( null == m_categories )
+ {
+ return new CategoryDescriptor[0];
+ }
+ else
+ {
+ return m_categories.getCategoryDescriptors();
+ }
+ }
+
private ServiceDescriptor[] createServiceDescriptors( Class subject,
List list )
{
Class[] interfaces = subject.getInterfaces();
@@ -647,8 +692,7 @@
}
else
{
- InputStream input = url.openConnection().getInputStream();
- return DefaultStateMachine.load( input );
+ return STATE_BUILDER.loadState( url.toURI() );
}
}
catch( Throwable e )

Modified: trunk/main/metro/tools/src/main/net/dpml/metro/tools/TypesTask.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/TypesTask.java
2006-03-14 16:05:36 UTC (rev 1173)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/TypesTask.java
2006-03-14 16:11:04 UTC (rev 1174)
@@ -21,6 +21,8 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
+import java.io.OutputStream;
+import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.beans.IntrospectionException;
@@ -44,6 +46,9 @@
*/
public class TypesTask extends GenericTask implements DynamicElementNS
{
+ private static final net.dpml.metro.builder.TypeBuilder BUILDER =
+ new net.dpml.metro.builder.TypeBuilder();
+
private List m_builders = new LinkedList();

/**
@@ -100,21 +105,21 @@
try
{
final Type type = builder.buildType( classloader );
- final String classname = type.getInfo().getClassname();
- final String resource = getEmbeddedResourcePath( classname );
- final File file = getEmbeddedOutputFile( resource );
- file.getParentFile().mkdirs();
- final FileOutputStream output = new FileOutputStream( file );
- final BufferedOutputStream buffer = new
BufferedOutputStream( output );
+ OutputStream output = getOutputStream( type );
try
{
- Thread.currentThread().setContextClassLoader(
getClass().getClassLoader() );
- Type.encode( type, output );
+ BUILDER.export( type, output );
}
finally
{
- Thread.currentThread().setContextClassLoader( current );
- output.close();
+ try
+ {
+ output.close();
+ }
+ catch( IOException ioe )
+ {
+ ioe.printStackTrace();
+ }
}
}
catch( IntrospectionException e )
@@ -136,6 +141,15 @@
}
}
}
+
+ private OutputStream getOutputStream( Type type ) throws IOException
+ {
+ final String classname = type.getInfo().getClassname();
+ final String resource = getEmbeddedResourcePath( classname );
+ final File file = getEmbeddedOutputFile( resource );
+ file.getParentFile().mkdirs();
+ return new FileOutputStream( file );
+ }

private String getEmbeddedResourcePath( String classname )
{




  • r1174 - in trunk/main/metro: . builder builder/etc builder/etc/test builder/etc/test/parts builder/etc/test/types builder/src builder/src/main/net/dpml/metro/builder builder/src/test builder/src/test/net builder/src/test/net/dpml builder/src/test/net/dpml/metro builder/src/test/net/dpml/metro/builder exec exec/etc/bin model model/src/main/net/dpml/metro model/src/main/net/dpml/metro/data model/src/main/net/dpml/metro/info model/src/test/net/dpml/metro/data/test model/src/test/net/dpml/metro/info/test part/api part/api/src/main/net/dpml/part part/api/src/test/net/dpml/part/test part/test runtime runtime/src/main/net/dpml/metro/runtime state state/api/src/main/net/dpml/state state/impl state/impl/etc/test state/impl/src/main/net/dpml/state/impl state/impl/src/test/net/dpml/state state/impl/src/test/net/dpml/state/test station station/console station/console/etc/bin test test/src/test/net/dpml/metro/runtime/test tools tools/src/main/net/dpml/metro/tools, mcconnell at BerliOS, 03/14/2006

Archive powered by MHonArc 2.6.24.

Top of Page