Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2353 - in development/main/metro: . activity/api activity/impl automation composition/api/src/main/net/dpml/composition/data composition/api/src/test/net/dpml/composition/data/test composition/builder/src/main/net/dpml/composition/builder composition/builder/src/main/net/dpml/composition/builder/datatypes composition/control/src/main/net/dpml/composition/control composition/control/src/main/net/dpml/composition/models composition/control/src/main/net/dpml/composition/state composition/control/src/test composition/control/src/test/net composition/control/src/test/net/dpml composition/control/src/test/net/dpml/composition composition/control/src/test/net/dpml/composition/state composition/impl/src/main/net/dpml/composition/data/builder composition/impl/src/main/net/dpml/composition/model/impl composition/testing/acme/src/main/net/dpml/composition/testing composition/testing/activity composition/testing/unit composition/testing/unit/src/main composition/testing/unit/src/main/net composition/testing/unit/src/main/net/dpml composition/testing/unit/src/main/net/dpml/test composition/testing/unit/src/main/net/dpml/test/config composition/testing/unit/src/main/net/dpml/test/state composition/testing/unit/src/test/net/dpml/composition/testing composition/testing/unit/src/test/net/dpml/test composition/testing/unit/src/test/net/dpml/test/config composition/testing/unit/src/test/net/dpml/test/state meta/api/src/main/net/dpml/meta/info parts parts/builder parts/control parts/src parts/src/main parts/src/main/net parts/src/main/net/dpml parts/src/main/net/dpml/parts parts/src/main/net/dpml/parts/builder parts/src/main/net/dpml/parts/control parts/src/main/net/dpml/parts/model parts/src/main/net/dpml/parts/part parts/src/main/net/dpml/parts/state state

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2353 - in development/main/metro: . activity/api activity/impl automation composition/api/src/main/net/dpml/composition/data composition/api/src/test/net/dpml/composition/data/test composition/builder/src/main/net/dpml/composition/builder composition/builder/src/main/net/dpml/composition/builder/datatypes composition/control/src/main/net/dpml/composition/control composition/control/src/main/net/dpml/composition/models composition/control/src/main/net/dpml/composition/state composition/control/src/test composition/control/src/test/net composition/control/src/test/net/dpml composition/control/src/test/net/dpml/composition composition/control/src/test/net/dpml/composition/state composition/impl/src/main/net/dpml/composition/data/builder composition/impl/src/main/net/dpml/composition/model/impl composition/testing/acme/src/main/net/dpml/composition/testing composition/testing/activity composition/testing/unit composition/testing/unit/src/main composition/testing/unit/src/main/net composition/testing/unit/src/main/net/dpml composition/testing/unit/src/main/net/dpml/test composition/testing/unit/src/main/net/dpml/test/config composition/testing/unit/src/main/net/dpml/test/state composition/testing/unit/src/test/net/dpml/composition/testing composition/testing/unit/src/test/net/dpml/test composition/testing/unit/src/test/net/dpml/test/config composition/testing/unit/src/test/net/dpml/test/state meta/api/src/main/net/dpml/meta/info parts parts/builder parts/control parts/src parts/src/main parts/src/main/net parts/src/main/net/dpml parts/src/main/net/dpml/parts parts/src/main/net/dpml/parts/builder parts/src/main/net/dpml/parts/control parts/src/main/net/dpml/parts/model parts/src/main/net/dpml/parts/part parts/src/main/net/dpml/parts/state state
  • Date: Fri, 22 Apr 2005 02:43:08 -0400

Author: mcconnell AT dpml.net
Date: Fri Apr 22 02:43:03 2005
New Revision: 2353

Added:

development/main/metro/composition/control/src/main/net/dpml/composition/control/ManagerInvocationHandler.java
- copied, changed from r2339,
development/main/metro/composition/control/src/main/net/dpml/composition/control/StateManagerInvocationHandler.java

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

development/main/metro/composition/control/src/main/net/dpml/composition/state/DefaultManager.java

development/main/metro/composition/control/src/main/net/dpml/composition/state/DefaultOperation.java

development/main/metro/composition/control/src/main/net/dpml/composition/state/DefaultState.java

development/main/metro/composition/control/src/main/net/dpml/composition/state/DefaultTransition.java

development/main/metro/composition/control/src/main/net/dpml/composition/state/ExecutableManager.java

development/main/metro/composition/control/src/main/net/dpml/composition/state/NoSuchHandlerException.java

development/main/metro/composition/control/src/main/net/dpml/composition/state/NullManager.java

development/main/metro/composition/control/src/main/net/dpml/composition/state/RecursiveInitializationException.java

development/main/metro/composition/control/src/main/net/dpml/composition/state/RecursiveTerminationException.java

development/main/metro/composition/control/src/main/net/dpml/composition/state/StartableManager.java

development/main/metro/composition/control/src/main/net/dpml/composition/state/ValueManager.java
development/main/metro/composition/control/src/test/
development/main/metro/composition/control/src/test/net/
development/main/metro/composition/control/src/test/net/dpml/
development/main/metro/composition/control/src/test/net/dpml/composition/

development/main/metro/composition/control/src/test/net/dpml/composition/state/

development/main/metro/composition/control/src/test/net/dpml/composition/state/DefaultManagerTestCase.java

development/main/metro/composition/control/src/test/net/dpml/composition/state/DefaultOperationTestCase.java

development/main/metro/composition/control/src/test/net/dpml/composition/state/DefaultStateTestCase.java

development/main/metro/composition/control/src/test/net/dpml/composition/state/DefaultTransitionTestCase.java
development/main/metro/composition/testing/unit/src/main/
development/main/metro/composition/testing/unit/src/main/net/
development/main/metro/composition/testing/unit/src/main/net/dpml/
development/main/metro/composition/testing/unit/src/main/net/dpml/test/

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

development/main/metro/composition/testing/unit/src/main/net/dpml/test/config/ConfigurableComponent.java

development/main/metro/composition/testing/unit/src/main/net/dpml/test/config/ConfigurableContainer.java

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

development/main/metro/composition/testing/unit/src/main/net/dpml/test/state/ManagedComponent.java

development/main/metro/composition/testing/unit/src/main/net/dpml/test/state/ManagingContainer.java
development/main/metro/composition/testing/unit/src/test/net/dpml/test/

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

development/main/metro/composition/testing/unit/src/test/net/dpml/test/config/ConfigurationTestCase.java

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

development/main/metro/composition/testing/unit/src/test/net/dpml/test/state/ManagementTestCase.java
development/main/metro/parts/ (props changed)
- copied from r2339, development/main/metro/automation/
development/main/metro/parts/build.properties
development/main/metro/parts/build.xml
- copied, changed from r2352,
development/main/metro/automation/build.xml
development/main/metro/parts/src/
development/main/metro/parts/src/main/
development/main/metro/parts/src/main/net/
development/main/metro/parts/src/main/net/dpml/
development/main/metro/parts/src/main/net/dpml/parts/
development/main/metro/parts/src/main/net/dpml/parts/builder/
development/main/metro/parts/src/main/net/dpml/parts/builder/Builder.java

development/main/metro/parts/src/main/net/dpml/parts/builder/BuilderRuntimeException.java

development/main/metro/parts/src/main/net/dpml/parts/builder/IntrospectionException.java

development/main/metro/parts/src/main/net/dpml/parts/builder/PartBuilder.java
development/main/metro/parts/src/main/net/dpml/parts/control/
development/main/metro/parts/src/main/net/dpml/parts/control/Control.java

development/main/metro/parts/src/main/net/dpml/parts/control/ControlException.java

development/main/metro/parts/src/main/net/dpml/parts/control/ControlRuntimeException.java

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

development/main/metro/parts/src/main/net/dpml/parts/control/DelegationException.java

development/main/metro/parts/src/main/net/dpml/parts/control/Disposable.java

development/main/metro/parts/src/main/net/dpml/parts/control/DuplicateNameException.java

development/main/metro/parts/src/main/net/dpml/parts/control/EntryNotFoundException.java

development/main/metro/parts/src/main/net/dpml/parts/control/HandlerNotFoundException.java

development/main/metro/parts/src/main/net/dpml/parts/control/Identifiable.java

development/main/metro/parts/src/main/net/dpml/parts/control/InvalidQueryException.java

development/main/metro/parts/src/main/net/dpml/parts/control/LifecycleException.java

development/main/metro/parts/src/main/net/dpml/parts/control/LifecycleRuntimeException.java

development/main/metro/parts/src/main/net/dpml/parts/control/LifestyleException.java

development/main/metro/parts/src/main/net/dpml/parts/control/Manageable.java
development/main/metro/parts/src/main/net/dpml/parts/control/Monitor.java

development/main/metro/parts/src/main/net/dpml/parts/control/NoSuchControlException.java

development/main/metro/parts/src/main/net/dpml/parts/control/PartHandler.java

development/main/metro/parts/src/main/net/dpml/parts/control/PartHandlerRuntimeException.java

development/main/metro/parts/src/main/net/dpml/parts/control/PartNotFoundException.java

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

development/main/metro/parts/src/main/net/dpml/parts/control/UnknownSchemaException.java

development/main/metro/parts/src/main/net/dpml/parts/control/UnsupportedPartTypeException.java
development/main/metro/parts/src/main/net/dpml/parts/model/
development/main/metro/parts/src/main/net/dpml/parts/model/Model.java

development/main/metro/parts/src/main/net/dpml/parts/model/ModelException.java

development/main/metro/parts/src/main/net/dpml/parts/model/ModelRuntimeException.java

development/main/metro/parts/src/main/net/dpml/parts/model/PartClassNotFoundException.java

development/main/metro/parts/src/main/net/dpml/parts/model/ServiceClassNotFoundException.java

development/main/metro/parts/src/main/net/dpml/parts/model/TypeClassNotFoundException.java
development/main/metro/parts/src/main/net/dpml/parts/part/
development/main/metro/parts/src/main/net/dpml/parts/part/Part.java
development/main/metro/parts/src/main/net/dpml/parts/part/PartHolder.java

development/main/metro/parts/src/main/net/dpml/parts/part/PartReference.java
development/main/metro/parts/src/main/net/dpml/parts/state/

development/main/metro/parts/src/main/net/dpml/parts/state/DuplicateKeyException.java
development/main/metro/parts/src/main/net/dpml/parts/state/Manager.java

development/main/metro/parts/src/main/net/dpml/parts/state/NoSuchOperationException.java

development/main/metro/parts/src/main/net/dpml/parts/state/NoSuchStateException.java

development/main/metro/parts/src/main/net/dpml/parts/state/NoSuchTransitionException.java
development/main/metro/parts/src/main/net/dpml/parts/state/Operation.java
development/main/metro/parts/src/main/net/dpml/parts/state/State.java
development/main/metro/parts/src/main/net/dpml/parts/state/Transition.java

development/main/metro/parts/src/main/net/dpml/parts/state/ValidationException.java
Removed:
development/main/metro/activity/api/
development/main/metro/activity/impl/
development/main/metro/automation/

development/main/metro/composition/control/src/main/net/dpml/composition/control/StateManagerInvocationHandler.java
development/main/metro/composition/testing/activity/
development/main/metro/parts/builder/
development/main/metro/parts/control/
development/main/metro/state/
Modified:
development/main/metro/build.xml

development/main/metro/composition/api/src/main/net/dpml/composition/data/ComponentProfile.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/ContextDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/DependencyDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/DeploymentProfile.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/ImportDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/ReferenceDirective.java

development/main/metro/composition/api/src/main/net/dpml/composition/data/ValueDirective.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ComponentProfileTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContainmentProfileTestCase.java

development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContextDirectiveTestCase.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ContainerBuilderTask.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/PartReferenceBuilder.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/SerializableObjectHelper.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilder.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypesTask.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ContextDataType.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartDataType.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartsDataType.java

development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ReferenceDataType.java

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

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

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

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

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

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

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

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

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

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

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

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

development/main/metro/composition/control/src/main/net/dpml/composition/models/AbstractModel.java

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

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

development/main/metro/composition/control/src/main/net/dpml/composition/models/DuplicateKeyException.java

development/main/metro/composition/control/src/main/net/dpml/composition/models/EntryTable.java

development/main/metro/composition/control/src/main/net/dpml/composition/models/Holder.java

development/main/metro/composition/control/src/main/net/dpml/composition/models/InvalidModelException.java

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

development/main/metro/composition/control/src/main/net/dpml/composition/models/ValueModel.java

development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLComponentProfileCreator.java

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContextModel.java

development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeContainer.java
development/main/metro/composition/testing/unit/build.xml

development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/CompositeTestCase.java

development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/ExampleTestCase.java

development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/SimpleTestCase.java
development/main/metro/index.xml

development/main/metro/meta/api/src/main/net/dpml/meta/info/PartDescriptor.java
Log:
Reshuffling some content and improving the overall management model.

Modified: development/main/metro/build.xml
==============================================================================
--- development/main/metro/build.xml (original)
+++ development/main/metro/build.xml Fri Apr 22 02:43:03 2005
@@ -23,4 +23,37 @@

<transit:import uri="artifact:template:dpml/magic/reactor"/>

+ <target name="patch">
+ <!--
+ <replace token="net.dpml.automation.control" value="net.dpml.control">
+ <fileset dir=".">
+ <include name="**/*.java"/>
+ <include name="**/*.xml"/>
+ </fileset>
+ </replace>
+ <replace token="net.dpml.automation.part" value="net.dpml.part">
+ <fileset dir=".">
+ <include name="**/*.java"/>
+ <include name="**/*.xml"/>
+ </fileset>
+ </replace>
+ <replace token="net.dpml.automation.model" value="net.dpml.model">
+ <fileset dir=".">
+ <include name="**/*.java"/>
+ <include name="**/*.xml"/>
+ </fileset>
+ </replace>
+ <replace token="net.dpml.automation.builder" value="net.dpml.automation">
+ <fileset dir=".">
+ <include name="**/*.java"/>
+ <include name="**/*.xml"/>
+ </fileset>
+ </replace>
+ -->
+ <replace token="net.dpml.parts.state" value="net.dpml.parts.state"
dir=".">
+ <include name="**/*.java"/>
+ <include name="**/*.xml"/>
+ </replace>
+ </target>
+
</project>

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ComponentProfile.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ComponentProfile.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ComponentProfile.java
Fri Apr 22 02:43:03 2005
@@ -18,7 +18,7 @@

package net.dpml.composition.data;

-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.part.PartReference;
import net.dpml.configuration.Configuration;
import net.dpml.lang.NullArgumentException;
import net.dpml.logging.data.CategoriesDirective;

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ContextDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ContextDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ContextDirective.java
Fri Apr 22 02:43:03 2005
@@ -20,7 +20,7 @@

import java.io.Serializable;

-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.part.PartReference;

/**
* A context descriptor declares the context creation criteria for

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/DependencyDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/DependencyDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/DependencyDirective.java
Fri Apr 22 02:43:03 2005
@@ -22,7 +22,7 @@
import java.net.URI;
import java.net.URISyntaxException;

-import net.dpml.automation.part.Part;
+import net.dpml.parts.part.Part;

/**
* A DependencyDirective is a reference to another part within the scope of
the

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/DeploymentProfile.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/DeploymentProfile.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/DeploymentProfile.java
Fri Apr 22 02:43:03 2005
@@ -23,7 +23,7 @@
import java.net.URI;
import java.net.URISyntaxException;

-import net.dpml.automation.part.Part;
+import net.dpml.parts.part.Part;

import net.dpml.logging.data.CategoriesDirective;


Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ImportDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ImportDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ImportDirective.java
Fri Apr 22 02:43:03 2005
@@ -22,7 +22,7 @@
import java.net.URI;
import java.net.URISyntaxException;

-import net.dpml.automation.part.Part;
+import net.dpml.parts.part.Part;

/**
* An inport directive used within a context directive to request a
container scoped values.

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ReferenceDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ReferenceDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ReferenceDirective.java
Fri Apr 22 02:43:03 2005
@@ -22,7 +22,7 @@
import java.net.URI;
import java.net.URISyntaxException;

-import net.dpml.automation.part.Part;
+import net.dpml.parts.part.Part;

/**
* A reference directive is a reference to a part within the enclosing part's

Modified:
development/main/metro/composition/api/src/main/net/dpml/composition/data/ValueDirective.java
==============================================================================
---
development/main/metro/composition/api/src/main/net/dpml/composition/data/ValueDirective.java
(original)
+++
development/main/metro/composition/api/src/main/net/dpml/composition/data/ValueDirective.java
Fri Apr 22 02:43:03 2005
@@ -24,7 +24,7 @@

import net.dpml.lang.NullArgumentException;

-import net.dpml.automation.part.Part;
+import net.dpml.parts.part.Part;

/**
* A <code>Value</code> represents a single constructor typed argument
value. The directive

Modified:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ComponentProfileTestCase.java
==============================================================================
---
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ComponentProfileTestCase.java
(original)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ComponentProfileTestCase.java
Fri Apr 22 02:43:03 2005
@@ -17,7 +17,7 @@

package net.dpml.composition.data.test;

-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.data.ClassLoaderDirective;
import net.dpml.composition.data.ComponentProfile;
import net.dpml.composition.data.ContextDirective;

Modified:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContainmentProfileTestCase.java
==============================================================================
---
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContainmentProfileTestCase.java
(original)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContainmentProfileTestCase.java
Fri Apr 22 02:43:03 2005
@@ -17,7 +17,7 @@

package net.dpml.composition.data.test;

-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.data.ClassLoaderDirective;
import net.dpml.composition.data.ComponentProfile;
import net.dpml.composition.data.ContainmentProfile;

Modified:
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContextDirectiveTestCase.java
==============================================================================
---
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContextDirectiveTestCase.java
(original)
+++
development/main/metro/composition/api/src/test/net/dpml/composition/data/test/ContextDirectiveTestCase.java
Fri Apr 22 02:43:03 2005
@@ -17,7 +17,7 @@

package net.dpml.composition.data.test;

-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.data.ContextDirective;
import net.dpml.composition.data.ValueDirective;


Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ComponentBuilderTask.java
Fri Apr 22 02:43:03 2005
@@ -28,10 +28,10 @@
import java.net.URL;
import java.util.ArrayList;

-import net.dpml.automation.builder.IntrospectionException;
-import net.dpml.automation.part.Part;
-import net.dpml.automation.part.PartHolder;
-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.builder.IntrospectionException;
+import net.dpml.parts.part.Part;
+import net.dpml.parts.part.PartHolder;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.builder.datatypes.CategoriesDataType;
import net.dpml.composition.builder.datatypes.ConfigurationDataType;
import net.dpml.composition.builder.datatypes.ContextDataType;

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ContainerBuilderTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ContainerBuilderTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/ContainerBuilderTask.java
Fri Apr 22 02:43:03 2005
@@ -26,9 +26,9 @@
import java.util.LinkedList;
import java.util.List;

-import net.dpml.automation.builder.PartBuilder;
-import net.dpml.automation.part.Part;
-import net.dpml.automation.part.PartHolder;
+import net.dpml.parts.builder.PartBuilder;
+import net.dpml.parts.part.Part;
+import net.dpml.parts.part.PartHolder;
import net.dpml.composition.data.ClassLoaderDirective;
import net.dpml.composition.data.ClasspathDirective;
import net.dpml.composition.data.ContainmentProfile;

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/PartReferenceBuilder.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/PartReferenceBuilder.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/PartReferenceBuilder.java
Fri Apr 22 02:43:03 2005
@@ -20,8 +20,8 @@

import java.io.IOException;

-import net.dpml.automation.builder.IntrospectionException;
-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.builder.IntrospectionException;
+import net.dpml.parts.part.PartReference;
import net.dpml.meta.info.Type;

/**

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/SerializableObjectHelper.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/SerializableObjectHelper.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/SerializableObjectHelper.java
Fri Apr 22 02:43:03 2005
@@ -26,7 +26,7 @@
import java.io.OutputStream;
import java.io.Serializable;

-import net.dpml.automation.builder.BuilderRuntimeException;
+import net.dpml.parts.builder.BuilderRuntimeException;

/**
* A datatype that enables custom part builders.

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilder.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilder.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilder.java
Fri Apr 22 02:43:03 2005
@@ -21,8 +21,8 @@
import java.io.IOException;
import java.net.URI;

-import net.dpml.automation.builder.Builder;
-import net.dpml.automation.builder.IntrospectionException;
+import net.dpml.parts.builder.Builder;
+import net.dpml.parts.builder.IntrospectionException;

import net.dpml.meta.info.Type;


Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypeBuilderTask.java
Fri Apr 22 02:43:03 2005
@@ -30,7 +30,7 @@
import java.util.Properties;
import java.util.Map.Entry;

-import net.dpml.automation.builder.IntrospectionException;
+import net.dpml.parts.builder.IntrospectionException;
import net.dpml.configuration.Configuration;
import net.dpml.configuration.impl.DefaultConfigurationBuilder;
import net.dpml.magic.tasks.ProjectTask;
@@ -458,6 +458,10 @@
{
return null; // ignore java.* interfaces
}
+ else if( classname.startsWith( "net.dpml.activity." ) )
+ {
+ return null;
+ }
else if( type == parent )
{
return null; // ignore immediate inner interfaces
@@ -548,11 +552,16 @@
validateEntryReturnType( method );
validateAtMostOneParameter( method );
}
- if( PartDescriptor.STATE_MANAGER_KEY.equals( postfix ) )
+ else if( PartDescriptor.MANAGER_KEY.equals( postfix ) )
{
validateNonNullReturnType( method );
validateAtMostOneParameter( method );
}
+ else if( PartDescriptor.MODEL_KEY.equals( postfix ) )
+ {
+ validateNonNullReturnType( method );
+ validateNoParameters( method );
+ }
else if( PartDescriptor.PARTS_MAP_KEY.equals( postfix ) ||
PartDescriptor.CONTEXT_MAP_KEY.equals( postfix ) )
{
validateMapReturnType( method );

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypesTask.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypesTask.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/TypesTask.java
Fri Apr 22 02:43:03 2005
@@ -23,7 +23,7 @@
import java.util.LinkedList;
import java.util.List;

-import net.dpml.automation.builder.IntrospectionException;
+import net.dpml.parts.builder.IntrospectionException;
import net.dpml.magic.model.Policy;
import net.dpml.magic.tasks.ProjectTask;
import net.dpml.meta.info.Type;

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ContextDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ContextDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ContextDataType.java
Fri Apr 22 02:43:03 2005
@@ -22,8 +22,8 @@
import java.util.ArrayList;
import java.util.List;

-import net.dpml.automation.builder.IntrospectionException;
-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.builder.IntrospectionException;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.builder.ComponentBuilderTask;
import net.dpml.composition.builder.PartReferenceBuilder;
import net.dpml.composition.data.ContextDirective;

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/DependenciesDataType.java
Fri Apr 22 02:43:03 2005
@@ -21,8 +21,8 @@
import java.util.ArrayList;
import java.util.List;

-import net.dpml.automation.part.Part;
-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.part.Part;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.builder.ConstructionException;
import net.dpml.composition.builder.PartReferenceBuilder;
import net.dpml.composition.data.DependencyDirective;

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/EntryDataType.java
Fri Apr 22 02:43:03 2005
@@ -21,8 +21,8 @@
import java.net.URI;
import java.net.URISyntaxException;

-import net.dpml.automation.part.Part;
-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.part.Part;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.builder.ConstructionException;
import net.dpml.composition.builder.PartReferenceBuilder;
import net.dpml.composition.data.ValueDirective;

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartDataType.java
Fri Apr 22 02:43:03 2005
@@ -22,10 +22,10 @@
import java.net.URI;
import java.net.URISyntaxException;

-import net.dpml.automation.control.DelegationException;
-import net.dpml.automation.control.PartNotFoundException;
-import net.dpml.automation.part.Part;
-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.control.DelegationException;
+import net.dpml.parts.control.PartNotFoundException;
+import net.dpml.parts.part.Part;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.builder.PartReferenceBuilder;
import net.dpml.composition.control.CompositionPartHandler;
import net.dpml.meta.info.Type;

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartsDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartsDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/PartsDataType.java
Fri Apr 22 02:43:03 2005
@@ -22,8 +22,8 @@
import java.util.LinkedList;
import java.util.List;

-import net.dpml.automation.builder.IntrospectionException;
-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.builder.IntrospectionException;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.builder.ComponentBuilderTask;
import net.dpml.composition.builder.PartReferenceBuilder;
import net.dpml.meta.info.Type;

Modified:
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ReferenceDataType.java
==============================================================================
---
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ReferenceDataType.java
(original)
+++
development/main/metro/composition/builder/src/main/net/dpml/composition/builder/datatypes/ReferenceDataType.java
Fri Apr 22 02:43:03 2005
@@ -21,8 +21,8 @@
import java.net.URI;
import java.net.URISyntaxException;

-import net.dpml.automation.part.Part;
-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.part.Part;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.builder.ConstructionException;
import net.dpml.composition.builder.PartReferenceBuilder;
import net.dpml.composition.data.ReferenceDirective;

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/ApplianceInvocationHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/ApplianceInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/ApplianceInvocationHandler.java
Fri Apr 22 02:43:03 2005
@@ -24,7 +24,7 @@
import java.lang.reflect.UndeclaredThrowableException;
import java.net.URI;

-import net.dpml.automation.control.Disposable;
+import net.dpml.parts.control.Disposable;
import net.dpml.composition.models.Holder;

/**

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionClassLoader.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionClassLoader.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionClassLoader.java
Fri Apr 22 02:43:03 2005
@@ -22,7 +22,7 @@
import java.net.URL;
import java.net.URLClassLoader;

-import net.dpml.automation.control.ControlRuntimeException;
+import net.dpml.parts.control.ControlRuntimeException;

/**
* A named classloader.

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionController.java
Fri Apr 22 02:43:03 2005
@@ -29,18 +29,20 @@
import java.util.Map.Entry;
import java.util.logging.Logger;

-import net.dpml.automation.control.ControlRuntimeException;
-import net.dpml.automation.control.Controller;
-import net.dpml.automation.control.DelegationException;
-import net.dpml.automation.control.Disposable;
-import net.dpml.automation.control.EntryNotFoundException;
-import net.dpml.automation.control.LifecycleException;
-import net.dpml.automation.control.Monitor;
-import net.dpml.automation.control.PartNotFoundException;
-import net.dpml.automation.control.UnknownSchemaException;
-import net.dpml.automation.model.Model;
-import net.dpml.automation.model.ModelException;
-import net.dpml.automation.part.Part;
+import net.dpml.parts.control.ControlRuntimeException;
+import net.dpml.parts.control.Controller;
+import net.dpml.parts.control.DelegationException;
+import net.dpml.parts.control.Disposable;
+import net.dpml.parts.control.EntryNotFoundException;
+import net.dpml.parts.control.LifecycleException;
+import net.dpml.parts.control.Monitor;
+import net.dpml.parts.control.PartNotFoundException;
+import net.dpml.parts.control.UnknownSchemaException;
+import net.dpml.parts.model.Model;
+import net.dpml.parts.model.ModelException;
+import net.dpml.parts.state.Manager;
+import net.dpml.parts.part.Part;
+
import net.dpml.composition.data.ClassLoaderDirective;
import net.dpml.composition.data.ClasspathDirective;
import net.dpml.composition.data.ComponentProfile;
@@ -49,6 +51,8 @@
import net.dpml.composition.models.EntryTable;
import net.dpml.composition.models.Holder;
import net.dpml.composition.models.ValueModel;
+import net.dpml.composition.state.ValueManager;
+
import net.dpml.system.SystemContext;

/**
@@ -71,8 +75,8 @@

private final Monitor m_monitor;
private final SystemContext m_system;
- private final LifecycleHandler m_factory;
- private final LifestyleHandler m_handler;
+ private final LifecycleHandler m_lifecycleHandler;
+ private final LifestyleHandler m_lifestyleHandler;
private final URI m_partition;

//--------------------------------------------------------------------
@@ -86,8 +90,8 @@
m_system = system;
m_partition = partition;

- m_handler = new LifestyleHandler( monitor );
- m_factory = new LifecycleHandler( monitor, system );
+ m_lifestyleHandler = new LifestyleHandler( monitor );
+ m_lifecycleHandler = new LifecycleHandler( monitor, system );
}

//--------------------------------------------------------------------
@@ -216,12 +220,6 @@
}
}

- public Object getProcessController( Holder holder )
- throws LifecycleException, InvocationTargetException
- {
- return m_factory.getProcessController( holder );
- }
-
private EntryTable getEntryTable( CompositionModel model, URI uri )
throws UnknownSchemaException
{
final String scheme = uri.getScheme();
@@ -330,10 +328,10 @@
* @param model the component model
* @return the resolved instance
*/
- public Entry create( Model model ) throws Exception
- {
- return create( model, null, "create/1" );
- }
+ //public Entry create( Model model ) throws Exception
+ //{
+ // return create( model, null, "create/1" );
+ //}

/**
* Create and return an instance entry using a supplied instance
identifier.
@@ -342,10 +340,10 @@
* @param key the instance identifier
* @return the resolved instance
*/
- public Entry create( Model model, Object key ) throws Exception
- {
- return create( model, key, "create/2" );
- }
+ //public Entry create( Model model, Object key ) throws Exception
+ //{
+ // return create( model, key, "create/2" );
+ //}

/**
* Create and return an instance entry using a supplied instance
identifier.
@@ -354,25 +352,61 @@
* @param key the instance identifier
* @return the resolved instance
*/
- private Entry create( Model model, Object key, String method ) throws
Exception
+ //private Entry create( Model model, Object key, String method ) throws
Exception
+ //{
+ // if( model instanceof CompositionModel )
+ // {
+ // CompositionModel standard = (CompositionModel) model;
+ // return getHolder( standard, key );
+ // }
+ // else
+ // {
+ // final String error =
+ // "Unsupported model implementation class ["
+ // + model.getClass().getName()
+ // + "] passed to "
+ // + method
+ // + ".";
+ // throw new UnsupportedOperationException( error );
+ // }
+ //}
+
+ public Manager getManager( Model model ) throws Exception
+ {
+ if( model instanceof ValueModel )
+ {
+ return new ValueManager( (ValueModel) model );
+ }
+ else
+ {
+ return getManager( model, null );
+ }
+ }
+
+ public Manager getManager( Model model, Object key ) throws Exception
{
if( model instanceof CompositionModel )
{
- CompositionModel standard = (CompositionModel) model;
- return getHolder( standard, key );
+ CompositionModel componentModel = (CompositionModel) model;
+ Holder holder = getHolder( componentModel , key );
+ return getManager( holder );
}
else
{
final String error =
"Unsupported model implementation class ["
+ model.getClass().getName()
- + "] passed to "
- + method
- + ".";
+ + "] passed to getManager/n.";
throw new UnsupportedOperationException( error );
}
}

+ public Manager getManager( Holder holder )
+ throws LifecycleException, InvocationTargetException
+ {
+ return m_lifecycleHandler.getManager( holder );
+ }
+
/**
* Create and return a new instance of the component represented
* by the supplied model using the assigned lifestyle policy.
@@ -456,7 +490,7 @@
}
else
{
- m_factory.etherialize( instance );
+ m_lifecycleHandler.etherialize( instance );
}
}

@@ -499,7 +533,7 @@

public Object incarnate( Holder holder ) throws LifecycleException,
InvocationTargetException
{
- return m_factory.incarnate( holder );
+ return m_lifecycleHandler.incarnate( holder );
}

public void etherialize( Object instance )
@@ -519,7 +553,7 @@
}
else
{
- m_factory.etherialize( instance );
+ m_lifecycleHandler.etherialize( instance );
}
}

@@ -550,22 +584,23 @@
}
}

- //--------------------------------------------------------------------
- // private
- //--------------------------------------------------------------------
-
- private Holder getHolder( CompositionModel model, Object key ) throws
LifecycleException, InvocationTargetException
+ public Holder getHolder( CompositionModel model, Object key ) throws
LifecycleException, InvocationTargetException
{
if( null == key )
{
- return m_handler.aquire( model );
+ return m_lifestyleHandler.aquire( model );
}
else
{
- return m_handler.aquire( model, key );
+ return m_lifestyleHandler.aquire( model, key );
}
}

+ //--------------------------------------------------------------------
+ // private
+ //--------------------------------------------------------------------
+
+
private ClassLoader getClassLoader( URI partition, ClassLoader parent,
ComponentProfile profile )
{
final String name = profile.getName();

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionManager.java
Fri Apr 22 02:43:03 2005
@@ -32,14 +32,14 @@
import java.util.logging.LogManager;

import net.dpml.activity.Startable;
-import net.dpml.automation.control.ControlRuntimeException;
-import net.dpml.automation.control.Controller;
-import net.dpml.automation.control.DelegationException;
-import net.dpml.automation.control.PartNotFoundException;
-import net.dpml.automation.control.SystemManager;
-import net.dpml.automation.model.Model;
-import net.dpml.automation.model.ModelException;
-import net.dpml.automation.part.Part;
+import net.dpml.parts.control.ControlRuntimeException;
+import net.dpml.parts.control.Controller;
+import net.dpml.parts.control.DelegationException;
+import net.dpml.parts.control.PartNotFoundException;
+import net.dpml.parts.control.SystemManager;
+import net.dpml.parts.model.Model;
+import net.dpml.parts.model.ModelException;
+import net.dpml.parts.part.Part;
import net.dpml.system.SystemContext;

import org.apache.commons.cli.CommandLine;

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionPartHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionPartHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/CompositionPartHandler.java
Fri Apr 22 02:43:03 2005
@@ -26,14 +26,14 @@
import java.net.URI;
import java.net.URL;

-import net.dpml.automation.part.Part;
-import net.dpml.automation.part.PartHolder;
-import net.dpml.automation.control.PartNotFoundException;
-import net.dpml.automation.control.Controller;
-import net.dpml.automation.control.PartHandler;
-import net.dpml.automation.control.PartHandlerRuntimeException;
-import net.dpml.automation.control.HandlerNotFoundException;
-import net.dpml.automation.control.DelegationException;
+import net.dpml.parts.part.Part;
+import net.dpml.parts.part.PartHolder;
+import net.dpml.parts.control.PartNotFoundException;
+import net.dpml.parts.control.Controller;
+import net.dpml.parts.control.PartHandler;
+import net.dpml.parts.control.PartHandlerRuntimeException;
+import net.dpml.parts.control.HandlerNotFoundException;
+import net.dpml.parts.control.DelegationException;

import net.dpml.meta.info.Type;
import net.dpml.meta.info.TypeHolder;

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/ConsoleMonitor.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/ConsoleMonitor.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/ConsoleMonitor.java
Fri Apr 22 02:43:03 2005
@@ -18,7 +18,7 @@

package net.dpml.composition.control;

-import net.dpml.automation.control.Monitor;
+import net.dpml.parts.control.Monitor;


/**

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextInvocationHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextInvocationHandler.java
Fri Apr 22 02:43:03 2005
@@ -21,8 +21,8 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

-import net.dpml.automation.control.LifecycleException;
-import net.dpml.automation.model.ModelException;
+import net.dpml.parts.control.LifecycleException;
+import net.dpml.parts.model.ModelException;
import net.dpml.composition.models.CompositionModel;
import net.dpml.composition.models.Holder;
import net.dpml.system.SystemContext;

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextManagerInvocationHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextManagerInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/ContextManagerInvocationHandler.java
Fri Apr 22 02:43:03 2005
@@ -21,8 +21,8 @@
import java.lang.reflect.Method;
import java.util.Map;

-import net.dpml.automation.control.LifecycleException;
-import net.dpml.automation.model.ModelException;
+import net.dpml.parts.control.LifecycleException;
+import net.dpml.parts.model.ModelException;
import net.dpml.composition.models.Holder;
import net.dpml.system.SystemContext;


Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/DefaultMonitor.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/DefaultMonitor.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/DefaultMonitor.java
Fri Apr 22 02:43:03 2005
@@ -19,7 +19,7 @@
package net.dpml.composition.control;

import net.dpml.logging.Logger;
-import net.dpml.automation.control.Monitor;
+import net.dpml.parts.control.Monitor;


/**

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifecycleHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifecycleHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifecycleHandler.java
Fri Apr 22 02:43:03 2005
@@ -24,15 +24,24 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.util.Observer;

import javax.swing.event.ChangeListener;

-import net.dpml.automation.control.LifecycleException;
-import net.dpml.automation.control.LifecycleRuntimeException;
-import net.dpml.automation.control.Monitor;
+import net.dpml.activity.Startable;
+import net.dpml.activity.Executable;
+
+import net.dpml.parts.control.LifecycleException;
+import net.dpml.parts.control.LifecycleRuntimeException;
+import net.dpml.parts.control.Monitor;
+import net.dpml.parts.state.Manager;

import net.dpml.composition.models.CompositionModel;
import net.dpml.composition.models.Holder;
+import net.dpml.composition.state.NullManager;
+import net.dpml.composition.state.ValueManager;
+import net.dpml.composition.state.ExecutableManager;
+import net.dpml.composition.state.StartableManager;

import net.dpml.meta.info.Type;

@@ -45,6 +54,7 @@

import net.dpml.lang.DefaultInvocationHandler;

+
/**
* A lifestyle handler provides support for the aquisition and release
* of component instances. An implementation is responsible for the
@@ -165,33 +175,42 @@
}

/**
- * Execute the incarnation sequence and return a new
- * component instance.
+ * Return the state manager for the component instance.
*
- * @return a new component instance
+ * @return the state manager (possibly null)
*/
- public Object getProcessController( Holder holder ) throws
LifecycleException, InvocationTargetException
+ public Manager getManager( Holder holder ) throws LifecycleException,
InvocationTargetException
{
if( getMonitor().isDebugEnabled() )
{
final String message =
- "Instantiating controller for ["
+ "Instantiating state manager for ["
+ holder.getURI()
+ "].";
getMonitor().debug( message );
}
- CompositionModel model = holder.getModel();
- URI uri = holder.getURI();

+ CompositionModel model = holder.getModel();
Class subject = model.getDeploymentClass();
- Class parts = getInnerClass( subject, "$Parts" );
- ClassLoader classloader = subject.getClassLoader();
Class control = getInnerClass( subject, "Controller" );
if( null == control )
{
- return null;
+ if( Startable.class.isAssignableFrom( subject ) )
+ {
+ return new StartableManager( holder );
+ }
+ else if( Executable.class.isAssignableFrom( subject ) )
+ {
+ return new ExecutableManager( holder );
+ }
+ else
+ {
+ return new NullManager( holder );
+ }
}

+ URI uri = holder.getURI();
+ ClassLoader classloader = subject.getClassLoader();
Constructor constructor = getConstructor( control );
Class[] classes = constructor.getParameterTypes();
Object[] args = new Object[ classes.length ];
@@ -208,10 +227,6 @@
{
args[i] =
model.getCompositionController().getLoggingChannel( model );
}
- else if( ( null != parts ) && parts.isAssignableFrom( c ) )
- {
- args[i] = newPartsInvocationHandler( holder, parts );
- }
else if( subject.isAssignableFrom( c ) )
{
args[i] = instance;
@@ -236,7 +251,7 @@

try
{
- return constructor.newInstance( args );
+ return (Manager) constructor.newInstance( args );
}
catch( Throwable e )
{

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifestyleHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifestyleHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/LifestyleHandler.java
Fri Apr 22 02:43:03 2005
@@ -20,8 +20,8 @@

import java.lang.reflect.InvocationTargetException;

-import net.dpml.automation.control.LifecycleException;
-import net.dpml.automation.control.Monitor;
+import net.dpml.parts.control.LifecycleException;
+import net.dpml.parts.control.Monitor;

import net.dpml.composition.models.CompositionModel;
import net.dpml.composition.models.Holder;

Copied:
development/main/metro/composition/control/src/main/net/dpml/composition/control/ManagerInvocationHandler.java
(from r2339,
development/main/metro/composition/control/src/main/net/dpml/composition/control/StateManagerInvocationHandler.java)
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/StateManagerInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/ManagerInvocationHandler.java
Fri Apr 22 02:43:03 2005
@@ -31,15 +31,16 @@

import net.dpml.composition.models.Holder;
import net.dpml.composition.data.ValueDirective;
+import net.dpml.composition.state.NullManager;

import net.dpml.system.SystemContext;

-import net.dpml.state.State;
-import net.dpml.state.StateManager;
-import net.dpml.state.Transition;
-import net.dpml.state.Operation;
-import net.dpml.state.NoSuchTransitionException;
-import net.dpml.state.NoSuchOperationException;
+import net.dpml.parts.state.State;
+import net.dpml.parts.state.Manager;
+import net.dpml.parts.state.Transition;
+import net.dpml.parts.state.Operation;
+import net.dpml.parts.state.NoSuchTransitionException;
+import net.dpml.parts.state.NoSuchOperationException;

import net.dpml.lang.DelegationRuntimeException;

@@ -49,14 +50,14 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id: ApplianceInvocationHandler.java 2106 2005-03-21 18:46:10Z
mcconnell AT dpml.net $
*/
-final class StateManagerInvocationHandler implements InvocationHandler
+final class ManagerInvocationHandler implements InvocationHandler
{
//-------------------------------------------------------------------
// state
//-------------------------------------------------------------------

private final Holder m_holder;
- private final Object m_control;
+ private final Object m_manager;
private final Class m_class;

//-------------------------------------------------------------------
@@ -69,11 +70,11 @@
* @param system the system context
* @param model the component model
*/
- StateManagerInvocationHandler( Holder holder )
+ ManagerInvocationHandler( Holder holder, Object manager )
{
m_holder = holder;
- m_control = holder.getProcessController();
- m_class = m_control.getClass();
+ m_manager = manager;
+ m_class = m_manager.getClass();
}

//-------------------------------------------------------------------
@@ -99,7 +100,7 @@
Class source = method.getDeclaringClass();
if( Object.class == method.getDeclaringClass() )
{
- return method.invoke( m_control, args );
+ return method.invoke( m_manager, args );
}

if( name.equals( "initialize" ) || name.equals( "terminate" ) )
@@ -107,11 +108,11 @@
try
{
Method target = m_class.getMethod( name, new Class[0] );
- return target.invoke( m_control, args );
+ return target.invoke( m_manager, args );
}
catch( NoSuchMethodException e )
{
- return null;
+ return m_holder.getValue();
}
catch( Throwable e )
{
@@ -123,11 +124,11 @@
try
{
Method target = m_class.getMethod( name, new Class[0] );
- return method.invoke( m_control, args );
+ return method.invoke( m_manager, args );
}
catch( NoSuchMethodException e )
{
- return new Available();
+ return NullManager.AVAILABLE;
}
catch( Throwable e )
{
@@ -139,7 +140,7 @@
try
{
Method target = m_class.getMethod( name, new Class[]{
String.class } );
- return method.invoke( m_control, args );
+ return method.invoke( m_manager, args );
}
catch( NoSuchMethodException e )
{
@@ -209,96 +210,4 @@
}
return e;
}
-
-
- public static class Available implements State
- {
- public String getName()
- {
- return "available";
- }
-
- public String[] getTransitionNames()
- {
- return new String[0];
- }
-
- public Operation getOperation( String key )
- {
- throw new NoSuchOperationException( key );
- }
-
- public Transition getTransition( String key )
- {
- throw new NoSuchTransitionException( key );
- }
-
- public boolean isTerminal()
- {
- return true;
- }
-
- public String list()
- {
- return "state:available";
- }
- }
-
- public static class SimpleStateManager implements StateManager
- {
- private static final State AVALIABLE = new Available();
-
- private Object m_instance;
- private boolean m_initialized = false;
-
- public SimpleStateManager( Object instance )
- {
- m_instance = instance;
- }
-
- public void initialize() throws Exception
- {
- Class c = m_instance.getClass();
- if( Executable.class.isAssignableFrom( c ) )
- {
- ((Executable)m_instance).execute();
- }
- else if( Startable.class.isAssignableFrom( c ) )
- {
- ((Startable)m_instance).start();
- m_initialized = true;
- }
- }
-
- public State getState()
- {
- return AVALIABLE;
- }
-
- public boolean apply( String key )
- {
- throw new NoSuchTransitionException( key );
- }
-
- public void execute( String key )
- {
- throw new NoSuchOperationException( key );
- }
-
- public void terminate()
- {
- Class c = m_instance.getClass();
- if( m_initialized && Startable.class.isAssignableFrom( c ) )
- {
- try
- {
- ((Startable)m_instance).stop();
- }
- catch( Throwable e )
- {
- // TODO: we need a monitor down here
- }
- }
- }
- }
}

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/control/PartsInvocationHandler.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/control/PartsInvocationHandler.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/control/PartsInvocationHandler.java
Fri Apr 22 02:43:03 2005
@@ -25,13 +25,15 @@
import java.net.URI;
import java.util.Map.Entry;

-import net.dpml.automation.control.Controller;
-import net.dpml.automation.control.DelegationException;
-import net.dpml.automation.model.Model;
+import net.dpml.parts.control.Controller;
+import net.dpml.parts.control.DelegationException;
+import net.dpml.parts.model.Model;
import net.dpml.composition.models.CompositionModel;
import net.dpml.composition.models.Holder;
import net.dpml.meta.info.PartDescriptor;
-import net.dpml.state.StateManager;
+
+import net.dpml.parts.state.Manager;
+
import net.dpml.system.SystemContext;

/**
@@ -179,6 +181,7 @@
throw new IllegalStateException( error );
}
}
+ /*
else if( PartDescriptor.ENTRY_KEY.equals( postfix ) )
{
if( null == args )
@@ -201,6 +204,7 @@
throw new IllegalStateException( error );
}
}
+ */
else if( PartDescriptor.CONTEXT_MANAGER_KEY.equals( postfix )
|| PartDescriptor.CONTEXT_MAP_KEY.equals( postfix ) )
{
@@ -243,7 +247,7 @@
new ContextManagerInvocationHandler( system, holder );
return Proxy.newProxyInstance( classloader, new Class[]{
clazz }, handler );
}
- else if( PartDescriptor.STATE_MANAGER_KEY.equals( postfix ) )
+ else if( PartDescriptor.MANAGER_KEY.equals( postfix ) )
{
if( false == ( provider instanceof CompositionModel ) )
{
@@ -260,25 +264,48 @@
+ "Instance: " + m_holder.getURI();
throw new UnsupportedOperationException( error );
}
+ else
+ {
+ CompositionModel model = (CompositionModel) provider;
+ return getManager( model, args );
+ }

+ /*
CompositionModel model = (CompositionModel) provider;
Controller controller = model.getController();
Holder holder = getHolder( model, args );
- Object manager = holder.getProcessController();
+ Manager manager = holder.getManager();
if( null == manager )
{
- return new
StateManagerInvocationHandler.SimpleStateManager( holder.getValue() );
+ return new ClassicManager( holder.getValue() );
}
- else if( StateManager.class.isAssignableFrom(
manager.getClass() ) )
+ else if( Manager.class.isAssignableFrom( manager.getClass()
) )
{
return manager;
}
else
{
ClassLoader classloader = model.getClassLoader();
- StateManagerInvocationHandler handler =
- new StateManagerInvocationHandler( holder );
- return Proxy.newProxyInstance( classloader, new Class[]{
StateManager.class }, handler );
+ ManagerInvocationHandler handler =
+ new ManagerInvocationHandler( holder );
+ return Proxy.newProxyInstance( classloader, new Class[]{
Manager.class }, handler );
+ }
+ */
+ }
+ else if( PartDescriptor.MODEL_KEY.equals( postfix ) )
+ {
+ if( false == ( provider instanceof Model ) )
+ {
+ final String error =
+ "Selected entry does not implement the Model
interface."
+ + "\nClass: " + provider.getClass().getName()
+ + "\nKey: " + provider.getKey()
+ + "Instance: " + m_holder.getURI();
+ throw new UnsupportedOperationException( error );
+ }
+ else
+ {
+ return (Model) provider;
}
}
else if( PartDescriptor.PARTS_MANAGER_KEY.equals( postfix )
@@ -301,6 +328,7 @@
throw new IllegalStateException( error );
}
}
+ /*
else if( PartDescriptor.CREATE == semantic )
{
if( null == args )
@@ -353,6 +381,7 @@
throw new IllegalStateException( error );
}
}
+ */
else if( PartDescriptor.RELEASE == semantic )
{
if( args.length == 1 )
@@ -397,6 +426,7 @@
}
}

+ /*
private Entry invokeCreate( String key, Model provider ) throws
DelegationException
{
Controller controller = provider.getController();
@@ -426,6 +456,7 @@
throw exception;
}
}
+ */

private DelegationException createDelegationException( String key, Model
provider, String function, Throwable e )
{
@@ -523,20 +554,37 @@
}
}

+ private Manager getManager( CompositionModel model, Object[] args )
throws Exception
+ {
+ CompositionController controller = model.getCompositionController();
+ if( null == args )
+ {
+ return controller.getManager( model );
+ }
+ else if( args.length == 0 )
+ {
+ return controller.getManager( model );
+ }
+ else
+ {
+ return controller.getManager( model, args[0] );
+ }
+ }
+
private Holder getHolder( CompositionModel model, Object[] args ) throws
Exception
{
- Controller controller = model.getController();
+ CompositionController controller = model.getCompositionController();
if( null == args )
{
- return (Holder) controller.create( model );
+ return (Holder) controller.getHolder( model, null );
}
else if( args.length == 0 )
{
- return (Holder) controller.create( model );
+ return (Holder) controller.getHolder( model, null );
}
else
{
- return (Holder) controller.create( model, args[0] );
+ return (Holder) controller.getHolder( model, args[0] );
}
}
}

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/models/AbstractModel.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/models/AbstractModel.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/models/AbstractModel.java
Fri Apr 22 02:43:03 2005
@@ -20,10 +20,12 @@

import java.net.URI;

-import net.dpml.automation.control.Controller;
-import net.dpml.automation.model.Model;
+import net.dpml.parts.control.Controller;
+import net.dpml.parts.model.Model;
import net.dpml.composition.control.CompositionController;

+import net.dpml.parts.state.Manager;
+
/**
* A context entry model.
*
@@ -82,6 +84,14 @@

public abstract URI getURI();

+ /**
+ * Return a Manager for the default instance.
+ */
+ public Manager getManager() throws Exception
+ {
+ return getCompositionController().getManager( this );
+ }
+
//--------------------------------------------------------------
// Entry
//--------------------------------------------------------------

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/models/CompositionModel.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/models/CompositionModel.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/models/CompositionModel.java
Fri Apr 22 02:43:03 2005
@@ -23,23 +23,25 @@
import java.util.LinkedList;
import java.util.List;

-import net.dpml.automation.model.Model;
-import net.dpml.automation.model.ModelException;
-import net.dpml.automation.model.ModelRuntimeException;
-import net.dpml.automation.model.ServiceClassNotFoundException;
-import net.dpml.automation.model.TypeClassNotFoundException;
-import net.dpml.automation.part.Part;
-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.model.Model;
+import net.dpml.parts.model.ModelException;
+import net.dpml.parts.model.ModelRuntimeException;
+import net.dpml.parts.model.ServiceClassNotFoundException;
+import net.dpml.parts.model.TypeClassNotFoundException;
+import net.dpml.parts.part.Part;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.control.CompositionController;
import net.dpml.composition.data.ComponentProfile;
import net.dpml.composition.data.ContextDirective;
import net.dpml.configuration.Configuration;
+import net.dpml.configuration.Configurable;
import net.dpml.configuration.impl.DefaultConfiguration;
import net.dpml.meta.info.DependencyDescriptor;
import net.dpml.meta.info.EntryDescriptor;
import net.dpml.meta.info.ServiceDescriptor;
import net.dpml.meta.info.Type;
import net.dpml.parameters.Parameters;
+import net.dpml.parameters.Parameterizable;
import net.dpml.parameters.impl.DefaultParameters;

/**
@@ -48,7 +50,7 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
*/
-public class CompositionModel extends AbstractModel implements Model,
Serializable
+public class CompositionModel extends AbstractModel implements Model,
Configurable, Parameterizable, Serializable
{
private final List m_errors = new LinkedList();

@@ -248,7 +250,7 @@
}
}

- public void setConfiguration( Configuration configuration )
+ public void configure( Configuration configuration )
{
m_configuration = configuration;
}
@@ -265,7 +267,7 @@
}
}

- public void setParameters( Parameters parameters )
+ public void parameterize( Parameters parameters )
{
m_parameters = parameters;
}

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/models/ContextTable.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/models/ContextTable.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/models/ContextTable.java
Fri Apr 22 02:43:03 2005
@@ -21,8 +21,8 @@
import java.net.URI;
import java.util.Map.Entry;

-import net.dpml.automation.model.ModelException;
-import net.dpml.automation.part.Part;
+import net.dpml.parts.model.ModelException;
+import net.dpml.parts.part.Part;
import net.dpml.composition.data.ReferenceDirective;

/**

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/models/DuplicateKeyException.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/models/DuplicateKeyException.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/models/DuplicateKeyException.java
Fri Apr 22 02:43:03 2005
@@ -18,7 +18,7 @@

package net.dpml.composition.models;

-import net.dpml.automation.model.ModelException;
+import net.dpml.parts.model.ModelException;

/**
* Exception thrown in response to an attempt to register a part model

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/models/EntryTable.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/models/EntryTable.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/models/EntryTable.java
Fri Apr 22 02:43:03 2005
@@ -22,8 +22,8 @@
import java.util.Map;
import java.util.Map.Entry;

-import net.dpml.automation.model.ModelException;
-import net.dpml.automation.part.Part;
+import net.dpml.parts.model.ModelException;
+import net.dpml.parts.part.Part;
import net.dpml.composition.control.CompositionController;

/**

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/models/Holder.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/models/Holder.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/models/Holder.java
Fri Apr 22 02:43:03 2005
@@ -31,10 +31,12 @@
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

-import net.dpml.automation.control.Identifiable;
-import net.dpml.automation.control.LifecycleException;
-import net.dpml.automation.control.Monitor;
+import net.dpml.parts.control.Identifiable;
+import net.dpml.parts.control.LifecycleException;
+import net.dpml.parts.control.Monitor;
+
import net.dpml.composition.control.CompositionController;
+import net.dpml.parts.state.Manager;

/**
* A lifestyle handler provides support for the aquisition and release
@@ -55,7 +57,6 @@
private final URI m_uri;
private final ContextMap m_context;
private final Object m_instance;
- private final Object m_manager;

private boolean m_disposed = false;

@@ -94,11 +95,8 @@

m_context = new ContextMap( model );
m_instance = model.getCompositionController().incarnate( this );
-
CompositionController controller = model.getCompositionController();
super.addObserver( controller );
-
- m_manager = model.getCompositionController().getProcessController(
this );
}

public Object getKey()
@@ -131,11 +129,6 @@
return m_uri;
}

- public Object getProcessController()
- {
- return m_manager;
- }
-
/**
* Create, register and return a proxy to the instance managed by this
* holder. The implementation will register the proxy as a weak reference
@@ -187,12 +180,12 @@
}

/**
- * Disposal set the disposed flag on this holder to true and triggers
+ * Disposal sets the disposed flag on this holder to true and triggers
* etherialization of any proxy references that this holder has relative
* to the instance it is managing. On completing the implementation will
* remove the instance for the model's instance table and trigger instance
* etherialization.
- */
+ */
public void dispose()
{
if( m_disposed )
@@ -225,7 +218,6 @@
* instance handled by this holder
* @see #dispose
*/
-
public void release( Object proxy )
{
synchronized( m_proxies )

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/models/InvalidModelException.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/models/InvalidModelException.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/models/InvalidModelException.java
Fri Apr 22 02:43:03 2005
@@ -20,7 +20,7 @@

import java.net.URI;

-import net.dpml.automation.model.ModelRuntimeException;
+import net.dpml.parts.model.ModelRuntimeException;

/**
* Unexpected runtime exception indicating an internal model error.

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/models/PartsTable.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/models/PartsTable.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/models/PartsTable.java
Fri Apr 22 02:43:03 2005
@@ -18,8 +18,8 @@

package net.dpml.composition.models;

-import net.dpml.automation.model.ModelException;
-import net.dpml.automation.part.Part;
+import net.dpml.parts.model.ModelException;
+import net.dpml.parts.part.Part;
import net.dpml.composition.data.ReferenceDirective;

/**

Modified:
development/main/metro/composition/control/src/main/net/dpml/composition/models/ValueModel.java
==============================================================================
---
development/main/metro/composition/control/src/main/net/dpml/composition/models/ValueModel.java
(original)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/models/ValueModel.java
Fri Apr 22 02:43:03 2005
@@ -21,10 +21,10 @@
import java.lang.reflect.Constructor;
import java.net.URI;

-import net.dpml.automation.control.Controller;
-import net.dpml.automation.model.Model;
-import net.dpml.automation.model.ModelException;
-import net.dpml.automation.model.ModelRuntimeException;
+import net.dpml.parts.control.Controller;
+import net.dpml.parts.model.Model;
+import net.dpml.parts.model.ModelException;
+import net.dpml.parts.model.ModelRuntimeException;
import net.dpml.composition.control.CompositionController;
import net.dpml.composition.data.ValueDirective;
import net.dpml.composition.data.ValueDirective.Value;

Added:
development/main/metro/composition/control/src/main/net/dpml/composition/state/DefaultManager.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/state/DefaultManager.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,769 @@
+/*
+ * 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.composition.state;
+
+import java.util.Map;
+import java.util.Hashtable;
+import java.util.TreeMap;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+import java.lang.reflect.Method;
+import java.net.URI;
+
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import net.dpml.parts.state.State;
+import net.dpml.parts.state.Transition;
+import net.dpml.parts.state.Manager;
+import net.dpml.parts.state.DuplicateKeyException;
+import net.dpml.parts.state.NoSuchTransitionException;
+import net.dpml.parts.state.NoSuchOperationException;
+import net.dpml.parts.state.ValidationException;
+import net.dpml.parts.state.Operation;
+
+/**
+ * The State interface is an interface representing an immutable state of
+ * a component instance.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class DefaultManager implements Manager
+{
+ private final DefaultState m_graph;
+ private DefaultState m_state;
+ private Object m_instance;
+ private ChangeListener m_listener;
+ private Map m_handlers = new Hashtable();
+ private Logger m_logger;
+
+ /**
+ * Creation of a new AbstractStateManager.
+ * @param graph the root state of a state graph
+ * @param logger the assinged logging channel
+ * @param listener a change listener
+ * @param instance the managed instance
+ */
+ public DefaultManager( DefaultState graph, Logger logger, ChangeListener
listener, Object instance )
+ {
+ if( null == logger )
+ {
+ throw new NullPointerException( "logger" );
+ }
+ if( null == instance )
+ {
+ throw new NullPointerException( "instance" );
+ }
+ if( null == listener )
+ {
+ throw new NullPointerException( "listener" );
+ }
+ if( null == graph )
+ {
+ throw new NullPointerException( "graph" );
+ }
+ m_instance = instance;
+ m_listener = listener;
+ m_logger = logger;
+ m_graph = graph;
+ }
+
+ /**
+ * Return an registered transition or operation handler.
+ *
+ * @param uri a handler uri
+ * @return the handler instance
+ * @exception NoSuchHandlerException if the supplied key is unknown
+ * @exception NullPointerException if the key is null
+ */
+ protected Object getHandler( String key ) throws NoSuchHandlerException
+ {
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+ Object handler = m_handlers.get( key );
+ if( null == handler )
+ {
+ throw new NoSuchHandlerException( key );
+ }
+ return handler;
+ }
+
+ /**
+ * Register a handler with the manager. The handler object must
+ * implement a publically accessible method named 'handle'. Method
parameters
+ * may include java.net.logging.Logger, up to two occurance of
net.dpml.parts.state.State
+ * (the first occurance will be assingned the current state and second
the
+ * transition target state), and lastly, a type assignable to the current
+ * component instance. All parameters are optional.
+ *
+ * @param key the key under which the handler is registered
+ * @param handler the handler instance
+ * @exception NullPointerException if the key or handler argument is null
+ * @exception DuplicateKeyException if a handler is already registered
under
+ * the supplied key
+ */
+ protected void addHandler( String key, Object handler ) throws
ValidationException
+ {
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+ if( null == handler )
+ {
+ throw new NullPointerException( "handler" );
+ }
+ if( m_handlers.containsKey( key ) )
+ {
+ throw new DuplicateKeyException( key );
+ }
+ else
+ {
+ Class clazz = handler.getClass();
+ locateMethod( clazz, "handle" );
+ m_handlers.put( key, handler );
+ }
+ }
+
+ /**
+ * Initialization of the manager by a controller.
+ * If the root state is not terminal the implementation will invoke a
+ * transiton named "initalize". If the transition results in a modified
+ * state, the implementation will continue to recursivly invoke
+ * initialize operations until a non-initializable state is established
+ * as the current state.
+ *
+ * @return the initialized object
+ * @exception IllegalStateException if an error occurs during validation
+ * @exception Exception if an error is raised by a handler assigned to
+ * and invoked initialization transition
+ */
+ public synchronized Object initialize() throws ValidationException,
Exception
+ {
+ List visited = new LinkedList();
+ DefaultState graph = getStateGraph();
+ validate( graph );
+ m_state = getStateGraph();
+ boolean flag = true;
+ while( flag )
+ {
+ DefaultState state = getCurrentState();
+ DefaultTransition initialization = state.getInitialization();
+ if( null == initialization )
+ {
+ flag = false;
+ }
+ else if( false == visited.contains( state.getName() ) )
+ {
+ visited.add( state.getName() );
+ flag = applyTransition( initialization );
+ }
+ else
+ {
+ boolean first = true;
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "Initialization sequence aborted." );
+ buffer.append( "\nReason: detection of a recursive
initialization sequence" );
+ Iterator iterator = visited.iterator();
+ while( iterator.hasNext() )
+ {
+ String name = (String) iterator.next();
+ if( first )
+ {
+ buffer.append( "\n State [" + name + "]" );
+ first = false;
+ }
+ else
+ {
+ buffer.append( " --> [" + name + "]" );
+ }
+ }
+ buffer.append( " --> [" + state.getName() + "]" );
+ String error = buffer.toString();
+ visited.clear();
+ throw new RecursiveInitializationException( error );
+ }
+ }
+ return m_instance;
+ }
+
+ private void validate( DefaultState state ) throws ValidationException
+ {
+ DefaultTransition init = state.getInitialization();
+ if( null != init )
+ {
+ URI uri = init.getHandlerURI();
+ try
+ {
+ validateHandlerURI( uri );
+ }
+ catch( ValidationException e )
+ {
+ final String error =
+ "Initialization handler uri validation failure."
+ + "\nState: " + state.getName()
+ + "\nInitialization Handler URI: " + uri
+ + "\nMessage: " + e.getMessage();
+ throw new ValidationException( error, e.getCause() );
+ }
+ }
+ String[] operations = state.getLocalOperationNames();
+ for( int i=0; i<operations.length; i++ )
+ {
+ String key = operations[i];
+ DefaultOperation operation = state.getNamedOperation( key );
+ URI uri = operation.getHandlerURI();
+ try
+ {
+ validateHandlerURI( uri );
+ }
+ catch( ValidationException e )
+ {
+ final String error =
+ "Operation handler uri validation failure."
+ + "\nState: " + state.getName()
+ + "\nOperation Key: " + key
+ + "\nOperation Handler URI: " + uri
+ + "\nMessage: " + e.getMessage();
+ throw new ValidationException( error, e.getCause() );
+ }
+ }
+ String[] transitions = state.getLocalTransitionNames();
+ for( int i=0; i<transitions.length; i++ )
+ {
+ String key = transitions[i];
+ DefaultTransition transition = state.getNamedTransition( key );
+ URI uri = transition.getHandlerURI();
+ try
+ {
+ validateHandlerURI( uri );
+ }
+ catch( ValidationException e )
+ {
+ final String error =
+ "Operation handler uri validation failure."
+ + "\nState: " + state.getName()
+ + "\nOperation Key: " + key
+ + "\nOperation Handler URI: " + uri
+ + "\nMessage: " + e.getMessage();
+ throw new ValidationException( error, e.getCause() );
+ }
+ }
+ DefaultTransition terminator = state.getTerminator();
+ if( null != terminator )
+ {
+ URI uri = terminator.getHandlerURI();
+ try
+ {
+ validateHandlerURI( uri );
+ }
+ catch( ValidationException e )
+ {
+ final String error =
+ "Terminator handler uri validation failure."
+ + "\nState: " + state.getName()
+ + "\nTerminator Handler URI: " + uri
+ + "\nMessage: " + e.getMessage();
+ throw new ValidationException( error );
+ }
+ }
+ }
+
+ private void validateHandlerURI( URI uri ) throws ValidationException
+ {
+ if( null == uri )
+ {
+ return;
+ }
+ String scheme = uri.getScheme();
+ String spec = uri.getSchemeSpecificPart();
+ if( "method".equals( scheme ) )
+ {
+ if( "null".equals( spec ) )
+ {
+ return;
+ }
+ else
+ {
+ Class c = m_instance.getClass();
+ Method method = locateMethod( c, spec );
+ }
+ }
+ else if( "handler".equals( scheme ) )
+ {
+ try
+ {
+ getHandler( spec );
+ }
+ catch( NoSuchHandlerException e )
+ {
+ final String error =
+ "no handler registered under the key [" + spec + "]";
+ throw new ValidationException( error );
+ }
+ }
+ else
+ {
+ final String error =
+ "handler scheme '"
+ + scheme
+ + "' not supported";
+ throw new ValidationException( error );
+ }
+ }
+
+ /**
+ * Return the current state. The current state is the function of
+ * the initialization and subsequent transition actions applied to
+ * the state model. The current state established the active
+ * state chain as the sequence of states from the current state to
+ * root state. Any transitions defined in the active state chain
+ * are candidates for execution. Transitions that are logically closer
to the
+ * current state override transitions declare higher up in the
+ * state chain. This method is exposed via the ServiceManager
+ * interface to the controlling application (possibly the enclossing
+ * component or the model controller). State instances returned from
+ * this method are automatically proxied behind a State invocation
+ * handler thereby ensuring the integrity of the state's state and
+ * non-disclosure of implemetation features.
+ *
+ * @return the current state
+ */
+ public synchronized State getState()
+ {
+ return getCurrentState().getProxy();
+ }
+
+ /**
+ * Internal utility method that returns a non-proxied reference to the
+ * current state.
+ *
+ * @return the state representing the current state of execution
+ */
+ protected DefaultState getCurrentState()
+ {
+ if( null == m_state )
+ {
+ final String error =
+ "State manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+ else
+ {
+ return m_state;
+ }
+ }
+
+ /**
+ * Apply a transition identified by a supplied transition key. The
+ * implementation will attempt to locate the transition relative to the
current
+ * state (taking into account the DefaultState search semantics) from
which
+ * a invocation handler is resolve and invoked. If the transition is
successful
+ * the target transition state declared by the transition will be
assigned as the
+ * current current state and all listeners will be notified of a state
change.
+ * If the transition resolved from the supplied key references a target
state
+ * that is the same as the current state the transition will not be
invoked and
+ * the method will return false.
+ *
+ * @param key the transition key
+ * @return the state established by the transition
+ * @exception if a error occurs in transition execution
+ */
+ public State apply( String key ) throws Exception
+ {
+ DefaultState state = getCurrentState();
+ DefaultTransition transition = state.getNamedTransition( key );
+ applyTransition( transition );
+ return getState();
+ }
+
+ /**
+ * Apply a transition identified by a supplied transition key. The
+ * implementation will attempt to locate the transition relative to the
current
+ * state (taking into account the DefaultState search semantics) from
which
+ * a invocation handler is resolve and invoked. If the transition is
successful
+ * the target transition state declared by the transtion will be assigned
as the
+ * current current state and all listeners will be notified of a state
change.
+ * If the transition resolved from the supplied key references a target
state
+ * that is the same as the current state the transition will not be
invoked and
+ * the method will return false.
+ *
+ * @param key the transition key
+ * @return TRUE if the transition was executed
+ * @exception if a error occurs in transition execution
+ */
+ private boolean applyTransition( DefaultTransition transition ) throws
Exception
+ {
+ DefaultState state = getCurrentState();
+ URI handler = transition.getHandlerURI();
+ DefaultState target = transition.getTransitionTarget();
+ if( state.equals( target ) )
+ {
+ return false;
+ }
+ else
+ {
+ if( getLogger().isLoggable( Level.FINE ) )
+ {
+ final String message =
+ "applying ["
+ + handler.toString()
+ + "] to state ["
+ + state.getName()
+ + "]";
+ getLogger().fine( message );
+ }
+ Logger logger = getLogger();
+ execution( handler, state, target, logger );
+ setState( target );
+ return true;
+ }
+ }
+
+ /**
+ * Execute an operation identified by a supplied operation key. The
+ * implementation will attempt to locate the operation relative to the
current
+ * state (taking into account the DefaultState search semantics) from
which
+ * a invocation handler is resolve and invoked.
+ *
+ * @param key the operation key
+ * @exception if a error occurs in transition execution
+ */
+ public void execute( String key ) throws Exception
+ {
+ DefaultState state = getCurrentState();
+ DefaultOperation operation = state.getNamedOperation( key );
+ URI handler = operation.getHandlerURI();
+ if( null == handler )
+ {
+ return;
+ }
+ else
+ {
+ if( getLogger().isLoggable( Level.FINE ) )
+ {
+ final String message =
+ "executing operation ["
+ + handler.toString()
+ + "]";
+ getLogger().fine( message );
+ }
+ Logger logger = getLogger();
+ execution( handler, state, null, logger );
+ }
+ }
+
+ /**
+ * Internal utility method that handles the resolution of a handler based
on
+ * the object assigned to the DefaultTransition handler attribute. If
the
+ * handler is an instance of URI, the following schemes will be evaluated:
+ *
+ * <ol>
+ * <li>part:[key] - invocation of the handle method on the component's
part
+ * referenced by the scheme specific part of the supplied uri</li>
+ * <li>handler:[key] - invocation of the handle method on a class
identified by
+ * the scheme specific part of the uri</li>
+ * <li>method:[key] - invocation of the handle method against the
component
+ * instance</li>
+ * </ol>
+ *
+ * @param handler the object describing the handler
+ * @param state the current state
+ * @param target the target of the transition
+ * @param logger the assigned logging channel
+ * @excetion Exception of an invocation or handler error occurs
+ */
+ private void execution( URI uri, State state, State target, Logger
logger ) throws Exception
+ {
+ if( null == uri )
+ {
+ return;
+ }
+ String scheme = uri.getScheme();
+ if( "method".equals( scheme ) )
+ {
+ //
+ // invoke the named method on the component instance
+ //
+
+ String spec = uri.getSchemeSpecificPart();
+ if( "null".equals( spec ) )
+ {
+ return;
+ }
+ else
+ {
+ Class c = m_instance.getClass();
+ Method method = locateMethod( c, spec );
+ Class[] parameters = method.getParameterTypes();
+ Object[] args = resolveArguments( parameters, state, target,
logger );
+ method.invoke( m_instance, args );
+ }
+ }
+ else if( "handler".equals( scheme ) )
+ {
+ //
+ // delegate execution to a registered handler
+ //
+
+ String spec = uri.getSchemeSpecificPart();
+ if( "null".equals( spec ) )
+ {
+ return;
+ }
+ else
+ {
+ Object h = getHandler( spec );
+ Class c = h.getClass();
+ Method method = locateMethod( c, "handle" );
+ Class[] parameters = method.getParameterTypes();
+ Object[] args = resolveArguments( parameters, state, target,
logger );
+ method.invoke( h, args );
+ }
+ }
+ else
+ {
+ final String error =
+ "Scheme not recognized."
+ + "\nScheme: " + scheme
+ + "\nURI: " + uri;
+ throw new IllegalArgumentException( error );
+ }
+ }
+
+ /**
+ * Internal utility to populate method arguments using the current state,
target state
+ * (in the case of transitions), assigned logging channel, and the active
component
+ * instance.
+ *
+ * @param parameters the array of method parameter arguments
+ * @param state the current state
+ * @param target the transition target state (possible null when handling
operations)
+ * @param logger the assinged logging channel
+ * @return the populated object array
+ */
+ private Object[] resolveArguments( Class[] parameters, State state,
State target, Logger logger )
+ {
+ boolean firstStateAssigned = false;
+ Object[] args = new Object[ parameters.length ];
+ for( int i=0; i<parameters.length; i++ )
+ {
+ Class c = parameters[i];
+ if( Logger.class.isAssignableFrom( c ) )
+ {
+ args[i] = logger;
+ }
+ else if( State.class.isAssignableFrom( c ) )
+ {
+ if( false == firstStateAssigned )
+ {
+ args[i] = state;
+ firstStateAssigned = true;
+ }
+ else
+ {
+ if( null != target )
+ {
+ args[i] = target; // its a transition
+ }
+ else
+ {
+ args[i] = state; // fallback to using current state
+ }
+ }
+ }
+ else if( m_instance.getClass().isAssignableFrom( c ) )
+ {
+ args[i] = m_instance;
+ }
+ else
+ {
+ final String error =
+ "Could not resolve a argument value for the parameter type
["
+ + c.getName()
+ + "].";
+ throw new RuntimeException( error );
+ }
+ }
+ return args;
+ }
+
+ /**
+ * Utility operation to apply a state change. If the supplied state is
+ * differnet from the current state the current state will be updated to
+ * the supplied value and a notification event issued to the listener
+ * assigned under the constructor.
+ *
+ * @param state the state to assign as the current state
+ */
+ protected synchronized void setState( DefaultState state )
+ {
+ if( false == m_state.equals( state ) )
+ {
+ if( getLogger().isLoggable( Level.FINE ) )
+ {
+ final String message =
+ "changing state from '"
+ + m_state.getName()
+ + "' to '"
+ + state.getName()
+ + "'";
+ getLogger().fine( message );
+ }
+ m_state = state;
+ ChangeEvent event = new ChangeEvent( this );
+ m_listener.stateChanged( event );
+ }
+ }
+
+ /**
+ * Handles a request for termination by a controller. The implementation
+ * will attempt to locate a transition named 'terminate' and if located,
+ * will apply that transition. If the result of the transition if a new
+ * non-terminal state the procedure will be repeated. If the current
state
+ * is a terminal state the operation simply returns.
+ */
+ public synchronized void terminate()
+ {
+ try
+ {
+ executeTermination();
+ }
+ catch( RecursiveTerminationException e )
+ {
+ // recusive termination path
+ String error = e.getMessage();
+ getLogger().log( Level.WARNING, error );
+ }
+ finally
+ {
+ m_state = null;
+ }
+ }
+
+ synchronized void executeTermination() throws
RecursiveTerminationException
+ {
+ if( null == m_state )
+ {
+ return; // we were never initialized
+ }
+
+ List visited = new LinkedList();
+ boolean flag = true;
+ while( flag )
+ {
+ DefaultState state = getCurrentState();
+ DefaultTransition terminator = state.getTerminator();
+ if( null == terminator )
+ {
+ return;
+ }
+ else if( !visited.contains( state.getName() ) )
+ {
+ try
+ {
+ visited.add( state.getName() );
+ flag = applyTransition( terminator );
+ }
+ catch( Exception e )
+ {
+ flag = false;
+ getLogger().log( Level.WARNING, "Ignoring termination
handler error", e );
+ }
+ }
+ else
+ {
+ boolean first = true;
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "Termination sequence aborted." );
+ buffer.append( "\nReason: detection of a recursive
termination sequence" );
+ Iterator iterator = visited.iterator();
+ while( iterator.hasNext() )
+ {
+ String name = (String) iterator.next();
+ if( first )
+ {
+ buffer.append( "\n State [" + name + "]" );
+ first = false;
+ }
+ else
+ {
+ buffer.append( " --> [" + name + "]" );
+ }
+ }
+ buffer.append( " --> [" + state.getName() + "]" );
+ String error = buffer.toString();
+ visited.clear();
+ throw new RecursiveTerminationException( error );
+ }
+ }
+ }
+
+ /**
+ * Utility operation to return the logging channel assigned by the
container.
+ * @return the logging channel
+ */
+ protected Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ /**
+ * Utility to locate athe first public method with the supplied name in
the
+ * supplied class.
+ * @param c the class to introspect
+ * @param operation the method name
+ * @return the first method found
+ * @exception ValidationException if the class does not delcare the
+ * the named method
+ */
+ private Method locateMethod( Class c, String operation ) throws
ValidationException
+ {
+ Method[] methods = c.getMethods();
+ for( int i=0; i<methods.length; i++ )
+ {
+ Method method = methods[i];
+ String name = method.getName();
+ if( operation.equals( method.getName() ) )
+ {
+ return method;
+ }
+ }
+ final String error =
+ "Class does not implement a public method '"
+ + operation
+ + "'."
+ + "\nClass: " + c.getName();
+ throw new ValidationException( error );
+ }
+
+ /**
+ * The operation returns the state instance represening the state graph.
+ * @return the root state
+ */
+ private DefaultState getStateGraph()
+ {
+ return m_graph;
+ }
+}

Added:
development/main/metro/composition/control/src/main/net/dpml/composition/state/DefaultOperation.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/state/DefaultOperation.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,58 @@
+/*
+ * 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.composition.state;
+
+import java.net.URI;
+
+import net.dpml.parts.state.Operation;
+
+/**
+ * The DefaultOperation links an operation to a handler uri.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class DefaultOperation implements Operation
+{
+ private final URI m_handler;
+
+ /**
+ * Internal utility to construct a new operation instance. This
constructor
+ * is used by the DefaultState implementation class as part of it's
operation
+ * factory service.
+ *
+ * @param handler the uri identifying the operation handler
+ */
+ protected DefaultOperation( URI handler )
+ {
+ if( null == handler )
+ {
+ throw new NullPointerException( "handler" );
+ }
+ m_handler = handler;
+ }
+
+ /**
+ * Return the handler uri identifier associated with this operation.
+ * @return the uri identiifying the handler
+ */
+ public URI getHandlerURI()
+ {
+ return m_handler;
+ }
+}

Added:
development/main/metro/composition/control/src/main/net/dpml/composition/state/DefaultState.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/state/DefaultState.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,880 @@
+/*
+ * 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.composition.state;
+
+import java.util.Map;
+import java.util.Hashtable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.net.URI;
+
+import net.dpml.parts.state.NoSuchOperationException;
+import net.dpml.parts.state.State;
+import net.dpml.parts.state.NoSuchStateException;
+import net.dpml.parts.state.NoSuchTransitionException;
+import net.dpml.parts.state.DuplicateKeyException;
+import net.dpml.parts.state.Operation;
+import net.dpml.parts.state.Transition;
+
+import net.dpml.lang.DefaultInvocationHandler;
+
+/**
+ * The State interface is an interface representing an immutable state of
+ * a component instance.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class DefaultState implements State
+{
+ private final String m_name;
+ private final DefaultState m_parent;
+ private final boolean m_terminal;
+
+ private final Map m_operations = new Hashtable();
+ private final Map m_transitions = new Hashtable();
+ private final State m_proxy;
+
+ private DefaultTransition m_initialization;
+ private DefaultTransition m_terminator;
+
+ private final Map m_states = new Hashtable();
+
+ /**
+ * Creation of a new top-level non-terminal state.
+ */
+ public DefaultState()
+ {
+ this( false );
+ }
+
+ /**
+ * Creation of a new top-level state.
+ * @param terminal the terminal status of the state
+ */
+ public DefaultState( boolean terminal )
+ {
+ this( null, "root", terminal );
+ }
+
+ /**
+ * Internal constructor for a state instance. If the parent argument is
null
+ * the created state representing a root state in a state graph. The
terminal
+ * attribute declares the terminal node status of the state. If the
state is
+ * flagged as terminal, no sub-states or transitions may be added or
assigned
+ * to the state.
+ *
+ * @paren parent the parent of the created state
+ * @param name the name that the state is index under
+ * @param terminal TRUE if this is a terminal state else FALSE
+ * @exception NullPointerException if the name argument is null
+ */
+ private DefaultState( DefaultState parent, String name, boolean terminal
)
+ {
+ if( null == name )
+ {
+ throw new NullPointerException( "name" );
+ }
+ m_name = name;
+ m_parent = parent;
+ m_terminal = terminal;
+
+ InvocationHandler handler = new DefaultInvocationHandler( this );
+ ClassLoader classloader = getClass().getClassLoader();
+ m_proxy = (State) Proxy.newProxyInstance( classloader, new Class[]{
State.class }, handler );
+ }
+
+ /**
+ * Return the name of the state.
+ *
+ * @return the state name
+ */
+ public String getName()
+ {
+ return m_name;
+ }
+
+ /**
+ * Return the parent state.
+ * @return the parent
+ */
+ protected DefaultState getParent()
+ {
+ return m_parent;
+ }
+
+ /**
+ * Return the parent state.
+ * @return the parent
+ */
+ public State getProxy()
+ {
+ return m_proxy;
+ }
+
+ /**
+ * Return the terminal status of this state. If a state is terminal it
cannot
+ * contain sub-states or transitions. Furthermore, a component declaring
a current
+ * state where the current state is terminal cannot change it's state
without explicit
+ * re-initialization of the componet's service manager.
+ *
+ * @return TRUE if this state is a terminal state
+ */
+ public boolean isTerminal()
+ {
+ return m_terminal;
+ }
+
+ /**
+ * Add a new sub-state to the set of states contained within this
+ * state. If the supplied key is not unique within the scope of the graph
+ * an exception will be thrown.
+ *
+ * @param key the key identifying the new state
+ * @return the created state
+ */
+ public DefaultState addState( String key )
+ {
+ return addState( this, key, false );
+ }
+
+ /**
+ * Add a new terminal sub-state to the set of states contained within
this
+ * state. If the supplied key is not unique within the scope of the graph
+ * an exception will be thrown.
+ *
+ * @param key the key identifying the new state
+ * @return the created state
+ */
+ public DefaultState addTerminalState( String key )
+ {
+ return addState( this, key, true );
+ }
+
+ /**
+ * Internal operation to construct a new sub-state state. The
implementation
+ * will delegate the state addition to the parent under which all states
in the
+ * state graph are aggregated relative to unique keys.
+ *
+ * @param parent the enclosing state
+ * @param key the key identifying the new state
+ * @param terminal true if this is a terminal state
+ * @return the created state
+ * @exception IllegalStateException if the parent state is a terminal
state
+ * @exception DuplicateKeyException if a state with the supplied key is
already assingned
+ * @exception IllegalArgumentException if the initial parameter is true
and an initial
+ * state has already beeen declared
+ */
+ private DefaultState addState( DefaultState parent, String key, boolean
terminal )
+ {
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+ if( m_parent != null )
+ {
+ return m_parent.addState( parent, key, terminal );
+ }
+ else
+ {
+ if( parent.isTerminal() )
+ {
+ final String error =
+ "Cannot add substate to a terminal state."
+ + "\nState: " + parent.getName()
+ + "\nSubstate: " + key;
+ throw new IllegalStateException( error );
+ }
+
+ if( m_states.containsKey( key ) )
+ {
+ throw new DuplicateKeyException( key );
+ }
+ else
+ {
+ DefaultState state = new DefaultState( parent, key, terminal
);
+ m_states.put( key, state );
+ return state;
+ }
+ }
+ }
+
+ /**
+ * Return an array of all states within the state graph. This includes
+ * all substates of the root state and all substates of substates, etc.
+ *
+ * @return the state array
+ */
+ protected DefaultState[] getAllStates()
+ {
+ if( null != m_parent )
+ {
+ return m_parent.getAllStates();
+ }
+ else
+ {
+ ArrayList list = new ArrayList( );
+ DefaultState[] nested =
+ (DefaultState[]) m_states.values().toArray( new
DefaultState[0] );
+ DefaultState[] states = new DefaultState[ nested.length + 1 ];
+ states[0] = this;
+ System.arraycopy( nested, 0, states, 1, nested.length );
+ return states;
+ }
+ }
+
+ /**
+ * Return an array of local states directly contained within this state
+ * instance.
+ *
+ * @return the local state array
+ */
+ protected DefaultState[] getStates()
+ {
+ return getStates( this );
+ }
+
+ /**
+ * Return an array of all states contained within the supplied state.
+ *
+ * @param parent the enclosing parent state
+ * @return the state array
+ */
+ protected DefaultState[] getStates( DefaultState parent )
+ {
+ ArrayList list = new ArrayList();
+ DefaultState[] states = getAllStates();
+ for( int i=(states.length -1); i>-1; i-- )
+ {
+ DefaultState state = states[i];
+ if( parent.equals( state.getParent() ) )
+ {
+ list.add( state );
+ }
+ }
+ return (DefaultState[]) list.toArray( new DefaultState[0] );
+ }
+
+ /**
+ * Return a state from the state graph matching the supplied key.
+ * The search does not include the root state of the state graph.
+ *
+ * @param key the state key
+ * @return the state assigned to the key
+ * @exception NoSuchStateException if the key does not match a state
+ * within the state graph
+ */
+ protected DefaultState getState( String key )
+ {
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+ if( null != m_parent )
+ {
+ return m_parent.getState( key );
+ }
+ else
+ {
+ DefaultState state = (DefaultState) m_states.get( key );
+ if( null == state )
+ {
+ throw new NoSuchStateException( key );
+ }
+ else
+ {
+ return state;
+ }
+ }
+ }
+
+ /**
+ * Add a transition to the state. Transition keys are unique within the
scope
+ * of the state under which the transition is assigned. Transitions with
the
+ * same name as a transition within a parent state will take precedence
when
+ * selecting transitions.
+ *
+ * @param key the transition key
+ * @param target the transition target state
+ */
+ public void addTransition( String key, DefaultState target )
+ {
+ addTransition( key, null, target );
+ }
+
+ /**
+ * Add a transition to the state. Transition keys are unique within the
scope
+ * of the state under which the transition is assigned. Transitions with
the
+ * same name as a transition within a parent state will take precedence
when
+ * selecting transitions.
+ *
+ * @param key the transition key
+ * @param uri the uri identifying the handler to be assigned as the
handler
+ * of the transition action
+ * @param target the transition target state
+ */
+ public void addTransition( String key, URI uri, DefaultState target )
+ {
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+ if( m_transitions.containsKey( key ) )
+ {
+ throw new DuplicateKeyException( key );
+ }
+ validateTransition( "transition", key, uri, target );
+ DefaultTransition transition = new DefaultTransition( uri, target );
+ m_transitions.put( key, transition );
+ }
+
+ /**
+ * Optionally set the initializer for this state. During the state
manager
+ * initialization phase an initializer declared on the assigned state
model
+ * will be invoked. If the current state is modified as a result of
invocation
+ * of an initializer, any initializer associated with the new state will
be
+ * fired. This process will continue until a state is established that
does not
+ * delcare an initializor.
+ *
+ * @param target the target initialization state
+ */
+ public void setInitialization( DefaultState target )
+ {
+ setInitialization( null, target );
+ }
+
+ /**
+ * Optionally set the initializer for this state. During the state
manager
+ * initialization phase an initializer declared on the assigned state
model
+ * will be invoked. If the current state is modified as a result of
invocation
+ * of an initializer, any initializer associated with the new state will
be
+ * fired. This process will continue until a state is established that
does not
+ * delcare an initializor.
+ *
+ * @param uri the uri identifying the handler to be assigned as the
handler
+ * of the initialization action
+ * @param target the target initialization state
+ */
+ public void setInitialization( URI uri, DefaultState target )
+ {
+ if( null != m_initialization )
+ {
+ final String error =
+ "Initilization already set."
+ + "\nState: " + getName();
+ throw new IllegalStateException( error );
+ }
+ validateTransition( INITIALIZER, null, uri, target );
+ m_initialization = new DefaultTransition( uri, target );
+ }
+
+ /**
+ * Return the initialization transition assigned to the state.
+ * @return the initialization transition (possibly null)
+ */
+ public DefaultTransition getInitialization()
+ {
+ return m_initialization;
+ }
+
+ /**
+ * Optionally set the terminator for this state. During the state manager
+ * termination phase a terminator declared on the assigned state model
+ * will be invoked. If the current state is modified as a result of
invocation
+ * of a terminator, a terminator associated with the new state will be
+ * fired (if declared). This process will continue until a terminal
state is
+ * established or no additional terminators can be fired.
+ *
+ * @param target the transition target state
+ */
+ public void setTerminator( DefaultState target )
+ {
+ setTerminator( null, target );
+ }
+
+ /**
+ * Optionally set the terminator for this state. During the state manager
+ * termination phase a terminator declared on the assigned state model
+ * will be invoked. If the current state is modified as a result of
invocation
+ * of a terminator, a terminator associated with the new state will be
+ * fired (if declared). This process will continue until a terminal
state is
+ * established or no additional terminators can be fired.
+ *
+ * @param uri the uri identifying the handler to be assigned as the
handler
+ * of the transition action
+ * @param target the transition target state
+ */
+ public void setTerminator( URI uri, DefaultState target )
+ {
+ if( null != m_terminator )
+ {
+ final String error =
+ "Terminator already set."
+ + "\nState: " + getName();
+ throw new IllegalStateException( error );
+ }
+ validateTransition( TERMINATOR, null, uri, target );
+ m_terminator = new DefaultTransition( uri, target );
+ }
+
+ /**
+ * Return the terminator transition assigned to the state.
+ * @return the terminator transition (possibly null)
+ */
+ public DefaultTransition getTerminator()
+ {
+ return m_terminator;
+ }
+
+ /**
+ * Return the first transition matching the supplied key in this state
graph. The search
+ * for a matching transition proceeds from the local state upwards uptil
the root state is
+ * reached unless a local or intermidiate transition matches the supplied
key.
+ *
+ * @param key the transition key
+ * @return a matching transition
+ * @exception NoSuchTransitionException if no matching transition can be
found
+ */
+ public Transition getTransition( String key )
+ {
+ return getNamedTransition( key );
+ }
+
+ /**
+ * Return the fisrt transition matching the supplied key in this state
graph. The search
+ * for a matching transition proceeds from the local state upwards uptil
the root state is
+ * reached unless a local or intermidiate transition matches the supplied
key.
+ *
+ * @param key the transition key
+ * @return a matching transition
+ * @exception NoSuchTransitionException if no matching transition can be
found
+ */
+ public DefaultTransition getNamedTransition( String key )
+ {
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+ DefaultTransition transition = (DefaultTransition)
m_transitions.get( key );
+ if( null != transition )
+ {
+ return transition;
+ }
+ else
+ {
+ if( null == m_parent )
+ {
+ throw new NoSuchTransitionException( key );
+ }
+ else
+ {
+ return m_parent.getNamedTransition( key );
+ }
+ }
+ }
+
+ /**
+ * Returns an array of transition names declared in this state and all
+ * parent states in the active state chain. This method via the
+ * StateManager interface (through exposeure of State) to controlling
+ * applications. The controlling application can apply a tranistion
+ * by invoking the 'apply' operation on the associated ServiceManager.
+ *
+ * @return the available transition names
+ */
+ public String[] getTransitionNames()
+ {
+ if( m_terminal )
+ {
+ return new String[0];
+ }
+ if( null == m_parent )
+ {
+ return getLocalTransitionNames();
+ }
+ else
+ {
+ String[] keys = m_parent.getTransitionNames();
+ String[] local = getLocalTransitionNames();
+ List list = new ArrayList( Arrays.asList( local ) );
+ for( int i=0; i<keys.length; i++ )
+ {
+ String key = keys[i];
+ if( false == list.contains( key ) )
+ {
+ if( false == getNamedTransition( key
).getTargetState().equals( this ) )
+ {
+ list.add( key );
+ }
+ }
+ }
+ return (String[]) list.toArray( new String[0] );
+ }
+ }
+
+ /**
+ * Return the list of transition names local to this state.
+ * @return the array of transition names
+ */
+ protected String[] getLocalTransitionNames()
+ {
+ return (String[]) m_transitions.keySet().toArray( new String[0] );
+ }
+
+ /**
+ * An operation is the declarion of the association of a handler with a
particular
+ * state. When the active state chain includes the state the the
operation is
+ * asssigned to the operation is available. Operation do not modify the
current
+ * state maintained by the state manager (unlike transitions). Operations
can be
+ * be considered as dynamic methods that are exposed to a controller as a
function
+ * of the active state of the component. The operation key must be
unique within
+ * the scope of the state to which it is assigned. If the an operation
with the
+ * same name is assigned to a parent or higher state then this operation
will
+ * override the higher operation.
+ *
+ * @param key the operation key
+ * @param uri the uri identifying the operation handler
+ * @exception NullPointerException if key or uri are null
+ * @exception DuplicateKeyException if the key is already locally assigned
+ */
+ public void addOperation( String key, URI uri )
+ {
+ addOperation( key, uri, false );
+ }
+
+ /**
+ * An operation is the declarion of the association of a handler with a
particular
+ * state. When the active state chain includes the state the the
operation is
+ * asssigned to the operation is available. Operation do not modify the
current
+ * state maintained by the state manager (unlike transitions). Operations
can be
+ * be considered as dynamic methods that are exposed to a controller as a
function
+ * of the active state of the component. The operation key must be
unique within
+ * the scope of the state to which it is assigned. If the an operation
with the
+ * same name is assigned to a parent or higher state then this operation
will
+ * override the higher operation. If an operation already exists locally
on this
+ * state matching the supplied key and the replace is policy is true, the
existing
+ * operation will be replaced otherwise a DuplicateKeyException will be
thrown.
+ *
+ * @param key the operation key
+ * @param uri the uri identifying the operation handler
+ * @param replace operation replacement policy
+ * @exception NullPointerException if key or uri are null
+ * @exception DuplicateKeyException if the key is already locally
assigned and
+ * the supplied replacement policy is FALSE
+ */
+ public void addOperation( String key, URI uri, boolean replace )
+ {
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+ if( null == uri )
+ {
+ throw new NullPointerException( "uri" );
+ }
+ if( false == replace )
+ {
+ if( m_operations.containsKey( key ) )
+ {
+ throw new DuplicateKeyException( key );
+ }
+ }
+ DefaultOperation operation = new DefaultOperation( uri );
+ m_operations.put( key, operation );
+ }
+
+ /**
+ * Return the first operation matching the supplied key in this state
graph. The search
+ * for a matching operation proceeds from the local state upwards uptil
the root state is
+ * reached unless a local or intermidiate operation matches the supplied
key.
+ *
+ * @param key the operation key
+ * @return a matching operation
+ * @exception NoSuchOperationException if no matching operation can be
found
+ */
+ public Operation getOperation( String key )
+ {
+ return getNamedOperation( key );
+ }
+
+ /**
+ * Return the fisrt operation matching the supplied key in this state
graph. The search
+ * for a matching operation proceeds from the local state upwards uptil
the root state is
+ * reached unless a local or intermidiate operation matches the supplied
key.
+ *
+ * @param key the operation key
+ * @return a matching operation
+ * @exception NoSuchOperationException if no matching operation can be
found
+ */
+ public DefaultOperation getNamedOperation( String key )
+ {
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+ DefaultOperation operation = (DefaultOperation) m_operations.get(
key );
+ if( null != operation )
+ {
+ return operation;
+ }
+ else
+ {
+ if( null == m_parent )
+ {
+ throw new NoSuchOperationException( key );
+ }
+ else
+ {
+ return m_parent.getNamedOperation( key );
+ }
+ }
+ }
+
+ /**
+ * Returns an array of operation names declared in this state and all
+ * parent states in the active state chain. This method is exposed via
the
+ * StateManager interface (through exposure of State) to controlling
+ * applications. The controlling application can execute an operation
+ * by invoking the 'execute' method on the associated ServiceManager.
+ *
+ * @return the available operation names
+ */
+ public String[] getOperationNames()
+ {
+ if( null == m_parent )
+ {
+ return getLocalOperationNames();
+ }
+ else
+ {
+ String[] keys = m_parent.getOperationNames();
+ String[] local = getLocalOperationNames();
+ String[] result = new String[ keys.length + local.length ];
+ System.arraycopy( keys, 0, result, 0, keys.length );
+ System.arraycopy( local, 0, result, keys.length, local.length );
+ return result;
+ }
+ }
+
+ /**
+ * Return the list of operation names local to this state.
+ * @return the array of operation names
+ */
+ protected String[] getLocalOperationNames()
+ {
+ return (String[]) m_operations.keySet().toArray( new String[0] );
+ }
+
+ /**
+ * return a string representation of this state.
+ * @return the string representation
+ */
+ public String toString()
+ {
+ if( null != m_parent )
+ {
+ return "[state " + m_name + " (from:" + m_parent.getName() +
")]";
+ }
+ else
+ {
+ return "[state " + m_name + "]";
+ }
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( this.hashCode() == other.hashCode() )
+ {
+ return true;
+ }
+ else if( other instanceof DefaultState )
+ {
+ DefaultState state = (DefaultState) other;
+ return m_name.equals( state.getName() );
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ private boolean equals( Object one, Object two )
+ {
+ if( null == one )
+ {
+ return ( null == two );
+ }
+ else
+ {
+ return one.equals( two );
+ }
+ }
+
+ public int hashCode()
+ {
+ return m_name.hashCode();
+ }
+
+ /**
+ * Untility function that returns a string representation of this state
+ * in the form of a graph.
+ * @return the string representation of the graph represented by this
+ * node and all child nodes
+ */
+ public String list()
+ {
+ StringBuffer buffer = new StringBuffer();
+ graph( buffer, this, "" );
+ return buffer.toString();
+ }
+
+ /**
+ * Internal utility to handle graph construction.
+ * @param buffer a string buffer to write to
+ * @param state the state to include
+ * @param offset a character offset to apply when writting out the state
features
+ */
+ private void graph( StringBuffer buffer, DefaultState state, String
offset )
+ {
+ String name = state.getName();
+ buffer.append( "\n" + offset );
+ buffer.append( "state: " + name );
+ if( state.isTerminal() )
+ {
+ buffer.append( " (terminal)" );
+ }
+ DefaultTransition initializer = state.getInitialization();
+ if( initializer != null )
+ {
+ buffer.append(
+ "\n " + offset + "initializer:" + name + " --> state:"
+ + initializer.getTargetState().getName() );
+ }
+ DefaultTransition terminator = state.getTerminator();
+ if( terminator != null )
+ {
+ buffer.append(
+ "\n " + offset + "terminator:" + name + " --> state:"
+ + terminator.getTargetState().getName() );
+ }
+ String[] transitions = state.getLocalTransitionNames();
+ for( int i=0; i<transitions.length; i++ )
+ {
+ String t = transitions[i];
+ DefaultTransition transition = state.getNamedTransition( t );
+ State target = transition.getTargetState();
+ buffer.append( "\n " + offset + "transition:" + t + " -->
state:" + target.getName() );
+ }
+ String[] operations = state.getLocalOperationNames();
+ for( int i=0; i<operations.length; i++ )
+ {
+ String o = operations[i];
+ DefaultOperation operation = state.getNamedOperation( o );
+ buffer.append( "\n " + offset + "operation:" + o );
+ }
+
+ DefaultState[] states = state.getStates();
+ for( int i=0; i<states.length; i++ )
+ {
+ DefaultState s = states[i];
+ graph( buffer, s, offset + " " );
+ }
+ }
+
+ /**
+ * Utility operation to test if a supplied state instance is an
+ * instance from this state graph.
+ *
+ * @param state the instance to evalue
+ * @return TRUE if the instance is a member else FALSE
+ */
+ private boolean isaMemberOfGraph( DefaultState state )
+ {
+ DefaultState[] states = getAllStates();
+ for( int i=0; i<states.length; i++ )
+ {
+ DefaultState s = states[i];
+ if( s == state ) return true;
+ }
+ return false;
+ }
+
+ private void validateTransition( String role, String key, URI uri,
DefaultState target )
+ {
+ if( null == target )
+ {
+ throw new NullPointerException( "target" );
+ }
+ String line = "";
+ String uriLine = "";
+ if( null != key )
+ {
+ line = "\nKey: " + key;
+ }
+ if( null != uri )
+ {
+ uriLine = "\nURI: " + uri;
+ }
+ if( isTerminal() && ( false == role.equals( TERMINATOR ) ) )
+ {
+ final String error =
+ "Cannot add " + role + " to a terminal state."
+ + "\nState: " + getName()
+ + "\nTarget: " + target.getName()
+ + uriLine
+ + line;
+ throw new IllegalStateException( error );
+ }
+ if( false == isaMemberOfGraph( target ) )
+ {
+ final String error =
+ "Cannot add " + role
+ + " because "
+ + "the declared target state is not a member of the state
graph."
+ + "\nState: " + getName()
+ + "\nTarget: " + target.getName()
+ + uriLine
+ + line;
+ throw new IllegalArgumentException( error );
+ }
+ if( this == target )
+ {
+ final String error =
+ "Cannot add " + role
+ + " because "
+ + "the containing state and target state are the same."
+ + "\nState: " + getName()
+ + "\nTarget: " + target.getName()
+ + uriLine
+ + line;
+ throw new IllegalArgumentException( error );
+ }
+ }
+
+ private static final String TERMINATOR = "terminator";
+ private static final String INITIALIZER = "initializer";
+ private static final String TRANSITION = "transition";
+
+}

Added:
development/main/metro/composition/control/src/main/net/dpml/composition/state/DefaultTransition.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/state/DefaultTransition.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,83 @@
+/*
+ * 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.composition.state;
+
+import java.net.URI;
+
+import net.dpml.parts.state.State;
+import net.dpml.parts.state.Transition;
+
+/**
+ * The DefualtTransition class associated a transition handler and a target
+ * state.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class DefaultTransition implements Transition
+{
+ private final DefaultState m_target;
+ private final URI m_handler;
+
+ /**
+ * Internal utility to construct a new transition instance. This
constructor
+ * is used by the DefaultState state implementation class as part of it's
transition
+ * factory operations.
+ *
+ * @param handler the uri identifying the handler
+ * @param target the transition target state
+ * @param system if TRUE this is a system transition otherwise the
transition
+ * is a user (application) transition
+ */
+ protected DefaultTransition( URI handler, DefaultState target )
+ {
+ if( null == target )
+ {
+ throw new NullPointerException( "target" );
+ }
+ m_handler = handler;
+ m_target = target;
+ }
+
+ /**
+ * Return the handler uri identifier associated with this transition.
+ * @return the transition handler identfier
+ */
+ public URI getHandlerURI()
+ {
+ return m_handler;
+ }
+
+ /**
+ * Return the target of this transition.
+ * @return the transition target
+ */
+ public State getTargetState()
+ {
+ return getTransitionTarget();
+ }
+
+ /**
+ * Return the target of this transition.
+ * @return the transition target
+ */
+ public DefaultState getTransitionTarget()
+ {
+ return m_target;
+ }
+}

Added:
development/main/metro/composition/control/src/main/net/dpml/composition/state/ExecutableManager.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/state/ExecutableManager.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,187 @@
+/*
+ * 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.composition.state;
+
+import java.util.Map.Entry;
+
+import net.dpml.parts.state.Manager;
+import net.dpml.parts.state.NoSuchOperationException;
+import net.dpml.parts.state.NoSuchTransitionException;
+import net.dpml.parts.state.State;
+
+import net.dpml.activity.Executable;
+
+/**
+ * The Manager interface is an interface representing a component controller.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class ExecutableManager implements Manager
+{
+ private final Entry m_entry;
+
+ private boolean m_initialized = false;
+
+ public ExecutableManager( Entry entry )
+ {
+ m_entry = entry;
+ }
+
+ /**
+ * Initialize the component.
+ */
+ public Object initialize() throws Exception
+ {
+ if( false == m_initialized )
+ {
+ m_initialized = true;
+ return m_entry.getValue();
+ }
+ else
+ {
+ final String error =
+ "Manager has already been initialized.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ /**
+ * Return the current state of the component.
+ * @return the current state
+ */
+ public State getState()
+ {
+ if( m_initialized )
+ {
+ return AVAILABLE;
+ }
+ else
+ {
+ final String error =
+ "Manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ /**
+ * Applies a state transition identified by a supplied transition key.
+ *
+ * @param key the key identifying the transition to apply to the
component's controller
+ * @return the state resulting from the transition
+ * @exception if a transition error occurs
+ */
+ public State apply( String key ) throws Exception
+ {
+ if( false == m_initialized )
+ {
+ final String error =
+ "Manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+ else
+ {
+ throw new NoSuchTransitionException( key );
+ }
+ }
+
+ /**
+ * Executes an operation identified by a supplied operation key.
+ *
+ * @param key the key identifying the operation to execute
+ * @exception if a transition error occurs
+ */
+ public void execute( String key ) throws Exception
+ {
+ if( m_initialized )
+ {
+ if( ExecutableState.EXECUTE.equals( key ) )
+ {
+ Executable executable = (Executable) m_entry.getValue();
+ executable.execute();
+ }
+ else
+ {
+ throw new NoSuchOperationException ( key );
+ }
+ }
+ else
+ {
+ final String error =
+ "Manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ /**
+ * Termination of the component.
+ */
+ public void terminate()
+ {
+ m_initialized = false;
+ }
+
+ private static final State AVAILABLE = new ExecutableState();
+
+ public static class ExecutableState implements State
+ {
+ /**
+ * Return the name of the state.
+ * @return the state name
+ */
+ public String getName()
+ {
+ return AVAILABLE;
+ }
+
+ /**
+ * Return the array of available transition names.
+ *
+ * @return the transition names
+ */
+ public String[] getTransitionNames()
+ {
+ return EMPTY_TRANSITIONS;
+ }
+
+ /**
+ * Return the array of available operation names.
+ *
+ * @return the operation names
+ */
+ public String[] getOperationNames()
+ {
+ return OPERATION_NAMES;
+ }
+
+ /**
+ * Return true if this is a terminal state.
+ * @return TRUE if terminal
+ */
+ public boolean isTerminal()
+ {
+ return true;
+ }
+
+ private static final String EXECUTE = "execute";
+ private static final String AVAILABLE = "available";
+ private static final String[] EMPTY_TRANSITIONS = new String[0];
+ private static final String[] OPERATION_NAMES = new String[]{
EXECUTE };
+ }
+
+}

Added:
development/main/metro/composition/control/src/main/net/dpml/composition/state/NoSuchHandlerException.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/state/NoSuchHandlerException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,39 @@
+/*
+ * 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.composition.state;
+
+/**
+ * Exception thrown when a request for a handler could not be resolved.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class NoSuchHandlerException extends RuntimeException
+{
+ /**
+ * Construct a new <code>NoSuchHandlerException</code> instance.
+ *
+ * @param handler the handler name
+ */
+ public NoSuchHandlerException( final String handler )
+ {
+ super( handler );
+ }
+
+}
+

Added:
development/main/metro/composition/control/src/main/net/dpml/composition/state/NullManager.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/state/NullManager.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,176 @@
+/*
+ * 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.composition.state;
+
+import java.util.Map.Entry;
+
+import net.dpml.parts.state.Manager;
+import net.dpml.parts.state.NoSuchOperationException;
+import net.dpml.parts.state.NoSuchTransitionException;
+import net.dpml.parts.state.State;
+
+/**
+ * The Manager interface is an interface representing a component controller.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class NullManager implements Manager
+{
+ private final Entry m_entry;
+
+ private boolean m_initialized = false;
+
+ public NullManager( Entry entry )
+ {
+ m_entry = entry;
+ }
+
+ /**
+ * Initialize the component.
+ */
+ public Object initialize() throws Exception
+ {
+ if( false == m_initialized )
+ {
+ m_initialized = true;
+ return m_entry.getValue();
+ }
+ else
+ {
+ final String error =
+ "Manager has already been initialized.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ /**
+ * Return the current state of the component.
+ * @return the current state
+ */
+ public State getState()
+ {
+ if( m_initialized )
+ {
+ return AVAILABLE;
+ }
+ else
+ {
+ final String error =
+ "Manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ /**
+ * Applies a state transition identified by a supplied transition key.
+ *
+ * @param key the key identifying the transition to apply to the
component's controller
+ * @return the state resulting from the transition
+ * @exception if a transition error occurs
+ */
+ public State apply( String key ) throws Exception
+ {
+ if( false == m_initialized )
+ {
+ final String error =
+ "Manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+ else
+ {
+ throw new NoSuchTransitionException( key );
+ }
+ }
+
+ /**
+ * Executes an operation identified by a supplied operation key.
+ *
+ * @param key the key identifying the operation to execute
+ * @exception if a transition error occurs
+ */
+ public void execute( String key ) throws Exception
+ {
+ if( m_initialized )
+ {
+ throw new NoSuchOperationException ( key );
+ }
+ else
+ {
+ final String error =
+ "Manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ /**
+ * Termination of the component.
+ */
+ public void terminate()
+ {
+ m_initialized = false;
+ }
+
+ public static final State AVAILABLE = new AvailableState();
+
+ public static class AvailableState implements State
+ {
+ /**
+ * Return the name of the state.
+ * @return the state name
+ */
+ public String getName()
+ {
+ return AVAILABLE_NAME;
+ }
+
+ /**
+ * Return the array of available transition names.
+ *
+ * @return the transition names
+ */
+ public String[] getTransitionNames()
+ {
+ return EMPTY_TRANSITIONS;
+ }
+
+ /**
+ * Return the array of available operation names.
+ *
+ * @return the operation names
+ */
+ public String[] getOperationNames()
+ {
+ return EMPTY_OPERATIONS;
+ }
+
+ /**
+ * Return true if this is a terminal state.
+ * @return TRUE if terminal
+ */
+ public boolean isTerminal()
+ {
+ return true;
+ }
+
+ private static final String AVAILABLE_NAME = "available";
+ private static final String[] EMPTY_TRANSITIONS = new String[0];
+ private static final String[] EMPTY_OPERATIONS = new String[0];
+ }
+
+}

Added:
development/main/metro/composition/control/src/main/net/dpml/composition/state/RecursiveInitializationException.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/state/RecursiveInitializationException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,41 @@
+/*
+ * 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.composition.state;
+
+import net.dpml.parts.state.ValidationException;
+
+/**
+ * Exception thrown when a recursive initialization sequence is encountered.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class RecursiveInitializationException extends ValidationException
+{
+ /**
+ * Construct a new <code>RecursiveTerminationException</code> instance.
+ *
+ * @param handler the handler name
+ */
+ public RecursiveInitializationException( final String message )
+ {
+ super( message );
+ }
+
+}
+

Added:
development/main/metro/composition/control/src/main/net/dpml/composition/state/RecursiveTerminationException.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/state/RecursiveTerminationException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,41 @@
+/*
+ * 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.composition.state;
+
+import net.dpml.parts.state.ValidationException;
+
+/**
+ * Exception thrown when a recursive termination sequence is encountered.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class RecursiveTerminationException extends ValidationException
+{
+ /**
+ * Construct a new <code>RecursiveTerminationException</code> instance.
+ *
+ * @param handler the handler name
+ */
+ public RecursiveTerminationException( final String message )
+ {
+ super( message );
+ }
+
+}
+

Added:
development/main/metro/composition/control/src/main/net/dpml/composition/state/StartableManager.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/state/StartableManager.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,235 @@
+/*
+ * 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.composition.state;
+
+import java.util.Map.Entry;
+
+import net.dpml.parts.state.Manager;
+import net.dpml.parts.state.NoSuchOperationException;
+import net.dpml.parts.state.NoSuchTransitionException;
+import net.dpml.parts.state.State;
+
+import net.dpml.activity.Startable;
+
+/**
+ * The Manager interface is an interface representing a component controller.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class StartableManager implements Manager
+{
+ private final Entry m_entry;
+
+ private boolean m_initialized = false;
+
+ private State m_state = AVAILABLE;
+
+ public StartableManager( Entry entry )
+ {
+ m_entry = entry;
+ }
+
+ /**
+ * Initialize the component.
+ */
+ public Object initialize() throws Exception
+ {
+ if( false == m_initialized )
+ {
+ m_state = INITIALIZED;
+ m_initialized = true;
+ return m_entry.getValue();
+ }
+ else
+ {
+ final String error =
+ "Manager has already been initialized.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ /**
+ * Return the current state of the component.
+ * @return the current state
+ */
+ public synchronized State getState()
+ {
+ if( m_initialized )
+ {
+ return m_state;
+ }
+ else
+ {
+ final String error =
+ "Manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ /**
+ * Applies a state transition identified by a supplied transition key.
+ *
+ * @param key the key identifying the transition to apply to the
component's controller
+ * @return the state resulting from the transition
+ * @exception if a transition error occurs
+ */
+ public synchronized State apply( String key ) throws Exception
+ {
+ if( false == m_initialized )
+ {
+ final String error =
+ "Manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+
+ if(( m_state == INITIALIZED ) && "start".equals( key ))
+ {
+ ((Startable)m_entry.getValue()).start();
+ m_state = STARTED;
+ }
+ else if(( m_state == STARTED ) && "stop".equals( key ))
+ {
+ ((Startable)m_entry.getValue()).stop();
+ m_state = STOPPED;
+ }
+ else if(( m_state == STOPPED ) && "start".equals( key ))
+ {
+ ((Startable)m_entry.getValue()).start();
+ m_state = STARTED;
+ }
+ else
+ {
+ throw new NoSuchTransitionException( key );
+ }
+
+ return m_state;
+ }
+
+ /**
+ * Executes an operation identified by a supplied operation key.
+ *
+ * @param key the key identifying the operation to execute
+ * @exception if a transition error occurs
+ */
+ public void execute( String key ) throws Exception
+ {
+ if( m_initialized )
+ {
+ throw new NoSuchOperationException ( key );
+ }
+ else
+ {
+ final String error =
+ "Manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ /**
+ * Termination of the component.
+ */
+ public synchronized void terminate()
+ {
+ if( m_state == STARTED )
+ {
+ try
+ {
+ ((Startable)m_entry.getValue()).stop();
+ }
+ catch( Throwable e )
+ {
+ // we need a logging channel
+ }
+ }
+ m_state = TERMINATED;
+ m_initialized = false;
+ }
+
+ private static final State AVAILABLE = new AvailableState( "available" );
+ private static final State INITIALIZED = new AvailableState(
"initialized", new String[]{ "start" } );
+ private static final State STARTED = new AvailableState( "started", new
String[]{ "stop" } );
+ private static final State STOPPED = new AvailableState( "stopped", new
String[]{ "start" } );
+ private static final State TERMINATED = new AvailableState( "terminated"
);
+
+
+ static class AvailableState implements State
+ {
+ private final String m_name;
+ private final String[] m_transitions;
+ private final String[] m_operations;
+
+ AvailableState( String name )
+ {
+ this( name, EMPTY_TRANSITIONS );
+ }
+
+ AvailableState( String name, String[] transitions )
+ {
+ this( name, transitions, EMPTY_OPERATIONS );
+ }
+
+ AvailableState( String name, String[] transitions, String[]
operations )
+ {
+ m_name = name;
+ m_transitions = transitions;
+ m_operations = operations;
+ }
+
+ /**
+ * Return the name of the state.
+ * @return the state name
+ */
+ public String getName()
+ {
+ return m_name;
+ }
+
+ /**
+ * Return the array of available transition names.
+ *
+ * @return the transition names
+ */
+ public String[] getTransitionNames()
+ {
+ return m_transitions;
+ }
+
+ /**
+ * Return the array of available operation names.
+ *
+ * @return the operation names
+ */
+ public String[] getOperationNames()
+ {
+ return m_operations;
+ }
+
+ /**
+ * Return true if this is a terminal state.
+ * @return TRUE if terminal
+ */
+ public boolean isTerminal()
+ {
+ return false;
+ }
+
+ private static final String[] EMPTY_TRANSITIONS = new String[0];
+ private static final String[] EMPTY_OPERATIONS = new String[0];
+ }
+}

Added:
development/main/metro/composition/control/src/main/net/dpml/composition/state/ValueManager.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/main/net/dpml/composition/state/ValueManager.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,178 @@
+/*
+ * 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.composition.state;
+
+import java.util.Map.Entry;
+
+import net.dpml.parts.state.Manager;
+import net.dpml.parts.state.NoSuchOperationException;
+import net.dpml.parts.state.NoSuchTransitionException;
+import net.dpml.parts.state.State;
+
+import net.dpml.composition.models.ValueModel;
+
+/**
+ * The Manager interface is an interface representing a component controller.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class ValueManager implements Manager
+{
+ private final ValueModel m_model;
+
+ private boolean m_initialized = false;
+
+ public ValueManager( ValueModel model )
+ {
+ m_model = model;
+ }
+
+ /**
+ * Initialize the component.
+ */
+ public Object initialize() throws Exception
+ {
+ if( false == m_initialized )
+ {
+ m_initialized = true;
+ return m_model.getValue();
+ }
+ else
+ {
+ final String error =
+ "Manager has already been initialized.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ /**
+ * Return the current state of the component.
+ * @return the current state
+ */
+ public State getState()
+ {
+ if( m_initialized )
+ {
+ return AVAILABLE;
+ }
+ else
+ {
+ final String error =
+ "Manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ /**
+ * Applies a state transition identified by a supplied transition key.
+ *
+ * @param key the key identifying the transition to apply to the
component's controller
+ * @return the state resulting from the transition
+ * @exception if a transition error occurs
+ */
+ public State apply( String key ) throws Exception
+ {
+ if( false == m_initialized )
+ {
+ final String error =
+ "Manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+ else
+ {
+ throw new NoSuchTransitionException( key );
+ }
+ }
+
+ /**
+ * Executes an operation identified by a supplied operation key.
+ *
+ * @param key the key identifying the operation to execute
+ * @exception if a transition error occurs
+ */
+ public void execute( String key ) throws Exception
+ {
+ if( m_initialized )
+ {
+ throw new NoSuchOperationException ( key );
+ }
+ else
+ {
+ final String error =
+ "Manager has not been initialized.";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ /**
+ * Termination of the component.
+ */
+ public void terminate()
+ {
+ m_initialized = false;
+ }
+
+ public static final State AVAILABLE = new AvailableState();
+
+ public static class AvailableState implements State
+ {
+ /**
+ * Return the name of the state.
+ * @return the state name
+ */
+ public String getName()
+ {
+ return AVAILABLE_NAME;
+ }
+
+ /**
+ * Return the array of available transition names.
+ *
+ * @return the transition names
+ */
+ public String[] getTransitionNames()
+ {
+ return EMPTY_TRANSITIONS;
+ }
+
+ /**
+ * Return the array of available operation names.
+ *
+ * @return the operation names
+ */
+ public String[] getOperationNames()
+ {
+ return EMPTY_OPERATIONS;
+ }
+
+ /**
+ * Return true if this is a terminal state.
+ * @return TRUE if terminal
+ */
+ public boolean isTerminal()
+ {
+ return true;
+ }
+
+ private static final String AVAILABLE_NAME = "available";
+ private static final String[] EMPTY_TRANSITIONS = new String[0];
+ private static final String[] EMPTY_OPERATIONS = new String[0];
+ }
+
+}

Added:
development/main/metro/composition/control/src/test/net/dpml/composition/state/DefaultManagerTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/test/net/dpml/composition/state/DefaultManagerTestCase.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,428 @@
+/*
+ * 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.composition.state;
+
+import java.net.URI;
+import java.util.logging.Logger;
+
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+import junit.framework.TestCase;
+
+import net.dpml.parts.state.State;
+import net.dpml.parts.state.Manager;
+import net.dpml.parts.state.DuplicateKeyException;
+import net.dpml.parts.state.NoSuchStateException;
+import net.dpml.parts.state.NoSuchTransitionException;
+import net.dpml.parts.state.NoSuchOperationException;
+import net.dpml.parts.state.Transition;
+import net.dpml.parts.state.Operation;
+import net.dpml.parts.state.ValidationException;
+
+/**
+ * Test the default state manager implementation.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: AbstractDescriptorTestCase.java 1556 2005-01-22 12:43:42Z
niclas $
+ */
+public class DefaultManagerTestCase extends TestCase
+{
+ /**
+ * Test the case of a root terminal graph.
+ */
+ public void testCaseOne() throws Exception
+ {
+ DefaultState graph = new DefaultState( true );
+ MockComponent instance = new MockComponent();
+ Manager manager = setupManager( graph, instance );
+ manager.initialize();
+ assertEquals( "root is graph", graph, manager.getState() );
+ manager.terminate();
+ }
+
+ /**
+ * Test the case of a root terminal graph.
+ */
+ public void testExecuteWithoutInitialize() throws Exception
+ {
+ DefaultState graph = new DefaultState( true );
+ graph.addOperation( "aaa", new URI( "method:foo" ) );
+ MockComponent instance = new MockComponent();
+ Manager manager = setupManager( graph, instance );
+ try
+ {
+ manager.execute( "aaa" );
+ }
+ catch( IllegalStateException e )
+ {
+ // success
+ }
+ }
+
+ /**
+ * Add a couple of operations to the graph and invoke these via the
+ * the state manager. Validate the invocations by checking the counter
+ * values in the mock component.
+ */
+ public void testMethodInvocation() throws Exception
+ {
+ DefaultState graph = new DefaultState( true );
+ MockComponent instance = new MockComponent();
+ Manager manager = setupManager( graph, instance );
+ graph.addOperation( "aaa", new URI( "method:foo" ) );
+ graph.addOperation( "bbb", new URI( "method:bar" ) );
+ manager.initialize();
+ int n = 100;
+ for( int i=0; i<n; i++ )
+ {
+ manager.execute( "aaa" );
+ }
+ int m = 10;
+ for( int i=0; i<m; i++ )
+ {
+ manager.execute( "bbb" );
+ }
+ manager.terminate();
+ assertEquals( "foo invocations", n, instance.FOO_COUNTER );
+ assertEquals( "bar invocations", m, instance.BAR_COUNTER );
+ }
+
+ /**
+ * Test that the validation process catches an missing method.
+ */
+ public void testMissingMethod() throws Exception
+ {
+ DefaultState graph = new DefaultState( true );
+ graph.addOperation( "foo", new URI( "method:badMethodName" ) );
+ MockComponent instance = new MockComponent();
+ DefaultManager manager = setupManager( graph, instance );
+ try
+ {
+ manager.initialize();
+ }
+ catch( ValidationException e )
+ {
+ // success
+ }
+ }
+
+ /**
+ * Add a couple of handler based operations to the graph and invoke these
via the
+ * the state manager. Validate the invocations by checking the counter
+ * values in the registered handler.
+ */
+ public void testHandlerInvocation() throws Exception
+ {
+ DefaultState graph = new DefaultState( true );
+ graph.addOperation( "foo", new URI( "handler:foo" ) );
+ MockComponent instance = new MockComponent();
+ MockComponent.Handler handler = new MockComponent.Handler();
+ DefaultManager manager = setupManager( graph, instance );
+ manager.addHandler( "foo", handler );
+ manager.initialize();
+ int n = 100;
+ for( int i=0; i<n; i++ )
+ {
+ manager.execute( "foo" );
+ }
+ manager.terminate();
+ assertEquals( "invocations", n, handler.COUNTER );
+ }
+
+ /**
+ * Test that the validation process catches an unregistered handler.
+ */
+ public void testMissingHandler() throws Exception
+ {
+ DefaultState graph = new DefaultState( true );
+ graph.addOperation( "foo", new URI( "handler:foo" ) );
+ MockComponent instance = new MockComponent();
+ DefaultManager manager = setupManager( graph, instance );
+ try
+ {
+ manager.initialize();
+ }
+ catch( ValidationException e )
+ {
+ // success
+ }
+ }
+
+ /**
+ * Test that the validation process catches an missing method.
+ */
+ public void testBadScheme() throws Exception
+ {
+ DefaultState graph = new DefaultState( true );
+ graph.addOperation( "foo", new URI( "acme:anything" ) );
+ MockComponent instance = new MockComponent();
+ DefaultManager manager = setupManager( graph, instance );
+ try
+ {
+ manager.initialize();
+ }
+ catch( ValidationException e )
+ {
+ // success
+ }
+ }
+
+ /**
+ * Test the case of a root terminal graph.
+ */
+ public void testApplyWithoutInitialize() throws Exception
+ {
+ DefaultState graph = new DefaultState();
+ DefaultState endpoint = graph.addTerminalState( "endpoint" );
+ graph.addTransition( "foo", endpoint );
+ MockComponent instance = new MockComponent();
+ Manager manager = setupManager( graph, instance );
+ try
+ {
+ manager.apply( "foo" );
+ }
+ catch( IllegalStateException e )
+ {
+ // success
+ }
+ }
+
+ /**
+ * Test execution of a transition by assigning the transitiion, applying
it,
+ * then checking that the current state exposed by the manager reflects
the
+ * transition.
+ */
+ public void testTransitionExecution() throws Exception
+ {
+ DefaultState graph = new DefaultState();
+ DefaultState endpoint = graph.addTerminalState( "endpoint" );
+ graph.addTransition( "foo", endpoint );
+ MockComponent instance = new MockComponent();
+ DefaultManager manager = setupManager( graph, instance );
+ manager.initialize();
+ manager.apply( "foo" );
+ String name = manager.getState().getName();
+ assertEquals( "current state post transiton", "endpoint", name );
+ }
+
+ /**
+ * Test if the root initializer gets executed.
+ */
+ public void testInitialization() throws Exception
+ {
+ DefaultState graph = new DefaultState();
+ DefaultState endpoint = graph.addTerminalState( "endpoint" );
+ graph.setInitialization( endpoint );
+ MockComponent instance = new MockComponent();
+ DefaultManager manager = setupManager( graph, instance );
+ manager.initialize();
+ String name = manager.getState().getName();
+ assertEquals( "current state post transiton", "endpoint", name );
+ }
+
+ /**
+ * Test if all initializers assigned in a chain get executed.
+ */
+ public void testCompoundInitialization() throws Exception
+ {
+ DefaultState graph = new DefaultState();
+ DefaultState foo = graph.addState( "foo" );
+ DefaultState bar = foo.addTerminalState( "bar" );
+ graph.setInitialization( foo );
+ foo.setInitialization( bar );
+ MockComponent instance = new MockComponent();
+ DefaultManager manager = setupManager( graph, instance );
+ manager.initialize();
+ String name = manager.getState().getName();
+ assertEquals( "current state post transiton", "bar", name );
+ }
+
+ /**
+ * Test recusive termination trap.
+ */
+ public void testRecursiveInitializationTrap() throws Exception
+ {
+ DefaultState graph = new DefaultState();
+ String root = graph.getName();
+ DefaultState foo = graph.addState( "foo" );
+ DefaultState bar = graph.addState( "bar" );
+ graph.setInitialization( foo );
+ foo.setInitialization( bar );
+ bar.setInitialization( graph );
+ MockComponent instance = new MockComponent();
+ DefaultManager manager = setupManager( graph, instance );
+ try
+ {
+ manager.initialize();
+ fail( "manager do not trap recusive initialization" );
+ }
+ catch( RecursiveInitializationException e )
+ {
+ // success
+ }
+ }
+
+ /**
+ * Test simple terminator case.
+ */
+ public void testTerminator() throws Exception
+ {
+ DefaultState graph = new DefaultState();
+ String root = graph.getName();
+ DefaultState foo = graph.addTerminalState( "foo" );
+ graph.setInitialization( foo );
+ foo.setTerminator( graph );
+ MockComponent instance = new MockComponent();
+ DefaultManager manager = setupManager( graph, instance );
+ manager.initialize();
+ String current = manager.getState().getName();
+ assertEquals( "current state post initialization", "foo", current );
+ manager.executeTermination();
+ current = manager.getState().getName();
+ assertEquals( "current state post termination", "root", current );
+ }
+
+ /**
+ * Test compound termination.
+ */
+ public void testCompoundTermination() throws Exception
+ {
+ DefaultState graph = new DefaultState();
+ String root = graph.getName();
+ DefaultState foo = graph.addState( "foo" );
+ DefaultState bar = graph.addState( "bar" );
+ graph.setInitialization( bar );
+ foo.setTerminator( graph );
+ bar.setTerminator( foo );
+ MockComponent instance = new MockComponent();
+ DefaultManager manager = setupManager( graph, instance );
+ manager.initialize();
+ String current = manager.getState().getName();
+ assertEquals( "current state post initialization", "bar", current );
+ manager.executeTermination();
+ current = manager.getState().getName();
+ assertEquals( "current state post termination", "root", current );
+ }
+
+ /**
+ * Test recusive termination trap.
+ */
+ public void testRecursiveTerminationTrap() throws Exception
+ {
+ DefaultState graph = new DefaultState();
+ String root = graph.getName();
+ DefaultState foo = graph.addState( "foo" );
+ DefaultState bar = graph.addState( "bar" );
+ graph.setInitialization( bar );
+ foo.setTerminator( graph );
+ bar.setTerminator( foo );
+ graph.setTerminator( bar );
+ MockComponent instance = new MockComponent();
+ DefaultManager manager = setupManager( graph, instance );
+ manager.initialize();
+ String current = manager.getState().getName();
+ assertEquals( "current state post initialization", "bar", current );
+ try
+ {
+ manager.executeTermination();
+ fail( "manager do not trap recusive termination" );
+ }
+ catch( RecursiveTerminationException e )
+ {
+ // success
+ }
+ }
+
+ // utilities
+
+ private DefaultManager setupManager( DefaultState graph, MockComponent
instance )
+ {
+ Logger logger = Logger.getAnonymousLogger();
+ ChangeListener listener = new MockChangeListener();
+ return new DefaultManager( graph, logger, listener, instance );
+ }
+
+ public static class MockChangeListener implements ChangeListener
+ {
+ public void stateChanged( ChangeEvent event )
+ {
+ }
+ }
+
+ public static class MockComponent
+ {
+ public static int FOO_COUNTER = 0;
+ public static int BAR_COUNTER = 0;
+ public void foo()
+ {
+ FOO_COUNTER++;
+ }
+
+ public void bar( State state )
+ {
+ BAR_COUNTER++;
+ }
+
+ public static class Handler
+ {
+ public static int COUNTER = 0;
+
+ public void handle( MockComponent instance, State state, State
target, Logger logger )
+ {
+ COUNTER++;
+ }
+ }
+ }
+
+ /*
+ public DefaultState setupStateGraph() throws Exception
+ {
+ //
+ // construct a state graph
+ //
+
+ DefaultState root = new DefaultState();
+ DefaultState initialized = root.addState( "initialized" );
+ DefaultState available = root.addState( "available" );
+ DefaultState started = available.addState( "started" );
+ DefaultState stopped = available.addState( "stopped" );
+ DefaultState terminated = root.addTerminalState( "terminated" );
+
+ //
+ // add operations and transitions
+ //
+
+ root.setInitialization( new URI( "handler:demo" ), initialized );
+ initialized.setTerminator( new URI( "handler:demo" ), terminated );
+ available.addTransition( "start", new URI( "handler:demo" ), started
);
+ root.addOperation( "foo", new URI( "handler:demo" ) );
+ started.addTransition( "stop", new URI( "handler:demo" ), stopped );
+ started.addOperation( "do-this", new URI( "method:foo" ) );
+ started.addOperation( "do-that", new URI( "method:foo" ) );
+ stopped.addTransition( "start", new URI( "handler:demo" ), started );
+
+ return root;
+ }
+ */
+}
+
+
+
+

Added:
development/main/metro/composition/control/src/test/net/dpml/composition/state/DefaultOperationTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/test/net/dpml/composition/state/DefaultOperationTestCase.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,87 @@
+/*
+ * 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.composition.state;
+
+import java.net.URI;
+import java.util.logging.Logger;
+
+import junit.framework.TestCase;
+
+import net.dpml.parts.state.State;
+import net.dpml.parts.state.DuplicateKeyException;
+import net.dpml.parts.state.NoSuchStateException;
+import net.dpml.parts.state.NoSuchTransitionException;
+import net.dpml.parts.state.NoSuchOperationException;
+import net.dpml.parts.state.Transition;
+import net.dpml.parts.state.Operation;
+
+/**
+ * Test creation of the default operation implentation.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: AbstractDescriptorTestCase.java 1556 2005-01-22 12:43:42Z
niclas $
+ */
+public class DefaultOperationTestCase extends TestCase
+{
+ private URI m_uri;
+ private DefaultOperation m_operation;
+
+ /**
+ * Setup the DefaultOperation
+ */
+ public void setUp() throws Exception
+ {
+ m_uri = new URI( "method:null" );
+ m_operation = new DefaultOperation( m_uri );
+ }
+
+ public void testURI() throws Exception
+ {
+ assertEquals( "uri", m_uri, m_operation.getHandlerURI() );
+ }
+
+ public void testConstructorWithNullURI() throws Exception
+ {
+ try
+ {
+ new DefaultOperation( null );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testImplementsOperation() throws Exception
+ {
+ try
+ {
+ Operation o = (Operation) m_operation;
+ }
+ catch( ClassCastException e )
+ {
+ fail( "DefaultOperation not castable to Operation" );
+ }
+ }
+
+
+}
+
+
+

Added:
development/main/metro/composition/control/src/test/net/dpml/composition/state/DefaultStateTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/test/net/dpml/composition/state/DefaultStateTestCase.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,777 @@
+/*
+ * 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.composition.state;
+
+import java.net.URI;
+import java.util.logging.Logger;
+
+import net.dpml.parts.state.State;
+
+import junit.framework.TestCase;
+
+import net.dpml.parts.state.DuplicateKeyException;
+import net.dpml.parts.state.NoSuchStateException;
+import net.dpml.parts.state.NoSuchTransitionException;
+import net.dpml.parts.state.NoSuchOperationException;
+import net.dpml.parts.state.Transition;
+import net.dpml.parts.state.Operation;
+
+/**
+ * Test creation of a state model.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: AbstractDescriptorTestCase.java 1556 2005-01-22 12:43:42Z
niclas $
+ */
+public class DefaultStateTestCase extends TestCase
+{
+ private DefaultState m_root = null;
+
+ /**
+ * Test the DefaultState as a vehicle for the creation of a state model.
+ */
+ public void setUp() throws Exception
+ {
+ DefaultState root = new DefaultState();
+ root.addOperation( "foo", new URI( "handler:foo" ) );
+ root.addOperation( "bar", new URI( "handler:bar" ) );
+ m_root = root;
+ }
+
+ public void testRootName() throws Exception
+ {
+ String name = m_root.getName();
+ assertEquals( "root name", "root", name );
+ }
+
+ public void testRootParent() throws Exception
+ {
+ DefaultState parent = m_root.getParent();
+ assertNull( "root parent", parent );
+ }
+
+ public void testRootProxy() throws Exception
+ {
+ State state = m_root.getProxy();
+ try
+ {
+ DefaultState s = (DefaultState) state;
+ fail( "casting proxied state object to implementation succeeded"
);
+ }
+ catch( ClassCastException e )
+ {
+ // success
+ }
+ }
+
+ public void testRootNotTerminal() throws Exception
+ {
+ assertFalse( "root is terminal", m_root.isTerminal() );
+ }
+
+ public void testRootTerminal() throws Exception
+ {
+ DefaultState root = new DefaultState( true );
+ assertTrue( "is terminal", root.isTerminal() );
+ }
+
+ public void testRootOperations() throws Exception
+ {
+ String[] operations = m_root.getOperationNames();
+ if( operations.length < 2 )
+ {
+ fail( "root operation count is less than 2" );
+ }
+ }
+
+ public void testStateCount() throws Exception
+ {
+ State[] states = m_root.getStates();
+ if( states.length > 0 )
+ {
+ fail( "nested state count is not 0" );
+ }
+ }
+
+ public void testAddStateWithNullKey() throws Exception
+ {
+ try
+ {
+ m_root.addState( null );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testAddState() throws Exception
+ {
+ String name = "running";
+ m_root.addState( name );
+ State[] states = m_root.getStates();
+ if( states.length != 1 )
+ {
+ fail( "sub-state count != 1" );
+ }
+ }
+
+ public void testAddDuplicateState() throws Exception
+ {
+ String name = "running";
+ m_root.addState( name );
+ try
+ {
+ m_root.addState( name );
+ }
+ catch( DuplicateKeyException e )
+ {
+ // success
+ }
+ State[] states = m_root.getStates();
+ if( states.length != 1 )
+ {
+ fail( "sub-state count != 1" );
+ }
+ }
+
+ public void testAddTerminalState() throws Exception
+ {
+ String name = "running";
+ State terminal = m_root.addTerminalState( name );
+ State[] states = m_root.getStates();
+ if( states.length != 1 )
+ {
+ fail( "sub-state count != 1" );
+ }
+ }
+
+ public void testTerminalState() throws Exception
+ {
+ String name = "running";
+ State terminal = m_root.addTerminalState( name );
+ assertTrue( "terminal state is terminal", terminal.isTerminal() );
+ }
+
+ public void testAddDuplicateTerminalState() throws Exception
+ {
+ String name = "running";
+ m_root.addTerminalState( name );
+ try
+ {
+ m_root.addState( name );
+ }
+ catch( DuplicateKeyException e )
+ {
+ // success
+ }
+ State[] states = m_root.getStates();
+ if( states.length != 1 )
+ {
+ fail( "sub-state count != 1" );
+ }
+ }
+
+ public void testLocalStateCount() throws Exception
+ {
+ m_root.addState( "aaa" );
+ m_root.addState( "bbb" );
+ m_root.addState( "ccc" );
+ State[] states = m_root.getStates();
+ if( states.length != 3 )
+ {
+ fail( "sub-state count != 3" );
+ }
+ }
+
+ public void testAllStatesCount() throws Exception
+ {
+ m_root.addState( "aaa" );
+ m_root.addState( "bbb" );
+ m_root.addState( "ccc" );
+ if( m_root.getAllStates().length != 4 )
+ {
+ fail( "total-state count != 4" );
+ }
+ }
+
+ public void testAllStatesCountInGraph() throws Exception
+ {
+ int n = 1;
+ for( int i=0; i<10; i++ )
+ {
+ DefaultState s = m_root.addState( "" + i );
+ n++;
+ }
+ DefaultState[] states = m_root.getStates( m_root );
+ for( int i=0; i<states.length; i++ )
+ {
+ DefaultState p = states[i];
+ for( int j=0; j<10; j++ )
+ {
+ p.addState( p.getName() + "." + j );
+ n++;
+ }
+ }
+ if( m_root.getAllStates().length != n )
+ {
+ fail( "sub-state count != " + n );
+ }
+ }
+
+ public void testStatesCountInTarget() throws Exception
+ {
+ int n = 0;
+ DefaultState foo = m_root.addState( "foo" );
+ for( int i=0; i<10; i++ )
+ {
+ DefaultState s = foo.addState( "" + i );
+ n++;
+ }
+ DefaultState[] states = foo.getStates();
+ if( states.length != n )
+ {
+ fail( "sub-state count " + states.length + " != " + n );
+ }
+ }
+
+ public void testStatesCountInSuppliedTarget() throws Exception
+ {
+ int n = 0;
+ DefaultState foo = m_root.addState( "foo" );
+ for( int i=0; i<10; i++ )
+ {
+ DefaultState s = foo.addState( "" + i );
+ n++;
+ }
+ DefaultState[] states = m_root.getStates( foo );
+ if( states.length != n )
+ {
+ fail( "sub-state count " + states.length + " != " + n );
+ }
+ }
+
+ public void testGetStateWithNull() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ try
+ {
+ m_root.getState( null );
+ fail( "do not throw NPE" );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testGetInvalidState() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ try
+ {
+ m_root.getState( "bar" );
+ fail( "do not throw NSSE" );
+ }
+ catch( NoSuchStateException e )
+ {
+ // success
+ }
+ }
+
+ public void testRootStateRetrieval() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ DefaultState s = m_root.getState( "foo" );
+ assertEquals( "testing created is retrieved", foo, s );
+ }
+
+ public void testSubStateRetrieval() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ DefaultState s = foo.getState( "foo" );
+ assertEquals( "testing created is retrieved", foo, s );
+ }
+
+ public void testAddTransitionNullKey() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ try
+ {
+ m_root.addTransition( null, new URI( "method:null" ), foo );
+ fail( "do not throw NPE" );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testAddTransitionNullURI() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ try
+ {
+ m_root.addTransition( "to-foo", null, foo );
+ }
+ catch( NullPointerException e )
+ {
+ fail( "null uris are allowed in transitions" );
+ }
+ }
+
+ public void testAddTransitionNullTarget() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ try
+ {
+ m_root.addTransition( "to-foo", new URI( "method:null" ), null );
+ fail( "do not throw NPE" );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testAddTransitionBadTarget() throws Exception
+ {
+ DefaultState foo = new DefaultState();
+ try
+ {
+ m_root.addTransition( "to-foo", new URI( "method:null" ), foo );
+ fail( "do not throw ISE" );
+ }
+ catch( IllegalArgumentException e )
+ {
+ // success
+ }
+ }
+
+ public void testAddTransitionInTerminal() throws Exception
+ {
+ DefaultState foo = m_root.addTerminalState( "foo" );
+ try
+ {
+ foo.addTransition( "from-foo", new URI( "method:null" ), m_root
);
+ fail( "do not throw ISE" );
+ }
+ catch( IllegalStateException e )
+ {
+ // success
+ }
+ }
+
+ public void testAddTransitionToSelf() throws Exception
+ {
+ try
+ {
+ m_root.addTransition( "nowhere", new URI( "method:null" ),
m_root );
+ fail( "do not throw IAE" );
+ }
+ catch( IllegalArgumentException e )
+ {
+ // success
+ }
+ }
+
+ public void testSetInitializationNullURI() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ try
+ {
+ m_root.setInitialization( null, foo );
+ }
+ catch( NullPointerException e )
+ {
+ fail( "null uris are allowed in initializers" );
+ }
+ }
+
+ public void testSetInitializationNullTarget() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ try
+ {
+ m_root.setInitialization( new URI( "system:null" ), null );
+ fail( "do not throw NPE" );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testSetInitializationBadTarget() throws Exception
+ {
+ DefaultState foo = new DefaultState();
+ try
+ {
+ m_root.setInitialization( new URI( "method:null" ), foo );
+ fail( "do not throw ISE" );
+ }
+ catch( IllegalArgumentException e )
+ {
+ // success
+ }
+ }
+
+ public void testSetInitializationInTerminal() throws Exception
+ {
+ DefaultState foo = m_root.addTerminalState( "foo" );
+ try
+ {
+ foo.setInitialization( new URI( "method:null" ), m_root );
+ fail( "do not throw ISE" );
+ }
+ catch( IllegalStateException e )
+ {
+ // success
+ }
+ }
+
+ public void testTerminatorNullURI() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ try
+ {
+ m_root.setTerminator( null, foo );
+ }
+ catch( NullPointerException e )
+ {
+ fail( "null uris are allowed in terminators" );
+ }
+ }
+
+ public void testTerminatorNullTarget() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ try
+ {
+ m_root.setTerminator( new URI( "system:null" ), null );
+ fail( "do not throw NPE" );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testSetTerminatorBadTarget() throws Exception
+ {
+ DefaultState foo = new DefaultState();
+ try
+ {
+ m_root.setTerminator( new URI( "method:null" ), foo );
+ fail( "do not throw ISE" );
+ }
+ catch( IllegalArgumentException e )
+ {
+ // success
+ }
+ }
+
+ public void testSetTerminatorInTerminal() throws Exception
+ {
+ DefaultState foo = m_root.addTerminalState( "foo" );
+ foo.setTerminator( m_root );
+ }
+
+ public void testGetTransition() throws Exception
+ {
+ String name = "bar";
+ URI uri = new URI( "method:null" );
+ DefaultState foo = m_root.addState( "foo" );
+ m_root.addTransition( name, uri, foo );
+ Transition bar = m_root.getTransition( name );
+ assertEquals( "target", foo, bar.getTargetState() );
+ }
+
+ public void testGetTransitionWithInvalidKey() throws Exception
+ {
+ try
+ {
+ m_root.getTransition( "fred" );
+ fail( "do not throw NSTE" );
+ }
+ catch( NoSuchTransitionException e )
+ {
+ // success
+ }
+ }
+
+ public void testGetTransitionWithNullKey() throws Exception
+ {
+ try
+ {
+ m_root.getTransition( null );
+ fail( "do not throw NPE" );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testGetNamedTransition() throws Exception
+ {
+ String name = "bar";
+ URI uri = new URI( "method:null" );
+ DefaultState foo = m_root.addState( "foo" );
+ m_root.addTransition( name, uri, foo );
+ DefaultTransition bar = m_root.getNamedTransition( name );
+ assertEquals( "target", foo, bar.getTargetState() );
+ assertEquals( "handler", uri, bar.getHandlerURI() );
+ }
+
+ public void testGetNamedTransitionWithNullKey() throws Exception
+ {
+ try
+ {
+ m_root.getNamedTransition( null );
+ fail( "do not throw NPE" );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testGetNamedTransitionWithInvalidKey() throws Exception
+ {
+ try
+ {
+ m_root.getNamedTransition( "fred" );
+ fail( "do not throw NSTE" );
+ }
+ catch( NoSuchTransitionException e )
+ {
+ // success
+ }
+ }
+
+ public void testAddOperationNullKey() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ try
+ {
+ m_root.addOperation( null, new URI( "method:null" ) );
+ fail( "do not throw NPE" );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testAddOperationNullURI() throws Exception
+ {
+ DefaultState foo = m_root.addState( "foo" );
+ try
+ {
+ m_root.addOperation( "key", null );
+ fail( "do not throw NPE" );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testAddDuplicateOperation() throws Exception
+ {
+ m_root.addOperation( "aaa", new URI( "method:null" ) );
+ try
+ {
+ m_root.addOperation( "aaa", new URI( "method:null" ) );
+ fail( "do not throw DKE" );
+ }
+ catch( DuplicateKeyException e )
+ {
+ // success
+ }
+ }
+
+ public void testAddDuplicateOperationWithPolicy() throws Exception
+ {
+ m_root.addOperation( "aaa", new URI( "method:null" ) );
+ try
+ {
+ m_root.addOperation( "aaa", new URI( "method:null" ), false );
+ fail( "do not throw DKE" );
+ }
+ catch( DuplicateKeyException e )
+ {
+ // success
+ }
+ }
+
+ public void testReplaceOperation() throws Exception
+ {
+ URI bar = new URI( "method:bar" );
+ m_root.addOperation( "aaa", new URI( "method:foo" ) );
+ m_root.addOperation( "aaa", bar, true );
+ DefaultOperation operation = m_root.getNamedOperation( "aaa" );
+ assertEquals( "uri", bar, operation.getHandlerURI() );
+ }
+
+ public void testGetOperationNullKey() throws Exception
+ {
+ try
+ {
+ m_root.getOperation( null );
+ fail( "do not throw NPE" );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testGetOperationBadKey() throws Exception
+ {
+ try
+ {
+ m_root.getOperation( "xyz" );
+ fail( "do not throw NSOE" );
+ }
+ catch( NoSuchOperationException e )
+ {
+ // success
+ }
+ }
+
+ public void testGetNamedOperationNullKey() throws Exception
+ {
+ try
+ {
+ m_root.getNamedOperation( null );
+ fail( "do not throw NPE" );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testGetNamedOperationBadKey() throws Exception
+ {
+ try
+ {
+ m_root.getNamedOperation( "xyz" );
+ fail( "do not throw NSOE" );
+ }
+ catch( NoSuchOperationException e )
+ {
+ // success
+ }
+ }
+
+ public void testGetLocalOperationNames() throws Exception
+ {
+ URI uri = new URI( "handler:gizmo" );
+ DefaultState foo = m_root.addState( "foo" );
+ foo.addOperation( "widget", uri );
+ foo.addOperation( "gizmo", uri );
+ String[] operations = foo.getLocalOperationNames();
+ assertEquals( "operations", operations.length, 2 );
+ }
+
+ public void testGetNamedOperation() throws Exception
+ {
+ URI uri = new URI( "handler:gizmo" );
+ DefaultState foo = m_root.addState( "foo" );
+ foo.addOperation( "widget", uri );
+ DefaultOperation operation = foo.getNamedOperation( "widget" );
+ assertNotNull( "operation", operation );
+ assertEquals( "uri", uri, operation.getHandlerURI() );
+ }
+
+ public void testGetOperationNames() throws Exception
+ {
+ URI uri = new URI( "handler:gizmo" );
+ int n = m_root.getOperationNames().length;
+ DefaultState foo = m_root.addState( "foo" );
+ foo.addOperation( "widget", uri );
+ int m = m_root.getOperationNames().length;
+ assertEquals( "operation count", m, n ); // we don't see child
operations
+ }
+
+ public void testGetNestedOperationNames() throws Exception
+ {
+ URI uri = new URI( "handler:gizmo" );
+ int n = m_root.getOperationNames().length;
+ DefaultState foo = m_root.addState( "foo" );
+ foo.addOperation( "widget", uri );
+ int m = foo.getOperationNames().length;
+ assertEquals( "operation count", m, n+1 ); // we see local plus
parent operations
+ }
+
+ public void testGraphOperationCount() throws Exception
+ {
+ DefaultState root = createComplexState();
+ DefaultState started = root.getState( "started" );
+ assertEquals( "operations", started.getOperationNames().length, 3 );
+ }
+
+ public void testGraphTransitionCount() throws Exception
+ {
+ DefaultState root = createComplexState();
+ DefaultState started = root.getState( "started" );
+ assertEquals( "transitions", started.getTransitionNames().length, 1
);
+ }
+
+ public void testList() throws Exception
+ {
+ DefaultState root = createComplexState();
+ root.list();
+ }
+
+ public DefaultState createComplexState() throws Exception
+ {
+ //
+ // construct a state graph
+ //
+
+ DefaultState root = new DefaultState();
+ DefaultState initialized = root.addState( "initialized" );
+ DefaultState available = root.addState( "available" );
+ DefaultState started = available.addState( "started" );
+ DefaultState stopped = available.addState( "stopped" );
+ DefaultState terminated = root.addTerminalState( "terminated" );
+
+ //
+ // add operations and transitions
+ //
+
+ root.setInitialization( new URI( "handler:demo" ), initialized );
+ initialized.setTerminator( new URI( "handler:demo" ), terminated );
+ available.addTransition( "start", new URI( "handler:demo" ), started
);
+ root.addOperation( "foo", new URI( "handler:bar" ) );
+ started.addTransition( "stop", new URI( "handler:demo" ), stopped );
+ started.addOperation( "do-this", new URI( "part:abc" ) );
+ started.addOperation( "do-that", new URI( "method:cde" ) );
+ stopped.addTransition( "start", new URI( "handler:demo" ), started );
+
+ return root;
+ }
+
+}
+
+
+

Added:
development/main/metro/composition/control/src/test/net/dpml/composition/state/DefaultTransitionTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/control/src/test/net/dpml/composition/state/DefaultTransitionTestCase.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,111 @@
+/*
+ * 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.composition.state;
+
+import java.net.URI;
+import java.util.logging.Logger;
+
+import junit.framework.TestCase;
+
+import net.dpml.parts.state.State;
+import net.dpml.parts.state.DuplicateKeyException;
+import net.dpml.parts.state.NoSuchStateException;
+import net.dpml.parts.state.NoSuchTransitionException;
+import net.dpml.parts.state.NoSuchOperationException;
+import net.dpml.parts.state.Transition;
+import net.dpml.parts.state.Operation;
+
+/**
+ * Test creation of a state model.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: AbstractDescriptorTestCase.java 1556 2005-01-22 12:43:42Z
niclas $
+ */
+public class DefaultTransitionTestCase extends TestCase
+{
+ private URI m_uri;
+ private DefaultState m_target;
+ private DefaultTransition m_transition;
+
+ /**
+ * Test the DefaultState as a vehicle for the creation of a state model.
+ */
+ public void setUp() throws Exception
+ {
+ m_uri = new URI( "method:null" );
+ m_target = new DefaultState();
+ m_transition = new DefaultTransition( m_uri, m_target );
+ }
+
+ public void testURI() throws Exception
+ {
+ assertEquals( "uri", m_uri, m_transition.getHandlerURI() );
+ }
+
+ public void testTargetState() throws Exception
+ {
+ assertEquals( "target", m_target, m_transition.getTargetState() );
+ }
+
+ public void testTransitionTargetState() throws Exception
+ {
+ assertEquals( "target", m_target, m_transition.getTransitionTarget()
);
+ }
+
+ public void testConstructorWithNullURI() throws Exception
+ {
+ try
+ {
+ new DefaultTransition( null, m_target );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testConstructorWithNullTarget() throws Exception
+ {
+ try
+ {
+ new DefaultTransition( m_uri, null );
+ }
+ catch( NullPointerException e )
+ {
+ // success
+ }
+ }
+
+ public void testImplementsTransition() throws Exception
+ {
+ try
+ {
+ Transition transition = (Transition) m_transition;
+ }
+ catch( ClassCastException e )
+ {
+ fail( "DefaultTransition not castable to Transition" );
+ }
+ }
+
+
+}
+
+
+

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLComponentProfileCreator.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLComponentProfileCreator.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/data/builder/XMLComponentProfileCreator.java
Fri Apr 22 02:43:03 2005
@@ -19,7 +19,7 @@

import java.util.ArrayList;

-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.data.ClassLoaderDirective;
import net.dpml.composition.data.ComponentProfile;
import net.dpml.composition.data.ContextDirective;

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
Fri Apr 22 02:43:03 2005
@@ -32,7 +32,7 @@
import java.util.LinkedList;
import java.util.List;

-import net.dpml.automation.part.Part;
+import net.dpml.parts.part.Part;

import net.dpml.composition.data.CompositionDirective;
import net.dpml.composition.data.ComponentProfile;

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContextModel.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContextModel.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContextModel.java
Fri Apr 22 02:43:03 2005
@@ -22,8 +22,8 @@
import java.util.Map;
import java.util.Map.Entry;

-import net.dpml.automation.part.Part;
-import net.dpml.automation.part.PartReference;
+import net.dpml.parts.part.Part;
+import net.dpml.parts.part.PartReference;
import net.dpml.composition.data.ContextDirective;
import net.dpml.composition.data.ImportDirective;
import net.dpml.composition.data.ValueDirective;

Modified:
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeContainer.java
==============================================================================
---
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeContainer.java
(original)
+++
development/main/metro/composition/testing/acme/src/main/net/dpml/composition/testing/AcmeContainer.java
Fri Apr 22 02:43:03 2005
@@ -110,17 +110,12 @@
// our parts interface
//

- debug( "getting gizmo impl" );
- Entry entry = parts.selectGizmoEntry();
- GizmoComponent newGizmo = (GizmoComponent) entry.getValue();
-
debug( "getting identified gizmo" );
Gizmo myGizmo = parts.selectGizmo( "my-gizmo" );

debug( "cleaning up" );
parts.releaseGizmo( gizmo );
parts.releaseGizmo( myGizmo );
- parts.releaseGizmo( newGizmo );
}

private Logger getLogger()
@@ -181,14 +176,6 @@
Gizmo selectGizmo( Object key );

/**
- * Create and return a new annonomouse instance of gizmo as a
- * non-proxied component.
- *
- * @return the gizmo component
- */
- Entry selectGizmoEntry();
-
- /**
* Optional release of an instance of the gizmo component.
*
* @param the gizmo to release

Modified: development/main/metro/composition/testing/unit/build.xml
==============================================================================
--- development/main/metro/composition/testing/unit/build.xml (original)
+++ development/main/metro/composition/testing/unit/build.xml Fri Apr 22
02:43:03 2005
@@ -201,6 +201,53 @@
</parts>
</component>

+ <!--
+ State management examples.
+ -->
+ <types xmlns="plugin:dpml/composition/dpml-composition-builder">
+ <type class="net.dpml.test.state.ManagedComponent"/>
+ <type class="net.dpml.test.state.ManagingContainer"/>
+ </types>
+
+ <component xmlns="plugin:dpml/composition/dpml-composition-builder"
+ type="net.dpml.test.state.ManagedComponent"
+ name="component" dest="target/test/managed-component.part"/>
+
+ <component xmlns="plugin:dpml/composition/dpml-composition-builder"
+ type="net.dpml.test.state.ManagingContainer"
+ name="container"
+ dest="target/test/managing-container.part">
+ <parts>
+ <component key="test" type="net.dpml.test.state.ManagedComponent"/>
+ </parts>
+ </component>
+
+ <!--
+ Configuration examples.
+ -->
+ <types xmlns="plugin:dpml/composition/dpml-composition-builder">
+ <type class="net.dpml.test.config.ConfigurableComponent"/>
+ <type class="net.dpml.test.config.ConfigurableContainer"/>
+ </types>
+
+ <component dest="target/test/configurable-container.part"
+ xmlns="plugin:dpml/composition/dpml-composition-builder"
+ type="net.dpml.test.config.ConfigurableContainer"
+ name="container">
+ <configuration>
+ <test>
+ <color>red</color>
+ </test>
+ </configuration>
+ <parts>
+ <component name="test"
type="net.dpml.test.config.ConfigurableComponent">
+ <configuration>
+ <color>blue</color>
+ </configuration>
+ </component>
+ </parts>
+ </component>
+
</target>
-
+
</project>

Added:
development/main/metro/composition/testing/unit/src/main/net/dpml/test/config/ConfigurableComponent.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/testing/unit/src/main/net/dpml/test/config/ConfigurableComponent.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,82 @@
+/*
+ * 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.test.config;
+
+import java.util.logging.Logger;
+
+import net.dpml.configuration.Configuration;
+
+import net.dpml.activity.Executable;
+
+/**
+ * Experimental component dealing with state management.
+ *
+ * @author <a href="mailto:info AT dpml.net";>The Digital Product Meta
Library</a>
+ */
+public class ConfigurableComponent implements Executable
+{
+ // ------------------------------------------------------------------
+ // static
+ // ------------------------------------------------------------------
+
+ public static final boolean TYPE_THREADSAFE_CAPABLE = true;
+
+ // ------------------------------------------------------------------
+ // state
+ // ------------------------------------------------------------------
+
+ private final Logger m_logger;
+ private final Configuration m_configuration;
+
+ // ------------------------------------------------------------------
+ // constructor
+ // ------------------------------------------------------------------
+
+ /**
+ * Creation of a component that uses a supplied configuration.
+ *
+ * @param logger the logging channel assigned by the container
+ * @param configuration the supplied component configuration
+ */
+ public ConfigurableComponent( final Logger logger, final Configuration
configuration )
+ {
+ m_logger = logger;
+ m_configuration = configuration;
+ }
+
+ // ------------------------------------------------------------------
+ // activity
+ // ------------------------------------------------------------------
+
+ public void execute() throws Exception
+ {
+ Configuration color = m_configuration.getChild( "color" );
+ String value = color.getValue( "undefined" );
+ getLogger().info( "color: " + value );
+ }
+
+ // ------------------------------------------------------------------
+ // implementation
+ // ------------------------------------------------------------------
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+}

Added:
development/main/metro/composition/testing/unit/src/main/net/dpml/test/config/ConfigurableContainer.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/testing/unit/src/main/net/dpml/test/config/ConfigurableContainer.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,123 @@
+/*
+ * 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.test.config;
+
+import java.util.logging.Logger;
+
+import net.dpml.configuration.Configuration;
+import net.dpml.configuration.Configurable;
+import net.dpml.configuration.ConfigurationException;
+
+import net.dpml.activity.Executable;
+
+import net.dpml.parts.control.Controller;
+import net.dpml.parts.model.Model;
+
+import net.dpml.parts.state.Manager;
+
+/**
+ * Demonstration of a component that uses a supplied configuration to
+ * configure its children.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class ConfigurableContainer implements Executable
+{
+ //------------------------------------------------------------------
+ // static
+ //------------------------------------------------------------------
+
+ public static final boolean TYPE_THREADSAFE_CAPABLE = true;
+
+ //------------------------------------------------------------------
+ // state
+ //------------------------------------------------------------------
+
+ private final Logger m_logger;
+ private final Parts m_parts;
+ private final Configuration m_configuration;
+
+ //------------------------------------------------------------------
+ // constructor
+ //------------------------------------------------------------------
+
+ /**
+ * This container demonstrates how a supplied configuration can be
+ * used as the source for configuration of the model of a contained
+ * part.
+ *
+ * @param logger the logging channel asign by the container
+ * @param parts the parts managed by this container
+ * @param configuration the container configuration
+ */
+ public ConfigurableContainer( final Logger logger, Parts parts,
Configuration configuration )
+ {
+ m_logger = logger;
+ m_parts = parts;
+ m_configuration = configuration;
+ }
+
+ //------------------------------------------------------------------
+ // implementation
+ //------------------------------------------------------------------
+
+ public void execute() throws Exception
+ {
+ Parts parts = getParts();
+ Model model = parts.selectTestModel();
+ if( model instanceof Configurable )
+ {
+ Configuration conf = m_configuration.getChild( "test", false );
+ if( null != conf )
+ {
+ getLogger().info( "applying configuration to " + model );
+ ((Configurable)model).configure( conf );
+ }
+ }
+ Manager manager = model.getManager();
+ try
+ {
+ manager.initialize();
+ manager.execute( "execute" );
+ }
+ finally
+ {
+ manager.terminate();
+ }
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ private Parts getParts()
+ {
+ return m_parts;
+ }
+
+ //------------------------------------------------------------------
+ // concerns
+ //------------------------------------------------------------------
+
+ public interface Parts
+ {
+ Model selectTestModel();
+ }
+}

Added:
development/main/metro/composition/testing/unit/src/main/net/dpml/test/state/ManagedComponent.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/testing/unit/src/main/net/dpml/test/state/ManagedComponent.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,220 @@
+/*
+ * 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.test.state;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.logging.Logger;
+
+import javax.swing.event.ChangeListener;
+
+import net.dpml.parts.state.State;
+import net.dpml.composition.state.DefaultState;
+import net.dpml.composition.state.DefaultManager;
+
+/**
+ * Experimental component dealing with state management.
+ *
+ * @author <a href="mailto:info AT dpml.net";>The Digital Product Meta
Library</a>
+ */
+public class ManagedComponent
+{
+ // ------------------------------------------------------------------
+ // static
+ // ------------------------------------------------------------------
+
+ public static final boolean TYPE_THREADSAFE_CAPABLE = true;
+
+ // ------------------------------------------------------------------
+ // state
+ // ------------------------------------------------------------------
+
+ private final Logger m_logger;
+ // ------------------------------------------------------------------
+ // constructor
+ // ------------------------------------------------------------------
+
+ /**
+ * Creation of a component that describes an activity model.
+ *
+ * @param logger the logging channel assigned by the container
+ */
+ public ManagedComponent( final Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ // ------------------------------------------------------------------
+ // concerns
+ // ------------------------------------------------------------------
+
+ public class Controller extends DefaultManager
+ {
+ public Controller( Logger logger, ChangeListener listener,
ManagedComponent instance )
+ {
+ super( COMPONENT_STATE_MODEL, logger, listener, instance );
+ }
+
+ //
+ // Override the default initialize method with an demo of the
+ // optional registration of a generic handler.
+ //
+
+ public Object initialize() throws Exception
+ {
+ addHandler( "terminate", GENERIC_HANDLER );
+ return super.initialize();
+ }
+ }
+
+ // ------------------------------------------------------------------
+ // implementation
+ // ------------------------------------------------------------------
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ //
+ // The following component methods are invoked by the state manager
based on
+ // uris assigned to transitions. The state manager locates the method
+ // from the uri and invokes the operation after constructing arguments
+ // from the possible set of Logger, Object (component impl), State
(initial),
+ // and State (target). If the method requires the target state it must
+ // delcare both current and target state in the method parameters.
+ //
+
+ public void terminate( State state )
+ {
+ String name = state.getName();
+ getLogger().info( "handling termination within " + name );
+ }
+
+ public void start( State starting )
+ {
+ String from = starting.getName();
+ getLogger().info( "starting from within " + from );
+ }
+
+ public void stop()
+ {
+ getLogger().info( "stopping the component" );
+ }
+
+ //
+ // The following two methods are examples of methods invoked
+ // via operation declarations. Operations do not trigger state
+ // change - instead they are gaurded methods that become visible
+ // to a controlling application when the state to which the operation
+ // is assigned becomes visible in the active state chain.
+ //
+
+ public void audit( State state )
+ {
+ StringBuffer buffer = new StringBuffer( "Audit Report" );
+ buffer.append( "\n-------------------------------------------------"
);
+ buffer.append( "\nState Model:" );
+ buffer.append( "\nCurrent State: " + state.getName() );
+ buffer.append( "\n-------------------------------------------------"
);
+ buffer.append( COMPONENT_STATE_MODEL.list() );
+ buffer.append( "\n-------------------------------------------------"
);
+ getLogger().info( buffer.toString() );
+ }
+
+ // ------------------------------------------------------------------
+ // static utilities
+ // ------------------------------------------------------------------
+
+ private static final DefaultState COMPONENT_STATE_MODEL = new
DefaultState();
+
+ static
+ {
+ //
+ // construct a state graph
+ //
+
+ DefaultState root = COMPONENT_STATE_MODEL;
+ DefaultState initialized = root.addState( "initialized" );
+ DefaultState available = root.addState( "available" );
+ DefaultState started = available.addState( "started" );
+ DefaultState stopped = available.addState( "stopped" );
+ DefaultState terminated = root.addTerminalState( "terminated" );
+
+ //
+ // create the handler declarations and add then under transitions
+ //
+
+ try
+ {
+ //
+ // add system transitions dealing with initilization and
+ // termination - each transition is added to a particular
+ // state and is qualified with the uri of the handler to
+ // use, and the transitions target state
+ //
+
+ root.setInitialization( initialized );
+ root.setTerminator( new URI( "handler:terminate" ), terminated );
+ started.setTerminator( new URI( "method:stop" ), stopped );
+
+ //
+ // add user (application) transitions
+ //
+
+ initialized.addTransition( "start", new URI( "method:start" ),
started );
+ started.addTransition( "stop", new URI( "method:stop" ), stopped
);
+ stopped.addTransition( "start", new URI( "method:start" ),
started );
+
+ //
+ // add an operations that is only accessible in the active state
chain
+ // when the component is in the started state
+ //
+
+ started.addOperation( "audit", new URI( "method:audit" ) );
+
+ }
+ catch( URISyntaxException e )
+ {
+ e.printStackTrace(); // will not happen
+ }
+ }
+
+ //
+ // The following class is an example of a transition handler. Instances
+ // of this class may be registered with the state manager and referenced
in
+ // transitiond via the urn "handler:[key]".
+ //
+
+ private static final Handler GENERIC_HANDLER = new Handler();
+
+ public static class Handler
+ {
+ public void handle( ManagedComponent instance, State state, State
target, Logger logger )
+ {
+ final String message =
+ "handling transition from ["
+ + state.getName()
+ + "] to ["
+ + target.getName()
+ + "]";
+ logger.info( message );
+ }
+ }
+}

Added:
development/main/metro/composition/testing/unit/src/main/net/dpml/test/state/ManagingContainer.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/testing/unit/src/main/net/dpml/test/state/ManagingContainer.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,97 @@
+/*
+ * 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.test.state;
+
+import java.util.logging.Logger;
+
+import net.dpml.configuration.Configuration;
+import net.dpml.activity.Executable;
+import net.dpml.parts.state.Manager;
+
+/**
+ * Demonstration of a component that manages the state of a contained part.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class ManagingContainer implements Executable
+{
+ //------------------------------------------------------------------
+ // static
+ //------------------------------------------------------------------
+
+ public static final boolean TYPE_THREADSAFE_CAPABLE = true;
+
+ //------------------------------------------------------------------
+ // state
+ //------------------------------------------------------------------
+
+ private final Logger m_logger;
+ private final Parts m_parts;
+
+ //------------------------------------------------------------------
+ // constructor
+ //------------------------------------------------------------------
+
+ /**
+ * Creation of a composite component. This implementation demonstrates
+ * access to parts within itself and invocation of service and non-service
+ * operations on its parts.
+ *
+ * @param logger the logging channel asign by the container
+ */
+ public ManagingContainer( final Logger logger, Parts parts )
+ {
+ m_logger = logger;
+ m_parts = parts;
+ }
+
+ //------------------------------------------------------------------
+ // implementation
+ //------------------------------------------------------------------
+
+ public void execute() throws Exception
+ {
+ Parts parts = getParts();
+ Manager manager = parts.selectTestManager();
+ manager.initialize();
+ manager.apply( "start" );
+ manager.execute( "audit" );
+ manager.terminate();
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ private Parts getParts()
+ {
+ return m_parts;
+ }
+
+ //------------------------------------------------------------------
+ // concerns
+ //------------------------------------------------------------------
+
+ public interface Parts
+ {
+ Manager selectTestManager();
+ }
+
+}

Modified:
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/CompositeTestCase.java
==============================================================================
---
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/CompositeTestCase.java
(original)
+++
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/CompositeTestCase.java
Fri Apr 22 02:43:03 2005
@@ -25,10 +25,13 @@

import junit.framework.TestCase;

-import net.dpml.automation.model.Model;
-import net.dpml.automation.control.Controller;
+import net.dpml.parts.model.Model;
+import net.dpml.parts.control.Controller;
import net.dpml.composition.unit.CompositionHelper;

+import net.dpml.parts.state.Manager;
+
+
/**
* Test a simple component case.
*
@@ -66,12 +69,17 @@
CompositionHelper helper = new CompositionHelper();
URI uri = helper.toURI( "acme-bad-widget.part" );
Model model = helper.getCompositionManager().addPart( uri, "acme" );
- Controller controller = model.getController();
- Entry entry = controller.create( model );
- AcmeContainer container = (AcmeContainer) entry.getValue();
+
+ //Controller controller = model.getController();
+ //Entry entry = controller.create( model );
+ //AcmeContainer container = (AcmeContainer) entry.getValue();
+
+ Manager manager = model.getManager();
+ AcmeContainer container = (AcmeContainer) manager.initialize();
+
try
{
- container.execute();
+ container.execute();
}
catch( BadColorException e )
{
@@ -79,7 +87,8 @@
}
finally
{
- controller.release( container );
+ //controller.release( container );
+ manager.terminate();
helper.dispose();
}
}
@@ -89,16 +98,22 @@
CompositionHelper helper = new CompositionHelper();
URI uri = helper.toURI( path );
Model model = helper.getCompositionManager().addPart( uri, "acme" );
- Controller controller = model.getController();
- Entry entry = controller.create( model );
- AcmeContainer container = (AcmeContainer) entry.getValue();
+
+ Manager manager = model.getManager();
+ AcmeContainer container = (AcmeContainer) manager.initialize();
+
+ //Controller controller = model.getController();
+ //Entry entry = controller.create( model );
+ //AcmeContainer container = (AcmeContainer) entry.getValue();
+
try
{
container.execute();
}
finally
{
- controller.release( container );
+ manager.terminate();
+ //controller.release( container );
helper.dispose();
}
}

Modified:
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/ExampleTestCase.java
==============================================================================
---
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/ExampleTestCase.java
(original)
+++
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/ExampleTestCase.java
Fri Apr 22 02:43:03 2005
@@ -25,8 +25,8 @@

import junit.framework.TestCase;

-import net.dpml.automation.model.Model;
-import net.dpml.automation.control.Controller;
+import net.dpml.parts.model.Model;
+import net.dpml.parts.control.Controller;
import net.dpml.composition.unit.CompositionHelper;

/**

Modified:
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/SimpleTestCase.java
==============================================================================
---
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/SimpleTestCase.java
(original)
+++
development/main/metro/composition/testing/unit/src/test/net/dpml/composition/testing/SimpleTestCase.java
Fri Apr 22 02:43:03 2005
@@ -25,10 +25,13 @@

import junit.framework.TestCase;

-import net.dpml.automation.model.Model;
-import net.dpml.automation.control.Controller;
+import net.dpml.parts.model.Model;
+import net.dpml.parts.control.Controller;
import net.dpml.composition.unit.CompositionHelper;

+import net.dpml.parts.state.Manager;
+
+
/**
* Test a simple component case.
*
@@ -100,21 +103,25 @@
CompositionHelper helper = new CompositionHelper();
URI uri = helper.toURI( PATH );
Model model = helper.getCompositionManager().addPart( uri, "widget"
);
- Controller controller = model.getController();
- Entry entry = controller.create( model );
- WidgetComponent widget = (WidgetComponent) entry.getValue();
+ Manager manager = model.getManager();
+ //Controller controller = model.getController();
+ //Entry entry = controller.create( model );
+ //WidgetComponent widget = (WidgetComponent) entry.getValue();
+
+ WidgetComponent widget = (WidgetComponent) manager.initialize();
String name = widget.getName();
assertEquals( "name", "widget", name );
String newName = "freight";
widget.setName( newName );
assertEquals( "name", newName, widget.getName() );
- controller.release( widget );
+ //controller.release( widget );
}

/**
* Test the construction of the widget implementation and invocation
* of a non-service public method on the implementation class.
*/
+ /*
public void testIdentifiableEntryCreation() throws Exception
{
String id = "niclas";
@@ -127,6 +134,7 @@
assertEquals( "key", id, key );
controller.release( entry );
}
+ */

/**
* Test the construction of an identifiable widget instance. We create

Added:
development/main/metro/composition/testing/unit/src/test/net/dpml/test/config/ConfigurationTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/testing/unit/src/test/net/dpml/test/config/ConfigurationTestCase.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,67 @@
+/*
+ * 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.test.config;
+
+import java.net.URI;
+import java.util.Hashtable;
+import java.util.Map.Entry;
+
+import junit.framework.TestCase;
+
+import net.dpml.parts.model.Model;
+import net.dpml.parts.control.Controller;
+import net.dpml.composition.unit.CompositionHelper;
+
+import net.dpml.parts.state.Manager;
+
+/**
+ * Test a simple component case.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: AbstractDescriptorTestCase.java 1556 2005-01-22 12:43:42Z
niclas $
+ */
+public class ConfigurationTestCase extends TestCase
+{
+ /**
+ * Test the construction of the example component and the invocation of
+ * an operation on the example service interface.
+ */
+ public void testConfigurableContainer() throws Exception
+ {
+ CompositionHelper helper = new CompositionHelper();
+ URI uri = helper.toURI( "configurable-container.part" );
+ Model model = helper.getCompositionManager().addPart( uri );
+ Manager manager = model.getManager();
+
+ //Controller controller = model.getController();
+ //Entry entry = controller.create( model );
+ //ConfigurableContainer container = (ConfigurableContainer)
entry.getValue();
+ try
+ {
+ manager.initialize();
+ manager.execute( "execute" );
+ }
+ finally
+ {
+ manager.terminate();
+ helper.dispose();
+ }
+ }
+}

Added:
development/main/metro/composition/testing/unit/src/test/net/dpml/test/state/ManagementTestCase.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/testing/unit/src/test/net/dpml/test/state/ManagementTestCase.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,93 @@
+/*
+ * 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.test.state;
+
+import java.net.URI;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Map.Entry;
+
+import junit.framework.TestCase;
+
+import net.dpml.parts.model.Model;
+
+import net.dpml.composition.models.Holder;
+
+import net.dpml.composition.unit.CompositionHelper;
+
+import net.dpml.parts.state.State;
+import net.dpml.parts.state.Manager;
+
+/**
+ * Test a simple component case.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta
+ * Library</a>
+ */
+public class ManagementTestCase extends TestCase
+{
+ /**
+ * Test the construction of the example component and the invocation of
+ * the provided controller via </code>the
net.dpml.parts.state.StateManager</code> interface
+ */
+ public void testManagedComponent() throws Exception
+ {
+ Manager manager = getComponentManager();
+ manager.initialize();
+ List list = new LinkedList();
+ while ( false == list.contains( manager.getState() ) )
+ {
+ State state = manager.getState();
+ list.add( state );
+ String[] transitions = state.getTransitionNames();
+ for( int i=0; i<transitions.length; i++ )
+ {
+ String name = transitions[i];
+ manager.apply( name );
+ break;
+ }
+ }
+ manager.terminate();
+ }
+
+ public void testManagingContainer() throws Exception
+ {
+ CompositionHelper helper = new CompositionHelper( false );
+ URI uri = helper.toURI( "managing-container.part" );
+ Model model = helper.getCompositionManager().getModel( uri );
+ Manager manager = model.getManager();
+ try
+ {
+ manager.initialize();
+ }
+ finally
+ {
+ manager.terminate();
+ }
+ }
+
+ Manager getComponentManager() throws Exception
+ {
+ CompositionHelper helper = new CompositionHelper( false );
+ URI uri = helper.toURI( "managed-component.part" );
+ Model model = helper.getCompositionManager().getModel( uri );
+ return model.getManager();
+ }
+}

Modified: development/main/metro/index.xml
==============================================================================
--- development/main/metro/index.xml (original)
+++ development/main/metro/index.xml Fri Apr 22 02:43:03 2005
@@ -23,63 +23,18 @@
</dependencies>
</project>

- <!-- State (experimental) -->
+ <!-- Parts -->

- <project basedir="state/api">
- <info>
- <group>dpml/metro/public</group>
- <name>dpml-state-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- <types>
- <type>jar</type>
- </types>
- </info>
- </project>
-
- <project basedir="state/impl">
- <info>
- <group>dpml/metro/public</group>
- <name>dpml-state-impl</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- <types>
- <type>jar</type>
- </types>
- </info>
- <dependencies>
- <include key="dpml-state-api"/>
- <include key="dpml-transit-main"/>
- </dependencies>
- </project>
-
- <!-- Automation -->
-
- <project basedir="automation/control">
+ <project basedir="parts">
<info>
<group>dpml/metro/protected</group>
- <name>dpml-automation-control</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- <types>
- <type>jar</type>
- </types>
- </info>
- </project>
-
- <project basedir="automation/builder">
- <info>
- <group>dpml/metro/tools</group>
- <name>dpml-automation-builder</name>
+ <name>dpml-parts-api</name>
<version>1.0.0</version>
<status>SNAPSHOT</status>
<types>
<type>jar</type>
</types>
</info>
- <dependencies>
- <include key="dpml-automation-control"/>
- </dependencies>
</project>

<!-- Activity -->
@@ -332,7 +287,7 @@
</types>
</info>
<dependencies>
- <include key="dpml-automation-control" tag="api"/>
+ <include key="dpml-parts-api" tag="api"/>
<include key="dpml-composition-spi"/>
<include key="dpml-composition-impl" build="false"/>
<include key="dpml-configuration-api"/>
@@ -363,7 +318,7 @@
</types>
</info>
<dependencies>
- <include key="dpml-automation-control"/>
+ <include key="dpml-parts-api"/>
<include key="dpml-transit-main"/>
<include key="dpml-meta-api"/>
<include key="dpml-util-i18n"/>
@@ -474,14 +429,13 @@
</info>
<dependencies>
<include key="dpml-transit-main" tag="api"/>
- <include key="dpml-state-api" tag="api"/>
<include key="dpml-activity-api" tag="api"/>
<include key="dpml-parameters-api" tag="api"/>
<include key="dpml-configuration-api" tag="api"/>
- <include key="dpml-automation-control" tag="spi"/>
+ <include key="dpml-activity-api" tag="api"/>
+ <include key="dpml-parts-api" tag="spi"/>
<include key="dpml-composition-api" tag="spi"/>
<include key="dpml-system-api" tag="spi"/>
- <include key="dpml-activity-api"/>
<include key="dpml-util-exception"/>
<include key="commons-cli"/>
<include key="dpml-parameters-impl"/>
@@ -503,7 +457,7 @@
<include key="dpml-meta-api"/>
<include key="dpml-meta-spi"/>
<include key="dpml-meta-tools"/>
- <include key="dpml-automation-builder"/>
+ <include key="dpml-parts-api"/>
<include key="dpml-magic-core"/>
<include key="dpml-logging-spi"/>
<include key="dpml-configuration-api"/>
@@ -550,28 +504,6 @@
</plugins>
</project>

- <project basedir="composition/testing/activity">
- <info>
- <group>dpml/test</group>
- <name>dpml-composition-testing-activity</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- <types>
- <type>jar</type>
- <type>part</type>
- </types>
- </info>
- <dependencies>
- <include key="dpml-state-api"/>
- <include key="dpml-state-impl"/>
- <include key="dpml-activity-api"/>
- <include key="dpml-composition-unit" runtime="false"/>
- </dependencies>
- <plugins>
- <include key="dpml-composition-builder"/>
- </plugins>
- </project>
-
<project basedir="composition/testing/unit">
<info>
<group>dpml/test</group>
@@ -583,9 +515,13 @@
</types>
</info>
<dependencies>
+ <include key="dpml-composition-control"/>
+ <include key="dpml-configuration-api"/>
+ <include key="dpml-activity-api"/>
+ <include key="dpml-parts-api"/>
<include key="dpml-composition-testing-acme"/>
- <include key="dpml-composition-unit" runtime="false"/>
- <include key="dpml-util-exception" runtime="false"/>
+ <include key="dpml-composition-unit"/>
+ <include key="dpml-util-exception"/>
</dependencies>
<plugins>
<include key="dpml-composition-builder"/>
@@ -944,7 +880,7 @@
<include key="dpml-transit-main" tag="api"/>
<include key="dpml-activation-api" tag="api"/>
<include key="dpml-composition-api" tag="api"/>
- <include key="dpml-automation-control" tag="api"/>
+ <include key="dpml-parts-api" tag="api"/>
<include key="dpml-activation-metro-provider" build="false"/>
<include key="dpml-activation-avalon-provider" build="false"/>
<include key="dpml-system-impl" build="false"/>
@@ -1221,6 +1157,7 @@
<group>xerces</group>
</info>
</resource>
+
<resource>
<info>
<name>xstream</name>

Modified:
development/main/metro/meta/api/src/main/net/dpml/meta/info/PartDescriptor.java
==============================================================================
---
development/main/metro/meta/api/src/main/net/dpml/meta/info/PartDescriptor.java
(original)
+++
development/main/metro/meta/api/src/main/net/dpml/meta/info/PartDescriptor.java
Fri Apr 22 02:43:03 2005
@@ -69,7 +69,8 @@
public static final String CONTEXT_MANAGER_KEY = "ContextManager";
public static final String PARTS_MANAGER_KEY = "PartsManager";
public static final String PARTS_MAP_KEY = "PartsMap";
- public static final String STATE_MANAGER_KEY = "StateManager";
+ public static final String MANAGER_KEY = "Manager";
+ public static final String MODEL_KEY = "Model";
public static final String ENTRY_KEY = "Entry";

public static String toString( int semantic )
@@ -111,14 +112,18 @@
{
return PARTS_MANAGER_KEY;
}
- else if( name.endsWith( STATE_MANAGER_KEY ) )
- {
- return STATE_MANAGER_KEY;
- }
else if( name.endsWith( PARTS_MAP_KEY ) )
{
return PARTS_MAP_KEY;
}
+ else if( name.endsWith( MODEL_KEY ) )
+ {
+ return MODEL_KEY;
+ }
+ else if( name.endsWith( MANAGER_KEY ) )
+ {
+ return MANAGER_KEY;
+ }
else if( name.endsWith( ENTRY_KEY ) )
{
return ENTRY_KEY;
@@ -197,16 +202,23 @@
String substring = name.substring( 0, j );
return formatKey( substring, 6 );
}
- else if( name.endsWith( STATE_MANAGER_KEY ) )
+ else if( name.endsWith( PARTS_MAP_KEY ) )
{
- int n = STATE_MANAGER_KEY.length();
+ int n = PARTS_MAP_KEY.length();
int j = name.length() - n;
String substring = name.substring( 0, j );
return formatKey( substring, 6 );
}
- else if( name.endsWith( PARTS_MAP_KEY ) )
+ else if( name.endsWith( MANAGER_KEY ) )
{
- int n = PARTS_MAP_KEY.length();
+ int n = MANAGER_KEY.length();
+ int j = name.length() - n;
+ String substring = name.substring( 0, j );
+ return formatKey( substring, 6 );
+ }
+ else if( name.endsWith( MODEL_KEY ) )
+ {
+ int n = MODEL_KEY.length();
int j = name.length() - n;
String substring = name.substring( 0, j );
return formatKey( substring, 6 );

Added: development/main/metro/parts/build.properties
==============================================================================
--- (empty file)
+++ development/main/metro/parts/build.properties Fri Apr 22 02:43:03
2005
@@ -0,0 +1,2 @@
+
+project.test.fork = true

Copied: development/main/metro/parts/build.xml (from r2352,
development/main/metro/automation/build.xml)
==============================================================================
--- development/main/metro/automation/build.xml (original)
+++ development/main/metro/parts/build.xml Fri Apr 22 02:43:03 2005
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>

-<project name="dpml-automation" default="default" basedir="."
+<project name="dpml-parts-api" default="default" basedir="."
xmlns:transit="antlib:net.dpml.transit">

- <transit:import uri="artifact:template:dpml/magic/reactor"/>
+ <transit:import uri="artifact:template:dpml/magic/standard"/>

</project>


Added:
development/main/metro/parts/src/main/net/dpml/parts/builder/Builder.java
==============================================================================
--- (empty file)
+++ development/main/metro/parts/src/main/net/dpml/parts/builder/Builder.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,38 @@
+/*
+ * 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.parts.builder;
+
+import java.net.URI;
+
+/**
+ * The abstract contract for builders that create a objects that are builder
identified.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface Builder
+{
+ /**
+ * Return a uri identitifying the builder.
+ *
+ * @return the builder uri
+ */
+ URI getBuilderURI();
+
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/builder/BuilderRuntimeException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/builder/BuilderRuntimeException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,33 @@
+/*
+ * 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.parts.builder;
+
+/**
+ * An exception throws if an internal error occurs during builder execution.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class BuilderRuntimeException extends RuntimeException
+{
+ public BuilderRuntimeException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/builder/IntrospectionException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/builder/IntrospectionException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,33 @@
+/*
+ * 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.parts.builder;
+
+/**
+ * An exception throws if an error occurs while introspecting a method or
class.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class IntrospectionException extends Exception
+{
+ public IntrospectionException( String message )
+ {
+ super( message );
+ }
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/builder/PartBuilder.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/builder/PartBuilder.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,50 @@
+/*
+ * 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.parts.builder;
+
+import java.io.IOException;
+import java.net.URI;
+
+import net.dpml.parts.part.Part;
+
+/**
+ * The contract for builders that create component parts.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface PartBuilder extends Builder
+{
+
+ /**
+ * Return a urn identitifying the part handler for this builder.
+ *
+ * @return a strategy uri
+ */
+ URI getPartHandlerURI();
+
+ /**
+ * Build the part.
+ * @param classloader the classloader to use if type creation is required
+ * @return the serializable part
+ * @exception Exception if a construction error occurs
+ */
+ Part buildPart( ClassLoader classloader )
+ throws IntrospectionException, IOException, ClassNotFoundException;
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/Control.java
==============================================================================
--- (empty file)
+++ development/main/metro/parts/src/main/net/dpml/parts/control/Control.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,36 @@
+/*
+ * 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.parts.control;
+
+
+/**
+ * Common interface implemented by controls.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface Control extends Identifiable
+{
+ /**
+ * Return a human readable short name of the controller.
+ * @return the controller name
+ */
+ String getName();
+
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/ControlException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/ControlException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,77 @@
+/*
+ * 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.parts.control;
+
+import java.net.URI;
+
+/**
+ * Exception indicating an controller related error. A controller exception
+ * delcares the URI of the controller form which the exception was initiated.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class ControlException extends Exception
+{
+ private final URI m_uri;
+
+ /**
+ * Creation of a new ControlException.
+ *
+ * @param controller the uri identifying the controller iniating the
exception
+ */
+ public ControlException( URI controller )
+ {
+ this( controller, null );
+ }
+
+ /**
+ * Creation of a new ControlException.
+ *
+ * @param controller the uri identifying the controller iniating the
exception
+ * @param message the description of the exception
+ */
+ public ControlException( URI controller, String message )
+ {
+ this( controller, message, null );
+ }
+
+ /**
+ * Creation of a new ControlException.
+ *
+ * @param controller the uri identifying the controller iniating the
exception
+ * @param message the description of the exception
+ * @param cause the causal exception
+ */
+ public ControlException( URI controller, String message, Throwable cause
)
+ {
+ super( message, cause );
+ m_uri = controller;
+ }
+
+ /**
+ * Return the uri of the controller initiating this exception.
+ * @return the controller uri
+ */
+ public URI getControlURI()
+ {
+ return m_uri;
+ }
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/ControlRuntimeException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/ControlRuntimeException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,78 @@
+/*
+ * 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.parts.control;
+
+import java.net.URI;
+
+/**
+ * Exception indicating an unexpected controller related error. A
controller
+ * runtime exception delcares the URI of the controller form which the
exception
+ * was initiated.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class ControlRuntimeException extends RuntimeException
+{
+ private final URI m_uri;
+
+ /**
+ * Creation of a new ControlRuntimeException.
+ *
+ * @param controller the uri identifying the controller iniating the
exception
+ */
+ public ControlRuntimeException( URI controller )
+ {
+ this( controller, null );
+ }
+
+ /**
+ * Creation of a new ControlRuntimeException.
+ *
+ * @param controller the uri identifying the controller iniating the
exception
+ * @param message the description of the exception
+ */
+ public ControlRuntimeException( URI controller, String message )
+ {
+ this( controller, message, null );
+ }
+
+ /**
+ * Creation of a new ControlRuntimeException.
+ *
+ * @param controller the uri identifying the controller iniating the
exception
+ * @param message the description of the exception
+ * @param cause the causal exception
+ */
+ public ControlRuntimeException( URI controller, String message,
Throwable cause )
+ {
+ super( message, cause );
+ m_uri = controller;
+ }
+
+ /**
+ * Return the uri of the controller initiating this exception.
+ * @return the controller uri
+ */
+ public URI getControlURI()
+ {
+ return m_uri;
+ }
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/Controller.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/Controller.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,129 @@
+/*
+ * 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.parts.control;
+
+import java.net.URI;
+import java.util.Map.Entry;
+
+import net.dpml.parts.model.Model;
+import net.dpml.parts.model.ModelException;
+import net.dpml.parts.part.Part;
+
+/**
+ * The Controller interface defines the a contract for a object that is
capable of
+ * operation management of a set of arbitary models together with part
handling for
+ * a particular part strategy.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface Controller extends Control
+{
+ /**
+ * Return a resource relative to the supplied urn. Standard
+ * urn values are listed in the following table.
+ *
+ * <ol>
+ * <li>system:domain.uri</li>
+ * <li>system:work.dir</li>
+ * <li>system:temp.dir</li>
+ * <li>model:name</li>
+ * <li>model:urn</li>
+ * <li>model:partition</li>
+ * </ol>
+ *
+ * An implementation may choose to provide support for additional urns
beyond those
+ * listed in the above table.
+ *
+ * @param model the model from which any model relative urn values are to
be resolved
+ * @param urn the uniform resource identifier identifying the requested
resource
+ * @return the resource matching the supplied urn
+ * @exception IllegalStateException if the supplied urn is not valid
+ */
+ Object getResource( Model model, URI urn );
+
+ /**
+ * Create a return a new model for a supplied part.
+ *
+ * @param partition the enclosing partition
+ * @param parent the parent classloader
+ * @param part the part datastructure
+ * @param name the name to assign to the model
+ * @return the model
+ */
+ Model getModel( ClassLoader parent, Part part, String name )
+ throws ModelException;
+
+ /**
+ * Create and return an entry containing the default instance of the part
managed
+ * by the supplied model.
+ *
+ * @param model the component model
+ * @return an entry containing instance value
+ */
+ //Entry create( Model model ) throws Exception;
+
+ /**
+ * Create and return an entry containing an identifiable instance of the
part managed
+ * by the supplied model.
+ *
+ * @param model the component model
+ * @param key the instance key
+ * @return an entry containing the key and instance value
+ */
+ //Entry create( Model model, Object key ) throws Exception;
+
+ /**
+ * Create and return a new instance of the component represented
+ * by the supplied model.
+ *
+ * @param model the component model
+ * @return the resolved instance
+ */
+ Object resolve( Model model ) throws Exception;
+
+ /**
+ * Return an identified instance of the component type represented
+ * by the supplied model.
+ *
+ * @param model the component model
+ * @param key the instance identifier
+ * @return the resolved instance
+ */
+ Object resolve( Model model, Object key ) throws Exception;
+
+ /**
+ * Return an identified instance of the component type represented
+ * by the supplied model.
+ *
+ * @param model the component model
+ * @param key the instance identifier
+ * @param policy the proxy creation policy
+ * @return the resolved instance
+ */
+ Object resolve( Model model, Object key, boolean policy ) throws
Exception;
+
+ /**
+ * Return a component instance
+ *
+ * @param instance the instance to release
+ */
+ void release( Object instance );
+
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/DelegationException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/DelegationException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,45 @@
+/*
+ * 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.parts.control;
+
+import java.net.URI;
+
+/**
+ * Exception thrown when an attempt is made to reference an unknown handler.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class DelegationException extends Exception
+{
+ private URI m_target;
+
+ public DelegationException( URI target, String message, Throwable cause )
+ {
+ super( message, cause );
+ m_target = target;
+ }
+
+ public URI getDelegationTarget()
+ {
+ return m_target;
+ }
+
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/Disposable.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/Disposable.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,34 @@
+/*
+ * 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.parts.control;
+
+
+/**
+ * Common interface implemented by disposable objects.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface Disposable
+{
+ /**
+ * Dispose of the object.
+ */
+ void dispose();
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/DuplicateNameException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/DuplicateNameException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,43 @@
+/*
+ * 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.parts.control;
+
+/**
+ * Exception thrown when an attempt is made to reference an unknown handler.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class DuplicateNameException extends Exception
+{
+ private String m_name;
+
+ public DuplicateNameException( String name )
+ {
+ super( name );
+ m_name = name;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/EntryNotFoundException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/EntryNotFoundException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,63 @@
+/*
+ * 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.parts.control;
+
+import java.net.URI;
+
+/**
+ * Exception thrown when an attempt is made to reference an unknown part.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class EntryNotFoundException extends Exception
+{
+ private URI m_model;
+ private URI m_query;
+
+ public EntryNotFoundException( URI model, URI query )
+ {
+ super( buildMessage( model, query ) );
+ m_model = model;
+ m_query = query;
+ }
+
+ public URI getModelURI()
+ {
+ return m_model;
+ }
+
+ public URI getQuery()
+ {
+ return m_query;
+ }
+
+ private static String buildMessage( URI model, URI query )
+ {
+ final String error =
+ "Could not locate an entry within the enclosing model ["
+ + model
+ + "] relative to the query ["
+ + query
+ + "].";
+ return error;
+ }
+
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/HandlerNotFoundException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/HandlerNotFoundException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,50 @@
+/*
+ * 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.parts.control;
+
+import java.net.URI;
+
+/**
+ * Exception thrown when an attempt is made to reference an unknown handler.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class HandlerNotFoundException extends Exception
+{
+ private URI m_uri;
+
+ public HandlerNotFoundException( URI uri )
+ {
+ this( uri, null );
+ }
+
+ public HandlerNotFoundException( URI uri, Throwable cause )
+ {
+ super( uri.toString(), cause );
+ m_uri = uri;
+ }
+
+ public URI getURI()
+ {
+ return m_uri;
+ }
+
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/Identifiable.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/Identifiable.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,36 @@
+/*
+ * 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.parts.control;
+
+import java.net.URI;
+
+/**
+ * Interface implemented by objects that expose an identity.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface Identifiable
+{
+ /**
+ * Returns the identity of the object implementing this interface.
+ * @return a uri identifying the object
+ */
+ URI getURI();
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/InvalidQueryException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/InvalidQueryException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,65 @@
+/*
+ * 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.parts.control;
+
+import java.net.URI;
+
+/**
+ * Exception thrown in response to an attempt to register a part model
+ * under a key that is already assigned.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class InvalidQueryException extends ControlRuntimeException
+{
+ private URI m_model;
+ private URI m_query;
+
+ public InvalidQueryException( URI control, URI model, URI query )
+ {
+ super( control );
+ m_model = model;
+ m_query = query;
+ }
+
+ public URI getModelURI()
+ {
+ return m_model;
+ }
+
+ public URI getQueryURI()
+ {
+ return m_query;
+ }
+
+ public String getMessage()
+ {
+ final String error =
+ "Invalid query."
+ + "\nController: "
+ + getControlURI()
+ + "\nModel: "
+ + getModelURI()
+ + "\nQuery: "
+ + getQueryURI();
+ return error;
+ }
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/LifecycleException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/LifecycleException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,50 @@
+/*
+ * 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.parts.control;
+
+import net.dpml.parts.model.Model;
+
+
+/**
+ * Exception to indicate that there was a lifecycle related error.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: LifecycleException.java 259 2004-10-30 07:24:40Z mcconnell $
+ */
+public class LifecycleException
+ extends Exception
+{
+ private Model m_model;
+
+ /**
+ * Construct a new <code>LifecycleException</code> instance.
+ *
+ * @param throwable the root cause of the exception
+ */
+ public LifecycleException( final Model model, final Throwable throwable )
+ {
+ super( null, throwable );
+ }
+
+ public Model getModel()
+ {
+ return m_model;
+ }
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/LifecycleRuntimeException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/LifecycleRuntimeException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,51 @@
+/*
+ * 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.parts.control;
+
+/**
+ * Exception to indicate that there was a lifecycle runtime related error.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: LifecycleRuntimeException.java 259 2004-10-30 07:24:40Z
mcconnell $
+ */
+public class LifecycleRuntimeException
+ extends RuntimeException
+{
+ /**
+ * Construct a new <code>LifecycleRuntimeException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ */
+ public LifecycleRuntimeException( final String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * Construct a new <code>LifecycleRuntimeException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ * @param throwable the root cause of the exception
+ */
+ public LifecycleRuntimeException( final String message, final Throwable
throwable )
+ {
+ super( message, throwable );
+ }
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/LifestyleException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/LifestyleException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,51 @@
+/*
+ * 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.parts.control;
+
+/**
+ * Exception to indicate that there was a lifecycle related error.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: LifecycleException.java 259 2004-10-30 07:24:40Z mcconnell $
+ */
+public class LifestyleException
+ extends Exception
+{
+ /**
+ * Construct a new <code>LifecycleException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ */
+ public LifestyleException( final String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * Construct a new <code>LifestyleException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ * @param throwable the root cause of the exception
+ */
+ public LifestyleException( final String message, final Throwable
throwable )
+ {
+ super( message, throwable );
+ }
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/Manageable.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/Manageable.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,42 @@
+/*
+ * 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.parts.control;
+
+import net.dpml.parts.model.Model;
+
+import net.dpml.parts.state.Manager;
+
+/**
+ * The Manager interface is an interface representing a component controller.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public interface Manageable
+{
+ /**
+ * Return a Manager for the default instance.
+ */
+ Manager getManager( Model model ) throws Exception;
+
+ /**
+ * Return a Manager for the identified instance.
+ */
+ Manager getManager( Model model, Object key ) throws Exception;
+
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/Monitor.java
==============================================================================
--- (empty file)
+++ development/main/metro/parts/src/main/net/dpml/parts/control/Monitor.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,95 @@
+/*
+ * 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.parts.control;
+
+/**
+ * Monitor supplied to a startable controller.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface Monitor
+{
+ /**
+ * Returns TRUE if debug level monitoring is enabled.
+ *
+ * @return TRUE if DEBUG level monitoring is enabled
+ */
+ boolean isDebugEnabled();
+
+ /**
+ * Returns TRUE if info level monitoring is enabled.
+ *
+ * @return TRUE if INFO level monitoring is enabled
+ */
+ boolean isInfoEnabled();
+
+ /**
+ * Returns TRUE if warn level monitoring is enabled.
+ *
+ * @return TRUE if WARN level monitoring is enabled
+ */
+ boolean isWarnEnabled();
+
+ /**
+ * Returns TRUE if error level monitoring is enabled.
+ *
+ * @return TRUE if ERROR level monitoring is enabled
+ */
+ boolean isErrorEnabled();
+
+ /**
+ * Log the supplied debug level message.
+ * @param message the message to log
+ */
+ void debug( String message );
+
+ /**
+ * Log the supplied info level message.
+ * @param message the message to log
+ */
+ void info( String message );
+
+ /**
+ * Log the supplied info level message.
+ * @param message the message to log
+ */
+ void warn( String message );
+
+ /**
+ * Log the supplied error level message.
+ * @param message the message to log
+ * @param throwable the exception
+ */
+ void error( String message, Throwable throwable );
+
+ /**
+ * Log the monitor of a normal termination.
+ * @param status TRUE if the monitor completed all scheduled activities
+ * without interruption
+ */
+ void notifyCompletion( boolean status );
+
+ /**
+ * Log the monitor of a runtime failure.
+ * @param throwable the failure cause
+ */
+ void notifyFailure( Throwable throwable );
+
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/NoSuchControlException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/NoSuchControlException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,33 @@
+/*
+ * 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.parts.control;
+
+/**
+ * An exception thrown in responde to a request for an unknown control.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class NoSuchControlException extends Exception
+{
+ public NoSuchControlException( String name )
+ {
+ super( name );
+ }
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/PartHandler.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/PartHandler.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,69 @@
+/*
+ * 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.parts.control;
+
+import java.io.IOException;
+import java.net.URI;
+
+import net.dpml.parts.part.Part;
+
+/**
+ * Definition of a part handler.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface PartHandler
+{
+ /**
+ * Returns the uri of the handler.
+ * @return the handler uri
+ */
+ URI getURI();
+
+ /**
+ * Load the model controller.
+ * @return the controller
+ */
+ Controller getController();
+
+ /**
+ * Load a part handler giiven a handler uri.
+ * @return the part handler
+ */
+ PartHandler loadPartHandler( URI uri )
+ throws HandlerNotFoundException, IOException, DelegationException;
+
+ /**
+ * Load a part from serialized form. The uri is assumed to be a uri that
+ * can be transformed to a URL from which an input stream to a PartHolder
+ * can be established.
+ *
+ * @return the part estracted from the part handler referenced by the uri
+ */
+ public Part loadPart( URI uri )
+ throws DelegationException, PartNotFoundException, IOException;
+
+ /**
+ * Load a part from a serialized object byte array.
+ * @param bytes the byte array
+ * @return the part
+ */
+ Part loadPart( byte[] bytes ) throws IOException;
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/PartHandlerRuntimeException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/PartHandlerRuntimeException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,35 @@
+/*
+ * 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.parts.control;
+
+/**
+ * Unexpected runtime exception indicating an internal part handler error.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class PartHandlerRuntimeException extends RuntimeException
+{
+ public PartHandlerRuntimeException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/PartNotFoundException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/PartNotFoundException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,79 @@
+/*
+ * 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.parts.control;
+
+import java.net.URI;
+
+/**
+ * Exception thrown when an attempt is made to reference an unknown part.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class PartNotFoundException extends Exception
+{
+ private URI m_target;
+ private URI m_parent;
+
+ public PartNotFoundException( URI target )
+ {
+ this( target, null );
+ }
+
+ public PartNotFoundException( URI parent, URI target )
+ {
+ super( buildMessage( parent, target ) );
+ m_target = target;
+ m_parent = parent;
+ }
+
+ public URI getParentURI()
+ {
+ return m_parent;
+ }
+
+ public URI getTargetURI()
+ {
+ return m_target;
+ }
+
+ private static String buildMessage( URI parent, URI target )
+ {
+ if( null != parent )
+ {
+ final String error =
+ "Could not find the a part uri ["
+ + target
+ + "] relative to the enclosing part ["
+ + parent.toString()
+ + "].";
+ return error;
+ }
+ else
+ {
+ final String error =
+ "Could not find a part ["
+ + target
+ + "].";
+ return error;
+ }
+ }
+
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/SystemManager.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/SystemManager.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,66 @@
+/*
+ * 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.parts.control;
+
+import java.io.IOException;
+import java.net.URI;
+
+import net.dpml.parts.model.Model;
+import net.dpml.parts.model.ModelException;
+
+/**
+ * The SystemManager interface defines the a contract for a object that is
capable of
+ * operational management of a set of arbitary models within the scope of a
single
+ * jvm.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface SystemManager extends Controller
+{
+ /**
+ * Add a part designated by a supplied uri to the system scope.
+ * @param uri a part uri
+ * @return the management view of the loaded part
+ */
+ Model addPart( URI uri, String key ) throws IOException,
DelegationException, ModelException, PartNotFoundException;
+
+ /**
+ * Add a model to the system scope.
+ * @param model the model to add to the controller
+ */
+ void addModel( Model model );
+
+ /**
+ * Start the system.
+ * @exception if a startup failure occurs
+ */
+ void start() throws Exception;
+
+ /**
+ * Stop the system.
+ */
+ void stop();
+
+ /**
+ * Dispose of the manager.
+ */
+ //void dispose();
+
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/UnknownSchemaException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/UnknownSchemaException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,64 @@
+/*
+ * 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.parts.control;
+
+import java.net.URI;
+
+/**
+ * Exception thrown when an attempt is made to reference an unknown handler.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class UnknownSchemaException extends ControlException
+{
+ private URI m_query;
+ private URI m_model;
+
+ public UnknownSchemaException( URI controller, URI model, URI query )
+ {
+ super( controller );
+ m_query = query;
+ m_model = model;
+ }
+
+ public URI getQueryURI()
+ {
+ return m_query;
+ }
+
+ public URI getModelURI()
+ {
+ return m_model;
+ }
+
+ public String getMessage()
+ {
+ final String error =
+ "Schema not recognized."
+ + "\nController: "
+ + getControlURI()
+ + "\nModel: "
+ + getModelURI()
+ + "\nQuery: "
+ + getQueryURI();
+ return error;
+ }
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/control/UnsupportedPartTypeException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/control/UnsupportedPartTypeException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,52 @@
+/*
+ * 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.parts.control;
+
+import net.dpml.parts.part.Part;
+
+/**
+ * Exception thrown when an strategy handler attempts to handle an
+ * incompatible type.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class UnsupportedPartTypeException extends RuntimeException
+{
+ private String m_type;
+
+ public UnsupportedPartTypeException( Part part )
+ {
+ this( part.getClass().getName() );
+ }
+
+ public UnsupportedPartTypeException( String classname )
+ {
+ super( classname );
+ m_type = classname;
+ }
+
+ public String getPartTypeClassname()
+ {
+ return m_type;
+ }
+
+}
+
+

Added: development/main/metro/parts/src/main/net/dpml/parts/model/Model.java
==============================================================================
--- (empty file)
+++ development/main/metro/parts/src/main/net/dpml/parts/model/Model.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,56 @@
+/*
+ * 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.parts.model;
+
+import java.net.URI;
+import java.util.Map.Entry;
+
+import net.dpml.parts.control.Controller;
+import net.dpml.parts.control.Identifiable;
+
+import net.dpml.parts.state.Manager;
+
+
+/**
+ * The Model interface defines a common view of a component part. Operations
+ * delcared on this interface concern the managment of the model state.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface Model extends Entry, Identifiable
+{
+ /**
+ * Return the primary controller assigned to the model.
+ * @return the primary controller
+ */
+ Controller getController();
+
+ /**
+ * Return the uri identifying the partition that this model is enclosed
within.
+ * @return the partition uri
+ */
+ URI getPartition();
+
+ /**
+ * Return a Manager for the default instance.
+ */
+ Manager getManager() throws Exception;
+
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/model/ModelException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/model/ModelException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,40 @@
+/*
+ * 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.parts.model;
+
+/**
+ * Unexpected runtime exception indicating an internal model error.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class ModelException extends Exception
+{
+ public ModelException( String message )
+ {
+ this( message, null );
+ }
+
+ public ModelException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/model/ModelRuntimeException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/model/ModelRuntimeException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,39 @@
+/*
+ * 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.parts.model;
+
+/**
+ * Unexpected runtime exception indicating an internal model error.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class ModelRuntimeException extends RuntimeException
+{
+ public ModelRuntimeException( String message )
+ {
+ super( message );
+ }
+
+ public ModelRuntimeException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/model/PartClassNotFoundException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/model/PartClassNotFoundException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,43 @@
+/*
+ * 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.parts.model;
+
+/**
+ * Exception thrown when an attempt is made to locate a class declared
+ * by a parts accessor and the class cannot be found.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class PartClassNotFoundException extends ModelRuntimeException
+{
+ private String m_classname;
+
+ public PartClassNotFoundException( String classname )
+ {
+ super( classname );
+ m_classname = classname;
+ }
+
+ public String getClassname()
+ {
+ return m_classname;
+ }
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/model/ServiceClassNotFoundException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/model/ServiceClassNotFoundException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,61 @@
+/*
+ * 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.parts.model;
+
+/**
+ * Unexpected runtime exception indicating an internal model error.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class ServiceClassNotFoundException extends ModelRuntimeException
+{
+ private String m_serviceClassname;
+ private String m_componentClassname;
+
+ public ServiceClassNotFoundException( String componentClassname, String
serviceClassname )
+ {
+ super( buildMessage( componentClassname, serviceClassname ) );
+ m_serviceClassname = serviceClassname;
+ m_componentClassname = componentClassname;
+ }
+
+ public String getComponentClassname()
+ {
+ return m_componentClassname;
+ }
+
+ public String getServiceClassname()
+ {
+ return m_serviceClassname;
+ }
+
+ private static String buildMessage( String componentClassname, String
serviceClassname )
+ {
+ String error =
+ "Service class ["
+ + serviceClassname
+ + "] declared by the component type ["
+ + componentClassname
+ + "] was not found.";
+ return error;
+ }
+
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/model/TypeClassNotFoundException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/model/TypeClassNotFoundException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,42 @@
+/*
+ * 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.parts.model;
+
+/**
+ * Unexpected runtime exception indicating an internal model error.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class TypeClassNotFoundException extends ModelRuntimeException
+{
+ private String m_classname;
+
+ public TypeClassNotFoundException( String classname )
+ {
+ super( classname );
+ m_classname = classname;
+ }
+
+ public String getClassname()
+ {
+ return m_classname;
+ }
+}
+

Added: development/main/metro/parts/src/main/net/dpml/parts/part/Part.java
==============================================================================
--- (empty file)
+++ development/main/metro/parts/src/main/net/dpml/parts/part/Part.java Fri
Apr 22 02:43:03 2005
@@ -0,0 +1,40 @@
+/*
+ * 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.parts.part;
+
+import java.io.Serializable;
+import java.net.URI;
+
+/**
+ * The common interface implemented by all parts.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public interface Part extends Serializable
+{
+ static final String ARTIFACT_TYPE = "part";
+
+ /**
+ * Return the part handler uri.
+ * @return the uri of the part handler
+ */
+ URI getPartHandlerURI();
+
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/part/PartHolder.java
==============================================================================
--- (empty file)
+++ development/main/metro/parts/src/main/net/dpml/parts/part/PartHolder.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,97 @@
+/*
+ * 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.parts.part;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Arrays;
+
+/**
+ *
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class PartHolder implements Serializable
+{
+ private final URI m_handler;
+ private final byte[] m_part;
+
+ public PartHolder( URI handler, byte[] part )
+ {
+ m_handler = handler;
+ m_part = part;
+ }
+
+ public URI getPartHandlerURI()
+ {
+ return m_handler;
+ }
+
+ public byte[] getByteArray()
+ {
+ return m_part;
+ }
+
+ public int hashCode()
+ {
+ int hash = super.hashCode();
+ hash ^= m_handler.hashCode();
+ for( int i=0; i<m_part.length; i++ )
+ {
+ hash ^= new Byte( m_part[i] ).hashCode();
+ }
+ return hash;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof PartHolder )
+ {
+ PartHolder holder = (PartHolder) other;
+ if( getPartHandlerURI().equals( holder.getPartHandlerURI() ) ==
false )
+ {
+ return false;
+ }
+ else if( Arrays.equals( getByteArray(), holder.getByteArray() )
== false )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public String toString()
+ {
+ return "[part-holder handler:" + m_handler + " size:" +
m_part.length + "]";
+ }
+
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/part/PartReference.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/part/PartReference.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,122 @@
+/*
+ * 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.parts.part;
+
+import java.io.Serializable;
+
+
+/**
+ * A <code>PartReference</code> is a serializable object that contains a key
and
+ * an associated part.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: Parameter.java 2119 2005-03-23 02:04:46Z mcconnell AT dpml.net
$
+ */
+public class PartReference implements Serializable
+{
+ /**
+ * The key.
+ */
+ private final String m_key;
+
+ /**
+ * The supplied argument.
+ */
+ private Part m_part;
+
+ /**
+ * Creation of a new parameter using the default
<code>java.lang.String</code>
+ * type and a supplied value.
+ *
+ * @param value the string value
+ */
+ public PartReference( final String key, Part part )
+ {
+ if( null == key )
+ {
+ throw new NullPointerException( "key" );
+ }
+ if( null == part )
+ {
+ throw new NullPointerException( "part" );
+ }
+ m_key = key;
+ m_part = part;
+ }
+
+ /**
+ * Return the key.
+ * @return the key
+ */
+ public String getKey()
+ {
+ return m_key;
+ }
+
+ /**
+ * Return the part.
+ */
+ public Part getPart()
+ {
+ return m_part;
+ }
+
+ /**
+ * 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( false == ( other instanceof PartReference ) )
+ {
+ return false;
+ }
+ else
+ {
+ PartReference reference = (PartReference) other;
+ if( false == m_key.equals( reference.getKey() ) )
+ {
+ return false;
+ }
+ else
+ {
+ return m_part.equals( reference.getPart() );
+ }
+ }
+ }
+ }
+
+ /**
+ * Return the hashcode for the instance.
+ * @return the instance hashcode
+ */
+ public int hashCode()
+ {
+ int hash = m_key.hashCode();
+ hash ^= m_part.hashCode();
+ return hash;
+ }
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/state/DuplicateKeyException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/state/DuplicateKeyException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,42 @@
+/*
+ * 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.parts.state;
+
+
+/**
+ * Exception thrown when a operation attempts to overrite an existing key.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class DuplicateKeyException extends RuntimeException
+{
+ private String m_transition;
+
+ /**
+ * Construct a new <code>DuplicateKeyException</code> instance.
+ *
+ * @param transition the transition name
+ */
+ public DuplicateKeyException( final String transition )
+ {
+ super( transition );
+ }
+
+}
+

Added: development/main/metro/parts/src/main/net/dpml/parts/state/Manager.java
==============================================================================
--- (empty file)
+++ development/main/metro/parts/src/main/net/dpml/parts/state/Manager.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,61 @@
+/*
+ * 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.parts.state;
+
+/**
+ * The Manager interface is an interface representing a component controller.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public interface Manager
+{
+ /**
+ * Initialize the component.
+ */
+ Object initialize() throws Exception;
+
+ /**
+ * Return the current state of the component.
+ * @return the current state
+ */
+ State getState();
+
+ /**
+ * Applies a state transition identified by a supplied transition key.
+ *
+ * @param key the key identifying the transition to apply to the
component's controller
+ * @return the state resulting from the transition
+ * @exception if a transition error occurs
+ */
+ State apply( String key ) throws Exception;
+
+ /**
+ * Executes an operation identified by a supplied operation key.
+ *
+ * @param key the key identifying the operation to execute
+ * @exception if a transition error occurs
+ */
+ void execute( String key ) throws Exception;
+
+ /**
+ * Termination of the component.
+ */
+ void terminate();
+
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/state/NoSuchOperationException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/state/NoSuchOperationException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,41 @@
+/*
+ * 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.parts.state;
+
+
+/**
+ * Exception thrown when a request is made for retrival of an operation
+ * via an operation key and the key is unresolvable.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class NoSuchOperationException extends RuntimeException
+{
+ /**
+ * Construct a new <code>NoSuchOperationException</code> instance.
+ *
+ * @param key the operation key
+ */
+ public NoSuchOperationException( final String key )
+ {
+ super( key );
+ }
+
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/state/NoSuchStateException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/state/NoSuchStateException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,43 @@
+/*
+ * 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.parts.state;
+
+
+/**
+ * Exception thrown when a request is made to apply a transition that is
unknown
+ * relative to the target state.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class NoSuchStateException extends RuntimeException
+{
+ private String m_transition;
+
+ /**
+ * Construct a new <code>NoSuchStateException</code> instance.
+ *
+ * @param transition the transition name
+ */
+ public NoSuchStateException( final String transition )
+ {
+ super( transition );
+ }
+
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/state/NoSuchTransitionException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/state/NoSuchTransitionException.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,43 @@
+/*
+ * 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.parts.state;
+
+
+/**
+ * Exception thrown when a request is made to apply a transition that is
unknown
+ * relative to the target state.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class NoSuchTransitionException extends RuntimeException
+{
+ private String m_transition;
+
+ /**
+ * Construct a new <code>NoSuchTransitionException</code> instance.
+ *
+ * @param transition the transition name
+ */
+ public NoSuchTransitionException( final String transition )
+ {
+ super( transition );
+ }
+
+}
+

Added:
development/main/metro/parts/src/main/net/dpml/parts/state/Operation.java
==============================================================================
--- (empty file)
+++ development/main/metro/parts/src/main/net/dpml/parts/state/Operation.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,33 @@
+/*
+ * 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.parts.state;
+
+/**
+ * The Operation interface is a base interface to actions executable withing
+ * scope of a state. An implementation of an operation must implement a
single
+ * "execute" method. Argument parameter applied to the execute method will
be
+ * resolved by the state manager relative to the runtime context and
declared
+ * parameter types.
+ *
+ * @author <a href="mailto:info AT dpml.net";>The Digital Product Meta
Library</a>
+ */
+public interface Operation
+{
+ // public void execute( .... ) throws Exception;
+}

Added: development/main/metro/parts/src/main/net/dpml/parts/state/State.java
==============================================================================
--- (empty file)
+++ development/main/metro/parts/src/main/net/dpml/parts/state/State.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,54 @@
+/*
+ * 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.parts.state;
+
+/**
+ * The State interface is an interface representing an immutable state of
+ * a component instance.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public interface State
+{
+ /**
+ * Return the name of the state.
+ * @return the state name
+ */
+ String getName();
+
+ /**
+ * Return the array of available transition names.
+ *
+ * @return the transition names
+ */
+ String[] getTransitionNames();
+
+ /**
+ * Return the array of available operation names.
+ *
+ * @return the operation names
+ */
+ String[] getOperationNames();
+
+ /**
+ * Return true if this is a terminal state.
+ * @return TRUE if terminal
+ */
+ boolean isTerminal();
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/state/Transition.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/state/Transition.java
Fri Apr 22 02:43:03 2005
@@ -0,0 +1,34 @@
+/*
+ * 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.parts.state;
+
+/**
+ * The Transition interface delcares the target state and system or user
+ * mode in which this transition exists.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public interface Transition
+{
+ /**
+ * Return the target of this transition.
+ * @return the transition target
+ */
+ State getTargetState();
+}

Added:
development/main/metro/parts/src/main/net/dpml/parts/state/ValidationException.java
==============================================================================
--- (empty file)
+++
development/main/metro/parts/src/main/net/dpml/parts/state/ValidationException.java
Fri Apr 22 02:43:03 2005
@@ -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.parts.state;
+
+
+/**
+ * Exception indication a validate failure raised by a state manager as
+ * a part of the manager initialization.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class ValidationException extends Exception
+{
+ /**
+ * Construct a new <code>ValidationException</code> instance.
+ *
+ * @param message the exception message
+ */
+ public ValidationException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * Construct a new <code>ValidationException</code> instance.
+ *
+ * @param message the exception message
+ * @param cause the causal exception
+ */
+ public ValidationException( final String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+}
+



  • svn commit: r2353 - in development/main/metro: . activity/api activity/impl automation composition/api/src/main/net/dpml/composition/data composition/api/src/test/net/dpml/composition/data/test composition/builder/src/main/net/dpml/composition/builder composition/builder/src/main/net/dpml/composition/builder/datatypes composition/control/src/main/net/dpml/composition/control composition/control/src/main/net/dpml/composition/models composition/control/src/main/net/dpml/composition/state composition/control/src/test composition/control/src/test/net composition/control/src/test/net/dpml composition/control/src/test/net/dpml/composition composition/control/src/test/net/dpml/composition/state composition/impl/src/main/net/dpml/composition/data/builder composition/impl/src/main/net/dpml/composition/model/impl composition/testing/acme/src/main/net/dpml/composition/testing composition/testing/activity composition/testing/unit composition/testing/unit/src/main composition/testing/unit/src/main/net composition/testing/unit/src/main/net/dpml composition/testing/unit/src/main/net/dpml/test composition/testing/unit/src/main/net/dpml/test/config composition/testing/unit/src/main/net/dpml/test/state composition/testing/unit/src/test/net/dpml/composition/testing composition/testing/unit/src/test/net/dpml/test composition/testing/unit/src/test/net/dpml/test/config composition/testing/unit/src/test/net/dpml/test/state meta/api/src/main/net/dpml/meta/info parts parts/builder parts/control parts/src parts/src/main parts/src/main/net parts/src/main/net/dpml parts/src/main/net/dpml/parts parts/src/main/net/dpml/parts/builder parts/src/main/net/dpml/parts/control parts/src/main/net/dpml/parts/model parts/src/main/net/dpml/parts/part parts/src/main/net/dpml/parts/state state, mcconnell, 04/21/2005

Archive powered by MHonArc 2.6.24.

Top of Page