Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1288 - in development/main: . central/site/src/docs/about/community/people magic/core magic/spells/cruisecontrol/etc/main metro metro/activation/impl/src/main/net/dpml/activation/impl metro/activation/providers/avalon metro/activation/providers/avalon/src/main/net/dpml/activation/avalon metro/activation/providers/metro metro/activation/providers/metro/src/main/net/dpml/activation/metro metro/activation/test metro/activation/test/etc/test metro/activation/test/src/test/net/dpml/activation/impl/test metro/composition/impl/etc/main metro/composition/impl/src/main/net/dpml/composition/model/impl metro/composition/impl/src/main/net/dpml/composition/util metro/composition/spi/src/main/net/dpml/composition/provider metro/composition/test/etc/test metro/composition/test/src/main/net/dpml/composition/test metro/composition/test/src/test/net/dpml/composition/util metro/main metro/main/src/main/net/dpml/metro metro/system/impl metro/system/impl/etc/test metro/system/impl/src/main/net/dpml/system/impl metro/testing/cli metro/testing/cli/etc/test metro/testing/cli/src/test/net/dpml/metro/test metro/testing/testschema metro/testing/testschema/src/main/net/dpml/test/testschema metro/unit transit/plugin util/cli util/cli/src/main/net/dpml/cli util/criteria/src/main/net/dpml/criteria

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: niclas AT netcompartner.com
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r1288 - in development/main: . central/site/src/docs/about/community/people magic/core magic/spells/cruisecontrol/etc/main metro metro/activation/impl/src/main/net/dpml/activation/impl metro/activation/providers/avalon metro/activation/providers/avalon/src/main/net/dpml/activation/avalon metro/activation/providers/metro metro/activation/providers/metro/src/main/net/dpml/activation/metro metro/activation/test metro/activation/test/etc/test metro/activation/test/src/test/net/dpml/activation/impl/test metro/composition/impl/etc/main metro/composition/impl/src/main/net/dpml/composition/model/impl metro/composition/impl/src/main/net/dpml/composition/util metro/composition/spi/src/main/net/dpml/composition/provider metro/composition/test/etc/test metro/composition/test/src/main/net/dpml/composition/test metro/composition/test/src/test/net/dpml/composition/util metro/main metro/main/src/main/net/dpml/metro metro/system/impl metro/system/impl/etc/test metro/system/impl/src/main/net/dpml/system/impl metro/testing/cli metro/testing/cli/etc/test metro/testing/cli/src/test/net/dpml/metro/test metro/testing/testschema metro/testing/testschema/src/main/net/dpml/test/testschema metro/unit transit/plugin util/cli util/cli/src/main/net/dpml/cli util/criteria/src/main/net/dpml/criteria
  • Date: Fri, 24 Dec 2004 22:19:23 +0100

Author: niclas
Date: Fri Dec 24 22:19:23 2004
New Revision: 1288

Removed:
development/main/setup.sh
Modified:
development/main/central/site/src/docs/about/community/people/leangen.xml
(contents, props changed)

development/main/central/site/src/docs/about/community/people/pneubauer.xml
(props changed)
development/main/magic/core/build.xml (contents, props changed)
development/main/magic/spells/cruisecontrol/etc/main/cruisecontrol.xml
(contents, props changed)

development/main/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultState.java
(contents, props changed)
development/main/metro/activation/providers/avalon/build.xml (contents,
props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AbstractAppliance.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AbstractLifestyleManager.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/ApplianceInvocationHandler.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonConfiguration.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonContext.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonLogger.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonParameters.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonServiceManager.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/ContainerUtil.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultAppliance.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultComponentFactory.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultLifestyleFactory.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultRuntimeFactory.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultServiceManager.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/Resources.properties
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/SingletonLifestyleManager.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/ThreadLifestyleManager.java
(contents, props changed)

development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/TransientLifestyleManager.java
(contents, props changed)
development/main/metro/activation/providers/metro/build.xml (contents,
props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/AbstractAppliance.java
(contents, props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/AbstractLifestyleManager.java
(contents, props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/ApplianceInvocationHandler.java
(contents, props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/ContainerUtil.java
(contents, props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultAppliance.java
(contents, props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultComponentFactory.java
(contents, props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultLifestyleFactory.java
(contents, props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultRuntimeFactory.java
(contents, props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultServiceManager.java
(contents, props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/Resources.properties
(contents, props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/SingletonLifestyleManager.java
(contents, props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/ThreadLifestyleManager.java
(contents, props changed)

development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/TransientLifestyleManager.java
(contents, props changed)
development/main/metro/activation/test/build.xml (contents, props
changed)
development/main/metro/activation/test/etc/test/kernel.xml (contents,
props changed)
development/main/metro/activation/test/etc/test/logging.xml (contents,
props changed)
development/main/metro/activation/test/etc/test/metro.properties
(contents, props changed)
development/main/metro/activation/test/etc/test/playground.xml
(contents, props changed)

development/main/metro/activation/test/src/test/net/dpml/activation/impl/test/CodeSecurityDisabledTestCase.java
(contents, props changed)

development/main/metro/activation/test/src/test/net/dpml/activation/impl/test/CodeSecurityEnabledTestCase.java
(contents, props changed)

development/main/metro/activation/test/src/test/net/dpml/activation/impl/test/PlaygroundTestCase.java
(contents, props changed)
development/main/metro/build.xml (contents, props changed)
development/main/metro/composition/impl/etc/main/kernel.xml (contents,
props changed)

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionController.java
(contents, props changed)

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionCriteria.java
(contents, props changed)

development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultState.java
(contents, props changed)

development/main/metro/composition/impl/src/main/net/dpml/composition/util/ConfigurationSerializer.java
(props changed)

development/main/metro/composition/impl/src/main/net/dpml/composition/util/XercesSchemaValidator.java
(props changed)

development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionCriteria.java
(contents, props changed)

development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionException.java
(contents, props changed)

development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionFactory.java
(contents, props changed)

development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionHelper.java
(contents, props changed)

development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionRuntimeException.java
(contents, props changed)
development/main/metro/composition/test/etc/test/ConfigurableB.xml
(props changed)

development/main/metro/composition/test/etc/test/SelfValidatingConfigurableB.xml
(props changed)
development/main/metro/composition/test/etc/test/metro.properties
(contents, props changed)

development/main/metro/composition/test/src/main/net/dpml/composition/test/CompositionTestCase.java
(contents, props changed)

development/main/metro/composition/test/src/test/net/dpml/composition/util/SchemaValidationTestCase.java
(props changed)
development/main/metro/index.xml (contents, props changed)
development/main/metro/main/build.xml (contents, props changed)
development/main/metro/main/src/main/net/dpml/metro/Metro.java (props
changed)
development/main/metro/main/src/main/net/dpml/metro/Resources.properties
(contents, props changed)
development/main/metro/system/impl/build.xml (contents, props changed)
development/main/metro/system/impl/etc/test/metro.properties (props
changed)

development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContext.java
(contents, props changed)

development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContextFactory.java
(props changed)

development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemCriteria.java
(props changed)

development/main/metro/system/impl/src/main/net/dpml/system/impl/Resources.properties
(contents, props changed)
development/main/metro/testing/cli/build.xml (contents, props changed)
development/main/metro/testing/cli/etc/test/metro.properties (contents,
props changed)

development/main/metro/testing/cli/src/test/net/dpml/metro/test/MetroTestCase.java
(contents, props changed)
development/main/metro/testing/testschema/build.xml (contents, props
changed)

development/main/metro/testing/testschema/src/main/net/dpml/test/testschema/ConfigurableA.java
(props changed)

development/main/metro/testing/testschema/src/main/net/dpml/test/testschema/ConfigurableB.java
(props changed)

development/main/metro/testing/testschema/src/main/net/dpml/test/testschema/ConfigurableC.java
(props changed)
development/main/metro/unit/build.xml (contents, props changed)
development/main/transit/plugin/build.xml
development/main/util/cli/build.xml (contents, props changed)
development/main/util/cli/src/main/net/dpml/cli/ArgumentHandler.java
(contents, props changed)

development/main/util/criteria/src/main/net/dpml/criteria/URLParameter.java
(contents, props changed)
Log:
Many svn:eol-style were not set to 'native'.

Modified:
development/main/central/site/src/docs/about/community/people/leangen.xml
==============================================================================
--- development/main/central/site/src/docs/about/community/people/leangen.xml
(original)
+++ development/main/central/site/src/docs/about/community/people/leangen.xml
Fri Dec 24 22:19:23 2004
@@ -1,32 +1,32 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document>
- <properties>
- <author email="david.leangen AT konova.com">David Leangen</author>
- <title>DPML Central</title>
- </properties>
- <body>
- <section name="David Leangen">
- <p>(dleangen at konova dot com)</p>
- <p>
- David joined DPML in 2004 just as it was being spun out of the
Apache Avalon
- Project. He initially investigated component management tools as
part of
- his development in the area of bioinformatics. Very impressed with
the
- vision, diligence, and incredible user support provided by the
community,
- it was clear that from the start that he wanted to be a part of its
activities.
- </p>
- <p>
- Born and raised in Victoria, B.C., Canada, David lived for 2 years
in France, then
- about 10 years in Montreal, Quebec, Canada, where he obtained his
Bachelor's degree
- in electrical engineering from the Universit&#233; de Sherbrooke.
Soon after, he
- found his way to Japan where he is now married and the owner of both
a Japanese-based
- bioinformatics company as well as a Montreal-based software company.
- </p>
- <p>
- One of David's main interests is to import the knowledge available
at DPML
- into Japan. Along with some of his Japanese partners, he is working
on training
- materials and consulting services for advanced Java component
management.
- </p>
- <!--<img src="/images/people/leangen.jpg"/>-->
- </section>
- </body>
-</document>
+<?xml version="1.0" encoding="UTF-8"?>
+<document>
+ <properties>
+ <author email="david.leangen AT konova.com">David Leangen</author>
+ <title>DPML Central</title>
+ </properties>
+ <body>
+ <section name="David Leangen">
+ <p>(dleangen at konova dot com)</p>
+ <p>
+ David joined DPML in 2004 just as it was being spun out of the
Apache Avalon
+ Project. He initially investigated component management tools as
part of
+ his development in the area of bioinformatics. Very impressed with
the
+ vision, diligence, and incredible user support provided by the
community,
+ it was clear that from the start that he wanted to be a part of its
activities.
+ </p>
+ <p>
+ Born and raised in Victoria, B.C., Canada, David lived for 2 years
in France, then
+ about 10 years in Montreal, Quebec, Canada, where he obtained his
Bachelor's degree
+ in electrical engineering from the Universit&#233; de Sherbrooke.
Soon after, he
+ found his way to Japan where he is now married and the owner of both
a Japanese-based
+ bioinformatics company as well as a Montreal-based software company.
+ </p>
+ <p>
+ One of David's main interests is to import the knowledge available
at DPML
+ into Japan. Along with some of his Japanese partners, he is working
on training
+ materials and consulting services for advanced Java component
management.
+ </p>
+ <!--<img src="/images/people/leangen.jpg"/>-->
+ </section>
+ </body>
+</document>

Modified: development/main/magic/core/build.xml
==============================================================================
--- development/main/magic/core/build.xml (original)
+++ development/main/magic/core/build.xml Fri Dec 24 22:19:23 2004
@@ -1,97 +1,105 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-magic-core" default="install" basedir=".">
-
- <import file="../../bootstrap.xml"/>
-
- <available classname="net.dpml.transit.Main" property="transit.available"/>
- <available classname="junit.framework.TestCase"
property="junit.available"/>
-
- <target name="init" depends="bootstrap.init">
- <echo>
-#----------------------------------------------------------------------------------
-# Magic Core
-#----------------------------------------------------------------------------------
- </echo>
-
- <property name="dpml-magic-core.uri"
- value="artifact:meta:dpml/magic/dpml-magic-core#${project.version}"/>
-
- <echo>HANDLER FILENAME: ${dpml-transit-handler.filename}</echo>
- <echo>BOOT FILENAME: ${dpml-magic-bootstrap.filename}</echo>
- <echo>MAGIC URI: ${dpml-magic-core.uri}</echo>
-
- <filter token="PROJECT-PLUGIN-URN"
value="plugin:dpml/magic/dpml-magic-core"/>
- <filter token="PROJECT-PLUGIN-URI" value="${dpml-magic-core.uri}"/>
- </target>
-
- <!--
- Compile sources in target/build/main with oputput classes under
target/classes.
- -->
- <target name="build" depends="prepare">
- <javac srcdir="target/build/main" destdir="target/classes" debug="true">
- <classpath>
- <pathelement
location="${dpml.home}/main/dpml/transit/jars/${dpml-transit-handler.filename}"/>
- <pathelement
location="${dpml.home}/main/dpml/magic/jars/${dpml-magic-bootstrap.filename}"/>
- </classpath>
- </javac>
- <taskdef name="export" classname="net.dpml.magic.tasks.ExportTask">
- <classpath>
- <pathelement
location="${dpml.home}/main/junit/jars/${junit-filename}"/>
- <pathelement
location="${dpml.home}/main/dpml/transit/jars/${dpml-transit-handler.filename}"/>
- <pathelement
location="${dpml.home}/main/dpml/magic/jars/${dpml-magic-bootstrap.filename}"/>
- <pathelement location="target/classes"/>
- </classpath>
- </taskdef>
- <export>
- <antlib resource="net/dpml/magic/plugin.xml"
urn="plugin:dpml/magic/dpml-magic-core"/>
- </export>
- </target>
-
- <target name="install" depends="bootstrap.install">
- <mkdir dir="${dpml.home}/docs"/>
- <copy toDir="${dpml.home}">
- <fileset dir="target/deliverables">
- <include name="themes/**"/>
- <include name="processes/**"/>
- </fileset>
- </copy>
- </target>
-
- <target name="build-tests" depends="prepare,build">
- <mkdir dir="target/test-classes"/>
- <javac srcdir="target/build/test"
- destdir="target/test-classes"
- debug="true">
- <classpath>
- <pathelement
location="${dpml.home}/main/junit/jars/${junit-filename}"/>
- <pathelement
location="${dpml.home}/main/dpml/transit/jars/${dpml-transit-handler.filename}"/>
- <pathelement
location="${dpml.home}/main/dpml/magic/jars/${dpml-magic-bootstrap.filename}"/>
- <pathelement location="target/classes"/>
- </classpath>
- </javac>
- </target>
-
- <target name="test" depends="build-tests" if="junit.available">
- <mkdir dir="target/test-reports"/>
- <junit printsummary="yes" haltonfailure="yes" showoutput="true"
- dir="${basedir}" fork="true" forkmode="perBatch">
- <classpath>
- <pathelement location="target/classes"/>
- <pathelement location="target/test-classes"/>
- <pathelement
location="${dpml.home}/main/dpml/transit/jars/${dpml-transit-handler.filename}"/>
- <pathelement
location="${dpml.home}/main/dpml/magic/jars/${dpml-magic-bootstrap.filename}"/>
- <pathelement
location="${dpml.home}/main/junit/jars/${junit-filename}"/>
- </classpath>
- <formatter type="plain"/>
- <formatter type="xml"/>
- <batchtest fork="yes" todir="target/test-reports">
- <fileset dir="target/build/test">
- <include name="**/*TestCase.java"/>
- </fileset>
- </batchtest>
- </junit>
- </target>
-
-</project>
-
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-magic-core" default="dist" basedir=".">
+
+ <import file="../../bootstrap.xml"/>
+
+ <available classname="net.dpml.transit.Main" property="transit.available"/>
+ <available classname="junit.framework.TestCase"
property="junit.available"/>
+
+ <target name="init" depends="bootstrap.init">
+ <echo>
+#----------------------------------------------------------------------------------
+# Magic Core
+#----------------------------------------------------------------------------------
+ </echo>
+
+ <property name="dpml-magic-core.uri"
+ value="artifact:meta:dpml/magic/dpml-magic-core#${project.version}"/>
+
+ <echo>HANDLER FILENAME: ${dpml-transit-handler.filename}</echo>
+ <echo>BOOT FILENAME: ${dpml-magic-bootstrap.filename}</echo>
+ <echo>MAGIC URI: ${dpml-magic-core.uri}</echo>
+
+ <filter token="PROJECT-PLUGIN-URN"
value="plugin:dpml/magic/dpml-magic-core"/>
+ <filter token="PROJECT-PLUGIN-URI" value="${dpml-magic-core.uri}"/>
+ </target>
+
+ <!--
+ Compile sources in target/build/main with oputput classes under
target/classes.
+ -->
+ <target name="build" depends="prepare">
+ <javac srcdir="target/build/main" destdir="target/classes" debug="true">
+ <classpath>
+ <pathelement
location="${dpml.home}/main/dpml/transit/jars/${dpml-transit-handler.filename}"/>
+ <pathelement
location="${dpml.home}/main/dpml/magic/jars/${dpml-magic-bootstrap.filename}"/>
+ </classpath>
+ </javac>
+ <taskdef name="export" classname="net.dpml.magic.tasks.ExportTask">
+ <classpath>
+ <pathelement
location="${dpml.home}/main/junit/jars/${junit-filename}"/>
+ <pathelement
location="${dpml.home}/main/dpml/transit/jars/${dpml-transit-handler.filename}"/>
+ <pathelement
location="${dpml.home}/main/dpml/magic/jars/${dpml-magic-bootstrap.filename}"/>
+ <pathelement location="target/classes"/>
+ </classpath>
+ </taskdef>
+ <export>
+ <antlib resource="net/dpml/magic/plugin.xml"
urn="plugin:dpml/magic/dpml-magic-core"/>
+ </export>
+ </target>
+
+ <target name="install" depends="bootstrap.install">
+ <mkdir dir="${dpml.home}/docs"/>
+ <copy toDir="${dpml.home}">
+ <fileset dir="target/deliverables">
+ <include name="themes/**"/>
+ <include name="processes/**"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="build-tests" depends="prepare,build">
+ <mkdir dir="target/test-classes"/>
+ <javac srcdir="target/build/test"
+ destdir="target/test-classes"
+ debug="true">
+ <classpath>
+ <pathelement
location="${dpml.home}/main/junit/jars/${junit-filename}"/>
+ <pathelement
location="${dpml.home}/main/dpml/transit/jars/${dpml-transit-handler.filename}"/>
+ <pathelement
location="${dpml.home}/main/dpml/magic/jars/${dpml-magic-bootstrap.filename}"/>
+ <pathelement location="target/classes"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="test" depends="build-tests" if="junit.available">
+ <mkdir dir="target/test-reports"/>
+ <junit printsummary="yes" haltonfailure="yes" showoutput="true"
+ dir="${basedir}" fork="true" forkmode="perBatch">
+ <classpath>
+ <pathelement location="target/classes"/>
+ <pathelement location="target/test-classes"/>
+ <pathelement
location="${dpml.home}/main/dpml/transit/jars/${dpml-transit-handler.filename}"/>
+ <pathelement
location="${dpml.home}/main/dpml/magic/jars/${dpml-magic-bootstrap.filename}"/>
+ <pathelement
location="${dpml.home}/main/junit/jars/${junit-filename}"/>
+ </classpath>
+ <formatter type="plain"/>
+ <formatter type="xml"/>
+ <batchtest fork="yes" todir="target/test-reports">
+ <fileset dir="target/build/test">
+ <include name="**/*TestCase.java"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ </target>
+
+ <target name="dist" depends="install">
+ <jar jarfile="${basedir}/target/deliverables/jars/dpml-magic-LATEST.jar"
>
+ <fileset dir="${user.home}" >
+ <include name=".ant/lib/dpml-magic-bootstrap.jar" />
+ <include name=".ant/lib/junit-3.8.1.jar" />
+ </fileset>
+ </jar>
+ </target>
+</project>
+

Modified:
development/main/magic/spells/cruisecontrol/etc/main/cruisecontrol.xml
==============================================================================
--- development/main/magic/spells/cruisecontrol/etc/main/cruisecontrol.xml
(original)
+++ development/main/magic/spells/cruisecontrol/etc/main/cruisecontrol.xml
Fri Dec 24 22:19:23 2004
@@ -1,29 +1,29 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<cruisecontrol>
- <project name="metro-main">
-
- <bootstrappers>
- <currentbuildstatusbootstrapper file="currentbuildstatus.txt"/>
- <svnbootstrapper localWorkingCopy="." />
- </bootstrappers>
-
-
- <modificationset quietperiod="120">
- <svn localWorkingCopy="."/>
- </modificationset>
-
- <schedule interval="10">
- <ant antscript="ant.bat" antWorkingDir="main" target="setup"
multiple="1" usedebug="false"/>
- <ant antscript="ant.bat" antWorkingDir="main" multiple="1"
usedebug="false"/>
- </schedule>
- <publishers>
- <!--email mailhost="194.132.132.3" subjectprefix="[GRUBS][OrchardJ]"
returnaddress="grubs AT scancoin.se" defaultsuffix=" AT scancoin.se"
spamwhilebroken="false" buildresultsurl="">
- <always address="pnb AT scancoin.se">
- </always>
- </email-->
- </publishers>
-
- <dateformat format="yyyy-MM-dd HH:mm:ss" />
- </project>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cruisecontrol>
+ <project name="metro-main">
+
+ <bootstrappers>
+ <currentbuildstatusbootstrapper file="currentbuildstatus.txt"/>
+ <svnbootstrapper localWorkingCopy="." />
+ </bootstrappers>
+
+
+ <modificationset quietperiod="120">
+ <svn localWorkingCopy="."/>
+ </modificationset>
+
+ <schedule interval="10">
+ <ant antscript="ant.bat" antWorkingDir="main" target="setup"
multiple="1" usedebug="false"/>
+ <ant antscript="ant.bat" antWorkingDir="main" multiple="1"
usedebug="false"/>
+ </schedule>
+ <publishers>
+ <!--email mailhost="194.132.132.3" subjectprefix="[GRUBS][OrchardJ]"
returnaddress="grubs AT scancoin.se" defaultsuffix=" AT scancoin.se"
spamwhilebroken="false" buildresultsurl="">
+ <always address="pnb AT scancoin.se">
+ </always>
+ </email-->
+ </publishers>
+
+ <dateformat format="yyyy-MM-dd HH:mm:ss" />
+ </project>
</cruisecontrol>
\ No newline at end of file

Modified:
development/main/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultState.java
==============================================================================
---
development/main/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultState.java
(original)
+++
development/main/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultState.java
Fri Dec 24 22:19:23 2004
@@ -1,62 +1,62 @@
-/*
- * 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.activation.impl;
-
-/**
- * The State class desribes a enabled versus disabled state.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id: DefaultState.java 187 2004-10-23 17:10:53Z niclas $
- */
-
-class DefaultState
-{
-
-
//---------------------------------------------------------------------------
- // state
-
//---------------------------------------------------------------------------
-
- private boolean m_enabled = false;
-
-
//---------------------------------------------------------------------------
- // State
-
//---------------------------------------------------------------------------
-
- /**
- * Return the enabled state of the state.
- * @return TRUE if the state has been enabled else FALSE
- */
- public boolean isEnabled()
- {
- return m_enabled;
- }
-
-
//---------------------------------------------------------------------------
- // implementation
-
//---------------------------------------------------------------------------
-
- /**
- * Set the enabled state of the state.
- * @param enabled the enabled state to assign
- */
- public void setEnabled( boolean enabled ) throws IllegalStateException
- {
- m_enabled = enabled;
- }
-}
+/*
+ * 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.activation.impl;
+
+/**
+ * The State class desribes a enabled versus disabled state.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: DefaultState.java 187 2004-10-23 17:10:53Z niclas $
+ */
+
+class DefaultState
+{
+
+
//---------------------------------------------------------------------------
+ // state
+
//---------------------------------------------------------------------------
+
+ private boolean m_enabled = false;
+
+
//---------------------------------------------------------------------------
+ // State
+
//---------------------------------------------------------------------------
+
+ /**
+ * Return the enabled state of the state.
+ * @return TRUE if the state has been enabled else FALSE
+ */
+ public boolean isEnabled()
+ {
+ return m_enabled;
+ }
+
+
//---------------------------------------------------------------------------
+ // implementation
+
//---------------------------------------------------------------------------
+
+ /**
+ * Set the enabled state of the state.
+ * @param enabled the enabled state to assign
+ */
+ public void setEnabled( boolean enabled ) throws IllegalStateException
+ {
+ m_enabled = enabled;
+ }
+}

Modified: development/main/metro/activation/providers/avalon/build.xml
==============================================================================
--- development/main/metro/activation/providers/avalon/build.xml
(original)
+++ development/main/metro/activation/providers/avalon/build.xml Fri
Dec 24 22:19:23 2004
@@ -1,13 +1,13 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-activation-avalon-provider" default="install"
basedir="."
- xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
-
- <magic:import uri="artifact:template:dpml/magic/standard"/>
-
- <target name="package" depends="standard.package">
- <x:export class="net.dpml.activation.avalon.DefaultRuntimeFactory"/>
- </target>
-
-</project>
-
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-activation-avalon-provider" default="install"
basedir="."
+ xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
+
+ <magic:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="package" depends="standard.package">
+ <x:export class="net.dpml.activation.avalon.DefaultRuntimeFactory"/>
+ </target>
+
+</project>
+

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AbstractAppliance.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AbstractAppliance.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AbstractAppliance.java
Fri Dec 24 22:19:23 2004
@@ -1,127 +1,127 @@
-/*
- * 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.activation.avalon;
-
-import net.dpml.activation.Appliance;
-
-import net.dpml.composition.model.DeploymentModel;
-
-import net.dpml.logging.Logger;
-
-/**
- * Abstract appliance.
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public abstract class AbstractAppliance implements Appliance
-{
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final DeploymentModel m_model;
-
- private final Logger m_logger;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- public AbstractAppliance( DeploymentModel model )
- {
- if( null == model )
- {
- throw new NullPointerException( "model" );
- }
-
- m_model = model;
- m_logger = model.getLogger();
- }
-
- //-------------------------------------------------------------------
- // Commissionable
- //-------------------------------------------------------------------
-
- /**
- * Commission the appliance.
- *
- * @exception Exception if a commissioning error occurs
- */
- public abstract void commission() throws Exception;
-
- /**
- * Decommission the appliance. Once an appliance is
- * decommissioned it may be re-commissioned.
- */
- public abstract void decommission();
-
- //-------------------------------------------------------------------
- // Resolver
- //-------------------------------------------------------------------
-
- /**
- * Resolve a object to a value.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- public abstract Object resolve() throws Exception;
-
- /**
- * Request resolution of an object from the runtime.
- * @param proxy if TRUE the return value will be proxied if the
- * underlying component typoe suppports proxy representation
- * @exception Exception if a deployment error occurs
- */
- public abstract Object resolve( boolean proxy ) throws Exception;
-
- /**
- * Release an object
- *
- * @param instance the object to be released
- */
- public abstract void release( Object instance );
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- protected Logger getLogger()
- {
- return m_logger;
- }
-
- /**
- * Return the model backing the handler.
- * @return the type that the appliance is managing
- */
- protected DeploymentModel getDeploymentModel()
- {
- return m_model;
- }
-
- //-------------------------------------------------------------------
- // Object
- //-------------------------------------------------------------------
-
- public String toString()
- {
- return "appliance:" + getDeploymentModel().getQualifiedName();
- }
-}
+/*
+ * 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.activation.avalon;
+
+import net.dpml.activation.Appliance;
+
+import net.dpml.composition.model.DeploymentModel;
+
+import net.dpml.logging.Logger;
+
+/**
+ * Abstract appliance.
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public abstract class AbstractAppliance implements Appliance
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final DeploymentModel m_model;
+
+ private final Logger m_logger;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public AbstractAppliance( DeploymentModel model )
+ {
+ if( null == model )
+ {
+ throw new NullPointerException( "model" );
+ }
+
+ m_model = model;
+ m_logger = model.getLogger();
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the appliance.
+ *
+ * @exception Exception if a commissioning error occurs
+ */
+ public abstract void commission() throws Exception;
+
+ /**
+ * Decommission the appliance. Once an appliance is
+ * decommissioned it may be re-commissioned.
+ */
+ public abstract void decommission();
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ public abstract Object resolve() throws Exception;
+
+ /**
+ * Request resolution of an object from the runtime.
+ * @param proxy if TRUE the return value will be proxied if the
+ * underlying component typoe suppports proxy representation
+ * @exception Exception if a deployment error occurs
+ */
+ public abstract Object resolve( boolean proxy ) throws Exception;
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ public abstract void release( Object instance );
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ protected Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ /**
+ * Return the model backing the handler.
+ * @return the type that the appliance is managing
+ */
+ protected DeploymentModel getDeploymentModel()
+ {
+ return m_model;
+ }
+
+ //-------------------------------------------------------------------
+ // Object
+ //-------------------------------------------------------------------
+
+ public String toString()
+ {
+ return "appliance:" + getDeploymentModel().getQualifiedName();
+ }
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AbstractLifestyleManager.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AbstractLifestyleManager.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AbstractLifestyleManager.java
Fri Dec 24 22:19:23 2004
@@ -1,318 +1,318 @@
-/*
- * 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.activation.avalon;
-
-import java.lang.ref.Reference;
-import java.lang.ref.SoftReference;
-import java.lang.ref.WeakReference;
-import java.lang.ref.ReferenceQueue;
-import java.util.Map;
-
-import net.dpml.activation.LifecycleException;
-import net.dpml.activation.ComponentFactory;
-
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.model.StageModel;
-import net.dpml.composition.provider.LifestyleManager;
-
-import net.dpml.logging.Logger;
-import net.dpml.context.Context;
-import net.dpml.context.impl.DefaultContext;
-
-import org.apache.avalon.lifecycle.Accessor;
-
-import net.dpml.meta.info.InfoDescriptor;
-import net.dpml.meta.info.StageDescriptor;
-
-import net.dpml.i18n.ResourceManager;
-import net.dpml.i18n.Resources;
-
-/**
- * Abstract implentation class for a lifestyle handler.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public abstract class AbstractLifestyleManager implements LifestyleManager
-{
- //-------------------------------------------------------------------
- // static
- //-------------------------------------------------------------------
-
- private static final Resources REZ =
- ResourceManager.getPackageResources( AbstractLifestyleManager.class );
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final ComponentModel m_model;
-
- private final ComponentFactory m_factory;
-
- private final Logger m_logger;
-
- private final ReferenceQueue m_liberals = new ReferenceQueue();
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- /**
- * Creation of a new instance.
- * @param model the component model
- * @param factory the component factory
- */
- public AbstractLifestyleManager( ComponentModel model, ComponentFactory
factory )
- {
- m_factory = factory;
- m_model = model;
- m_logger = model.getLogger();
- }
-
- //-------------------------------------------------------------------
- // Commissionable
- //-------------------------------------------------------------------
-
- /**
- * Commission the runtime handler.
- *
- * @exception Exception if a hanfdler commissioning error occurs
- */
- public abstract void commission() throws Exception;
-
- /**
- * Invokes the decommissioning phase. Once a handler is
- * decommissioned it may be re-commissioned.
- */
- public abstract void decommission();
-
- //-------------------------------------------------------------------
- // Resolver
- //-------------------------------------------------------------------
-
- /**
- * Resolve a object to a value.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- public Object resolve() throws Exception
- {
- Object instance = handleResolve();
- return applyExtensionStages( instance, true );
- }
-
- /**
- * Resolve a object to a value.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- public Object resolve( boolean proxy ) throws Exception
- {
- return resolve();
- }
-
- /**
- * Release an object
- *
- * @param instance the object to be released
- */
- public void release( Object instance )
- {
- try
- {
- applyExtensionStages( instance, false );
- }
- catch( Throwable e )
- {
- final String error =
- "Ignoring error returned from release extension.";
- getLogger().error( error, e );
- }
- handleRelease( instance );
- }
-
- //-------------------------------------------------------------------
- // LifecycleManager
- //-------------------------------------------------------------------
-
- public void finalize( Object instance )
- {
- synchronized( m_factory )
- {
- if( instance != null )
- {
- m_factory.etherialize( instance );
- }
- }
- }
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- protected abstract Object handleResolve() throws Exception;
-
- protected abstract void handleRelease( Object instance );
-
-
- protected Logger getLogger()
- {
- return m_logger;
- }
-
- protected ComponentModel getComponentModel()
- {
- return m_model;
- }
-
- protected ComponentFactory getComponentFactory()
- {
- return m_factory;
- }
-
- /**
- * Return the liberal queue.
- */
- ReferenceQueue getLiberalQueue()
- {
- return m_liberals;
- }
-
- protected Reference getReference( Object instance )
- {
- final int policy = getComponentModel().getCollectionPolicy();
- if( policy == InfoDescriptor.WEAK )
- {
- return new WeakReference( instance, m_liberals );
- }
- else if( policy == InfoDescriptor.SOFT )
- {
- return new SoftReference( instance );
- }
- else
- {
- return new StrongReference( instance );
- }
- }
-
- private class StrongReference extends WeakReference
- {
- private final Object m_instance;
-
- public StrongReference( Object instance )
- {
- super( instance );
- m_instance = instance;
- }
-
- public Object get()
- {
- return m_instance;
- }
- }
-
- private Object applyExtensionStages( Object instance, boolean flag )
- throws Exception
- {
- StageDescriptor[] stages = m_model.getType().getStages();
- for( int i=0; i<stages.length; i++ )
- {
- StageDescriptor descriptor = stages[i];
- StageModel stage = m_model.getStageModel( descriptor );
-
- ComponentModel provider = getStageProvider( stage );
- Class c = provider.getDeploymentClass();
-
- if( Accessor.class.isAssignableFrom( c ) )
- {
- Accessor handler = (Accessor) provider.resolve();
- try
- {
- Map map = m_model.getContextModel().getContextMap();
- Context context = new DefaultContext( map );
- if( flag )
- {
- if( getLogger().isDebugEnabled() )
- {
- int id = System.identityHashCode( instance );
- getLogger().debug( "applying access stage to: "
+ id );
- }
- handler.access( instance, new AvalonContext( context
) );
- }
- else
- {
- if( getLogger().isDebugEnabled() )
- {
- int id = System.identityHashCode( instance );
- getLogger().debug( "applying release stage to: "
+ id );
- }
- handler.release( instance, new AvalonContext(
context ) );
- }
- }
- catch( Throwable e )
- {
- final String error =
- REZ.getString(
- "lifecycle.stage.accessor.error",
- stage.getStage().getKey() );
- if( flag )
- {
- throw new LifecycleException( error, e );
- }
- else
- {
- getLogger().warn( error, e );
- }
- }
- finally
- {
- provider.release( handler );
- }
- }
- }
- return instance;
- }
-
- private ComponentModel getStageProvider( StageModel stage ) throws
LifecycleException
- {
- try
- {
- return (ComponentModel) stage.getProvider();
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to resolve access stage provider.";
- throw new LifecycleException( error, e );
- }
- }
-
- //-------------------------------------------------------------------
- // Object
- //-------------------------------------------------------------------
-
- public void finalize()
- {
- decommission();
- }
-
-}
+/*
+ * 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.activation.avalon;
+
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+import java.lang.ref.ReferenceQueue;
+import java.util.Map;
+
+import net.dpml.activation.LifecycleException;
+import net.dpml.activation.ComponentFactory;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.StageModel;
+import net.dpml.composition.provider.LifestyleManager;
+
+import net.dpml.logging.Logger;
+import net.dpml.context.Context;
+import net.dpml.context.impl.DefaultContext;
+
+import org.apache.avalon.lifecycle.Accessor;
+
+import net.dpml.meta.info.InfoDescriptor;
+import net.dpml.meta.info.StageDescriptor;
+
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+
+/**
+ * Abstract implentation class for a lifestyle handler.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public abstract class AbstractLifestyleManager implements LifestyleManager
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources( AbstractLifestyleManager.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final ComponentModel m_model;
+
+ private final ComponentFactory m_factory;
+
+ private final Logger m_logger;
+
+ private final ReferenceQueue m_liberals = new ReferenceQueue();
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new instance.
+ * @param model the component model
+ * @param factory the component factory
+ */
+ public AbstractLifestyleManager( ComponentModel model, ComponentFactory
factory )
+ {
+ m_factory = factory;
+ m_model = model;
+ m_logger = model.getLogger();
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the runtime handler.
+ *
+ * @exception Exception if a hanfdler commissioning error occurs
+ */
+ public abstract void commission() throws Exception;
+
+ /**
+ * Invokes the decommissioning phase. Once a handler is
+ * decommissioned it may be re-commissioned.
+ */
+ public abstract void decommission();
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ public Object resolve() throws Exception
+ {
+ Object instance = handleResolve();
+ return applyExtensionStages( instance, true );
+ }
+
+ /**
+ * Resolve a object to a value.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ public Object resolve( boolean proxy ) throws Exception
+ {
+ return resolve();
+ }
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ public void release( Object instance )
+ {
+ try
+ {
+ applyExtensionStages( instance, false );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Ignoring error returned from release extension.";
+ getLogger().error( error, e );
+ }
+ handleRelease( instance );
+ }
+
+ //-------------------------------------------------------------------
+ // LifecycleManager
+ //-------------------------------------------------------------------
+
+ public void finalize( Object instance )
+ {
+ synchronized( m_factory )
+ {
+ if( instance != null )
+ {
+ m_factory.etherialize( instance );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ protected abstract Object handleResolve() throws Exception;
+
+ protected abstract void handleRelease( Object instance );
+
+
+ protected Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ protected ComponentModel getComponentModel()
+ {
+ return m_model;
+ }
+
+ protected ComponentFactory getComponentFactory()
+ {
+ return m_factory;
+ }
+
+ /**
+ * Return the liberal queue.
+ */
+ ReferenceQueue getLiberalQueue()
+ {
+ return m_liberals;
+ }
+
+ protected Reference getReference( Object instance )
+ {
+ final int policy = getComponentModel().getCollectionPolicy();
+ if( policy == InfoDescriptor.WEAK )
+ {
+ return new WeakReference( instance, m_liberals );
+ }
+ else if( policy == InfoDescriptor.SOFT )
+ {
+ return new SoftReference( instance );
+ }
+ else
+ {
+ return new StrongReference( instance );
+ }
+ }
+
+ private class StrongReference extends WeakReference
+ {
+ private final Object m_instance;
+
+ public StrongReference( Object instance )
+ {
+ super( instance );
+ m_instance = instance;
+ }
+
+ public Object get()
+ {
+ return m_instance;
+ }
+ }
+
+ private Object applyExtensionStages( Object instance, boolean flag )
+ throws Exception
+ {
+ StageDescriptor[] stages = m_model.getType().getStages();
+ for( int i=0; i<stages.length; i++ )
+ {
+ StageDescriptor descriptor = stages[i];
+ StageModel stage = m_model.getStageModel( descriptor );
+
+ ComponentModel provider = getStageProvider( stage );
+ Class c = provider.getDeploymentClass();
+
+ if( Accessor.class.isAssignableFrom( c ) )
+ {
+ Accessor handler = (Accessor) provider.resolve();
+ try
+ {
+ Map map = m_model.getContextModel().getContextMap();
+ Context context = new DefaultContext( map );
+ if( flag )
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "applying access stage to: "
+ id );
+ }
+ handler.access( instance, new AvalonContext( context
) );
+ }
+ else
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "applying release stage to: "
+ id );
+ }
+ handler.release( instance, new AvalonContext(
context ) );
+ }
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.stage.accessor.error",
+ stage.getStage().getKey() );
+ if( flag )
+ {
+ throw new LifecycleException( error, e );
+ }
+ else
+ {
+ getLogger().warn( error, e );
+ }
+ }
+ finally
+ {
+ provider.release( handler );
+ }
+ }
+ }
+ return instance;
+ }
+
+ private ComponentModel getStageProvider( StageModel stage ) throws
LifecycleException
+ {
+ try
+ {
+ return (ComponentModel) stage.getProvider();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to resolve access stage provider.";
+ throw new LifecycleException( error, e );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Object
+ //-------------------------------------------------------------------
+
+ public void finalize()
+ {
+ decommission();
+ }
+
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/ApplianceInvocationHandler.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/ApplianceInvocationHandler.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/ApplianceInvocationHandler.java
Fri Dec 24 22:19:23 2004
@@ -1,241 +1,241 @@
-/*
- * 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.activation.avalon;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.lang.reflect.Method;
-import java.security.PrivilegedActionException;
-import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
-
-import net.dpml.activation.ApplianceException;
-import net.dpml.activation.TransientApplianceException;
-
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.model.TransientRuntimeException;
-import net.dpml.composition.model.Reclaimer;
-
-import net.dpml.logging.Logger;
-
-/**
- * This makes a dynamic proxy for an object. The object can be represented
- * by one, some or all of it's interfaces.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public final class ApplianceInvocationHandler
- implements InvocationHandler, Reclaimer
-{
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final DefaultAppliance m_appliance;
- private final Logger m_logger;
- private final ComponentModel m_model;
- private final boolean m_secure;
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private Object m_instance;
- private boolean m_destroyed = false;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- /**
- * Create a proxy invocation handler.
- *
- * @param appliance the runtime appliance
- * @param logger the assigned logging channel
- */
- ApplianceInvocationHandler(
- DefaultAppliance appliance, Logger logger, boolean secure )
- {
- assertNotNull( appliance, "appliance" );
- assertNotNull( logger, "logger" );
-
- m_appliance = appliance;
- m_logger = logger;
- m_secure = secure;
- m_model = m_appliance.getComponentModel();
- }
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- /**
- * Invoke the specified method on underlying object.
- * This is called by the proxy object.
- *
- * @param proxy the proxy object
- * @param method the method invoked on proxy object
- * @param args the arguments supplied to method
- * @return the return value of method
- * @throws Throwable if an error occurs
- */
- public Object invoke( final Object proxy,
- final Method method,
- final Object[] args )
- throws Throwable
- {
- if( proxy == null )
- throw new NullPointerException( "proxy" );
- if( method == null )
- throw new NullPointerException( "method" );
- if( m_destroyed )
- throw new IllegalStateException( "destroyed" );
-
- try
- {
- final Object instance = getInstance();
-
- if( m_secure )
- {
- return AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return method.invoke( instance, args );
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- return method.invoke( instance, args );
- }
- }
- catch( Throwable e )
- {
- throw handleInvocationThrowable( e );
- }
- }
-
- //-------------------------------------------------------------------
- // Reclaimer
- //-------------------------------------------------------------------
-
- public void release()
- {
- if( !m_destroyed )
- {
- m_destroyed = true;
- final String message =
- "Releasing component ["
- + System.identityHashCode( m_instance ) + "] ("
- + m_appliance.toString()
- + ").";
- getLogger().debug( message );
- m_appliance.release( m_instance );
- }
- }
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- protected void finalize() throws Throwable
- {
- if( !m_destroyed && ( null != m_instance ) )
- {
- final String message =
- "Finalizing proxy ["
- + System.identityHashCode( m_instance ) + "] ("
- + m_appliance.toString()
- + ").";
- getLogger().debug( message );
- release();
- }
- }
-
- private Logger getLogger()
- {
- return m_logger;
- }
-
- private Object getInstance() throws Exception
- {
- if( m_instance == null )
- m_instance = m_appliance.resolve( false );
- return m_instance;
- }
-
- private Throwable handleInvocationThrowable( Throwable e )
- {
- final String error =
- "Delegation error raised by component: "
- + m_appliance.toString();
- while( true )
- {
- if( e instanceof TransientApplianceException )
- {
- TransientApplianceException t =
- (TransientApplianceException) e;
- return new TransientRuntimeException(
- t.getMessage(), t.getDelay() );
- }
- else if( e instanceof UndeclaredThrowableException )
- {
- Throwable cause =
- ((UndeclaredThrowableException)
e).getUndeclaredThrowable();
- if( cause == null )
- return new ApplianceException( error, e );
- e = cause;
- }
- else if( e instanceof InvocationTargetException )
- {
- Throwable cause =
- ((InvocationTargetException) e).getTargetException();
- if( cause == null )
- return new ApplianceException( error, e );
- e = cause;
- }
- else if( e instanceof PrivilegedActionException )
- {
- Throwable cause =
- ((PrivilegedActionException) e).getException();
- if( cause == null )
- return new ApplianceException( error, e );
- e = cause;
- }
- else
- {
- break;
- }
- }
- return e;
- }
-
- private void assertNotNull( Object object, String key )
- {
- if( null == object )
- {
- throw new NullPointerException( key );
- }
- }
-}
+/*
+ * 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.activation.avalon;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.lang.reflect.Method;
+import java.security.PrivilegedActionException;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+
+import net.dpml.activation.ApplianceException;
+import net.dpml.activation.TransientApplianceException;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.TransientRuntimeException;
+import net.dpml.composition.model.Reclaimer;
+
+import net.dpml.logging.Logger;
+
+/**
+ * This makes a dynamic proxy for an object. The object can be represented
+ * by one, some or all of it's interfaces.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public final class ApplianceInvocationHandler
+ implements InvocationHandler, Reclaimer
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final DefaultAppliance m_appliance;
+ private final Logger m_logger;
+ private final ComponentModel m_model;
+ private final boolean m_secure;
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private Object m_instance;
+ private boolean m_destroyed = false;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Create a proxy invocation handler.
+ *
+ * @param appliance the runtime appliance
+ * @param logger the assigned logging channel
+ */
+ ApplianceInvocationHandler(
+ DefaultAppliance appliance, Logger logger, boolean secure )
+ {
+ assertNotNull( appliance, "appliance" );
+ assertNotNull( logger, "logger" );
+
+ m_appliance = appliance;
+ m_logger = logger;
+ m_secure = secure;
+ m_model = m_appliance.getComponentModel();
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Invoke the specified method on underlying object.
+ * This is called by the proxy object.
+ *
+ * @param proxy the proxy object
+ * @param method the method invoked on proxy object
+ * @param args the arguments supplied to method
+ * @return the return value of method
+ * @throws Throwable if an error occurs
+ */
+ public Object invoke( final Object proxy,
+ final Method method,
+ final Object[] args )
+ throws Throwable
+ {
+ if( proxy == null )
+ throw new NullPointerException( "proxy" );
+ if( method == null )
+ throw new NullPointerException( "method" );
+ if( m_destroyed )
+ throw new IllegalStateException( "destroyed" );
+
+ try
+ {
+ final Object instance = getInstance();
+
+ if( m_secure )
+ {
+ return AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return method.invoke( instance, args );
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ return method.invoke( instance, args );
+ }
+ }
+ catch( Throwable e )
+ {
+ throw handleInvocationThrowable( e );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Reclaimer
+ //-------------------------------------------------------------------
+
+ public void release()
+ {
+ if( !m_destroyed )
+ {
+ m_destroyed = true;
+ final String message =
+ "Releasing component ["
+ + System.identityHashCode( m_instance ) + "] ("
+ + m_appliance.toString()
+ + ").";
+ getLogger().debug( message );
+ m_appliance.release( m_instance );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ protected void finalize() throws Throwable
+ {
+ if( !m_destroyed && ( null != m_instance ) )
+ {
+ final String message =
+ "Finalizing proxy ["
+ + System.identityHashCode( m_instance ) + "] ("
+ + m_appliance.toString()
+ + ").";
+ getLogger().debug( message );
+ release();
+ }
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ private Object getInstance() throws Exception
+ {
+ if( m_instance == null )
+ m_instance = m_appliance.resolve( false );
+ return m_instance;
+ }
+
+ private Throwable handleInvocationThrowable( Throwable e )
+ {
+ final String error =
+ "Delegation error raised by component: "
+ + m_appliance.toString();
+ while( true )
+ {
+ if( e instanceof TransientApplianceException )
+ {
+ TransientApplianceException t =
+ (TransientApplianceException) e;
+ return new TransientRuntimeException(
+ t.getMessage(), t.getDelay() );
+ }
+ else if( e instanceof UndeclaredThrowableException )
+ {
+ Throwable cause =
+ ((UndeclaredThrowableException)
e).getUndeclaredThrowable();
+ if( cause == null )
+ return new ApplianceException( error, e );
+ e = cause;
+ }
+ else if( e instanceof InvocationTargetException )
+ {
+ Throwable cause =
+ ((InvocationTargetException) e).getTargetException();
+ if( cause == null )
+ return new ApplianceException( error, e );
+ e = cause;
+ }
+ else if( e instanceof PrivilegedActionException )
+ {
+ Throwable cause =
+ ((PrivilegedActionException) e).getException();
+ if( cause == null )
+ return new ApplianceException( error, e );
+ e = cause;
+ }
+ else
+ {
+ break;
+ }
+ }
+ return e;
+ }
+
+ private void assertNotNull( Object object, String key )
+ {
+ if( null == object )
+ {
+ throw new NullPointerException( key );
+ }
+ }
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonConfiguration.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonConfiguration.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonConfiguration.java
Fri Dec 24 22:19:23 2004
@@ -1,646 +1,646 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 2004 Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.dpml.activation.avalon;
-
-import java.util.ArrayList;
-
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-
-/**
- * <code>Configuration</code> is a interface encapsulating a configuration
node
- * used to retrieve configuration values.
- *
- * <p>
- * This is a "read only" interface preventing applications from modifying
their
- * own configurations. Once it is created, the information never changes.
- * </p>
- * <h3>Data Model</h3>
- * <p>
- * The data model is a subset of XML's; a single-rooted hierarchical tree
where each
- * node can contain multiple <em>attributes</em>, and leaf nodes can also
- * contain a <em>value</em>. Reflecting this, <code>Configuration</code>s are
- * usually built from an XML file by the DefaultConfigurationBuilder
- * class, or directly by a SAX parser using a SAXConfigurationHandler or
- * NamespacedSAXConfigurationHandler event handler.
- * </p>
- * <h4>Namespace support</h4>
- * <p>
- * Since version 4.1, each <code>Configuration</code> node has a namespace
- * associated with it, in the form of a string, accessible through {@link
- * #getNamespace}. If no namespace is present, <code>getNamespace</code> will
- * return blank (""). See DefaultConfigurationBuilder for details on how
- * XML namespaces are mapped to <code>Configuration</code> namespaces.
- * </p>
- * <h3>Example</h3>
- * <p>
- * As an example, consider two <code>Configuration</code>s (with and without
- * namespaces) built from this XML:
- * </p>
- * <pre>
- * &lt;my-system version="1.3" xmlns:doc="http://myco.com/documentation"&gt;
- * &lt;doc:desc&gt;This is a highly fictitious config file&lt;/doc:desc&gt;
- * &lt;widget name="fooWidget" initOrder="1" threadsafe="true"/&gt;
- * &lt;/my-system&gt;
- * </pre>
- * <p>If namespace support is enabled (eg through
- * DefaultConfigurationBuilder#DefaultConfigurationBuilder(boolean) new
- * DefaultConfigurationBuilder(true)), then the <code>xmlns:doc</code>
element
- * will not translate into a Configuration attribute, and the
- * <code>doc:desc</code> element will become a <code>Configuration</code>
node
- * with name "desc" and namespace "http://myco.com/documentation";. The
- * <code>widget</code> element will have namespace "".
- * </p>
- * <p>If namespace support is disabled (the default for
- * DefaultConfigurationBuilder), the above XML will translate directly to
- * <code>Configuration</code> nodes. The <code>my-system</code> node will
have
- * an attribute named "xmlns:doc", and a child called "doc:desc".
- * </p>
- * <p>
- * Assuming the <code>Configuration</code> object is named <code>conf</code>,
- * here is how the data could be retrieved:
- * </p>
- * <table border="1">
- * <tr align="center"><th>Code</th><th>No namespaces</th><th>With
namespaces</th></tr>
- * <tr align="center"><td align="left">
- * <code>conf.{@link #getName getName}()</code></td><td
colspan="2">my-system</td></tr>
- * <tr align="center"><td align="left">
- * <code>conf.{@link #getAttributeNames getAttributeNames}().length</code>
- * </td><td>2</td><td>1</td></tr>
- * <tr align="center"><td align="left">
- * <code>conf.{@link #getChildren getChildren}().length</code>
- * </td><td colspan="2">2</td></tr>
- * <tr align="center"><td align="left">
- * <code>conf.{@link #getAttributeAsFloat
getAttributeAsFloat}("version")</code>
- * </td><td colspan="2">1.3</td></tr>
- * <tr align="center"><td align="left">
- * <code>conf.{@link #getChild getChild}("widget").{@link #getAttribute
getAttribute}("name")</code>
- * </td><td colspan="2">fooWidget</td></tr>
- * <tr align="center"><td align="left">
- * <code>conf.{@link #getChild getChild}("widget")
- * .{@link #getAttributeAsBoolean
getAttributeAsBoolean}("threadsafe")</code></td><td colspan="2">
- * <code>true</code></td></tr>
- * <tr align="center"><td align="left">
- * <code>conf.{@link #getChild getChild}("widget").{@link #getLocation
getLocation}()</code>
- * </td><td
colspan="2">file:///home/jeff/tmp/java/avalon/src/java/new.xconf:4:60</td></tr>
- * <tr align="center"><td align="left">
- * <code>conf.{@link #getChild getChild}("desc").{@link #getName
getName}()</code>
- * </td><td>desc (see {@link #getChild(String)})</td><td>desc</td></tr>
- * <tr align="center"><td align="left">
- * <code>conf.{@link #getChild getChild}("doc:desc").{@link #getName
getName}()</code>
- * </td><td>doc:desc</td><td>doc:desc (see {@link
#getChild(String)})</td></tr>
- * <tr align="center"><td align="left">
- * <code>conf.{@link #getChild getChild}("desc").{@link #getValue
getValue}()</code>
- * </td><td>{@link ConfigurationException}</td><td>This is a highly
fictitious config file</td></tr>
- * <tr align="center"><td align="left">
- * <code>conf.{@link #getChild getChild}("doc:desc").{@link #getValue
getValue}()</code>
- * </td><td>This is a highly fictitious config file</td><td>{@link
ConfigurationException}</td></tr>
- * <tr align="center"><td align="left">
- * <code>conf.{@link #getChild getChild}("desc").{@link #getNamespace
getNamespace}()</code>
- * </td><td>&nbsp;</td><td>http://myco.com/documentation";</td></tr>
- * </table>
- * </p>
- * <p>
- * Type-safe utility methods are provided for retrieving attribute and
element
- * values as <code>String</code>, <code>int</code>, <code>long</code>,
- * <code>float</code> and <code>boolean</code>.
- * </p>
- * <h3>Miscellanea</h3>
- * <p>
- * Currently, the configuration tree can only be traversed one node at a
time,
- * eg., through {@link #getChild getChild("foo")} or {@link #getChildren}. In
- * a future release, it may be possible to access child nodes with an
XPath-like
- * syntax.
- * </p>
- * <p>
- * Checking for the existence of an attribute can be done as follows:
- * </p>
- * <pre>
- *String value = conf.getAttribute( "myAttribute", null );
- * if ( null == value )
- * {
- * // Do the processing applicable if the attribute isn't present.
- * }
- * </pre>
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class AvalonConfiguration implements Configuration
-{
- private final net.dpml.configuration.Configuration m_config;
-
- public AvalonConfiguration( net.dpml.configuration.Configuration config
)
- {
- m_config = config;
- }
-
- /**
- * Return the name of the node.
- *
- * @return name of the <code>Configuration</code> node.
- */
- public String getName()
- {
- return m_config.getName();
- }
-
- /**
- * Return a string describing location of Configuration.
- * Location can be different for different mediums (ie "file:line" for
normal XML files or
- * "table:primary-key" for DB based configurations);
- *
- * @return a string describing location of Configuration
- */
- public String getLocation()
- {
- return m_config.getLocation();
- }
-
- /**
- * Returns a string indicating which namespace this Configuration node
- * belongs to.
- *
- * <p>
- * What this returns is dependent on the configuration file and the
- * Configuration builder. If the Configuration builder does not support
- * namespaces, this method will return a blank string.
- * </p>
- * <p>In the case of DefaultConfigurationBuilder, the namespace will
- * be the URI associated with the XML element. Eg.,:</p>
- * <pre>
- * &lt;foo xmlns:x="http://blah.com"&gt;
- * &lt;x:bar/&gt;
- * &lt;/foo&gt;
- * </pre>
- * <p>The namespace of <code>foo</code> will be "", and the namespace of
- * <code>bar</code> will be "http://blah.com";.</p>
- *
- * @return a String identifying the namespace of this Configuration.
- * @throws ConfigurationException if an error occurs
- * @since 4.1
- */
- public String getNamespace() throws ConfigurationException
- {
- try
- {
- return m_config.getNamespace();
- }
- catch( net.dpml.configuration.ConfigurationException e )
- {
- throw new ConfigurationException( e.getMessage(), e.getCause() );
- }
- }
-
- /**
- * Return a new <code>Configuration</code> instance encapsulating the
- * specified child node.
- * <p>
- * If no such child node exists, an empty <code>Configuration</code>
will be
- * returned, allowing constructs such as
- * <code>conf.getChild("foo").getChild("bar").getChild("baz").{@link
- * #getValue(String) getValue}("default");</code>
- * </p>
- * <p>
- * If you wish to get a <code>null</code> return when no element is
present,
- * use {@link #getChild(String, boolean) getChild("foo", <b>false</b>)}.
- * </p>
- *
- * @param child The name of the child node.
- * @return Configuration
- */
- public Configuration getChild( String child )
- {
- return new AvalonConfiguration( m_config.getChild( child ) );
- }
-
- /**
- * Return a <code>Configuration</code> instance encapsulating the
specified
- * child node.
- *
- * @param child The name of the child node.
- * @param createNew If <code>true</code>, a new
<code>Configuration</code>
- * will be created and returned if the specified child does not exist. If
- * <code>false</code>, <code>null</code> will be returned when the
specified
- * child doesn't exist.
- * @return Configuration
- */
- public Configuration getChild( String child, boolean createNew )
- {
- return new AvalonConfiguration( m_config.getChild( child, createNew
) );
- }
-
- /**
- * Return an <code>Array</code> of <code>Configuration</code>
- * elements containing all node children. The array order will reflect
the
- * order in the source config file.
- *
- * @return All child nodes
- */
- public Configuration[] getChildren()
- {
- ArrayList list = new ArrayList();
- net.dpml.configuration.Configuration[] children =
m_config.getChildren();
- for( int i=0; i<children.length; i++ )
- {
- list.add( new AvalonConfiguration( children[i] ) );
- }
- return (Configuration[]) list.toArray( new Configuration[0] );
- }
-
- /**
- * Return an <code>Array</code> of <code>Configuration</code>
- * elements containing all node children with the specified name. The
array
- * order will reflect the order in the source config file.
- *
- * @param name The name of the children to get.
- * @return The child nodes with name <code>name</code>
- */
- public Configuration[] getChildren( String name )
- {
- ArrayList list = new ArrayList();
- net.dpml.configuration.Configuration[] children =
m_config.getChildren( name );
- for( int i=0; i<children.length; i++ )
- {
- list.add( new AvalonConfiguration( children[i] ) );
- }
- return (Configuration[]) list.toArray( new Configuration[0] );
- }
-
- /**
- * Return an array of all attribute names.
- * <p>
- * <em>The order of attributes in this array can not be relied on.</em>
As
- * with XML, a <code>Configuration</code>'s attributes are an
- * <em>unordered</em> set. If your code relies on order, eg
- * <tt>conf.getAttributeNames()[0]</tt>, then it is liable to break if a
- * different XML parser is used.
- * </p>
- * @return a <code>String[]</code> value
- */
- public String[] getAttributeNames()
- {
- return m_config.getAttributeNames();
- }
-
- /**
- * Return the value of specified attribute.
- *
- * @param paramName The name of the parameter you ask the value of.
- * @return String value of attribute.
- * @throws ConfigurationException If no attribute with that name exists.
- */
- public String getAttribute( String paramName ) throws
ConfigurationException
- {
- try
- {
- return m_config.getAttribute( paramName );
- }
- catch( net.dpml.configuration.ConfigurationException e )
- {
- throw new ConfigurationException( e.getMessage(), e.getCause() );
- }
- }
-
- /**
- * Return the <code>int</code> value of the specified attribute contained
- * in this node.
- *
- * @param paramName The name of the parameter you ask the value of.
- * @return int value of attribute
- * @throws ConfigurationException If no parameter with that name exists.
- * or if conversion to
<code>int</code> fails.
- *
- */
- public int getAttributeAsInteger( String paramName ) throws
ConfigurationException
- {
- try
- {
- return m_config.getAttributeAsInteger( paramName );
- }
- catch( net.dpml.configuration.ConfigurationException e )
- {
- throw new ConfigurationException( e.getMessage(), e.getCause() );
- }
- }
-
- /**
- * Returns the value of the attribute specified by its name as a
- * <code>long</code>.
- *
- * @param name The name of the parameter you ask the value of.
- * @return long value of attribute
- * @throws ConfigurationException If no parameter with that name exists.
- * or if conversion to
<code>long</code> fails.
- */
- public long getAttributeAsLong( String name ) throws
ConfigurationException
- {
- try
- {
- return m_config.getAttributeAsLong( name );
- }
- catch( net.dpml.configuration.ConfigurationException e )
- {
- throw new ConfigurationException( e.getMessage(), e.getCause() );
- }
- }
-
- /**
- * Return the <code>float</code> value of the specified parameter
contained
- * in this node.
- *
- * @param paramName The name of the parameter you ask the value of.
- * @return float value of attribute
- * @throws ConfigurationException If no parameter with that name exists.
- * or if conversion to
<code>float</code> fails.
- */
- public float getAttributeAsFloat( String paramName ) throws
ConfigurationException
- {
- try
- {
- return m_config.getAttributeAsFloat( paramName );
- }
- catch( net.dpml.configuration.ConfigurationException e )
- {
- throw new ConfigurationException( e.getMessage(), e.getCause() );
- }
- }
-
- /**
- * Return the <code>boolean</code> value of the specified parameter
contained
- * in this node.
- *
- * @param paramName The name of the parameter you ask the value of.
- * @return boolean value of attribute
- * @throws ConfigurationException If no parameter with that name exists.
- * or if conversion to
<code>boolean</code> fails.
- */
- public boolean getAttributeAsBoolean( String paramName ) throws
ConfigurationException
- {
- try
- {
- return m_config.getAttributeAsBoolean( paramName );
- }
- catch( net.dpml.configuration.ConfigurationException e )
- {
- throw new ConfigurationException( e.getMessage(), e.getCause() );
- }
- }
-
-
- /**
- * Return the <code>String</code> value of the node.
- *
- * @return the value of the node.
- * @throws ConfigurationException if an error occurs
- */
- public String getValue() throws ConfigurationException
- {
- try
- {
- return m_config.getValue();
- }
- catch( net.dpml.configuration.ConfigurationException e )
- {
- throw new ConfigurationException( e.getMessage(), e.getCause() );
- }
- }
-
- /**
- * Return the <code>int</code> value of the node.
- *
- * @return the value of the node.
- *
- * @throws ConfigurationException If conversion to <code>int</code>
fails.
- */
- public int getValueAsInteger() throws ConfigurationException
- {
- try
- {
- return m_config.getValueAsInteger();
- }
- catch( net.dpml.configuration.ConfigurationException e )
- {
- throw new ConfigurationException( e.getMessage(), e.getCause() );
- }
- }
-
- /**
- * Return the <code>float</code> value of the node.
- *
- * @return the value of the node.
- * @throws ConfigurationException If conversion to <code>float</code>
fails.
- */
- public float getValueAsFloat() throws ConfigurationException
- {
- try
- {
- return m_config.getValueAsFloat();
- }
- catch( net.dpml.configuration.ConfigurationException e )
- {
- throw new ConfigurationException( e.getMessage(), e.getCause() );
- }
- }
-
- /**
- * Return the <code>boolean</code> value of the node.
- *
- * @return the value of the node.
- * @throws ConfigurationException If conversion to <code>boolean</code>
fails.
- */
- public boolean getValueAsBoolean() throws ConfigurationException
- {
- try
- {
- return m_config.getValueAsBoolean();
- }
- catch( net.dpml.configuration.ConfigurationException e )
- {
- throw new ConfigurationException( e.getMessage(), e.getCause() );
- }
- }
-
- /**
- * Return the <code>long</code> value of the node.
- *
- * @return the value of the node.
- * @throws ConfigurationException If conversion to <code>long</code>
fails.
- */
- public long getValueAsLong() throws ConfigurationException
- {
- try
- {
- return m_config.getValueAsLong();
- }
- catch( net.dpml.configuration.ConfigurationException e )
- {
- throw new ConfigurationException( e.getMessage(), e.getCause() );
- }
- }
-
- /**
- * Returns the value of the configuration element as a
<code>String</code>.
- * If the configuration value is not set, the default value will be
- * used.
- *
- * @param defaultValue The default value desired.
- * @return String value of the <code>Configuration</code>, or default
- * if none specified.
- */
- public String getValue( String defaultValue )
- {
- return m_config.getValue( defaultValue );
- }
-
- /**
- * Returns the value of the configuration element as an <code>int</code>.
- * If the configuration value is not set, the default value will be
- * used.
- *
- * @param defaultValue The default value desired.
- * @return int value of the <code>Configuration</code>, or default
- * if none specified.
- */
- public int getValueAsInteger( int defaultValue )
- {
- return m_config.getValueAsInteger( defaultValue );
- }
-
- /**
- * Returns the value of the configuration element as a <code>long</code>.
- * If the configuration value is not set, the default value will be
- * used.
- *
- * @param defaultValue The default value desired.
- * @return long value of the <code>Configuration</code>, or default
- * if none specified.
- */
- public long getValueAsLong( long defaultValue )
- {
- return m_config.getValueAsLong( defaultValue );
- }
-
- /**
- * Returns the value of the configuration element as a
<code>float</code>.
- * If the configuration value is not set, the default value will be
- * used.
- *
- * @param defaultValue The default value desired.
- * @return float value of the <code>Configuration</code>, or default
- * if none specified.
- */
- public float getValueAsFloat( float defaultValue )
- {
- return m_config.getValueAsFloat( defaultValue );
- }
-
- /**
- * Returns the value of the configuration element as a
<code>boolean</code>.
- * If the configuration value is not set, the default value will be
- * used.
- *
- * @param defaultValue The default value desired.
- * @return boolean value of the <code>Configuration</code>, or default
- * if none specified.
- */
- public boolean getValueAsBoolean( boolean defaultValue )
- {
- return m_config.getValueAsBoolean( defaultValue );
- }
-
- /**
- * Returns the value of the attribute specified by its name as a
- * <code>String</code>, or the default value if no attribute by
- * that name exists or is empty.
- *
- * @param name The name of the attribute you ask the value of.
- * @param defaultValue The default value desired.
- * @return String value of attribute. It will return the default
- * value if the named attribute does not exist, or if
- * the value is not set.
- */
- public String getAttribute( String name, String defaultValue )
- {
- return m_config.getAttribute( name, defaultValue );
- }
-
- /**
- * Returns the value of the attribute specified by its name as a
- * <code>int</code>, or the default value if no attribute by
- * that name exists or is empty.
- *
- * @param name The name of the attribute you ask the value of.
- * @param defaultValue The default value desired.
- * @return int value of attribute. It will return the default
- * value if the named attribute does not exist, or if
- * the value is not set.
- */
- public int getAttributeAsInteger( String name, int defaultValue )
- {
- return m_config.getAttributeAsInteger( name, defaultValue );
- }
-
- /**
- * Returns the value of the attribute specified by its name as a
- * <code>long</code>, or the default value if no attribute by
- * that name exists or is empty.
- *
- * @param name The name of the attribute you ask the value of.
- * @param defaultValue The default value desired.
- * @return long value of attribute. It will return the default
- * value if the named attribute does not exist, or if
- * the value is not set.
- */
- public long getAttributeAsLong( String name, long defaultValue )
- {
- return m_config.getAttributeAsLong( name, defaultValue );
- }
-
- /**
- * Returns the value of the attribute specified by its name as a
- * <code>float</code>, or the default value if no attribute by
- * that name exists or is empty.
- *
- * @param name The name of the attribute you ask the value of.
- * @param defaultValue The default value desired.
- * @return float value of attribute. It will return the default
- * value if the named attribute does not exist, or if
- * the value is not set.
- */
- public float getAttributeAsFloat( String name, float defaultValue )
- {
- return m_config.getAttributeAsFloat( name, defaultValue );
- }
-
- /**
- * Returns the value of the attribute specified by its name as a
- * <code>boolean</code>, or the default value if no attribute by
- * that name exists or is empty.
- *
- * @param name The name of the attribute you ask the value of.
- * @param defaultValue The default value desired.
- * @return boolean value of attribute. It will return the default
- * value if the named attribute does not exist, or if
- * the value is not set.
- */
- public boolean getAttributeAsBoolean( String name, boolean defaultValue )
- {
- return m_config.getAttributeAsBoolean( name, defaultValue );
- }
-
-}
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ * Copyright 2004 Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.dpml.activation.avalon;
+
+import java.util.ArrayList;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+
+/**
+ * <code>Configuration</code> is a interface encapsulating a configuration
node
+ * used to retrieve configuration values.
+ *
+ * <p>
+ * This is a "read only" interface preventing applications from modifying
their
+ * own configurations. Once it is created, the information never changes.
+ * </p>
+ * <h3>Data Model</h3>
+ * <p>
+ * The data model is a subset of XML's; a single-rooted hierarchical tree
where each
+ * node can contain multiple <em>attributes</em>, and leaf nodes can also
+ * contain a <em>value</em>. Reflecting this, <code>Configuration</code>s are
+ * usually built from an XML file by the DefaultConfigurationBuilder
+ * class, or directly by a SAX parser using a SAXConfigurationHandler or
+ * NamespacedSAXConfigurationHandler event handler.
+ * </p>
+ * <h4>Namespace support</h4>
+ * <p>
+ * Since version 4.1, each <code>Configuration</code> node has a namespace
+ * associated with it, in the form of a string, accessible through {@link
+ * #getNamespace}. If no namespace is present, <code>getNamespace</code> will
+ * return blank (""). See DefaultConfigurationBuilder for details on how
+ * XML namespaces are mapped to <code>Configuration</code> namespaces.
+ * </p>
+ * <h3>Example</h3>
+ * <p>
+ * As an example, consider two <code>Configuration</code>s (with and without
+ * namespaces) built from this XML:
+ * </p>
+ * <pre>
+ * &lt;my-system version="1.3" xmlns:doc="http://myco.com/documentation"&gt;
+ * &lt;doc:desc&gt;This is a highly fictitious config file&lt;/doc:desc&gt;
+ * &lt;widget name="fooWidget" initOrder="1" threadsafe="true"/&gt;
+ * &lt;/my-system&gt;
+ * </pre>
+ * <p>If namespace support is enabled (eg through
+ * DefaultConfigurationBuilder#DefaultConfigurationBuilder(boolean) new
+ * DefaultConfigurationBuilder(true)), then the <code>xmlns:doc</code>
element
+ * will not translate into a Configuration attribute, and the
+ * <code>doc:desc</code> element will become a <code>Configuration</code>
node
+ * with name "desc" and namespace "http://myco.com/documentation";. The
+ * <code>widget</code> element will have namespace "".
+ * </p>
+ * <p>If namespace support is disabled (the default for
+ * DefaultConfigurationBuilder), the above XML will translate directly to
+ * <code>Configuration</code> nodes. The <code>my-system</code> node will
have
+ * an attribute named "xmlns:doc", and a child called "doc:desc".
+ * </p>
+ * <p>
+ * Assuming the <code>Configuration</code> object is named <code>conf</code>,
+ * here is how the data could be retrieved:
+ * </p>
+ * <table border="1">
+ * <tr align="center"><th>Code</th><th>No namespaces</th><th>With
namespaces</th></tr>
+ * <tr align="center"><td align="left">
+ * <code>conf.{@link #getName getName}()</code></td><td
colspan="2">my-system</td></tr>
+ * <tr align="center"><td align="left">
+ * <code>conf.{@link #getAttributeNames getAttributeNames}().length</code>
+ * </td><td>2</td><td>1</td></tr>
+ * <tr align="center"><td align="left">
+ * <code>conf.{@link #getChildren getChildren}().length</code>
+ * </td><td colspan="2">2</td></tr>
+ * <tr align="center"><td align="left">
+ * <code>conf.{@link #getAttributeAsFloat
getAttributeAsFloat}("version")</code>
+ * </td><td colspan="2">1.3</td></tr>
+ * <tr align="center"><td align="left">
+ * <code>conf.{@link #getChild getChild}("widget").{@link #getAttribute
getAttribute}("name")</code>
+ * </td><td colspan="2">fooWidget</td></tr>
+ * <tr align="center"><td align="left">
+ * <code>conf.{@link #getChild getChild}("widget")
+ * .{@link #getAttributeAsBoolean
getAttributeAsBoolean}("threadsafe")</code></td><td colspan="2">
+ * <code>true</code></td></tr>
+ * <tr align="center"><td align="left">
+ * <code>conf.{@link #getChild getChild}("widget").{@link #getLocation
getLocation}()</code>
+ * </td><td
colspan="2">file:///home/jeff/tmp/java/avalon/src/java/new.xconf:4:60</td></tr>
+ * <tr align="center"><td align="left">
+ * <code>conf.{@link #getChild getChild}("desc").{@link #getName
getName}()</code>
+ * </td><td>desc (see {@link #getChild(String)})</td><td>desc</td></tr>
+ * <tr align="center"><td align="left">
+ * <code>conf.{@link #getChild getChild}("doc:desc").{@link #getName
getName}()</code>
+ * </td><td>doc:desc</td><td>doc:desc (see {@link
#getChild(String)})</td></tr>
+ * <tr align="center"><td align="left">
+ * <code>conf.{@link #getChild getChild}("desc").{@link #getValue
getValue}()</code>
+ * </td><td>{@link ConfigurationException}</td><td>This is a highly
fictitious config file</td></tr>
+ * <tr align="center"><td align="left">
+ * <code>conf.{@link #getChild getChild}("doc:desc").{@link #getValue
getValue}()</code>
+ * </td><td>This is a highly fictitious config file</td><td>{@link
ConfigurationException}</td></tr>
+ * <tr align="center"><td align="left">
+ * <code>conf.{@link #getChild getChild}("desc").{@link #getNamespace
getNamespace}()</code>
+ * </td><td>&nbsp;</td><td>http://myco.com/documentation";</td></tr>
+ * </table>
+ * </p>
+ * <p>
+ * Type-safe utility methods are provided for retrieving attribute and
element
+ * values as <code>String</code>, <code>int</code>, <code>long</code>,
+ * <code>float</code> and <code>boolean</code>.
+ * </p>
+ * <h3>Miscellanea</h3>
+ * <p>
+ * Currently, the configuration tree can only be traversed one node at a
time,
+ * eg., through {@link #getChild getChild("foo")} or {@link #getChildren}. In
+ * a future release, it may be possible to access child nodes with an
XPath-like
+ * syntax.
+ * </p>
+ * <p>
+ * Checking for the existence of an attribute can be done as follows:
+ * </p>
+ * <pre>
+ *String value = conf.getAttribute( "myAttribute", null );
+ * if ( null == value )
+ * {
+ * // Do the processing applicable if the attribute isn't present.
+ * }
+ * </pre>
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class AvalonConfiguration implements Configuration
+{
+ private final net.dpml.configuration.Configuration m_config;
+
+ public AvalonConfiguration( net.dpml.configuration.Configuration config
)
+ {
+ m_config = config;
+ }
+
+ /**
+ * Return the name of the node.
+ *
+ * @return name of the <code>Configuration</code> node.
+ */
+ public String getName()
+ {
+ return m_config.getName();
+ }
+
+ /**
+ * Return a string describing location of Configuration.
+ * Location can be different for different mediums (ie "file:line" for
normal XML files or
+ * "table:primary-key" for DB based configurations);
+ *
+ * @return a string describing location of Configuration
+ */
+ public String getLocation()
+ {
+ return m_config.getLocation();
+ }
+
+ /**
+ * Returns a string indicating which namespace this Configuration node
+ * belongs to.
+ *
+ * <p>
+ * What this returns is dependent on the configuration file and the
+ * Configuration builder. If the Configuration builder does not support
+ * namespaces, this method will return a blank string.
+ * </p>
+ * <p>In the case of DefaultConfigurationBuilder, the namespace will
+ * be the URI associated with the XML element. Eg.,:</p>
+ * <pre>
+ * &lt;foo xmlns:x="http://blah.com"&gt;
+ * &lt;x:bar/&gt;
+ * &lt;/foo&gt;
+ * </pre>
+ * <p>The namespace of <code>foo</code> will be "", and the namespace of
+ * <code>bar</code> will be "http://blah.com";.</p>
+ *
+ * @return a String identifying the namespace of this Configuration.
+ * @throws ConfigurationException if an error occurs
+ * @since 4.1
+ */
+ public String getNamespace() throws ConfigurationException
+ {
+ try
+ {
+ return m_config.getNamespace();
+ }
+ catch( net.dpml.configuration.ConfigurationException e )
+ {
+ throw new ConfigurationException( e.getMessage(), e.getCause() );
+ }
+ }
+
+ /**
+ * Return a new <code>Configuration</code> instance encapsulating the
+ * specified child node.
+ * <p>
+ * If no such child node exists, an empty <code>Configuration</code>
will be
+ * returned, allowing constructs such as
+ * <code>conf.getChild("foo").getChild("bar").getChild("baz").{@link
+ * #getValue(String) getValue}("default");</code>
+ * </p>
+ * <p>
+ * If you wish to get a <code>null</code> return when no element is
present,
+ * use {@link #getChild(String, boolean) getChild("foo", <b>false</b>)}.
+ * </p>
+ *
+ * @param child The name of the child node.
+ * @return Configuration
+ */
+ public Configuration getChild( String child )
+ {
+ return new AvalonConfiguration( m_config.getChild( child ) );
+ }
+
+ /**
+ * Return a <code>Configuration</code> instance encapsulating the
specified
+ * child node.
+ *
+ * @param child The name of the child node.
+ * @param createNew If <code>true</code>, a new
<code>Configuration</code>
+ * will be created and returned if the specified child does not exist. If
+ * <code>false</code>, <code>null</code> will be returned when the
specified
+ * child doesn't exist.
+ * @return Configuration
+ */
+ public Configuration getChild( String child, boolean createNew )
+ {
+ return new AvalonConfiguration( m_config.getChild( child, createNew
) );
+ }
+
+ /**
+ * Return an <code>Array</code> of <code>Configuration</code>
+ * elements containing all node children. The array order will reflect
the
+ * order in the source config file.
+ *
+ * @return All child nodes
+ */
+ public Configuration[] getChildren()
+ {
+ ArrayList list = new ArrayList();
+ net.dpml.configuration.Configuration[] children =
m_config.getChildren();
+ for( int i=0; i<children.length; i++ )
+ {
+ list.add( new AvalonConfiguration( children[i] ) );
+ }
+ return (Configuration[]) list.toArray( new Configuration[0] );
+ }
+
+ /**
+ * Return an <code>Array</code> of <code>Configuration</code>
+ * elements containing all node children with the specified name. The
array
+ * order will reflect the order in the source config file.
+ *
+ * @param name The name of the children to get.
+ * @return The child nodes with name <code>name</code>
+ */
+ public Configuration[] getChildren( String name )
+ {
+ ArrayList list = new ArrayList();
+ net.dpml.configuration.Configuration[] children =
m_config.getChildren( name );
+ for( int i=0; i<children.length; i++ )
+ {
+ list.add( new AvalonConfiguration( children[i] ) );
+ }
+ return (Configuration[]) list.toArray( new Configuration[0] );
+ }
+
+ /**
+ * Return an array of all attribute names.
+ * <p>
+ * <em>The order of attributes in this array can not be relied on.</em>
As
+ * with XML, a <code>Configuration</code>'s attributes are an
+ * <em>unordered</em> set. If your code relies on order, eg
+ * <tt>conf.getAttributeNames()[0]</tt>, then it is liable to break if a
+ * different XML parser is used.
+ * </p>
+ * @return a <code>String[]</code> value
+ */
+ public String[] getAttributeNames()
+ {
+ return m_config.getAttributeNames();
+ }
+
+ /**
+ * Return the value of specified attribute.
+ *
+ * @param paramName The name of the parameter you ask the value of.
+ * @return String value of attribute.
+ * @throws ConfigurationException If no attribute with that name exists.
+ */
+ public String getAttribute( String paramName ) throws
ConfigurationException
+ {
+ try
+ {
+ return m_config.getAttribute( paramName );
+ }
+ catch( net.dpml.configuration.ConfigurationException e )
+ {
+ throw new ConfigurationException( e.getMessage(), e.getCause() );
+ }
+ }
+
+ /**
+ * Return the <code>int</code> value of the specified attribute contained
+ * in this node.
+ *
+ * @param paramName The name of the parameter you ask the value of.
+ * @return int value of attribute
+ * @throws ConfigurationException If no parameter with that name exists.
+ * or if conversion to
<code>int</code> fails.
+ *
+ */
+ public int getAttributeAsInteger( String paramName ) throws
ConfigurationException
+ {
+ try
+ {
+ return m_config.getAttributeAsInteger( paramName );
+ }
+ catch( net.dpml.configuration.ConfigurationException e )
+ {
+ throw new ConfigurationException( e.getMessage(), e.getCause() );
+ }
+ }
+
+ /**
+ * Returns the value of the attribute specified by its name as a
+ * <code>long</code>.
+ *
+ * @param name The name of the parameter you ask the value of.
+ * @return long value of attribute
+ * @throws ConfigurationException If no parameter with that name exists.
+ * or if conversion to
<code>long</code> fails.
+ */
+ public long getAttributeAsLong( String name ) throws
ConfigurationException
+ {
+ try
+ {
+ return m_config.getAttributeAsLong( name );
+ }
+ catch( net.dpml.configuration.ConfigurationException e )
+ {
+ throw new ConfigurationException( e.getMessage(), e.getCause() );
+ }
+ }
+
+ /**
+ * Return the <code>float</code> value of the specified parameter
contained
+ * in this node.
+ *
+ * @param paramName The name of the parameter you ask the value of.
+ * @return float value of attribute
+ * @throws ConfigurationException If no parameter with that name exists.
+ * or if conversion to
<code>float</code> fails.
+ */
+ public float getAttributeAsFloat( String paramName ) throws
ConfigurationException
+ {
+ try
+ {
+ return m_config.getAttributeAsFloat( paramName );
+ }
+ catch( net.dpml.configuration.ConfigurationException e )
+ {
+ throw new ConfigurationException( e.getMessage(), e.getCause() );
+ }
+ }
+
+ /**
+ * Return the <code>boolean</code> value of the specified parameter
contained
+ * in this node.
+ *
+ * @param paramName The name of the parameter you ask the value of.
+ * @return boolean value of attribute
+ * @throws ConfigurationException If no parameter with that name exists.
+ * or if conversion to
<code>boolean</code> fails.
+ */
+ public boolean getAttributeAsBoolean( String paramName ) throws
ConfigurationException
+ {
+ try
+ {
+ return m_config.getAttributeAsBoolean( paramName );
+ }
+ catch( net.dpml.configuration.ConfigurationException e )
+ {
+ throw new ConfigurationException( e.getMessage(), e.getCause() );
+ }
+ }
+
+
+ /**
+ * Return the <code>String</code> value of the node.
+ *
+ * @return the value of the node.
+ * @throws ConfigurationException if an error occurs
+ */
+ public String getValue() throws ConfigurationException
+ {
+ try
+ {
+ return m_config.getValue();
+ }
+ catch( net.dpml.configuration.ConfigurationException e )
+ {
+ throw new ConfigurationException( e.getMessage(), e.getCause() );
+ }
+ }
+
+ /**
+ * Return the <code>int</code> value of the node.
+ *
+ * @return the value of the node.
+ *
+ * @throws ConfigurationException If conversion to <code>int</code>
fails.
+ */
+ public int getValueAsInteger() throws ConfigurationException
+ {
+ try
+ {
+ return m_config.getValueAsInteger();
+ }
+ catch( net.dpml.configuration.ConfigurationException e )
+ {
+ throw new ConfigurationException( e.getMessage(), e.getCause() );
+ }
+ }
+
+ /**
+ * Return the <code>float</code> value of the node.
+ *
+ * @return the value of the node.
+ * @throws ConfigurationException If conversion to <code>float</code>
fails.
+ */
+ public float getValueAsFloat() throws ConfigurationException
+ {
+ try
+ {
+ return m_config.getValueAsFloat();
+ }
+ catch( net.dpml.configuration.ConfigurationException e )
+ {
+ throw new ConfigurationException( e.getMessage(), e.getCause() );
+ }
+ }
+
+ /**
+ * Return the <code>boolean</code> value of the node.
+ *
+ * @return the value of the node.
+ * @throws ConfigurationException If conversion to <code>boolean</code>
fails.
+ */
+ public boolean getValueAsBoolean() throws ConfigurationException
+ {
+ try
+ {
+ return m_config.getValueAsBoolean();
+ }
+ catch( net.dpml.configuration.ConfigurationException e )
+ {
+ throw new ConfigurationException( e.getMessage(), e.getCause() );
+ }
+ }
+
+ /**
+ * Return the <code>long</code> value of the node.
+ *
+ * @return the value of the node.
+ * @throws ConfigurationException If conversion to <code>long</code>
fails.
+ */
+ public long getValueAsLong() throws ConfigurationException
+ {
+ try
+ {
+ return m_config.getValueAsLong();
+ }
+ catch( net.dpml.configuration.ConfigurationException e )
+ {
+ throw new ConfigurationException( e.getMessage(), e.getCause() );
+ }
+ }
+
+ /**
+ * Returns the value of the configuration element as a
<code>String</code>.
+ * If the configuration value is not set, the default value will be
+ * used.
+ *
+ * @param defaultValue The default value desired.
+ * @return String value of the <code>Configuration</code>, or default
+ * if none specified.
+ */
+ public String getValue( String defaultValue )
+ {
+ return m_config.getValue( defaultValue );
+ }
+
+ /**
+ * Returns the value of the configuration element as an <code>int</code>.
+ * If the configuration value is not set, the default value will be
+ * used.
+ *
+ * @param defaultValue The default value desired.
+ * @return int value of the <code>Configuration</code>, or default
+ * if none specified.
+ */
+ public int getValueAsInteger( int defaultValue )
+ {
+ return m_config.getValueAsInteger( defaultValue );
+ }
+
+ /**
+ * Returns the value of the configuration element as a <code>long</code>.
+ * If the configuration value is not set, the default value will be
+ * used.
+ *
+ * @param defaultValue The default value desired.
+ * @return long value of the <code>Configuration</code>, or default
+ * if none specified.
+ */
+ public long getValueAsLong( long defaultValue )
+ {
+ return m_config.getValueAsLong( defaultValue );
+ }
+
+ /**
+ * Returns the value of the configuration element as a
<code>float</code>.
+ * If the configuration value is not set, the default value will be
+ * used.
+ *
+ * @param defaultValue The default value desired.
+ * @return float value of the <code>Configuration</code>, or default
+ * if none specified.
+ */
+ public float getValueAsFloat( float defaultValue )
+ {
+ return m_config.getValueAsFloat( defaultValue );
+ }
+
+ /**
+ * Returns the value of the configuration element as a
<code>boolean</code>.
+ * If the configuration value is not set, the default value will be
+ * used.
+ *
+ * @param defaultValue The default value desired.
+ * @return boolean value of the <code>Configuration</code>, or default
+ * if none specified.
+ */
+ public boolean getValueAsBoolean( boolean defaultValue )
+ {
+ return m_config.getValueAsBoolean( defaultValue );
+ }
+
+ /**
+ * Returns the value of the attribute specified by its name as a
+ * <code>String</code>, or the default value if no attribute by
+ * that name exists or is empty.
+ *
+ * @param name The name of the attribute you ask the value of.
+ * @param defaultValue The default value desired.
+ * @return String value of attribute. It will return the default
+ * value if the named attribute does not exist, or if
+ * the value is not set.
+ */
+ public String getAttribute( String name, String defaultValue )
+ {
+ return m_config.getAttribute( name, defaultValue );
+ }
+
+ /**
+ * Returns the value of the attribute specified by its name as a
+ * <code>int</code>, or the default value if no attribute by
+ * that name exists or is empty.
+ *
+ * @param name The name of the attribute you ask the value of.
+ * @param defaultValue The default value desired.
+ * @return int value of attribute. It will return the default
+ * value if the named attribute does not exist, or if
+ * the value is not set.
+ */
+ public int getAttributeAsInteger( String name, int defaultValue )
+ {
+ return m_config.getAttributeAsInteger( name, defaultValue );
+ }
+
+ /**
+ * Returns the value of the attribute specified by its name as a
+ * <code>long</code>, or the default value if no attribute by
+ * that name exists or is empty.
+ *
+ * @param name The name of the attribute you ask the value of.
+ * @param defaultValue The default value desired.
+ * @return long value of attribute. It will return the default
+ * value if the named attribute does not exist, or if
+ * the value is not set.
+ */
+ public long getAttributeAsLong( String name, long defaultValue )
+ {
+ return m_config.getAttributeAsLong( name, defaultValue );
+ }
+
+ /**
+ * Returns the value of the attribute specified by its name as a
+ * <code>float</code>, or the default value if no attribute by
+ * that name exists or is empty.
+ *
+ * @param name The name of the attribute you ask the value of.
+ * @param defaultValue The default value desired.
+ * @return float value of attribute. It will return the default
+ * value if the named attribute does not exist, or if
+ * the value is not set.
+ */
+ public float getAttributeAsFloat( String name, float defaultValue )
+ {
+ return m_config.getAttributeAsFloat( name, defaultValue );
+ }
+
+ /**
+ * Returns the value of the attribute specified by its name as a
+ * <code>boolean</code>, or the default value if no attribute by
+ * that name exists or is empty.
+ *
+ * @param name The name of the attribute you ask the value of.
+ * @param defaultValue The default value desired.
+ * @return boolean value of attribute. It will return the default
+ * value if the named attribute does not exist, or if
+ * the value is not set.
+ */
+ public boolean getAttributeAsBoolean( String name, boolean defaultValue )
+ {
+ return m_config.getAttributeAsBoolean( name, defaultValue );
+ }
+
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonContext.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonContext.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonContext.java
Fri Dec 24 22:19:23 2004
@@ -1,177 +1,177 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 1997-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.activation.avalon;
-
-/**
- * <p>
- * The context is the interface through which the component and its
- * container communicate.
- * </p>
- *
- * <p>
- * <i><b>Note:</b> In the text below there are several requirements that a
- * component may set up for a container. It is understood that a container
- * does not have to satisfy those requirements in order to be
Avalon-compliant.
- * If a component says "I require X to run" a container may reply with "I
don't
- * have any X, so I'm not running you". The requirements here are the maximum
- * that a component may ask for, not the minimum a container must deliver.
- * However, a container should document what it is and isn't capable of
- * delivering.</i>
- * </p>
- *
- * <p>Each Container-Component relationship involves defining a contract
- * between the two entities. A Context contract is defined by (1) an
optional
- * target class, and (2) a set of context entries.
- * </p>
- *
- * <ol>
- * <li>
- * <p>
- * The optional target class is an interface, called <code>T</code>
below.
- * It is required that the component should be able to perform
- * the following operation:
- * </p>
- *
- * <pre><code> public void contextualize( Context context )
- * throws ContextException
- * {
- * T tContext = (T) context;
- * }</code></pre>
- *
- * <p>
- * The container may choose any method to supply the component
- * with a context instance cast-able to <code>T</code>.
- * </p>
- *
- * <p>
- * There is no requirement for <code>T</code> to extend the
<code>Context</code>
- * interface.
- * </p>
- *
- * <p>
- * <i><b>Warning:</b> A component that specifies this requirement will
not
- * be as portable as one that doesn't. Few containers
- * support it. It is therefore discouraged for components
- * to require a castable context.</i>
- * </p>
- * </li>
- *
- * <li>
- * <p>
- * The second part of the context contract defines the set
- * of entries the component can access via the <code>Context.get()</code>
- * method, where an entry consists of the key passed to
<code>get()</code>
- * and the expected return type (the class or interface).
- * Optionally, an alias for the key name can be specified. The
- * contract associated with a particular entry is defined in the
- * container documentation.
- * </p>
- *
- * <p>
- * The class/interface <code>T</code> above may also have associated
- * meta-info that specifies entries, in which case these entries must
- * be supplied by the container in addition to any entries the
- * component itself requires.
- * </p>
- *
- * <p>
- * See: <a href="package-summary.html#meta">Context Meta-Info
- * Specification</a>
- * </p>
- *
- * <p>
- * Standard Avalon context entries, their keys, types and and
- * associated semantics are defined under the framework standard
- * attributes table.
- * </p>
- *
- * <p>
- * See: <a href="package-summary.html#attributes">
- * Avalon Standard Context Entries Specification</a>
- * </p>
- *
- * <h4>Examples, where the data is specified in a sample XML format:</h4>
- *
- * <h5>Example 1: Specification of Canonical Key</h5>
- *
- * <p>
- * When a component specifies:
- * </p>
- *
- * <pre><code> &lt;entry key="avalon:work"
type="java.io.File"/&gt;</code></pre>
- *
- * <p>
- * It should be able to do:
- * </p>
- *
- * <pre><code> File workDirectory = (File) context.get( "avalon:work"
);</code></pre>
- *
- * <p>
- * in order to obtain the value.
- * </p>
- *
- * <h5>Example 2: Specification of Canonical Key With Aliasing</h5>
- *
- * <p>
- * When a component specifies:
- * </p>
- *
- * <pre><code> &lt;entry alias="work" key="avalon:work"
type="java.io.File"/&gt;</code></pre>
- *
- * <p>
- * It should be able to do:
- * </p>
- *
- * <pre><code> File workDirectory = (File) context.get( "work" );
</code></pre>
- * </li>
- * </ol>
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class AvalonContext implements
org.apache.avalon.framework.context.Context
-{
- private final net.dpml.context.Context m_context;
-
- public AvalonContext( net.dpml.context.Context context )
- {
- m_context = context;
- }
-
- /**
- * Retrieve an object from Context.
- *
- * @param key the key into context
- * @return the object
- * @throws org.apache.avalon.framework.context.ContextException if
object not found. Note that this
- * means that either Component is asking for invalid entry
- * or the Container is not living up to contract.
- */
- public Object get( Object key )
- throws org.apache.avalon.framework.context.ContextException
- {
- try
- {
- return m_context.get( key );
- }
- catch( net.dpml.context.ContextException e )
- {
- throw new org.apache.avalon.framework.context.ContextException(
- e.getMessage(), e.getCause() );
- }
- }
-}
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ * Copyright 1997-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.activation.avalon;
+
+/**
+ * <p>
+ * The context is the interface through which the component and its
+ * container communicate.
+ * </p>
+ *
+ * <p>
+ * <i><b>Note:</b> In the text below there are several requirements that a
+ * component may set up for a container. It is understood that a container
+ * does not have to satisfy those requirements in order to be
Avalon-compliant.
+ * If a component says "I require X to run" a container may reply with "I
don't
+ * have any X, so I'm not running you". The requirements here are the maximum
+ * that a component may ask for, not the minimum a container must deliver.
+ * However, a container should document what it is and isn't capable of
+ * delivering.</i>
+ * </p>
+ *
+ * <p>Each Container-Component relationship involves defining a contract
+ * between the two entities. A Context contract is defined by (1) an
optional
+ * target class, and (2) a set of context entries.
+ * </p>
+ *
+ * <ol>
+ * <li>
+ * <p>
+ * The optional target class is an interface, called <code>T</code>
below.
+ * It is required that the component should be able to perform
+ * the following operation:
+ * </p>
+ *
+ * <pre><code> public void contextualize( Context context )
+ * throws ContextException
+ * {
+ * T tContext = (T) context;
+ * }</code></pre>
+ *
+ * <p>
+ * The container may choose any method to supply the component
+ * with a context instance cast-able to <code>T</code>.
+ * </p>
+ *
+ * <p>
+ * There is no requirement for <code>T</code> to extend the
<code>Context</code>
+ * interface.
+ * </p>
+ *
+ * <p>
+ * <i><b>Warning:</b> A component that specifies this requirement will
not
+ * be as portable as one that doesn't. Few containers
+ * support it. It is therefore discouraged for components
+ * to require a castable context.</i>
+ * </p>
+ * </li>
+ *
+ * <li>
+ * <p>
+ * The second part of the context contract defines the set
+ * of entries the component can access via the <code>Context.get()</code>
+ * method, where an entry consists of the key passed to
<code>get()</code>
+ * and the expected return type (the class or interface).
+ * Optionally, an alias for the key name can be specified. The
+ * contract associated with a particular entry is defined in the
+ * container documentation.
+ * </p>
+ *
+ * <p>
+ * The class/interface <code>T</code> above may also have associated
+ * meta-info that specifies entries, in which case these entries must
+ * be supplied by the container in addition to any entries the
+ * component itself requires.
+ * </p>
+ *
+ * <p>
+ * See: <a href="package-summary.html#meta">Context Meta-Info
+ * Specification</a>
+ * </p>
+ *
+ * <p>
+ * Standard Avalon context entries, their keys, types and and
+ * associated semantics are defined under the framework standard
+ * attributes table.
+ * </p>
+ *
+ * <p>
+ * See: <a href="package-summary.html#attributes">
+ * Avalon Standard Context Entries Specification</a>
+ * </p>
+ *
+ * <h4>Examples, where the data is specified in a sample XML format:</h4>
+ *
+ * <h5>Example 1: Specification of Canonical Key</h5>
+ *
+ * <p>
+ * When a component specifies:
+ * </p>
+ *
+ * <pre><code> &lt;entry key="avalon:work"
type="java.io.File"/&gt;</code></pre>
+ *
+ * <p>
+ * It should be able to do:
+ * </p>
+ *
+ * <pre><code> File workDirectory = (File) context.get( "avalon:work"
);</code></pre>
+ *
+ * <p>
+ * in order to obtain the value.
+ * </p>
+ *
+ * <h5>Example 2: Specification of Canonical Key With Aliasing</h5>
+ *
+ * <p>
+ * When a component specifies:
+ * </p>
+ *
+ * <pre><code> &lt;entry alias="work" key="avalon:work"
type="java.io.File"/&gt;</code></pre>
+ *
+ * <p>
+ * It should be able to do:
+ * </p>
+ *
+ * <pre><code> File workDirectory = (File) context.get( "work" );
</code></pre>
+ * </li>
+ * </ol>
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class AvalonContext implements
org.apache.avalon.framework.context.Context
+{
+ private final net.dpml.context.Context m_context;
+
+ public AvalonContext( net.dpml.context.Context context )
+ {
+ m_context = context;
+ }
+
+ /**
+ * Retrieve an object from Context.
+ *
+ * @param key the key into context
+ * @return the object
+ * @throws org.apache.avalon.framework.context.ContextException if
object not found. Note that this
+ * means that either Component is asking for invalid entry
+ * or the Container is not living up to contract.
+ */
+ public Object get( Object key )
+ throws org.apache.avalon.framework.context.ContextException
+ {
+ try
+ {
+ return m_context.get( key );
+ }
+ catch( net.dpml.context.ContextException e )
+ {
+ throw new org.apache.avalon.framework.context.ContextException(
+ e.getMessage(), e.getCause() );
+ }
+ }
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonLogger.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonLogger.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonLogger.java
Fri Dec 24 22:19:23 2004
@@ -1,205 +1,205 @@
-/*
- * 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.activation.avalon;
-
-import org.apache.avalon.framework.logger.Logger;
-
-/**
- * This is a facade for the different logging subsystems.
- * It offers a simplified interface that follows IOC patterns
- * and a simplified priority/level/severity abstraction.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class AvalonLogger implements Logger
-{
-
- private final net.dpml.logging.Logger m_logger;
-
- public AvalonLogger( net.dpml.logging.Logger logger )
- {
- m_logger = logger;
- }
-
- /**
- * Log a debug message.
- *
- * @param message the message
- */
- public void debug( String message )
- {
- m_logger.debug( message );
- }
-
- /**
- * Log a debug message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- public void debug( String message, Throwable throwable )
- {
- m_logger.debug( message, throwable );
- }
-
- /**
- * Determine if messages of priority "debug" will be logged.
- *
- * @return true if "debug" messages will be logged
- */
- public boolean isDebugEnabled()
- {
- return m_logger.isDebugEnabled();
- }
-
- /**
- * Log a info message.
- *
- * @param message the message
- */
- public void info( String message )
- {
- m_logger.info( message );
- }
-
- /**
- * Log a info message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- public void info( String message, Throwable throwable )
- {
- m_logger.info( message, throwable );
- }
-
- /**
- * Determine if messages of priority "info" will be logged.
- *
- * @return true if "info" messages will be logged
- */
- public boolean isInfoEnabled()
- {
- return m_logger.isInfoEnabled();
- }
-
- /**
- * Log a warn message.
- *
- * @param message the message
- */
- public void warn( String message )
- {
- m_logger.warn( message );
- }
-
- /**
- * Log a warn message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- public void warn( String message, Throwable throwable )
- {
- m_logger.warn( message, throwable );
- }
-
- /**
- * Determine if messages of priority "warn" will be logged.
- *
- * @return true if "warn" messages will be logged
- */
- public boolean isWarnEnabled()
- {
- return m_logger.isWarnEnabled();
- }
-
- /**
- * Log a error message.
- *
- * @param message the message
- */
- public void error( String message )
- {
- m_logger.error( message );
- }
-
- /**
- * Log a error message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- public void error( String message, Throwable throwable )
- {
- m_logger.error( message, throwable );
- }
-
- /**
- * Determine if messages of priority "error" will be logged.
- *
- * @return true if "error" messages will be logged
- */
- public boolean isErrorEnabled()
- {
- return m_logger.isErrorEnabled();
- }
-
- /**
- * Log a fatalError message.
- *
- * @param message the message
- */
- public void fatalError( String message )
- {
- m_logger.fatalError( message );
- }
-
- /**
- * Log a fatalError message.
- *
- * @param message the message
- * @param throwable the throwable
- */
- public void fatalError( String message, Throwable throwable )
- {
- m_logger.fatalError( message, throwable );
- }
-
- /**
- * Determine if messages of priority "fatalError" will be logged.
- *
- * @return true if "fatalError" messages will be logged
- */
- public boolean isFatalErrorEnabled()
- {
- return m_logger.isFatalErrorEnabled();
- }
-
- /**
- * Create a new child logger.
- * The name of the child logger is
[current-loggers-name].[passed-in-name]
- * Throws <code>IllegalArgumentException</code> if name has an empty
element name
- *
- * @param name the subname of this logger
- * @return the new logger
- */
- public Logger getChildLogger( String name )
- {
- return new AvalonLogger( m_logger.getChildLogger( name ) );
- }
-}
+/*
+ * 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.activation.avalon;
+
+import org.apache.avalon.framework.logger.Logger;
+
+/**
+ * This is a facade for the different logging subsystems.
+ * It offers a simplified interface that follows IOC patterns
+ * and a simplified priority/level/severity abstraction.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class AvalonLogger implements Logger
+{
+
+ private final net.dpml.logging.Logger m_logger;
+
+ public AvalonLogger( net.dpml.logging.Logger logger )
+ {
+ m_logger = logger;
+ }
+
+ /**
+ * Log a debug message.
+ *
+ * @param message the message
+ */
+ public void debug( String message )
+ {
+ m_logger.debug( message );
+ }
+
+ /**
+ * Log a debug message.
+ *
+ * @param message the message
+ * @param throwable the throwable
+ */
+ public void debug( String message, Throwable throwable )
+ {
+ m_logger.debug( message, throwable );
+ }
+
+ /**
+ * Determine if messages of priority "debug" will be logged.
+ *
+ * @return true if "debug" messages will be logged
+ */
+ public boolean isDebugEnabled()
+ {
+ return m_logger.isDebugEnabled();
+ }
+
+ /**
+ * Log a info message.
+ *
+ * @param message the message
+ */
+ public void info( String message )
+ {
+ m_logger.info( message );
+ }
+
+ /**
+ * Log a info message.
+ *
+ * @param message the message
+ * @param throwable the throwable
+ */
+ public void info( String message, Throwable throwable )
+ {
+ m_logger.info( message, throwable );
+ }
+
+ /**
+ * Determine if messages of priority "info" will be logged.
+ *
+ * @return true if "info" messages will be logged
+ */
+ public boolean isInfoEnabled()
+ {
+ return m_logger.isInfoEnabled();
+ }
+
+ /**
+ * Log a warn message.
+ *
+ * @param message the message
+ */
+ public void warn( String message )
+ {
+ m_logger.warn( message );
+ }
+
+ /**
+ * Log a warn message.
+ *
+ * @param message the message
+ * @param throwable the throwable
+ */
+ public void warn( String message, Throwable throwable )
+ {
+ m_logger.warn( message, throwable );
+ }
+
+ /**
+ * Determine if messages of priority "warn" will be logged.
+ *
+ * @return true if "warn" messages will be logged
+ */
+ public boolean isWarnEnabled()
+ {
+ return m_logger.isWarnEnabled();
+ }
+
+ /**
+ * Log a error message.
+ *
+ * @param message the message
+ */
+ public void error( String message )
+ {
+ m_logger.error( message );
+ }
+
+ /**
+ * Log a error message.
+ *
+ * @param message the message
+ * @param throwable the throwable
+ */
+ public void error( String message, Throwable throwable )
+ {
+ m_logger.error( message, throwable );
+ }
+
+ /**
+ * Determine if messages of priority "error" will be logged.
+ *
+ * @return true if "error" messages will be logged
+ */
+ public boolean isErrorEnabled()
+ {
+ return m_logger.isErrorEnabled();
+ }
+
+ /**
+ * Log a fatalError message.
+ *
+ * @param message the message
+ */
+ public void fatalError( String message )
+ {
+ m_logger.fatalError( message );
+ }
+
+ /**
+ * Log a fatalError message.
+ *
+ * @param message the message
+ * @param throwable the throwable
+ */
+ public void fatalError( String message, Throwable throwable )
+ {
+ m_logger.fatalError( message, throwable );
+ }
+
+ /**
+ * Determine if messages of priority "fatalError" will be logged.
+ *
+ * @return true if "fatalError" messages will be logged
+ */
+ public boolean isFatalErrorEnabled()
+ {
+ return m_logger.isFatalErrorEnabled();
+ }
+
+ /**
+ * Create a new child logger.
+ * The name of the child logger is
[current-loggers-name].[passed-in-name]
+ * Throws <code>IllegalArgumentException</code> if name has an empty
element name
+ *
+ * @param name the subname of this logger
+ * @return the new logger
+ */
+ public Logger getChildLogger( String name )
+ {
+ return new AvalonLogger( m_logger.getChildLogger( name ) );
+ }
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonParameters.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonParameters.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonParameters.java
Fri Dec 24 22:19:23 2004
@@ -1,306 +1,306 @@
-/*
- * 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.activation.avalon;
-
-import java.util.Properties;
-
-import net.dpml.parameters.Parameters;
-import net.dpml.parameters.ParameterException;
-import net.dpml.parameters.impl.DefaultParameters;
-
-
-/**
- * The <code>Parameters</code> class represents a set of key-value
- * pairs.
- * <p>
- * The <code>Parameters</code> object provides a mechanism to obtain
- * values based on a <code>String</code> name. There are convenience
- * methods that allow you to use defaults if the value does not exist,
- * as well as obtain the value in any of the same formats that are in
- * the {@link org.apache.avalon.framework.configuration.Configuration}
interface.
- * </p><p>
- * While there are similarities between the <code>Parameters</code>
- * object and the java.util.Properties object, there are some
- * important semantic differences. First, <code>Parameters</code> are
- * <i>read-only</i>. Second, <code>Parameters</code> are easily
- * derived from {@link
org.apache.avalon.framework.configuration.Configuration} objects. Lastly, the
- * <code>Parameters</code> object is derived from XML fragments that
- * look like this:
- * <pre><code>
- * &lt;parameter name="param-name" value="param-value" /&gt;
- * </code></pre>
- * </p><p>
- * <strong>Note: this class is not thread safe by default.</strong> If you
- * require thread safety please synchronize write access to this class to
- * prevent potential data corruption.
- * </p>
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class AvalonParameters extends
org.apache.avalon.framework.parameters.Parameters
-{
- private final Parameters m_params;
-
- public AvalonParameters( Parameters params )
- {
- m_params = params;
- }
-
- /**
- * Retrieve an array of all parameter names.
- *
- * @return the parameters names
- */
- public String[] getNames()
- {
- return m_params.getNames();
- }
-
- /**
- * Test if the specified parameter can be retrieved.
- *
- * @param name the parameter name
- * @return true if parameter is a name
- */
- public boolean isParameter( final String name )
- {
- return m_params.isParameter( name );
- }
-
- /**
- * Retrieve the <code>String</code> value of the specified parameter.
- * <p />
- * If the specified parameter cannot be found, an exception is thrown.
- *
- * @param name the name of parameter
- * @return the value of parameter
- * @throws org.apache.avalon.framework.parameters.ParameterException if
the specified parameter cannot be found
- */
- public String getParameter( final String name )
- throws org.apache.avalon.framework.parameters.ParameterException
- {
- try
- {
- return m_params.getParameter( name );
- }
- catch( ParameterException e )
- {
- throw new
org.apache.avalon.framework.parameters.ParameterException( e.getMessage(),
e.getCause() );
- }
- }
-
- /**
- * Retrieve the <code>String</code> value of the specified parameter.
- * <p />
- * If the specified parameter cannot be found, <code>defaultValue</code>
- * is returned.
- *
- * @param name the name of parameter
- * @param defaultValue the default value, returned if parameter does not
exist
- * or parameter's name is null
- * @return the value of parameter
- */
- public String getParameter( final String name, final String defaultValue
)
- {
- return m_params.getParameter( name, defaultValue );
- }
-
- /**
- * Retrieve the <code>int</code> value of the specified parameter.
- * <p />
- * If the specified parameter cannot be found, an exception is thrown.
- *
- * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and
binary
- * numbers begin with 0b, all other values are assumed to be decimal.
- *
- * @param name the name of parameter
- * @return the integer parameter type
- * @throws org.apache.avalon.framework.parameters.ParameterException if
the specified parameter cannot be found
- * or is not an Integer value
- */
- public int getParameterAsInteger( final String name )
- throws org.apache.avalon.framework.parameters.ParameterException
- {
- try
- {
- return m_params.getParameterAsInteger( name );
- }
- catch( ParameterException e )
- {
- throw new
org.apache.avalon.framework.parameters.ParameterException( e.getMessage(),
e.getCause() );
- }
- }
-
-
- /**
- * Retrieve the <code>int</code> value of the specified parameter.
- * <p />
- * If the specified parameter cannot be found, <code>defaultValue</code>
- * is returned.
- *
- * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and
binary
- * numbers begin with 0b, all other values are assumed to be decimal.
- *
- * @param name the name of parameter
- * @param defaultValue value returned if parameter does not exist or is
of wrong type
- * @return the integer parameter type
- */
- public int getParameterAsInteger( final String name, final int
defaultValue )
- {
- return m_params.getParameterAsInteger( name, defaultValue );
- }
-
- /**
- * Retrieve the <code>long</code> value of the specified parameter.
- * <p />
- * If the specified parameter cannot be found, an exception is thrown.
- *
- * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and
binary
- * numbers begin with 0b, all other values are assumed to be decimal.
- *
- * @param name the name of parameter
- * @return the long parameter type
- * @throws org.apache.avalon.framework.parameters.ParameterException if
the specified parameter cannot be found
- * or is not a Long value.
- */
- public long getParameterAsLong( final String name )
- throws org.apache.avalon.framework.parameters.ParameterException
- {
- try
- {
- return m_params.getParameterAsLong( name );
- }
- catch( ParameterException e )
- {
- throw new
org.apache.avalon.framework.parameters.ParameterException( e.getMessage(),
e.getCause() );
- }
- }
-
- /**
- * Retrieve the <code>long</code> value of the specified parameter.
- * <p />
- * If the specified parameter cannot be found, <code>defaultValue</code>
- * is returned.
- *
- * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and
binary
- * numbers begin with 0b, all other values are assumed to be decimal.
- *
- * @param name the name of parameter
- * @param defaultValue value returned if parameter does not exist or is
of wrong type
- * @return the long parameter type
- */
- public long getParameterAsLong( final String name, final long
defaultValue )
- {
- return m_params.getParameterAsLong( name, defaultValue );
- }
-
- /**
- * Retrieve the <code>float</code> value of the specified parameter.
- * <p />
- * If the specified parameter cannot be found, an exception is thrown.
- *
- * @param name the parameter name
- * @return the value
- * @throws org.apache.avalon.framework.parameters.ParameterException if
the specified parameter cannot be found
- * or is not a Float value
- */
- public float getParameterAsFloat( final String name )
- throws org.apache.avalon.framework.parameters.ParameterException
- {
- try
- {
- return m_params.getParameterAsFloat( name );
- }
- catch( ParameterException e )
- {
- throw new
org.apache.avalon.framework.parameters.ParameterException( e.getMessage(),
e.getCause() );
- }
- }
-
- /**
- * Retrieve the <code>float</code> value of the specified parameter.
- * <p />
- * If the specified parameter cannot be found, <code>defaultValue</code>
- * is returned.
- *
- * @param name the parameter name
- * @param defaultValue the default value if parameter does not exist or
is of wrong type
- * @return the value
- */
- public float getParameterAsFloat( final String name, final float
defaultValue )
- {
- return m_params.getParameterAsFloat( name, defaultValue );
- }
-
- /**
- * Retrieve the <code>boolean</code> value of the specified parameter.
- * <p />
- * If the specified parameter cannot be found, an exception is thrown.
- *
- * @param name the parameter name
- * @return the value
- * @throws org.apache.avalon.framework.parameters.ParameterException if
an error occurs
- */
- public boolean getParameterAsBoolean( final String name )
- throws org.apache.avalon.framework.parameters.ParameterException
- {
- try
- {
- return m_params.getParameterAsBoolean( name );
- }
- catch( ParameterException e )
- {
- throw new
org.apache.avalon.framework.parameters.ParameterException( e.getMessage(),
e.getCause() );
- }
- }
-
- /**
- * Retrieve the <code>boolean</code> value of the specified parameter.
- * <p />
- * If the specified parameter cannot be found, <code>defaultValue</code>
- * is returned.
- *
- * @param name the parameter name
- * @param defaultValue the default value if parameter does not exist or
is of wrong type
- * @return the value
- */
- public boolean getParameterAsBoolean( final String name, final boolean
defaultValue )
- {
- return m_params.getParameterAsBoolean( name, defaultValue );
- }
-
- /**
- * Merge parameters from another <code>Parameters</code> instance
- * into this.
- *
- * @param other the other Parameters
- * @return This <code>Parameters</code> instance.
- */
- public org.apache.avalon.framework.parameters.Parameters merge( final
org.apache.avalon.framework.parameters.Parameters other )
- {
- final Properties properties = new Properties();
- final String[] names = other.getNames();
- for( int i = 0; i < names.length; ++i )
- {
- properties.setProperty( names[ i ], other.getParameter( names[ i
], "" ) );
- }
- Parameters params = new DefaultParameters( properties );
- return new AvalonParameters( m_params.merge( params ) );
- }
-
-}
+/*
+ * 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.activation.avalon;
+
+import java.util.Properties;
+
+import net.dpml.parameters.Parameters;
+import net.dpml.parameters.ParameterException;
+import net.dpml.parameters.impl.DefaultParameters;
+
+
+/**
+ * The <code>Parameters</code> class represents a set of key-value
+ * pairs.
+ * <p>
+ * The <code>Parameters</code> object provides a mechanism to obtain
+ * values based on a <code>String</code> name. There are convenience
+ * methods that allow you to use defaults if the value does not exist,
+ * as well as obtain the value in any of the same formats that are in
+ * the {@link org.apache.avalon.framework.configuration.Configuration}
interface.
+ * </p><p>
+ * While there are similarities between the <code>Parameters</code>
+ * object and the java.util.Properties object, there are some
+ * important semantic differences. First, <code>Parameters</code> are
+ * <i>read-only</i>. Second, <code>Parameters</code> are easily
+ * derived from {@link
org.apache.avalon.framework.configuration.Configuration} objects. Lastly, the
+ * <code>Parameters</code> object is derived from XML fragments that
+ * look like this:
+ * <pre><code>
+ * &lt;parameter name="param-name" value="param-value" /&gt;
+ * </code></pre>
+ * </p><p>
+ * <strong>Note: this class is not thread safe by default.</strong> If you
+ * require thread safety please synchronize write access to this class to
+ * prevent potential data corruption.
+ * </p>
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class AvalonParameters extends
org.apache.avalon.framework.parameters.Parameters
+{
+ private final Parameters m_params;
+
+ public AvalonParameters( Parameters params )
+ {
+ m_params = params;
+ }
+
+ /**
+ * Retrieve an array of all parameter names.
+ *
+ * @return the parameters names
+ */
+ public String[] getNames()
+ {
+ return m_params.getNames();
+ }
+
+ /**
+ * Test if the specified parameter can be retrieved.
+ *
+ * @param name the parameter name
+ * @return true if parameter is a name
+ */
+ public boolean isParameter( final String name )
+ {
+ return m_params.isParameter( name );
+ }
+
+ /**
+ * Retrieve the <code>String</code> value of the specified parameter.
+ * <p />
+ * If the specified parameter cannot be found, an exception is thrown.
+ *
+ * @param name the name of parameter
+ * @return the value of parameter
+ * @throws org.apache.avalon.framework.parameters.ParameterException if
the specified parameter cannot be found
+ */
+ public String getParameter( final String name )
+ throws org.apache.avalon.framework.parameters.ParameterException
+ {
+ try
+ {
+ return m_params.getParameter( name );
+ }
+ catch( ParameterException e )
+ {
+ throw new
org.apache.avalon.framework.parameters.ParameterException( e.getMessage(),
e.getCause() );
+ }
+ }
+
+ /**
+ * Retrieve the <code>String</code> value of the specified parameter.
+ * <p />
+ * If the specified parameter cannot be found, <code>defaultValue</code>
+ * is returned.
+ *
+ * @param name the name of parameter
+ * @param defaultValue the default value, returned if parameter does not
exist
+ * or parameter's name is null
+ * @return the value of parameter
+ */
+ public String getParameter( final String name, final String defaultValue
)
+ {
+ return m_params.getParameter( name, defaultValue );
+ }
+
+ /**
+ * Retrieve the <code>int</code> value of the specified parameter.
+ * <p />
+ * If the specified parameter cannot be found, an exception is thrown.
+ *
+ * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and
binary
+ * numbers begin with 0b, all other values are assumed to be decimal.
+ *
+ * @param name the name of parameter
+ * @return the integer parameter type
+ * @throws org.apache.avalon.framework.parameters.ParameterException if
the specified parameter cannot be found
+ * or is not an Integer value
+ */
+ public int getParameterAsInteger( final String name )
+ throws org.apache.avalon.framework.parameters.ParameterException
+ {
+ try
+ {
+ return m_params.getParameterAsInteger( name );
+ }
+ catch( ParameterException e )
+ {
+ throw new
org.apache.avalon.framework.parameters.ParameterException( e.getMessage(),
e.getCause() );
+ }
+ }
+
+
+ /**
+ * Retrieve the <code>int</code> value of the specified parameter.
+ * <p />
+ * If the specified parameter cannot be found, <code>defaultValue</code>
+ * is returned.
+ *
+ * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and
binary
+ * numbers begin with 0b, all other values are assumed to be decimal.
+ *
+ * @param name the name of parameter
+ * @param defaultValue value returned if parameter does not exist or is
of wrong type
+ * @return the integer parameter type
+ */
+ public int getParameterAsInteger( final String name, final int
defaultValue )
+ {
+ return m_params.getParameterAsInteger( name, defaultValue );
+ }
+
+ /**
+ * Retrieve the <code>long</code> value of the specified parameter.
+ * <p />
+ * If the specified parameter cannot be found, an exception is thrown.
+ *
+ * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and
binary
+ * numbers begin with 0b, all other values are assumed to be decimal.
+ *
+ * @param name the name of parameter
+ * @return the long parameter type
+ * @throws org.apache.avalon.framework.parameters.ParameterException if
the specified parameter cannot be found
+ * or is not a Long value.
+ */
+ public long getParameterAsLong( final String name )
+ throws org.apache.avalon.framework.parameters.ParameterException
+ {
+ try
+ {
+ return m_params.getParameterAsLong( name );
+ }
+ catch( ParameterException e )
+ {
+ throw new
org.apache.avalon.framework.parameters.ParameterException( e.getMessage(),
e.getCause() );
+ }
+ }
+
+ /**
+ * Retrieve the <code>long</code> value of the specified parameter.
+ * <p />
+ * If the specified parameter cannot be found, <code>defaultValue</code>
+ * is returned.
+ *
+ * Hexadecimal numbers begin with 0x, Octal numbers begin with 0o and
binary
+ * numbers begin with 0b, all other values are assumed to be decimal.
+ *
+ * @param name the name of parameter
+ * @param defaultValue value returned if parameter does not exist or is
of wrong type
+ * @return the long parameter type
+ */
+ public long getParameterAsLong( final String name, final long
defaultValue )
+ {
+ return m_params.getParameterAsLong( name, defaultValue );
+ }
+
+ /**
+ * Retrieve the <code>float</code> value of the specified parameter.
+ * <p />
+ * If the specified parameter cannot be found, an exception is thrown.
+ *
+ * @param name the parameter name
+ * @return the value
+ * @throws org.apache.avalon.framework.parameters.ParameterException if
the specified parameter cannot be found
+ * or is not a Float value
+ */
+ public float getParameterAsFloat( final String name )
+ throws org.apache.avalon.framework.parameters.ParameterException
+ {
+ try
+ {
+ return m_params.getParameterAsFloat( name );
+ }
+ catch( ParameterException e )
+ {
+ throw new
org.apache.avalon.framework.parameters.ParameterException( e.getMessage(),
e.getCause() );
+ }
+ }
+
+ /**
+ * Retrieve the <code>float</code> value of the specified parameter.
+ * <p />
+ * If the specified parameter cannot be found, <code>defaultValue</code>
+ * is returned.
+ *
+ * @param name the parameter name
+ * @param defaultValue the default value if parameter does not exist or
is of wrong type
+ * @return the value
+ */
+ public float getParameterAsFloat( final String name, final float
defaultValue )
+ {
+ return m_params.getParameterAsFloat( name, defaultValue );
+ }
+
+ /**
+ * Retrieve the <code>boolean</code> value of the specified parameter.
+ * <p />
+ * If the specified parameter cannot be found, an exception is thrown.
+ *
+ * @param name the parameter name
+ * @return the value
+ * @throws org.apache.avalon.framework.parameters.ParameterException if
an error occurs
+ */
+ public boolean getParameterAsBoolean( final String name )
+ throws org.apache.avalon.framework.parameters.ParameterException
+ {
+ try
+ {
+ return m_params.getParameterAsBoolean( name );
+ }
+ catch( ParameterException e )
+ {
+ throw new
org.apache.avalon.framework.parameters.ParameterException( e.getMessage(),
e.getCause() );
+ }
+ }
+
+ /**
+ * Retrieve the <code>boolean</code> value of the specified parameter.
+ * <p />
+ * If the specified parameter cannot be found, <code>defaultValue</code>
+ * is returned.
+ *
+ * @param name the parameter name
+ * @param defaultValue the default value if parameter does not exist or
is of wrong type
+ * @return the value
+ */
+ public boolean getParameterAsBoolean( final String name, final boolean
defaultValue )
+ {
+ return m_params.getParameterAsBoolean( name, defaultValue );
+ }
+
+ /**
+ * Merge parameters from another <code>Parameters</code> instance
+ * into this.
+ *
+ * @param other the other Parameters
+ * @return This <code>Parameters</code> instance.
+ */
+ public org.apache.avalon.framework.parameters.Parameters merge( final
org.apache.avalon.framework.parameters.Parameters other )
+ {
+ final Properties properties = new Properties();
+ final String[] names = other.getNames();
+ for( int i = 0; i < names.length; ++i )
+ {
+ properties.setProperty( names[ i ], other.getParameter( names[ i
], "" ) );
+ }
+ Parameters params = new DefaultParameters( properties );
+ return new AvalonParameters( m_params.merge( params ) );
+ }
+
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonServiceManager.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonServiceManager.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/AvalonServiceManager.java
Fri Dec 24 22:19:23 2004
@@ -1,122 +1,122 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- * Copyright 1997-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.activation.avalon;
-
-import net.dpml.service.ServiceManager;
-import net.dpml.service.ServiceException;
-
-/**
- * A <code>ServiceManager</code> selects <code>Object</code>s based on a
- * role. The contract is that all the <code>Object</code>s implement the
- * differing roles and there is one <code>Object</code> per role. If you
- * need to select on of many <code>Object</code>s that implement the same
- * role, then you need to use a <code>ServiceSelector</code>. Roles are
- * usually the full interface name.
- *
- * A role is better understood by the analogy of a play. There are many
- * different roles in a script. Any actor or actress can play any given part
- * and you get the same results (phrases said, movements made, etc.). The
exact
- * nuances of the performance is different.
- *
- * Below is a list of things that might be considered the different roles:
- *
- * <ul>
- * <li> InputAdapter and OutputAdapter</li>
- * <li> Store and Spool</li>
- * </ul>
- *
- * The <code>ServiceManager</code> does not specify the methodology of
- * getting the <code>Object</code>, merely the interface used to get it.
- * Therefore the <code>ServiceManager</code> can be implemented with a
- * factory pattern, an object pool, or a simple Hashtable.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- * @see org.apache.avalon.framework.service.Serviceable
- * @see org.apache.avalon.framework.service.ServiceSelector
- */
-public class AvalonServiceManager implements
org.apache.avalon.framework.service.ServiceManager
-{
- private final ServiceManager m_manager;
-
- public AvalonServiceManager( ServiceManager manager )
- {
- m_manager = manager;
- }
-
- /**
- * Get the <code>Object</code> associated with the given key. For
- * instance, If the <code>ServiceManager</code> had a
- * <code>LoggerComponent</code> stored and referenced by key,
- * the following could be used:
- * <pre>
- * try
- * {
- * LoggerComponent log;
- * myComponent = (LoggerComponent) manager.lookup(
LoggerComponent.ROLE );
- * }
- * catch (...)
- * {
- * ...
- * }
- * </pre>
- *
- * @param key The lookup key of the <code>Object</code> to retrieve.
- * @return an <code>Object</code> value
- * @throws org.apache.avalon.framework.service.ServiceException if an
error occurs
- */
- public Object lookup( String key )
- throws org.apache.avalon.framework.service.ServiceException
- {
- try
- {
- return m_manager.lookup( key );
- }
- catch( ServiceException e )
- {
- throw new org.apache.avalon.framework.service.ServiceException(
- e.getKey(), e.getMessage(), e.getCause() );
- }
- }
-
- /**
- * Check to see if a <code>Object</code> exists for a key.
- *
- * @param key a string identifying the key to check.
- * @return True if the object exists, False if it does not.
- */
- public boolean hasService( String key )
- {
- return m_manager.hasService( key );
- }
-
- /**
- * Return the <code>Object</code> when you are finished with it. This
- * allows the <code>ServiceManager</code> to handle the End-Of-Life
Lifecycle
- * events associated with the <code>Object</code>. Please note, that no
- * Exception should be thrown at this point. This is to allow easy use
of the
- * ServiceManager system without having to trap Exceptions on a release.
- *
- * @param object The <code>Object</code> we are releasing, may also be
- * a <code>null</code> reference
- */
- public void release( Object object )
- {
- m_manager.release( object );
- }
-}
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ * Copyright 1997-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.activation.avalon;
+
+import net.dpml.service.ServiceManager;
+import net.dpml.service.ServiceException;
+
+/**
+ * A <code>ServiceManager</code> selects <code>Object</code>s based on a
+ * role. The contract is that all the <code>Object</code>s implement the
+ * differing roles and there is one <code>Object</code> per role. If you
+ * need to select on of many <code>Object</code>s that implement the same
+ * role, then you need to use a <code>ServiceSelector</code>. Roles are
+ * usually the full interface name.
+ *
+ * A role is better understood by the analogy of a play. There are many
+ * different roles in a script. Any actor or actress can play any given part
+ * and you get the same results (phrases said, movements made, etc.). The
exact
+ * nuances of the performance is different.
+ *
+ * Below is a list of things that might be considered the different roles:
+ *
+ * <ul>
+ * <li> InputAdapter and OutputAdapter</li>
+ * <li> Store and Spool</li>
+ * </ul>
+ *
+ * The <code>ServiceManager</code> does not specify the methodology of
+ * getting the <code>Object</code>, merely the interface used to get it.
+ * Therefore the <code>ServiceManager</code> can be implemented with a
+ * factory pattern, an object pool, or a simple Hashtable.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ * @see org.apache.avalon.framework.service.Serviceable
+ * @see org.apache.avalon.framework.service.ServiceSelector
+ */
+public class AvalonServiceManager implements
org.apache.avalon.framework.service.ServiceManager
+{
+ private final ServiceManager m_manager;
+
+ public AvalonServiceManager( ServiceManager manager )
+ {
+ m_manager = manager;
+ }
+
+ /**
+ * Get the <code>Object</code> associated with the given key. For
+ * instance, If the <code>ServiceManager</code> had a
+ * <code>LoggerComponent</code> stored and referenced by key,
+ * the following could be used:
+ * <pre>
+ * try
+ * {
+ * LoggerComponent log;
+ * myComponent = (LoggerComponent) manager.lookup(
LoggerComponent.ROLE );
+ * }
+ * catch (...)
+ * {
+ * ...
+ * }
+ * </pre>
+ *
+ * @param key The lookup key of the <code>Object</code> to retrieve.
+ * @return an <code>Object</code> value
+ * @throws org.apache.avalon.framework.service.ServiceException if an
error occurs
+ */
+ public Object lookup( String key )
+ throws org.apache.avalon.framework.service.ServiceException
+ {
+ try
+ {
+ return m_manager.lookup( key );
+ }
+ catch( ServiceException e )
+ {
+ throw new org.apache.avalon.framework.service.ServiceException(
+ e.getKey(), e.getMessage(), e.getCause() );
+ }
+ }
+
+ /**
+ * Check to see if a <code>Object</code> exists for a key.
+ *
+ * @param key a string identifying the key to check.
+ * @return True if the object exists, False if it does not.
+ */
+ public boolean hasService( String key )
+ {
+ return m_manager.hasService( key );
+ }
+
+ /**
+ * Return the <code>Object</code> when you are finished with it. This
+ * allows the <code>ServiceManager</code> to handle the End-Of-Life
Lifecycle
+ * events associated with the <code>Object</code>. Please note, that no
+ * Exception should be thrown at this point. This is to allow easy use
of the
+ * ServiceManager system without having to trap Exceptions on a release.
+ *
+ * @param object The <code>Object</code> we are releasing, may also be
+ * a <code>null</code> reference
+ */
+ public void release( Object object )
+ {
+ m_manager.release( object );
+ }
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/ContainerUtil.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/ContainerUtil.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/ContainerUtil.java
Fri Dec 24 22:19:23 2004
@@ -1,320 +1,320 @@
-/*
- * Copyright 1997-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.activation.avalon;
-
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Executable;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.activity.Startable;
-
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-
-import org.apache.avalon.framework.logger.LogEnabled;
-
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.parameters.Parameterizable;
-
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.Serviceable;
-
-
-/**
- * Utility class that makes it easier to transfer
- * a component throught it's lifecycle stages.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public final class ContainerUtil
-{
- /**
- * Private constructor to block instantiation.
- */
- private ContainerUtil()
- {
- }
-
- /**
- * Run specified object through shutdown lifecycle stages
- * (Stop and Dispose).
- *
- * @param object the object to shutdown
- * @throws Exception if there is a problem stoppping object
- */
- public static void shutdown( final Object object )
- throws Exception
- {
- stop( object );
- dispose( object );
- }
-
- /**
- * Supply specified object with Logger if it implements the
- * {@link LogEnabled} interface.
- *
- * @param object the object to Start
- * @param logger the logger to enable component with. May be null
- * in which case the specified object must not implement
LogEnabled.
- * @throws IllegalArgumentException if the object is LogEnabled but
Logger is null
- */
- public static void enableLogging( final Object object,
- final net.dpml.logging.Logger logger )
- {
- if( object instanceof LogEnabled )
- {
- if( null == logger )
- {
- final String message = "logger is null";
- throw new IllegalArgumentException( message );
- }
- ( (LogEnabled)object ).enableLogging( new AvalonLogger( logger )
);
- }
- }
-
- /**
- * Supply specified object with a Context object if it implements the
- * {@link Contextualizable} interface.
- *
- * @param object the object to contextualize
- * @param context the context object to use for object.
- * May be null in which case the specified object must not
- * implement Contextualizable.
- * @throws net.dpml.context.ContextException if there is a problem
contextualizing object
- * @throws IllegalArgumentException if the object is Contextualizable but
- * context is null
- */
- public static void contextualize( final Object object,
- final Object context )
- throws net.dpml.context.ContextException
- {
- if( object instanceof Contextualizable )
- {
- if( null == context )
- {
- final String message = "context is null";
- throw new IllegalArgumentException( message );
- }
- if( context instanceof Context )
- {
- try
- {
- ( (Contextualizable)object ).contextualize( (Context)
context );
- }
- catch( ContextException ce )
- {
- throw new net.dpml.context.ContextException(
ce.getMessage(), ce.getCause() );
- }
- }
- else
- {
- try
- {
- ( (Contextualizable)object ).contextualize( new
AvalonContext( (net.dpml.context.Context) context ) );
- }
- catch( ContextException ce )
- {
- throw new net.dpml.context.ContextException(
ce.getMessage(), ce.getCause() );
- }
- }
- }
- }
-
- /**
- * Supply specified object with ServiceManager if it implements the
- * {@link Serviceable} interface.
- *
- * @param object the object to service
- * @param serviceManager the serviceManager object to use for object.
- * May be null in which case the specified object must not
- * implement Serviceable.
- * @throws net.dpml.service.ServiceException if there is a problem
servicing object
- * @throws IllegalArgumentException if the object is Servicable but
- * ServiceManager is null
- */
- public static void service( final Object object,
- final net.dpml.service.ServiceManager
serviceManager )
- throws net.dpml.service.ServiceException
- {
- if( object instanceof Serviceable )
- {
- if( null == serviceManager )
- {
- final String message = "ServiceManager is null";
- throw new IllegalArgumentException( message );
- }
- try
- {
- ( (Serviceable)object ).service( new AvalonServiceManager(
serviceManager ) );
- }
- catch( ServiceException se )
- {
- throw new net.dpml.service.ServiceException( se.getKey(),
se.getMessage(), se.getCause() );
- }
- }
- }
-
- /**
- * Configure specified object if it implements the
- * {@link Configurable} interface.
- *
- * @param object the object to Start
- * @param configuration the configuration object to use during
- * configuration. May be null in which case the specified object
- * must not implement Configurable
- * @throws net.dpml.configuration.ConfigurationException if there is a
problem Configuring object,
- * or the object is Configurable but Configuration is null
- * @throws IllegalArgumentException if the object is Configurable but
- * Configuration is null
- */
- public static void configure( final Object object,
- final net.dpml.configuration.Configuration
configuration )
- throws net.dpml.configuration.ConfigurationException
- {
- if( object instanceof Configurable )
- {
- if( null == configuration )
- {
- final String message = "configuration is null";
- throw new IllegalArgumentException( message );
- }
- try
- {
- ( (Configurable)object ).configure( new AvalonConfiguration(
configuration ) );
- }
- catch( ConfigurationException e )
- {
- throw new net.dpml.configuration.ConfigurationException(
e.getMessage(), e.getCause() );
- }
- }
- }
-
- /**
- * Parameterize specified object if it implements the
- * {@link Parameterizable} interface.
- *
- * @param object the object to Parameterize.
- * @param parameters the parameters object to use during
Parameterization.
- * May be null in which case the specified object must not
- * implement Parameterizable.
- * @throws net.dpml.parameters.ParameterException if there is a problem
Parameterizing object
- * @throws IllegalArgumentException if the object is Parameterizable but
- * parameters is null
- */
- public static void parameterize( final Object object,
- final net.dpml.parameters.Parameters
parameters )
- throws net.dpml.parameters.ParameterException
- {
- if( object instanceof Parameterizable )
- {
- if( null == parameters )
- {
- final String message = "parameters is null";
- throw new IllegalArgumentException( message );
- }
- try
- {
- ( (Parameterizable)object ).parameterize( new
AvalonParameters( parameters ) );
- }
- catch( ParameterException e )
- {
- throw new net.dpml.parameters.ParameterException(
e.getMessage(), e.getCause() );
- }
- }
- }
-
- /**
- * Initialize specified object if it implements the
- * {@link Initializable} interface.
- *
- * @param object the object to Initialize
- * @throws Exception if there is a problem Initializing object
- */
- public static void initialize( final Object object )
- throws Exception
- {
- if( object instanceof Initializable )
- {
- ( (Initializable)object ).initialize();
- }
- }
-
- /**
- * Start specified object if it implements the
- * {@link Startable} interface.
- *
- * @param object the object to Start
- * @throws Exception if there is a problem Starting object
- */
- public static void start( final Object object )
- throws Exception
- {
- if( object instanceof Startable )
- {
- ( (Startable)object ).start();
- }
- }
-
- /**
- * Execute the specified object if it implements the
- * {@link Executable} interface.
- *
- * @param object the object to execute
- * @throws Exception if there is a problem executing object
- */
- public static void execute( final Object object )
- throws Exception
- {
- if( object instanceof Executable )
- {
- ( (Executable)object ).execute();
- }
- }
-
- /**
- * Stop specified object if it implements the
- * {@link Startable} interface.
- *
- * @param object the object to stop
- * @throws Exception if there is a problem stoppping object
- */
- public static void stop( final Object object )
- throws Exception
- {
- if( object instanceof Startable )
- {
- ( (Startable)object ).stop();
- }
- }
-
- /**
- * Dispose specified object if it implements the
- * {@link Disposable} interface.
- *
- * @param object the object to dispose
- */
- public static void dispose( final Object object )
- {
- if( object instanceof Disposable )
- {
- ( (Disposable)object ).dispose();
- }
- }
-}
+/*
+ * Copyright 1997-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.activation.avalon;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Executable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.Serviceable;
+
+
+/**
+ * Utility class that makes it easier to transfer
+ * a component throught it's lifecycle stages.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public final class ContainerUtil
+{
+ /**
+ * Private constructor to block instantiation.
+ */
+ private ContainerUtil()
+ {
+ }
+
+ /**
+ * Run specified object through shutdown lifecycle stages
+ * (Stop and Dispose).
+ *
+ * @param object the object to shutdown
+ * @throws Exception if there is a problem stoppping object
+ */
+ public static void shutdown( final Object object )
+ throws Exception
+ {
+ stop( object );
+ dispose( object );
+ }
+
+ /**
+ * Supply specified object with Logger if it implements the
+ * {@link LogEnabled} interface.
+ *
+ * @param object the object to Start
+ * @param logger the logger to enable component with. May be null
+ * in which case the specified object must not implement
LogEnabled.
+ * @throws IllegalArgumentException if the object is LogEnabled but
Logger is null
+ */
+ public static void enableLogging( final Object object,
+ final net.dpml.logging.Logger logger )
+ {
+ if( object instanceof LogEnabled )
+ {
+ if( null == logger )
+ {
+ final String message = "logger is null";
+ throw new IllegalArgumentException( message );
+ }
+ ( (LogEnabled)object ).enableLogging( new AvalonLogger( logger )
);
+ }
+ }
+
+ /**
+ * Supply specified object with a Context object if it implements the
+ * {@link Contextualizable} interface.
+ *
+ * @param object the object to contextualize
+ * @param context the context object to use for object.
+ * May be null in which case the specified object must not
+ * implement Contextualizable.
+ * @throws net.dpml.context.ContextException if there is a problem
contextualizing object
+ * @throws IllegalArgumentException if the object is Contextualizable but
+ * context is null
+ */
+ public static void contextualize( final Object object,
+ final Object context )
+ throws net.dpml.context.ContextException
+ {
+ if( object instanceof Contextualizable )
+ {
+ if( null == context )
+ {
+ final String message = "context is null";
+ throw new IllegalArgumentException( message );
+ }
+ if( context instanceof Context )
+ {
+ try
+ {
+ ( (Contextualizable)object ).contextualize( (Context)
context );
+ }
+ catch( ContextException ce )
+ {
+ throw new net.dpml.context.ContextException(
ce.getMessage(), ce.getCause() );
+ }
+ }
+ else
+ {
+ try
+ {
+ ( (Contextualizable)object ).contextualize( new
AvalonContext( (net.dpml.context.Context) context ) );
+ }
+ catch( ContextException ce )
+ {
+ throw new net.dpml.context.ContextException(
ce.getMessage(), ce.getCause() );
+ }
+ }
+ }
+ }
+
+ /**
+ * Supply specified object with ServiceManager if it implements the
+ * {@link Serviceable} interface.
+ *
+ * @param object the object to service
+ * @param serviceManager the serviceManager object to use for object.
+ * May be null in which case the specified object must not
+ * implement Serviceable.
+ * @throws net.dpml.service.ServiceException if there is a problem
servicing object
+ * @throws IllegalArgumentException if the object is Servicable but
+ * ServiceManager is null
+ */
+ public static void service( final Object object,
+ final net.dpml.service.ServiceManager
serviceManager )
+ throws net.dpml.service.ServiceException
+ {
+ if( object instanceof Serviceable )
+ {
+ if( null == serviceManager )
+ {
+ final String message = "ServiceManager is null";
+ throw new IllegalArgumentException( message );
+ }
+ try
+ {
+ ( (Serviceable)object ).service( new AvalonServiceManager(
serviceManager ) );
+ }
+ catch( ServiceException se )
+ {
+ throw new net.dpml.service.ServiceException( se.getKey(),
se.getMessage(), se.getCause() );
+ }
+ }
+ }
+
+ /**
+ * Configure specified object if it implements the
+ * {@link Configurable} interface.
+ *
+ * @param object the object to Start
+ * @param configuration the configuration object to use during
+ * configuration. May be null in which case the specified object
+ * must not implement Configurable
+ * @throws net.dpml.configuration.ConfigurationException if there is a
problem Configuring object,
+ * or the object is Configurable but Configuration is null
+ * @throws IllegalArgumentException if the object is Configurable but
+ * Configuration is null
+ */
+ public static void configure( final Object object,
+ final net.dpml.configuration.Configuration
configuration )
+ throws net.dpml.configuration.ConfigurationException
+ {
+ if( object instanceof Configurable )
+ {
+ if( null == configuration )
+ {
+ final String message = "configuration is null";
+ throw new IllegalArgumentException( message );
+ }
+ try
+ {
+ ( (Configurable)object ).configure( new AvalonConfiguration(
configuration ) );
+ }
+ catch( ConfigurationException e )
+ {
+ throw new net.dpml.configuration.ConfigurationException(
e.getMessage(), e.getCause() );
+ }
+ }
+ }
+
+ /**
+ * Parameterize specified object if it implements the
+ * {@link Parameterizable} interface.
+ *
+ * @param object the object to Parameterize.
+ * @param parameters the parameters object to use during
Parameterization.
+ * May be null in which case the specified object must not
+ * implement Parameterizable.
+ * @throws net.dpml.parameters.ParameterException if there is a problem
Parameterizing object
+ * @throws IllegalArgumentException if the object is Parameterizable but
+ * parameters is null
+ */
+ public static void parameterize( final Object object,
+ final net.dpml.parameters.Parameters
parameters )
+ throws net.dpml.parameters.ParameterException
+ {
+ if( object instanceof Parameterizable )
+ {
+ if( null == parameters )
+ {
+ final String message = "parameters is null";
+ throw new IllegalArgumentException( message );
+ }
+ try
+ {
+ ( (Parameterizable)object ).parameterize( new
AvalonParameters( parameters ) );
+ }
+ catch( ParameterException e )
+ {
+ throw new net.dpml.parameters.ParameterException(
e.getMessage(), e.getCause() );
+ }
+ }
+ }
+
+ /**
+ * Initialize specified object if it implements the
+ * {@link Initializable} interface.
+ *
+ * @param object the object to Initialize
+ * @throws Exception if there is a problem Initializing object
+ */
+ public static void initialize( final Object object )
+ throws Exception
+ {
+ if( object instanceof Initializable )
+ {
+ ( (Initializable)object ).initialize();
+ }
+ }
+
+ /**
+ * Start specified object if it implements the
+ * {@link Startable} interface.
+ *
+ * @param object the object to Start
+ * @throws Exception if there is a problem Starting object
+ */
+ public static void start( final Object object )
+ throws Exception
+ {
+ if( object instanceof Startable )
+ {
+ ( (Startable)object ).start();
+ }
+ }
+
+ /**
+ * Execute the specified object if it implements the
+ * {@link Executable} interface.
+ *
+ * @param object the object to execute
+ * @throws Exception if there is a problem executing object
+ */
+ public static void execute( final Object object )
+ throws Exception
+ {
+ if( object instanceof Executable )
+ {
+ ( (Executable)object ).execute();
+ }
+ }
+
+ /**
+ * Stop specified object if it implements the
+ * {@link Startable} interface.
+ *
+ * @param object the object to stop
+ * @throws Exception if there is a problem stoppping object
+ */
+ public static void stop( final Object object )
+ throws Exception
+ {
+ if( object instanceof Startable )
+ {
+ ( (Startable)object ).stop();
+ }
+ }
+
+ /**
+ * Dispose specified object if it implements the
+ * {@link Disposable} interface.
+ *
+ * @param object the object to dispose
+ */
+ public static void dispose( final Object object )
+ {
+ if( object instanceof Disposable )
+ {
+ ( (Disposable)object ).dispose();
+ }
+ }
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultAppliance.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultAppliance.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultAppliance.java
Fri Dec 24 22:19:23 2004
@@ -1,244 +1,244 @@
-/*
- * 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.activation.avalon;
-
-import java.lang.reflect.Proxy;
-
-import net.dpml.activation.ApplianceException;
-
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.model.TransientRuntimeException;
-import net.dpml.composition.provider.LifestyleManager;
-import net.dpml.composition.util.DefaultState;
-
-import net.dpml.logging.Logger;
-
-import net.dpml.i18n.ResourceManager;
-import net.dpml.i18n.Resources;
-
-/**
- * Abstract appliance.
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class DefaultAppliance extends AbstractAppliance
-{
- //-------------------------------------------------------------------
- // static
- //-------------------------------------------------------------------
-
- private static final Resources REZ =
- ResourceManager.getPackageResources(
- DefaultAppliance.class );
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final ComponentModel m_model;
-
- private final LifestyleManager m_lifestyle;
-
- private final DefaultState m_commissioned = new DefaultState();
-
- private long m_delay = 0;
-
- private final boolean m_secure;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- public DefaultAppliance(
- ComponentModel model, LifestyleManager lifestyle )
- {
- super( model );
- m_model = model;
- m_lifestyle = lifestyle;
- m_secure = model.isCodeSecurityEnabled();
- }
-
- //-------------------------------------------------------------------
- // Commissionable
- //-------------------------------------------------------------------
-
- /**
- * Commission the appliance.
- *
- * @exception Exception if a commissioning error occurs
- */
- public void commission() throws Exception
- {
- synchronized( m_commissioned )
- {
- if( m_commissioned.isEnabled() ) return;
-
- try
- {
- m_delay = m_model.getDeploymentTimeout();
- m_lifestyle.commission();
- m_delay = 0;
- m_commissioned.setEnabled( true );
- }
- finally
- {
- m_delay = 0;
- }
- }
- }
-
- /**
- * Decommission the appliance. Once an appliance is
- * decommissioned it may be re-commissioned.
- */
- public void decommission()
- {
- synchronized( m_commissioned )
- {
- if( !m_commissioned.isEnabled() ) return;
- m_lifestyle.decommission();
- m_commissioned.setEnabled( false );
- }
- }
-
- //-------------------------------------------------------------------
- // Resolver
- //-------------------------------------------------------------------
-
-
- /**
- * Resolve a object to a value.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- public Object resolve() throws Exception
- {
- //
- // handle the legacy 3.3.0 usage of the "urn:activation:proxy" key
- // if after handle the 3.4.0 semantics for resolution against the
model
- //
-
- if( getComponentModel().getType().getInfo().
- getAttribute( "urn:activation:proxy", "true" ).equals( "false"
) )
- {
- final String message =
- "Component type references the deprecated
'urn:activation:proxy' key."
- + " Please update to the key '" + ComponentModel.PROXY_KEY +
"'.";
- getLogger().warn( message );
- return resolve( false );
- }
- else
- {
- return resolve( getComponentModel().getProxyPolicy() );
- }
- }
-
- public Object resolve( boolean proxy ) throws Exception
- {
- if( !proxy )
- {
- if( m_delay > 0 )
- {
- final String error =
- REZ.getString(
- "appliance.error.resolve.transient",
- this.toString(),
- "" + m_delay );
- throw new TransientRuntimeException( error, m_delay );
- }
- else if( !m_commissioned.isEnabled() )
- {
- final String error =
- REZ.getString(
- "appliance.error.resolve.non-commission-state",
- this.toString() );
- throw new IllegalStateException( error );
- }
- else
- {
- return m_lifestyle.resolve();
- }
- }
- else
- {
- ComponentModel model = getComponentModel();
- Logger logger = model.getLogger().getChildLogger( "proxy" );
- ApplianceInvocationHandler handler =
- new ApplianceInvocationHandler( this, logger, m_secure );
-
- try
- {
- return Proxy.newProxyInstance(
- model.getDeploymentClass().getClassLoader(),
- model.getInterfaces(),
- handler );
- }
- catch( Throwable e )
- {
- final String error =
- "Proxy establishment failure in appliance: " + this;
- throw new ApplianceException( error, e );
- }
- }
- }
-
- /**
- * Release an object
- *
- * @param instance the object to be released
- */
- public void release( Object instance )
- {
- if( null == instance ) return;
- if( !m_commissioned.isEnabled() ) return;
- if( Proxy.isProxyClass( instance.getClass() ) )
- {
- ApplianceInvocationHandler handler =
- (ApplianceInvocationHandler) Proxy.getInvocationHandler(
instance );
- handler.release();
- }
- else
- {
- m_lifestyle.release( instance );
- }
- }
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- /**
- * Return the model backing the handler.
- * @return the type that the appliance is managing
- */
- protected ComponentModel getComponentModel()
- {
- return m_model;
- }
-
- //-------------------------------------------------------------------
- // Object
- //-------------------------------------------------------------------
-
- public String toString()
- {
- return "appliance:" + getComponentModel().getQualifiedName();
- }
-}
+/*
+ * 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.activation.avalon;
+
+import java.lang.reflect.Proxy;
+
+import net.dpml.activation.ApplianceException;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.TransientRuntimeException;
+import net.dpml.composition.provider.LifestyleManager;
+import net.dpml.composition.util.DefaultState;
+
+import net.dpml.logging.Logger;
+
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+
+/**
+ * Abstract appliance.
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class DefaultAppliance extends AbstractAppliance
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources(
+ DefaultAppliance.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final ComponentModel m_model;
+
+ private final LifestyleManager m_lifestyle;
+
+ private final DefaultState m_commissioned = new DefaultState();
+
+ private long m_delay = 0;
+
+ private final boolean m_secure;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public DefaultAppliance(
+ ComponentModel model, LifestyleManager lifestyle )
+ {
+ super( model );
+ m_model = model;
+ m_lifestyle = lifestyle;
+ m_secure = model.isCodeSecurityEnabled();
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the appliance.
+ *
+ * @exception Exception if a commissioning error occurs
+ */
+ public void commission() throws Exception
+ {
+ synchronized( m_commissioned )
+ {
+ if( m_commissioned.isEnabled() ) return;
+
+ try
+ {
+ m_delay = m_model.getDeploymentTimeout();
+ m_lifestyle.commission();
+ m_delay = 0;
+ m_commissioned.setEnabled( true );
+ }
+ finally
+ {
+ m_delay = 0;
+ }
+ }
+ }
+
+ /**
+ * Decommission the appliance. Once an appliance is
+ * decommissioned it may be re-commissioned.
+ */
+ public void decommission()
+ {
+ synchronized( m_commissioned )
+ {
+ if( !m_commissioned.isEnabled() ) return;
+ m_lifestyle.decommission();
+ m_commissioned.setEnabled( false );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+
+ /**
+ * Resolve a object to a value.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ public Object resolve() throws Exception
+ {
+ //
+ // handle the legacy 3.3.0 usage of the "urn:activation:proxy" key
+ // if after handle the 3.4.0 semantics for resolution against the
model
+ //
+
+ if( getComponentModel().getType().getInfo().
+ getAttribute( "urn:activation:proxy", "true" ).equals( "false"
) )
+ {
+ final String message =
+ "Component type references the deprecated
'urn:activation:proxy' key."
+ + " Please update to the key '" + ComponentModel.PROXY_KEY +
"'.";
+ getLogger().warn( message );
+ return resolve( false );
+ }
+ else
+ {
+ return resolve( getComponentModel().getProxyPolicy() );
+ }
+ }
+
+ public Object resolve( boolean proxy ) throws Exception
+ {
+ if( !proxy )
+ {
+ if( m_delay > 0 )
+ {
+ final String error =
+ REZ.getString(
+ "appliance.error.resolve.transient",
+ this.toString(),
+ "" + m_delay );
+ throw new TransientRuntimeException( error, m_delay );
+ }
+ else if( !m_commissioned.isEnabled() )
+ {
+ final String error =
+ REZ.getString(
+ "appliance.error.resolve.non-commission-state",
+ this.toString() );
+ throw new IllegalStateException( error );
+ }
+ else
+ {
+ return m_lifestyle.resolve();
+ }
+ }
+ else
+ {
+ ComponentModel model = getComponentModel();
+ Logger logger = model.getLogger().getChildLogger( "proxy" );
+ ApplianceInvocationHandler handler =
+ new ApplianceInvocationHandler( this, logger, m_secure );
+
+ try
+ {
+ return Proxy.newProxyInstance(
+ model.getDeploymentClass().getClassLoader(),
+ model.getInterfaces(),
+ handler );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Proxy establishment failure in appliance: " + this;
+ throw new ApplianceException( error, e );
+ }
+ }
+ }
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ public void release( Object instance )
+ {
+ if( null == instance ) return;
+ if( !m_commissioned.isEnabled() ) return;
+ if( Proxy.isProxyClass( instance.getClass() ) )
+ {
+ ApplianceInvocationHandler handler =
+ (ApplianceInvocationHandler) Proxy.getInvocationHandler(
instance );
+ handler.release();
+ }
+ else
+ {
+ m_lifestyle.release( instance );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Return the model backing the handler.
+ * @return the type that the appliance is managing
+ */
+ protected ComponentModel getComponentModel()
+ {
+ return m_model;
+ }
+
+ //-------------------------------------------------------------------
+ // Object
+ //-------------------------------------------------------------------
+
+ public String toString()
+ {
+ return "appliance:" + getComponentModel().getQualifiedName();
+ }
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultComponentFactory.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultComponentFactory.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultComponentFactory.java
Fri Dec 24 22:19:23 2004
@@ -1,896 +1,896 @@
-/*
- * 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.activation.avalon;
-
-import java.lang.reflect.Constructor;
-import java.util.Map;
-
-import net.dpml.activation.ComponentFactory;
-import net.dpml.activation.LifecycleException;
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.model.ContextModel;
-import net.dpml.composition.model.DeploymentModel;
-import net.dpml.composition.model.LifecycleCreateExtension;
-import net.dpml.composition.model.LifecycleDestroyExtension;
-import net.dpml.composition.model.StageModel;
-import net.dpml.configuration.Configuration;
-import net.dpml.context.Context;
-import net.dpml.context.impl.DefaultContext;
-import net.dpml.i18n.ResourceManager;
-import net.dpml.i18n.Resources;
-import net.dpml.logging.Logger;
-import net.dpml.meta.info.StageDescriptor;
-import net.dpml.parameters.Parameters;
-import net.dpml.service.ServiceManager;
-
-import org.apache.avalon.lifecycle.Creator;
-
-
-/**
- * A factory enabling the establishment of component instances.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class DefaultComponentFactory
- implements ComponentFactory
-{
- //-------------------------------------------------------------------
- // static
- //-------------------------------------------------------------------
-
- private static final Resources REZ =
- ResourceManager.getPackageResources(
- DefaultComponentFactory.class );
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final ComponentModel m_model;
-
- private final Logger m_logger;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- /**
- * Creation of a new component factory.
- * @param model the component model
- */
- public DefaultComponentFactory( ComponentModel model )
- {
- m_model = model;
-
- if( model.isCodeSecurityEnabled() )
- {
- final String error =
- "Code security is not supported under the avalon runtime.";
- throw new IllegalArgumentException( error );
- }
-
- m_logger = model.getLogger().getChildLogger( "lifecycle" );
- }
-
- //-------------------------------------------------------------------
- // ComponentFactory
- //-------------------------------------------------------------------
-
- /**
- * Creation of a new instance including all deployment stage handling.
- * @return the new incarnated instance
- */
- public Object incarnate() throws LifecycleException
- {
- ClassLoader current = Thread.currentThread().getContextClassLoader();
- ClassLoader classloader =
- m_model.getDeploymentClass().getClassLoader();
- Thread.currentThread().setContextClassLoader( classloader );
-
- try
- {
- return incarnation();
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( current );
- }
- }
-
- /**
- * Termination of the instance including all end-of-life processing.
- * @param instance the component instance to etherialize
- */
- public void etherialize( final Object instance )
- {
- if( getLogger().isDebugEnabled() )
- {
- final String message =
- "etherialization";
- getLogger().debug( message );
- }
-
- try
- {
- applyCreateStage( instance, false );
- }
- catch( Throwable e )
- {
- // will not happen
- }
- finally
- {
- if( instance instanceof
org.apache.avalon.framework.activity.Startable )
- {
- getLogger().debug( "applying shutdown" );
- try
- {
- ContainerUtil.stop( instance );
- }
- catch( Throwable e )
- {
- if( getLogger().isWarnEnabled() )
- {
- final String warning =
- "Ignoring component source shutdown error.";
- getLogger().warn( warning, e );
- }
- }
- }
-
- if( instance instanceof
org.apache.avalon.framework.activity.Disposable )
- {
- getLogger().debug( "applying disposal" );
- try
- {
- ContainerUtil.dispose( instance );
- }
- catch( Throwable e )
- {
- if( getLogger().isWarnEnabled() )
- {
- final String warning =
- "Ignoring component source disposal error.";
- getLogger().warn( warning, e );
- }
- }
- }
- }
- }
-
- //-------------------------------------------------------------------
- // protected implementation
- //-------------------------------------------------------------------
-
- protected Logger getLogger()
- {
- return m_logger;
- }
-
- //-------------------------------------------------------------------
- // private implementation
- //-------------------------------------------------------------------
-
- /**
- * Creation of a new instance including all deployment stage handling.
- * @return the new instance
- */
- private Object incarnation() throws LifecycleException
- {
- if( getLogger().isDebugEnabled() )
- {
- final String message =
- "incarnation";
- getLogger().debug( message );
- }
-
- Class clazz = m_model.getDeploymentClass();
- final Logger logger = m_model.getLogger();
- final Configuration config = m_model.getConfiguration();
- final Parameters params = m_model.getParameters();
- final ServiceManager manager = new DefaultServiceManager( m_model );
- final Object context = getTargetContext();
- final Class contextClass = getContextCastingClass();
-
- final Object instance =
- instantiate(
- clazz, logger, config, params, context, contextClass, manager );
-
- try
- {
- if( instance instanceof
org.apache.avalon.framework.logger.LogEnabled )
- {
- getLogger().debug( "applying logger" );
- ContainerUtil.enableLogging( instance, logger );
- }
-
- if( instance instanceof
org.apache.avalon.framework.context.Contextualizable )
- {
- ContainerUtil.contextualize( instance, context );
- }
-
- if( instance instanceof
org.apache.avalon.framework.service.Serviceable )
- {
- getLogger().debug( "applying service manager" );
- ContainerUtil.service( instance, manager );
- }
-
- if( instance instanceof
org.apache.avalon.framework.configuration.Configurable )
- {
- getLogger().debug( "applying configuration" );
- ContainerUtil.configure( instance, config );
- }
-
-
- if( instance instanceof
org.apache.avalon.framework.parameters.Parameterizable )
- {
- getLogger().debug( "applying parameters" );
- ContainerUtil.parameterize( instance, params );
- }
-
- //
- // handle lifecycle extensions
- //
-
- applyCreateStage( instance, true );
-
- //
- // complete intialization
- //
-
- if( instance instanceof
org.apache.avalon.framework.activity.Initializable )
- {
- getLogger().debug( "applying initialization" );
- ContainerUtil.initialize( instance );
- }
-
- if(
org.apache.avalon.framework.activity.Startable.class.isAssignableFrom( clazz
) )
- {
- getLogger().debug( "applying startup" );
- ContainerUtil.start( instance );
- getLogger().debug( "component startup completed" );
- }
- else if(
org.apache.avalon.framework.activity.Executable.class.isAssignableFrom( clazz
) )
- {
- getLogger().debug( "applying execution" );
- ContainerUtil.execute( instance );
- getLogger().debug( "component execution completed" );
- }
- }
- catch( Throwable e )
- {
- final String error =
- REZ.getString(
- "lifestyle.error.new",
- m_model.getQualifiedName() );
- throw new LifecycleException( error, e );
- }
-
- getLogger().debug( "incarnation complete" );
-
- return instance;
- }
-
- private Class getContextCastingClass() throws LifecycleException
- {
- String casting = m_model.getContextModel().getCastingClassname();
-
- if( null == casting )
- {
- return org.apache.avalon.framework.context.Context.class;
- }
- else
- {
- try
- {
- return
m_model.getDeploymentClass().getClassLoader().loadClass( casting );
- }
- catch( Throwable e )
- {
- final String error =
- "Could not load the custom context casting class ["
- + casting
- + "].";
- throw new LifecycleException( error, e );
- }
- }
-
- /*
- DeliveryDescriptor delivery =
m_model.getContextModel().getDeliveryDescriptor();
- if( null == delivery )
- {
- return null;
- }
- else
- {
- return delivery.getCastingInterfaceClass();
- }
- */
- }
-
- private Object getTargetContext()
- throws LifecycleException
- {
- ContextModel model = m_model.getContextModel();
- Class impl = getContextImplementationClass( model );
- return createComponentContext( impl, model.getContextMap() );
- }
-
- private Class getContextImplementationClass( ContextModel model ) throws
LifecycleException
- {
- String classname = model.getImplementationClassname();
-
- if( null == classname )
- {
- return org.apache.avalon.framework.context.DefaultContext.class;
- }
- else
- {
- try
- {
- return
m_model.getDeploymentClass().getClassLoader().loadClass( classname );
- }
- catch( Throwable e )
- {
- final String error =
- "Could not load the custom context implementation class ["
- + classname
- + "].";
- throw new LifecycleException( error, e );
- }
- }
- }
-
- /**
- * Creates a component context instance.
- *
- * @param clazz the type of context to be created.
- * @param map the configuration of the context.
- *
- * @return the context object compliant with the context casting
- * constraints declared by the component type
- * @exception LifecycleException if an error occurs while attempting to
- * construct the context instance
- */
- private Object createComponentContext( Class clazz, Map map )
- throws LifecycleException
- {
- try
- {
- return createComponentContextWithMap( clazz, map );
- }
- catch( LifecycleException le )
- {
- return createComponentContextWithAvalon( clazz, map );
- }
- }
-
- /**
- * Creates a component context instance.
- *
- * @param clazz the type of context to be created.
- * @param map the configuration of the context.
- *
- * @return the context object compliant with the context casting
- * constraints declared by the component type
- * @exception LifecycleException if an error occurs while attempting to
- * construct the context instance
- */
- private Object createComponentContextWithAvalon( Class clazz, Map map )
- throws LifecycleException
- {
- Context c = new DefaultContext( map );
- org.apache.avalon.framework.context.Context context =
- new AvalonContext( c );
-
- //
- // its a custom context object so we need to create it
- // using the classic context object as the constructor
- // argument
- //
-
- try
- {
- Constructor constructor = clazz.getConstructor(
- new Class[]{
org.apache.avalon.framework.context.Context.class } );
- return constructor.newInstance( new Object[]{ context } );
- }
- catch( NoSuchMethodException e )
- {
- final String error =
- REZ.getString( "context.non-compliance-constructor.error",
clazz.getName() );
- throw new LifecycleException( error, e );
- }
- catch( Throwable e )
- {
- final String error =
- REZ.getString( "context.custom-unexpected.error",
clazz.getName() );
- throw new LifecycleException( error, e );
- }
- }
-
-
- /**
- * Creates a component context instance.
- *
- * @param clazz the type of context to be created.
- * @param map the configuration of the context.
- * @return the context object compliant with the context casting
- * constraints declared by the component type
- * @exception LifecycleException if an error occurs while attempting to
- * construct the context instance
- */
- private Object createComponentContextWithMap( Class clazz, Map map )
- throws LifecycleException
- {
- //
- // its a custom context object so we need to create it
- // using the classic context object as the constructor
- // argument
- //
-
- try
- {
- Constructor constructor = clazz.getConstructor(
- new Class[]{ Map.class } );
- return constructor.newInstance( new Object[]{ map } );
- }
- catch( NoSuchMethodException e )
- {
- final String error =
- REZ.getString( "context.non-compliance-constructor.error",
clazz.getName() );
- throw new LifecycleException( error, e );
- }
- catch( Throwable e )
- {
- final String error =
- REZ.getString( "context.custom-unexpected.error",
clazz.getName() );
- throw new LifecycleException( error, e );
- }
- }
-
-
- private Object instantiate(
- Class clazz, Logger logger, Configuration config, Parameters params,
- Object context, Class contextClass, ServiceManager manager )
- throws LifecycleException
- {
- Constructor constructor = getConstructor( clazz );
-
- Class[] classes = constructor.getParameterTypes();
- Object[] args = new Object[ classes.length ];
- for( int i=0; i<classes.length; i++ )
- {
- Class c = classes[i];
- if(
org.apache.avalon.framework.logger.Logger.class.isAssignableFrom( c ) )
- {
- if( null == logger )
- {
- throw new NullPointerException( "logger" );
- }
- args[i] = new AvalonLogger( logger );
- }
- else if( ( null != contextClass ) &&
contextClass.isAssignableFrom( c ) )
- {
- if( null == context )
- {
- throw new NullPointerException( "context" );
- }
- args[i] = context;
- }
- else if(
org.apache.avalon.framework.configuration.Configuration.class.isAssignableFrom(
c ) )
- {
- if( null == config )
- {
- throw new NullPointerException( "config" );
- }
- args[i] = new AvalonConfiguration( config );
- }
- else if(
org.apache.avalon.framework.parameters.Parameters.class.isAssignableFrom( c )
)
- {
- if( null == params )
- {
- throw new NullPointerException( "params" );
- }
- args[i] = new AvalonParameters( params );
- }
- else if(
org.apache.avalon.framework.service.ServiceManager.class.isAssignableFrom( c
) )
- {
- if( null == manager )
- {
- throw new NullPointerException( "manager" );
- }
- args[i] = new AvalonServiceManager( manager );
- }
- else
- {
- final String error =
- REZ.getString(
- "lifecycle.error.unrecognized-parameter",
- c.getName(),
- clazz.getName() );
- throw new LifecycleException( error );
- }
- }
-
- //
- // instantiate the factory
- //
-
- return instantiateComponent( constructor, args );
- }
-
- private Constructor getConstructor( Class clazz ) throws
LifecycleException
- {
- Constructor[] constructors = clazz.getConstructors();
- if( constructors.length < 1 )
- {
- final String error =
- REZ.getString(
- "lifecycle.error.no-constructor",
- clazz.getName() );
- throw new LifecycleException( error );
- }
-
- if( constructors.length > 1 )
- {
- //
- // we risk conflicting with an object designed for 4.1.2 or
- // earlier that has a null arg constructor - so if this class
- // has a null arg constructor then invoke it, otherwise we
- // we are dealing with an ambigouse object
- //
-
- try
- {
- return clazz.getConstructor( new Class[0] );
- }
- catch( NoSuchMethodException e )
- {
- final String error =
- "Multiple constructor ambiguity in the component model "
- + m_model
- + ". The component class [" + clazz.getName()
- + "] declares "
- + constructors.length
- + " public constructors.";
- throw new LifecycleException( error );
- }
- }
- else
- {
- return constructors[0];
- }
- }
-
- /**
- * Instantiation of a component instance using a supplied constructor
- * and arguments.
- *
- * @param constructor the component constructor
- * @param args the constructor arguments
- * @return the component instance
- * @exception LifecycleException if an instantiation error occurs
- */
- private Object instantiateComponent(
- final Constructor constructor, final Object[] args )
- throws LifecycleException
- {
- try
- {
- if( args.length == 0 )
- {
- getLogger().debug(
- "instantiating component with a null constructor" );
- }
- else
- {
- int n = args.length;
- getLogger().debug(
- "instantiating component with "
- + n + " arguments." );
- }
-
- return constructor.newInstance( args );
- }
- catch( Throwable e )
- {
- Class clazz = constructor.getDeclaringClass();
- final String error =
- REZ.getString(
- "lifecycle.error.instantiation",
- clazz.getName() );
- throw new LifecycleException( error, e );
- }
- }
-
- private void applyCreateStage( Object instance, boolean flag )
- throws LifecycleException
- {
- StageDescriptor[] stages = m_model.getType().getStages();
- if( ( stages.length > 0 ) && getLogger().isDebugEnabled() )
- {
- getLogger().debug( "stage count: " + stages.length );
- }
-
- for( int i=0; i<stages.length; i++ )
- {
- StageDescriptor stage = stages[i];
- ComponentModel provider = getStageProvider( stage );
- Class c = provider.getDeploymentClass();
-
- if( Creator.class.isAssignableFrom( c ) )
- {
-
- getLogger().debug( "processing create: " + c.getName() );
-
- Creator handler = getCreator( provider );
- org.apache.avalon.framework.context.Context context =
- (org.apache.avalon.framework.context.Context)
getTargetContext();
-
- try
- {
- if( flag )
- {
- if( getLogger().isDebugEnabled() )
- {
- int id = System.identityHashCode( instance );
- getLogger().debug( "applying create stage to: "
+ id );
- }
- try
- {
- handler.create( instance, context );
- }
- catch( Throwable e )
- {
- final String error =
- "Create stage error raised by extension.";
- throw new LifecycleException( error, e );
- }
- }
- else
- {
- if( getLogger().isDebugEnabled() )
- {
- int id = System.identityHashCode( instance );
- getLogger().debug( "applying destroy stage to: "
+ id );
- }
- handler.destroy( instance, context );
- }
- }
- catch( Throwable e )
- {
- final String error =
- REZ.getString(
- "lifecycle.error.stage.creator", stage.getKey() );
- if( flag )
- {
- throw new LifecycleException( error, e );
- }
- else
- {
- getLogger().warn( error, e );
- }
- }
- finally
- {
- provider.release( handler );
- }
- }
-
- if( flag && LifecycleCreateExtension.class.isAssignableFrom( c )
)
- {
- LifecycleCreateExtension handler =
- getLifecycleCreateExtension( provider );
-
- try
- {
- if( getLogger().isDebugEnabled() )
- {
- int id = System.identityHashCode( instance );
- getLogger().debug( "applying model create stage to:
" + id );
- }
- handler.create( m_model, stage, instance );
- }
- catch( Throwable e )
- {
- final String error =
- "Create stage extension error.";
- throw new LifecycleException( error, e );
- }
- finally
- {
- provider.release( handler );
- }
- }
- else if( !flag &&
LifecycleDestroyExtension.class.isAssignableFrom( c ) )
- {
- LifecycleDestroyExtension handler =
- getLifecycleDestroyExtension( provider );
-
- try
- {
- if( getLogger().isDebugEnabled() )
- {
- int id = System.identityHashCode( instance );
- getLogger().debug( "applying model destroy stage to:
" + id );
- }
- handler.destroy( m_model, stage, instance );
- }
- catch( Throwable e )
- {
- if( getLogger().isWarnEnabled() )
- {
- final String error =
- "Ignoring destroy stage error";
- getLogger().warn( error, e );
- }
- }
- finally
- {
- provider.release( handler );
- }
- }
- }
- }
-
- private org.apache.avalon.lifecycle.Creator getCreator( DeploymentModel
provider )
- throws LifecycleException
- {
- try
- {
- return (org.apache.avalon.lifecycle.Creator) provider.resolve();
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to resolve creation stage provider.";
- throw new LifecycleException( error, e );
- }
- }
-
- private LifecycleCreateExtension getLifecycleCreateExtension(
- DeploymentModel provider ) throws LifecycleException
- {
- try
- {
- return (LifecycleCreateExtension) provider.resolve();
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to resolve lifecycle creation extension provider.";
- throw new LifecycleException( error, e );
- }
- }
-
- private LifecycleDestroyExtension getLifecycleDestroyExtension(
- DeploymentModel provider ) throws LifecycleException
- {
- try
- {
- return (LifecycleDestroyExtension) provider.resolve();
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to resolve lifecycle destroy extension provider.";
- throw new LifecycleException( error, e );
- }
- }
-
- private ComponentModel getStageProvider( StageDescriptor stage )
- throws IllegalStateException
- {
- final String key = stage.getKey();
- StageModel model = m_model.getStageModel( stage );
- DeploymentModel provider = model.getProvider();
- if( provider instanceof ComponentModel )
- {
- return (ComponentModel) provider;
- }
- else
- {
- final String error =
- REZ.getString(
- "lifecycle.error.invalid-stage-provider",
- key );
- throw new IllegalStateException( error );
- }
- }
-/* Never used
- private void applyContext(
- final Object instance, DeliveryDescriptor delivery, final Object
context )
- throws LifecycleException
- {
- if( null == context ) return;
-
- final ContextModel model = m_model.getContextModel();
- if( delivery instanceof NativeDeliveryDescriptor )
- {
- getLogger().debug( "applying context" );
-
- //
- // its classic context
- //
-
- try
- {
- ContainerUtil.contextualize( instance, context );
- }
- catch( Throwable e )
- {
- final String error =
- REZ.getString(
- "lifecycle.error.avalon-contextualization",
- m_model.getQualifiedName() );
- throw new LifecycleException( error, e );
- }
- }
- else if( delivery instanceof StagedDeliveryDescriptor )
- {
- getLogger().debug( "applying custom context" );
- final DeploymentModel provider = model.getProvider();
- try
- {
- ContextualizationHandler handler =
- (ContextualizationHandler) provider.resolve();
- handler.contextualize( instance, (Context) context );
- }
- catch( Throwable e )
- {
- final String error =
- REZ.getString(
- "lifecycle.error.custom-contextualization",
- m_model.getQualifiedName(),
- provider.toString() );
- throw new LifecycleException( error, e );
- }
- }
- else
- {
- final String error =
- "Unrecognized delivery strategy: ["
- + delivery.getClass().getName()
- + "].";
- throw new IllegalStateException( error );
- }
- }
-
- private void printClassLoader( String name, ClassLoader loader )
- {
- System.out.println( "## " + name + " " + System.identityHashCode(
loader ) );
- if( loader instanceof URLClassLoader )
- {
- URL[] urls = ((URLClassLoader)loader).getURLs();
- for( int i=0; i<urls.length; i++ )
- {
- System.out.println( " (" + i + ") " + m_system.toString(
urls[i] ) );
- }
- }
- ClassLoader parent = loader.getParent();
- if( parent != null )
- {
- printClassLoader( name + ">", parent );
- }
- }
-*/
-
-}
+/*
+ * 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.activation.avalon;
+
+import java.lang.reflect.Constructor;
+import java.util.Map;
+
+import net.dpml.activation.ComponentFactory;
+import net.dpml.activation.LifecycleException;
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.ContextModel;
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.model.LifecycleCreateExtension;
+import net.dpml.composition.model.LifecycleDestroyExtension;
+import net.dpml.composition.model.StageModel;
+import net.dpml.configuration.Configuration;
+import net.dpml.context.Context;
+import net.dpml.context.impl.DefaultContext;
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+import net.dpml.logging.Logger;
+import net.dpml.meta.info.StageDescriptor;
+import net.dpml.parameters.Parameters;
+import net.dpml.service.ServiceManager;
+
+import org.apache.avalon.lifecycle.Creator;
+
+
+/**
+ * A factory enabling the establishment of component instances.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class DefaultComponentFactory
+ implements ComponentFactory
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources(
+ DefaultComponentFactory.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final ComponentModel m_model;
+
+ private final Logger m_logger;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new component factory.
+ * @param model the component model
+ */
+ public DefaultComponentFactory( ComponentModel model )
+ {
+ m_model = model;
+
+ if( model.isCodeSecurityEnabled() )
+ {
+ final String error =
+ "Code security is not supported under the avalon runtime.";
+ throw new IllegalArgumentException( error );
+ }
+
+ m_logger = model.getLogger().getChildLogger( "lifecycle" );
+ }
+
+ //-------------------------------------------------------------------
+ // ComponentFactory
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new instance including all deployment stage handling.
+ * @return the new incarnated instance
+ */
+ public Object incarnate() throws LifecycleException
+ {
+ ClassLoader current = Thread.currentThread().getContextClassLoader();
+ ClassLoader classloader =
+ m_model.getDeploymentClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader( classloader );
+
+ try
+ {
+ return incarnation();
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( current );
+ }
+ }
+
+ /**
+ * Termination of the instance including all end-of-life processing.
+ * @param instance the component instance to etherialize
+ */
+ public void etherialize( final Object instance )
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "etherialization";
+ getLogger().debug( message );
+ }
+
+ try
+ {
+ applyCreateStage( instance, false );
+ }
+ catch( Throwable e )
+ {
+ // will not happen
+ }
+ finally
+ {
+ if( instance instanceof
org.apache.avalon.framework.activity.Startable )
+ {
+ getLogger().debug( "applying shutdown" );
+ try
+ {
+ ContainerUtil.stop( instance );
+ }
+ catch( Throwable e )
+ {
+ if( getLogger().isWarnEnabled() )
+ {
+ final String warning =
+ "Ignoring component source shutdown error.";
+ getLogger().warn( warning, e );
+ }
+ }
+ }
+
+ if( instance instanceof
org.apache.avalon.framework.activity.Disposable )
+ {
+ getLogger().debug( "applying disposal" );
+ try
+ {
+ ContainerUtil.dispose( instance );
+ }
+ catch( Throwable e )
+ {
+ if( getLogger().isWarnEnabled() )
+ {
+ final String warning =
+ "Ignoring component source disposal error.";
+ getLogger().warn( warning, e );
+ }
+ }
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // protected implementation
+ //-------------------------------------------------------------------
+
+ protected Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ //-------------------------------------------------------------------
+ // private implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new instance including all deployment stage handling.
+ * @return the new instance
+ */
+ private Object incarnation() throws LifecycleException
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "incarnation";
+ getLogger().debug( message );
+ }
+
+ Class clazz = m_model.getDeploymentClass();
+ final Logger logger = m_model.getLogger();
+ final Configuration config = m_model.getConfiguration();
+ final Parameters params = m_model.getParameters();
+ final ServiceManager manager = new DefaultServiceManager( m_model );
+ final Object context = getTargetContext();
+ final Class contextClass = getContextCastingClass();
+
+ final Object instance =
+ instantiate(
+ clazz, logger, config, params, context, contextClass, manager );
+
+ try
+ {
+ if( instance instanceof
org.apache.avalon.framework.logger.LogEnabled )
+ {
+ getLogger().debug( "applying logger" );
+ ContainerUtil.enableLogging( instance, logger );
+ }
+
+ if( instance instanceof
org.apache.avalon.framework.context.Contextualizable )
+ {
+ ContainerUtil.contextualize( instance, context );
+ }
+
+ if( instance instanceof
org.apache.avalon.framework.service.Serviceable )
+ {
+ getLogger().debug( "applying service manager" );
+ ContainerUtil.service( instance, manager );
+ }
+
+ if( instance instanceof
org.apache.avalon.framework.configuration.Configurable )
+ {
+ getLogger().debug( "applying configuration" );
+ ContainerUtil.configure( instance, config );
+ }
+
+
+ if( instance instanceof
org.apache.avalon.framework.parameters.Parameterizable )
+ {
+ getLogger().debug( "applying parameters" );
+ ContainerUtil.parameterize( instance, params );
+ }
+
+ //
+ // handle lifecycle extensions
+ //
+
+ applyCreateStage( instance, true );
+
+ //
+ // complete intialization
+ //
+
+ if( instance instanceof
org.apache.avalon.framework.activity.Initializable )
+ {
+ getLogger().debug( "applying initialization" );
+ ContainerUtil.initialize( instance );
+ }
+
+ if(
org.apache.avalon.framework.activity.Startable.class.isAssignableFrom( clazz
) )
+ {
+ getLogger().debug( "applying startup" );
+ ContainerUtil.start( instance );
+ getLogger().debug( "component startup completed" );
+ }
+ else if(
org.apache.avalon.framework.activity.Executable.class.isAssignableFrom( clazz
) )
+ {
+ getLogger().debug( "applying execution" );
+ ContainerUtil.execute( instance );
+ getLogger().debug( "component execution completed" );
+ }
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString(
+ "lifestyle.error.new",
+ m_model.getQualifiedName() );
+ throw new LifecycleException( error, e );
+ }
+
+ getLogger().debug( "incarnation complete" );
+
+ return instance;
+ }
+
+ private Class getContextCastingClass() throws LifecycleException
+ {
+ String casting = m_model.getContextModel().getCastingClassname();
+
+ if( null == casting )
+ {
+ return org.apache.avalon.framework.context.Context.class;
+ }
+ else
+ {
+ try
+ {
+ return
m_model.getDeploymentClass().getClassLoader().loadClass( casting );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Could not load the custom context casting class ["
+ + casting
+ + "].";
+ throw new LifecycleException( error, e );
+ }
+ }
+
+ /*
+ DeliveryDescriptor delivery =
m_model.getContextModel().getDeliveryDescriptor();
+ if( null == delivery )
+ {
+ return null;
+ }
+ else
+ {
+ return delivery.getCastingInterfaceClass();
+ }
+ */
+ }
+
+ private Object getTargetContext()
+ throws LifecycleException
+ {
+ ContextModel model = m_model.getContextModel();
+ Class impl = getContextImplementationClass( model );
+ return createComponentContext( impl, model.getContextMap() );
+ }
+
+ private Class getContextImplementationClass( ContextModel model ) throws
LifecycleException
+ {
+ String classname = model.getImplementationClassname();
+
+ if( null == classname )
+ {
+ return org.apache.avalon.framework.context.DefaultContext.class;
+ }
+ else
+ {
+ try
+ {
+ return
m_model.getDeploymentClass().getClassLoader().loadClass( classname );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Could not load the custom context implementation class ["
+ + classname
+ + "].";
+ throw new LifecycleException( error, e );
+ }
+ }
+ }
+
+ /**
+ * Creates a component context instance.
+ *
+ * @param clazz the type of context to be created.
+ * @param map the configuration of the context.
+ *
+ * @return the context object compliant with the context casting
+ * constraints declared by the component type
+ * @exception LifecycleException if an error occurs while attempting to
+ * construct the context instance
+ */
+ private Object createComponentContext( Class clazz, Map map )
+ throws LifecycleException
+ {
+ try
+ {
+ return createComponentContextWithMap( clazz, map );
+ }
+ catch( LifecycleException le )
+ {
+ return createComponentContextWithAvalon( clazz, map );
+ }
+ }
+
+ /**
+ * Creates a component context instance.
+ *
+ * @param clazz the type of context to be created.
+ * @param map the configuration of the context.
+ *
+ * @return the context object compliant with the context casting
+ * constraints declared by the component type
+ * @exception LifecycleException if an error occurs while attempting to
+ * construct the context instance
+ */
+ private Object createComponentContextWithAvalon( Class clazz, Map map )
+ throws LifecycleException
+ {
+ Context c = new DefaultContext( map );
+ org.apache.avalon.framework.context.Context context =
+ new AvalonContext( c );
+
+ //
+ // its a custom context object so we need to create it
+ // using the classic context object as the constructor
+ // argument
+ //
+
+ try
+ {
+ Constructor constructor = clazz.getConstructor(
+ new Class[]{
org.apache.avalon.framework.context.Context.class } );
+ return constructor.newInstance( new Object[]{ context } );
+ }
+ catch( NoSuchMethodException e )
+ {
+ final String error =
+ REZ.getString( "context.non-compliance-constructor.error",
clazz.getName() );
+ throw new LifecycleException( error, e );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString( "context.custom-unexpected.error",
clazz.getName() );
+ throw new LifecycleException( error, e );
+ }
+ }
+
+
+ /**
+ * Creates a component context instance.
+ *
+ * @param clazz the type of context to be created.
+ * @param map the configuration of the context.
+ * @return the context object compliant with the context casting
+ * constraints declared by the component type
+ * @exception LifecycleException if an error occurs while attempting to
+ * construct the context instance
+ */
+ private Object createComponentContextWithMap( Class clazz, Map map )
+ throws LifecycleException
+ {
+ //
+ // its a custom context object so we need to create it
+ // using the classic context object as the constructor
+ // argument
+ //
+
+ try
+ {
+ Constructor constructor = clazz.getConstructor(
+ new Class[]{ Map.class } );
+ return constructor.newInstance( new Object[]{ map } );
+ }
+ catch( NoSuchMethodException e )
+ {
+ final String error =
+ REZ.getString( "context.non-compliance-constructor.error",
clazz.getName() );
+ throw new LifecycleException( error, e );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString( "context.custom-unexpected.error",
clazz.getName() );
+ throw new LifecycleException( error, e );
+ }
+ }
+
+
+ private Object instantiate(
+ Class clazz, Logger logger, Configuration config, Parameters params,
+ Object context, Class contextClass, ServiceManager manager )
+ throws LifecycleException
+ {
+ Constructor constructor = getConstructor( clazz );
+
+ Class[] classes = constructor.getParameterTypes();
+ Object[] args = new Object[ classes.length ];
+ for( int i=0; i<classes.length; i++ )
+ {
+ Class c = classes[i];
+ if(
org.apache.avalon.framework.logger.Logger.class.isAssignableFrom( c ) )
+ {
+ if( null == logger )
+ {
+ throw new NullPointerException( "logger" );
+ }
+ args[i] = new AvalonLogger( logger );
+ }
+ else if( ( null != contextClass ) &&
contextClass.isAssignableFrom( c ) )
+ {
+ if( null == context )
+ {
+ throw new NullPointerException( "context" );
+ }
+ args[i] = context;
+ }
+ else if(
org.apache.avalon.framework.configuration.Configuration.class.isAssignableFrom(
c ) )
+ {
+ if( null == config )
+ {
+ throw new NullPointerException( "config" );
+ }
+ args[i] = new AvalonConfiguration( config );
+ }
+ else if(
org.apache.avalon.framework.parameters.Parameters.class.isAssignableFrom( c )
)
+ {
+ if( null == params )
+ {
+ throw new NullPointerException( "params" );
+ }
+ args[i] = new AvalonParameters( params );
+ }
+ else if(
org.apache.avalon.framework.service.ServiceManager.class.isAssignableFrom( c
) )
+ {
+ if( null == manager )
+ {
+ throw new NullPointerException( "manager" );
+ }
+ args[i] = new AvalonServiceManager( manager );
+ }
+ else
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.unrecognized-parameter",
+ c.getName(),
+ clazz.getName() );
+ throw new LifecycleException( error );
+ }
+ }
+
+ //
+ // instantiate the factory
+ //
+
+ return instantiateComponent( constructor, args );
+ }
+
+ private Constructor getConstructor( Class clazz ) throws
LifecycleException
+ {
+ Constructor[] constructors = clazz.getConstructors();
+ if( constructors.length < 1 )
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.no-constructor",
+ clazz.getName() );
+ throw new LifecycleException( error );
+ }
+
+ if( constructors.length > 1 )
+ {
+ //
+ // we risk conflicting with an object designed for 4.1.2 or
+ // earlier that has a null arg constructor - so if this class
+ // has a null arg constructor then invoke it, otherwise we
+ // we are dealing with an ambigouse object
+ //
+
+ try
+ {
+ return clazz.getConstructor( new Class[0] );
+ }
+ catch( NoSuchMethodException e )
+ {
+ final String error =
+ "Multiple constructor ambiguity in the component model "
+ + m_model
+ + ". The component class [" + clazz.getName()
+ + "] declares "
+ + constructors.length
+ + " public constructors.";
+ throw new LifecycleException( error );
+ }
+ }
+ else
+ {
+ return constructors[0];
+ }
+ }
+
+ /**
+ * Instantiation of a component instance using a supplied constructor
+ * and arguments.
+ *
+ * @param constructor the component constructor
+ * @param args the constructor arguments
+ * @return the component instance
+ * @exception LifecycleException if an instantiation error occurs
+ */
+ private Object instantiateComponent(
+ final Constructor constructor, final Object[] args )
+ throws LifecycleException
+ {
+ try
+ {
+ if( args.length == 0 )
+ {
+ getLogger().debug(
+ "instantiating component with a null constructor" );
+ }
+ else
+ {
+ int n = args.length;
+ getLogger().debug(
+ "instantiating component with "
+ + n + " arguments." );
+ }
+
+ return constructor.newInstance( args );
+ }
+ catch( Throwable e )
+ {
+ Class clazz = constructor.getDeclaringClass();
+ final String error =
+ REZ.getString(
+ "lifecycle.error.instantiation",
+ clazz.getName() );
+ throw new LifecycleException( error, e );
+ }
+ }
+
+ private void applyCreateStage( Object instance, boolean flag )
+ throws LifecycleException
+ {
+ StageDescriptor[] stages = m_model.getType().getStages();
+ if( ( stages.length > 0 ) && getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( "stage count: " + stages.length );
+ }
+
+ for( int i=0; i<stages.length; i++ )
+ {
+ StageDescriptor stage = stages[i];
+ ComponentModel provider = getStageProvider( stage );
+ Class c = provider.getDeploymentClass();
+
+ if( Creator.class.isAssignableFrom( c ) )
+ {
+
+ getLogger().debug( "processing create: " + c.getName() );
+
+ Creator handler = getCreator( provider );
+ org.apache.avalon.framework.context.Context context =
+ (org.apache.avalon.framework.context.Context)
getTargetContext();
+
+ try
+ {
+ if( flag )
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "applying create stage to: "
+ id );
+ }
+ try
+ {
+ handler.create( instance, context );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Create stage error raised by extension.";
+ throw new LifecycleException( error, e );
+ }
+ }
+ else
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "applying destroy stage to: "
+ id );
+ }
+ handler.destroy( instance, context );
+ }
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.stage.creator", stage.getKey() );
+ if( flag )
+ {
+ throw new LifecycleException( error, e );
+ }
+ else
+ {
+ getLogger().warn( error, e );
+ }
+ }
+ finally
+ {
+ provider.release( handler );
+ }
+ }
+
+ if( flag && LifecycleCreateExtension.class.isAssignableFrom( c )
)
+ {
+ LifecycleCreateExtension handler =
+ getLifecycleCreateExtension( provider );
+
+ try
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "applying model create stage to:
" + id );
+ }
+ handler.create( m_model, stage, instance );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Create stage extension error.";
+ throw new LifecycleException( error, e );
+ }
+ finally
+ {
+ provider.release( handler );
+ }
+ }
+ else if( !flag &&
LifecycleDestroyExtension.class.isAssignableFrom( c ) )
+ {
+ LifecycleDestroyExtension handler =
+ getLifecycleDestroyExtension( provider );
+
+ try
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "applying model destroy stage to:
" + id );
+ }
+ handler.destroy( m_model, stage, instance );
+ }
+ catch( Throwable e )
+ {
+ if( getLogger().isWarnEnabled() )
+ {
+ final String error =
+ "Ignoring destroy stage error";
+ getLogger().warn( error, e );
+ }
+ }
+ finally
+ {
+ provider.release( handler );
+ }
+ }
+ }
+ }
+
+ private org.apache.avalon.lifecycle.Creator getCreator( DeploymentModel
provider )
+ throws LifecycleException
+ {
+ try
+ {
+ return (org.apache.avalon.lifecycle.Creator) provider.resolve();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to resolve creation stage provider.";
+ throw new LifecycleException( error, e );
+ }
+ }
+
+ private LifecycleCreateExtension getLifecycleCreateExtension(
+ DeploymentModel provider ) throws LifecycleException
+ {
+ try
+ {
+ return (LifecycleCreateExtension) provider.resolve();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to resolve lifecycle creation extension provider.";
+ throw new LifecycleException( error, e );
+ }
+ }
+
+ private LifecycleDestroyExtension getLifecycleDestroyExtension(
+ DeploymentModel provider ) throws LifecycleException
+ {
+ try
+ {
+ return (LifecycleDestroyExtension) provider.resolve();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to resolve lifecycle destroy extension provider.";
+ throw new LifecycleException( error, e );
+ }
+ }
+
+ private ComponentModel getStageProvider( StageDescriptor stage )
+ throws IllegalStateException
+ {
+ final String key = stage.getKey();
+ StageModel model = m_model.getStageModel( stage );
+ DeploymentModel provider = model.getProvider();
+ if( provider instanceof ComponentModel )
+ {
+ return (ComponentModel) provider;
+ }
+ else
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.invalid-stage-provider",
+ key );
+ throw new IllegalStateException( error );
+ }
+ }
+/* Never used
+ private void applyContext(
+ final Object instance, DeliveryDescriptor delivery, final Object
context )
+ throws LifecycleException
+ {
+ if( null == context ) return;
+
+ final ContextModel model = m_model.getContextModel();
+ if( delivery instanceof NativeDeliveryDescriptor )
+ {
+ getLogger().debug( "applying context" );
+
+ //
+ // its classic context
+ //
+
+ try
+ {
+ ContainerUtil.contextualize( instance, context );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.avalon-contextualization",
+ m_model.getQualifiedName() );
+ throw new LifecycleException( error, e );
+ }
+ }
+ else if( delivery instanceof StagedDeliveryDescriptor )
+ {
+ getLogger().debug( "applying custom context" );
+ final DeploymentModel provider = model.getProvider();
+ try
+ {
+ ContextualizationHandler handler =
+ (ContextualizationHandler) provider.resolve();
+ handler.contextualize( instance, (Context) context );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.custom-contextualization",
+ m_model.getQualifiedName(),
+ provider.toString() );
+ throw new LifecycleException( error, e );
+ }
+ }
+ else
+ {
+ final String error =
+ "Unrecognized delivery strategy: ["
+ + delivery.getClass().getName()
+ + "].";
+ throw new IllegalStateException( error );
+ }
+ }
+
+ private void printClassLoader( String name, ClassLoader loader )
+ {
+ System.out.println( "## " + name + " " + System.identityHashCode(
loader ) );
+ if( loader instanceof URLClassLoader )
+ {
+ URL[] urls = ((URLClassLoader)loader).getURLs();
+ for( int i=0; i<urls.length; i++ )
+ {
+ System.out.println( " (" + i + ") " + m_system.toString(
urls[i] ) );
+ }
+ }
+ ClassLoader parent = loader.getParent();
+ if( parent != null )
+ {
+ printClassLoader( name + ">", parent );
+ }
+ }
+*/
+
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultLifestyleFactory.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultLifestyleFactory.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultLifestyleFactory.java
Fri Dec 24 22:19:23 2004
@@ -1,94 +1,94 @@
-/*
- * 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.activation.avalon;
-
-import net.dpml.activation.ComponentFactory;
-
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.provider.LifestyleFactory;
-import net.dpml.composition.provider.LifestyleManager;
-
-import net.dpml.meta.info.InfoDescriptor;
-
-
-/**
- * A factory enabling the establishment of runtime handlers.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class DefaultLifestyleFactory implements LifestyleFactory
-{
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- /**
- * Creation of a new default lifestyle factory.
- */
- public DefaultLifestyleFactory()
- {
- }
-
- //-------------------------------------------------------------------
- // LifestyleFactory
- //-------------------------------------------------------------------
-
-
- /**
- * Create a new lifestyle manager.
- * @param model the component model
- * @return the lifestyle manager
- */
- public LifestyleManager createLifestyleManager( ComponentModel model )
- {
- ComponentFactory factory = createComponentFactory( model );
-
- final String lifestyle =
- model.getType().getInfo().getLifestyle();
-
- if( lifestyle.equals( InfoDescriptor.SINGLETON ) )
- {
- return new SingletonLifestyleManager( model, factory );
- }
- else if( lifestyle.equals( InfoDescriptor.THREAD ) )
- {
- return new ThreadLifestyleManager( model, factory );
- }
- else if( lifestyle.equals( InfoDescriptor.TRANSIENT ) )
- {
- return new TransientLifestyleManager( model, factory );
- }
- else
- {
- final String error =
- "Unsupported lifestyle [" + lifestyle + "].";
- throw new IllegalArgumentException( error );
- }
- }
-
- private ComponentFactory createComponentFactory( ComponentModel model )
- {
- return new DefaultComponentFactory( model );
- }
-}
+/*
+ * 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.activation.avalon;
+
+import net.dpml.activation.ComponentFactory;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.provider.LifestyleFactory;
+import net.dpml.composition.provider.LifestyleManager;
+
+import net.dpml.meta.info.InfoDescriptor;
+
+
+/**
+ * A factory enabling the establishment of runtime handlers.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class DefaultLifestyleFactory implements LifestyleFactory
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new default lifestyle factory.
+ */
+ public DefaultLifestyleFactory()
+ {
+ }
+
+ //-------------------------------------------------------------------
+ // LifestyleFactory
+ //-------------------------------------------------------------------
+
+
+ /**
+ * Create a new lifestyle manager.
+ * @param model the component model
+ * @return the lifestyle manager
+ */
+ public LifestyleManager createLifestyleManager( ComponentModel model )
+ {
+ ComponentFactory factory = createComponentFactory( model );
+
+ final String lifestyle =
+ model.getType().getInfo().getLifestyle();
+
+ if( lifestyle.equals( InfoDescriptor.SINGLETON ) )
+ {
+ return new SingletonLifestyleManager( model, factory );
+ }
+ else if( lifestyle.equals( InfoDescriptor.THREAD ) )
+ {
+ return new ThreadLifestyleManager( model, factory );
+ }
+ else if( lifestyle.equals( InfoDescriptor.TRANSIENT ) )
+ {
+ return new TransientLifestyleManager( model, factory );
+ }
+ else
+ {
+ final String error =
+ "Unsupported lifestyle [" + lifestyle + "].";
+ throw new IllegalArgumentException( error );
+ }
+ }
+
+ private ComponentFactory createComponentFactory( ComponentModel model )
+ {
+ return new DefaultComponentFactory( model );
+ }
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultRuntimeFactory.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultRuntimeFactory.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultRuntimeFactory.java
Fri Dec 24 22:19:23 2004
@@ -1,152 +1,152 @@
-/*
- * 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.activation.avalon;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import net.dpml.activation.Appliance;
-import net.dpml.activation.RuntimeFactory;
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.model.DeploymentModel;
-import net.dpml.composition.model.ModelRuntimeException;
-import net.dpml.composition.provider.LifestyleFactory;
-import net.dpml.composition.provider.LifestyleManager;
-import net.dpml.i18n.ResourceManager;
-import net.dpml.i18n.Resources;
-import net.dpml.system.SystemContext;
-
-/**
- * A factory enabling the establishment of runtime handlers.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class DefaultRuntimeFactory implements RuntimeFactory
-{
- //-------------------------------------------------------------------
- // static
- //-------------------------------------------------------------------
-
- private static final Resources REZ =
- ResourceManager.getPackageResources(
- DefaultRuntimeFactory.class );
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final SystemContext m_system;
-
- private final Map m_map = new Hashtable();
-
- //-------------------------------------------------------------------
- // mutable state
- //-------------------------------------------------------------------
-
- private LifestyleFactory m_factory;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- public DefaultRuntimeFactory( SystemContext system )
- {
- m_system = system;
- m_factory = new DefaultLifestyleFactory();
- }
-
- //-------------------------------------------------------------------
- // RuntimeFactory
- //-------------------------------------------------------------------
-
- /**
- * Resolve a runtime handler for a model.
- * @param model the deployment model
- * @return the runtime appliance
- */
- public Appliance getRuntime( DeploymentModel model )
- {
- synchronized( m_map )
- {
- Appliance runtime = getRegisteredRuntime( model );
- if( null != runtime )
- return runtime;
-
- //
- // create the runtime
- // check the model for an overriding runtime using the
- // standard runtime as the default (not implemented
- // yet)
- //
-
- if( model instanceof ComponentModel )
- {
- m_system.getLogger().debug( "creating avalon runtime for " +
model );
- ComponentModel component = (ComponentModel) model;
- LifestyleManager manager =
- m_factory.createLifestyleManager( component );
- runtime = newComponentRuntime( component, manager );
- }
- else
- {
- final String error =
- REZ.getString(
- "runtime.error.unknown-model",
- model.toString(),
- model.getClass().getName() );
- throw new ModelRuntimeException( error );
- }
-
- registerRuntime( model, runtime );
- return runtime;
- }
- }
-
- //-------------------------------------------------------------------
- // private implementation
- //-------------------------------------------------------------------
-
- /**
- * Resolve a runtime handler for a component model.
- * @param model the containment model
- * @return the runtime handler
- */
- protected Appliance newComponentRuntime( ComponentModel model,
LifestyleManager manager )
- {
- return new DefaultAppliance( model, manager );
- }
-
- /**
- * Lookup a runtime relative to the model name.
- * @param model the deployment model
- * @return the matching runtime (possibly null)
- */
- private Appliance getRegisteredRuntime( DeploymentModel model )
- {
- String name = model.getQualifiedName();
- return (Appliance) m_map.get( name );
- }
-
- private void registerRuntime( DeploymentModel model, Appliance runtime )
- {
- String name = model.getQualifiedName();
- m_map.put( name, runtime );
- }
-}
+/*
+ * 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.activation.avalon;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import net.dpml.activation.Appliance;
+import net.dpml.activation.RuntimeFactory;
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.model.ModelRuntimeException;
+import net.dpml.composition.provider.LifestyleFactory;
+import net.dpml.composition.provider.LifestyleManager;
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+import net.dpml.system.SystemContext;
+
+/**
+ * A factory enabling the establishment of runtime handlers.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class DefaultRuntimeFactory implements RuntimeFactory
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources(
+ DefaultRuntimeFactory.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final SystemContext m_system;
+
+ private final Map m_map = new Hashtable();
+
+ //-------------------------------------------------------------------
+ // mutable state
+ //-------------------------------------------------------------------
+
+ private LifestyleFactory m_factory;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public DefaultRuntimeFactory( SystemContext system )
+ {
+ m_system = system;
+ m_factory = new DefaultLifestyleFactory();
+ }
+
+ //-------------------------------------------------------------------
+ // RuntimeFactory
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a runtime handler for a model.
+ * @param model the deployment model
+ * @return the runtime appliance
+ */
+ public Appliance getRuntime( DeploymentModel model )
+ {
+ synchronized( m_map )
+ {
+ Appliance runtime = getRegisteredRuntime( model );
+ if( null != runtime )
+ return runtime;
+
+ //
+ // create the runtime
+ // check the model for an overriding runtime using the
+ // standard runtime as the default (not implemented
+ // yet)
+ //
+
+ if( model instanceof ComponentModel )
+ {
+ m_system.getLogger().debug( "creating avalon runtime for " +
model );
+ ComponentModel component = (ComponentModel) model;
+ LifestyleManager manager =
+ m_factory.createLifestyleManager( component );
+ runtime = newComponentRuntime( component, manager );
+ }
+ else
+ {
+ final String error =
+ REZ.getString(
+ "runtime.error.unknown-model",
+ model.toString(),
+ model.getClass().getName() );
+ throw new ModelRuntimeException( error );
+ }
+
+ registerRuntime( model, runtime );
+ return runtime;
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // private implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a runtime handler for a component model.
+ * @param model the containment model
+ * @return the runtime handler
+ */
+ protected Appliance newComponentRuntime( ComponentModel model,
LifestyleManager manager )
+ {
+ return new DefaultAppliance( model, manager );
+ }
+
+ /**
+ * Lookup a runtime relative to the model name.
+ * @param model the deployment model
+ * @return the matching runtime (possibly null)
+ */
+ private Appliance getRegisteredRuntime( DeploymentModel model )
+ {
+ String name = model.getQualifiedName();
+ return (Appliance) m_map.get( name );
+ }
+
+ private void registerRuntime( DeploymentModel model, Appliance runtime )
+ {
+ String name = model.getQualifiedName();
+ m_map.put( name, runtime );
+ }
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultServiceManager.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultServiceManager.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/DefaultServiceManager.java
Fri Dec 24 22:19:23 2004
@@ -1,324 +1,324 @@
-/*
- * 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.activation.avalon;
-
-import java.util.Map;
-import java.util.Hashtable;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.InvocationHandler;
-
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.model.DeploymentModel;
-import net.dpml.composition.model.DependencyModel;
-
-import net.dpml.logging.Logger;
-
-import net.dpml.service.ServiceException;
-import net.dpml.service.ServiceManager;
-import net.dpml.service.FatalServiceException;
-
-import net.dpml.i18n.ResourceManager;
-import net.dpml.i18n.Resources;
-
-/**
- * Default implementation of the framework {@link ServiceManager} interface.
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- */
-class DefaultServiceManager implements ServiceManager
-{
- //-------------------------------------------------------------------
- // static
- //-------------------------------------------------------------------
-
- private static final Resources REZ =
- ResourceManager.getPackageResources(
- DefaultServiceManager.class );
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final Logger m_logger;
-
- /**
- * A table of identity hashcode integers of established objects
- * that map to the lookup key that was uased to establish the object.
- * Used to track which model is providing an object when we
- * handle release of objects.
- */
- private final Hashtable m_table = new Hashtable();
-
- /**
- * A table of dependency models keyed by lookup key.
- */
- private final Map m_map;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- /**
- * Construct a new ServiceManager.
- * @param model component model of the component that is
- * to be serviced.
- */
- public DefaultServiceManager( ComponentModel model )
- {
- if( model == null )
- {
- throw new NullPointerException( "model" );
- }
- m_logger = model.getLogger();
-
- m_map = new Hashtable();
- DependencyModel[] dependencies = model.getDependencyModels();
- for( int i=0; i < dependencies.length; i++ )
- {
- final DependencyModel dependency = dependencies[i];
-
- DeploymentModel provider = dependency.getProvider();
- if( provider != null )
- {
- final String key = dependency.getDependency().getKey();
- m_map.put( key, dependency );
- }
- }
- }
-
- //-------------------------------------------------------------------
- // ServiceManager
- //-------------------------------------------------------------------
-
- /**
- * Returns true if a provider exists for the supplied role.
- * @param key the service identifier key
- * @return boolean TRUE if the service is available else FALSE
- */
- public boolean hasService( String key )
- {
- if( key == null )
- {
- return false;
- }
- return ( m_map.get( key ) != null );
- }
-
- /**
- * Retrieve Object by key.
- * @param key the role
- * @return the Object
- * @throws ServiceException if an error occurs
- * @throws NullPointerException if the supplied key is null
- */
- public Object lookup( String key ) throws ServiceException
- {
- return lookup( key, -1 );
- }
-
- /**
- * Retrieve Object by key.
- * @param key the role
- * @return the Object or null if the Object doesn't exist
- * @throws ServiceException if an error occurs
- * @throws NullPointerException if the supplied key is null
- */
- public Object lookup( String key, long timeout ) throws ServiceException
- {
- if( key == null )
- {
- throw new NullPointerException( "key" );
- }
-
- if( !hasService( key ) )
- {
- final String error =
- "Unknown key: " + key;
- throw new ServiceException( key, error );
- }
-
- //
- // locate the provider model that is prividing components
- // for this dependency
- //
-
- DependencyModel dependency = (DependencyModel) m_map.get( key );
- final DeploymentModel provider = dependency.getProvider();
-
- if( null == provider )
- {
- final String error =
- REZ.getString( "service.error.null-provider", key );
- throw new IllegalStateException( error );
- }
-
- //
- // get a proxy to the service from the provider
- // (note that it is up to a provider to determine if
- // a proxy if generated based on its service export
- // parameters)
- //
-
- try
- {
- Object instance = provider.resolve();
- if( Proxy.isProxyClass( instance.getClass() ) )
- {
- return instance;
- }
-
- //
- // otherwise we need to hold a reference linking the
- // object with the source provider
- //
-
- String id = "" + System.identityHashCode( instance );
- m_table.put( id, key );
- if( getLogger().isDebugEnabled() )
- {
- final String message =
- "resolved service ["
- + id
- + "] for the key ["
- + key
- + "].";
- getLogger().debug( message );
- }
-
- return instance;
- }
- /*
- catch( TransientApplianceException e )
- {
- long delay = e.getDelay();
- if(( timeout == -1 ) || (( delay < timeout ) && ( delay > 0 )) )
- {
- try
- {
- Thread.currentThread().sleep( delay );
- }
- catch( Throwable interrupted )
- {
- // ignore
- }
- return lookup( key, delay );
- }
- else
- {
- final String error =
- "Requested service is not responding.";
- throw new TransientServiceException( key, error, delay );
- }
- }
- */
- catch( Throwable e )
- {
- //
- // TODO: framework states that ServiceException is thrown
- // if the service is not found - and in this case that isn't
- // the issue - in effect we have a good key, but we simply
- // have not been able to go from key to instance -
- // should look into some more concrete subtypes of
- // ServiceException
-
- final String error =
- "Unexpected runtime error while attempting to resolve service
for key: "
- + key;
- throw new FatalServiceException( key, error, e );
- }
- }
-
- /**
- * Release a service back to the manager.
- * @param instance the object to release
- */
- public void release( Object instance )
- {
- if( instance == null ) return;
-
- if( Proxy.isProxyClass( instance.getClass() ) )
- {
- InvocationHandler handler =
- Proxy.getInvocationHandler( instance );
- if( handler instanceof ApplianceInvocationHandler )
- {
- ApplianceInvocationHandler aic =
- (ApplianceInvocationHandler) handler;
- aic.release();
- return;
- }
- return;
- }
-
- //
- // otherwise we need to locate the source ourselves
- //
-
- String id = "" + System.identityHashCode( instance );
- final String key = (String) m_table.get( id );
- if( key == null )
- {
- if( getLogger().isWarnEnabled() )
- {
- final String warning =
- "Unrecognized object identity ["
- + id
- + "]. "
- + "Either this object was not provided by this service
manager "
- + "or it has already been released.";
- getLogger().warn( warning );
- }
- return;
- }
-
- DependencyModel dependency = (DependencyModel) m_map.get( key );
- final DeploymentModel provider = dependency.getProvider();
- if( provider == null )
- {
- if( getLogger().isErrorEnabled() )
- {
- final String error =
- "Unable to release component as no provider could be found
for the key ["
- + key
- + "].";
- getLogger().warn( error );
- }
- return;
- }
-
- provider.release( instance );
- if( getLogger().isDebugEnabled() )
- {
- final String message =
- "released service ["
- + id
- + "] from the key ["
- + key
- + "].";
- getLogger().debug( message );
- }
-
- m_table.remove( id );
- }
-
- private Logger getLogger()
- {
- return m_logger;
- }
-}
-
+/*
+ * 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.activation.avalon;
+
+import java.util.Map;
+import java.util.Hashtable;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.InvocationHandler;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.model.DependencyModel;
+
+import net.dpml.logging.Logger;
+
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+import net.dpml.service.FatalServiceException;
+
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+
+/**
+ * Default implementation of the framework {@link ServiceManager} interface.
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+class DefaultServiceManager implements ServiceManager
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources(
+ DefaultServiceManager.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final Logger m_logger;
+
+ /**
+ * A table of identity hashcode integers of established objects
+ * that map to the lookup key that was uased to establish the object.
+ * Used to track which model is providing an object when we
+ * handle release of objects.
+ */
+ private final Hashtable m_table = new Hashtable();
+
+ /**
+ * A table of dependency models keyed by lookup key.
+ */
+ private final Map m_map;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Construct a new ServiceManager.
+ * @param model component model of the component that is
+ * to be serviced.
+ */
+ public DefaultServiceManager( ComponentModel model )
+ {
+ if( model == null )
+ {
+ throw new NullPointerException( "model" );
+ }
+ m_logger = model.getLogger();
+
+ m_map = new Hashtable();
+ DependencyModel[] dependencies = model.getDependencyModels();
+ for( int i=0; i < dependencies.length; i++ )
+ {
+ final DependencyModel dependency = dependencies[i];
+
+ DeploymentModel provider = dependency.getProvider();
+ if( provider != null )
+ {
+ final String key = dependency.getDependency().getKey();
+ m_map.put( key, dependency );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // ServiceManager
+ //-------------------------------------------------------------------
+
+ /**
+ * Returns true if a provider exists for the supplied role.
+ * @param key the service identifier key
+ * @return boolean TRUE if the service is available else FALSE
+ */
+ public boolean hasService( String key )
+ {
+ if( key == null )
+ {
+ return false;
+ }
+ return ( m_map.get( key ) != null );
+ }
+
+ /**
+ * Retrieve Object by key.
+ * @param key the role
+ * @return the Object
+ * @throws ServiceException if an error occurs
+ * @throws NullPointerException if the supplied key is null
+ */
+ public Object lookup( String key ) throws ServiceException
+ {
+ return lookup( key, -1 );
+ }
+
+ /**
+ * Retrieve Object by key.
+ * @param key the role
+ * @return the Object or null if the Object doesn't exist
+ * @throws ServiceException if an error occurs
+ * @throws NullPointerException if the supplied key is null
+ */
+ public Object lookup( String key, long timeout ) throws ServiceException
+ {
+ if( key == null )
+ {
+ throw new NullPointerException( "key" );
+ }
+
+ if( !hasService( key ) )
+ {
+ final String error =
+ "Unknown key: " + key;
+ throw new ServiceException( key, error );
+ }
+
+ //
+ // locate the provider model that is prividing components
+ // for this dependency
+ //
+
+ DependencyModel dependency = (DependencyModel) m_map.get( key );
+ final DeploymentModel provider = dependency.getProvider();
+
+ if( null == provider )
+ {
+ final String error =
+ REZ.getString( "service.error.null-provider", key );
+ throw new IllegalStateException( error );
+ }
+
+ //
+ // get a proxy to the service from the provider
+ // (note that it is up to a provider to determine if
+ // a proxy if generated based on its service export
+ // parameters)
+ //
+
+ try
+ {
+ Object instance = provider.resolve();
+ if( Proxy.isProxyClass( instance.getClass() ) )
+ {
+ return instance;
+ }
+
+ //
+ // otherwise we need to hold a reference linking the
+ // object with the source provider
+ //
+
+ String id = "" + System.identityHashCode( instance );
+ m_table.put( id, key );
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "resolved service ["
+ + id
+ + "] for the key ["
+ + key
+ + "].";
+ getLogger().debug( message );
+ }
+
+ return instance;
+ }
+ /*
+ catch( TransientApplianceException e )
+ {
+ long delay = e.getDelay();
+ if(( timeout == -1 ) || (( delay < timeout ) && ( delay > 0 )) )
+ {
+ try
+ {
+ Thread.currentThread().sleep( delay );
+ }
+ catch( Throwable interrupted )
+ {
+ // ignore
+ }
+ return lookup( key, delay );
+ }
+ else
+ {
+ final String error =
+ "Requested service is not responding.";
+ throw new TransientServiceException( key, error, delay );
+ }
+ }
+ */
+ catch( Throwable e )
+ {
+ //
+ // TODO: framework states that ServiceException is thrown
+ // if the service is not found - and in this case that isn't
+ // the issue - in effect we have a good key, but we simply
+ // have not been able to go from key to instance -
+ // should look into some more concrete subtypes of
+ // ServiceException
+
+ final String error =
+ "Unexpected runtime error while attempting to resolve service
for key: "
+ + key;
+ throw new FatalServiceException( key, error, e );
+ }
+ }
+
+ /**
+ * Release a service back to the manager.
+ * @param instance the object to release
+ */
+ public void release( Object instance )
+ {
+ if( instance == null ) return;
+
+ if( Proxy.isProxyClass( instance.getClass() ) )
+ {
+ InvocationHandler handler =
+ Proxy.getInvocationHandler( instance );
+ if( handler instanceof ApplianceInvocationHandler )
+ {
+ ApplianceInvocationHandler aic =
+ (ApplianceInvocationHandler) handler;
+ aic.release();
+ return;
+ }
+ return;
+ }
+
+ //
+ // otherwise we need to locate the source ourselves
+ //
+
+ String id = "" + System.identityHashCode( instance );
+ final String key = (String) m_table.get( id );
+ if( key == null )
+ {
+ if( getLogger().isWarnEnabled() )
+ {
+ final String warning =
+ "Unrecognized object identity ["
+ + id
+ + "]. "
+ + "Either this object was not provided by this service
manager "
+ + "or it has already been released.";
+ getLogger().warn( warning );
+ }
+ return;
+ }
+
+ DependencyModel dependency = (DependencyModel) m_map.get( key );
+ final DeploymentModel provider = dependency.getProvider();
+ if( provider == null )
+ {
+ if( getLogger().isErrorEnabled() )
+ {
+ final String error =
+ "Unable to release component as no provider could be found
for the key ["
+ + key
+ + "].";
+ getLogger().warn( error );
+ }
+ return;
+ }
+
+ provider.release( instance );
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "released service ["
+ + id
+ + "] from the key ["
+ + key
+ + "].";
+ getLogger().debug( message );
+ }
+
+ m_table.remove( id );
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+}
+

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/Resources.properties
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/Resources.properties
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/Resources.properties
Fri Dec 24 22:19:23 2004
@@ -1,40 +1,40 @@
-
-#
-# DefaultRuntimeFactory
-# ---------------------
-runtime.error.unknown-model=Deployment model {0} class [{1}] is not
supported.
-runtime.error.lifestyle.no-constructor=The supplied lifestyle factory
artifact references a class [{1}] that does not declare a public constructor.
-runtime.error.unrecognized-runtime-parameter=LifestyleFactory constructor in
[{0}] is requesting an unrecognized parameter [{1}].
-runtime.error.runtime-instantiation=Cannot create lifestyle factory [{0}]
due to an instantiation error.
-
-#
-# DefaultComponentFactory
-# -----------------------
-lifestyle.error.no-constructor=Supplied component class {0} does not declare
a public constructor.
-lifecycle.error.unrecognized-parameter=The constructor argument [{0}] in
component class {1} is not recognized.
-lifecycle.error.instantiation=Component related exception during
instantiation of the class [{0}].
-lifecycle.error.invalid-stage-provider=Assigned stage provider [{0}] is not
a component model.
-lifecycle.error.stage.creator=Creation stage handler error raised by
extension id: [{0}].
-lifestyle.error.new=Unable to create a new component instance in appliance
[{0}] due to a component deployment failure.
-lifestyle.error.contextualization=Internal error while attempting to resolve
contexualization handler from the appliance [{0}].
-lifecycle.error.avalon-contextualization=Contextualization failure in [{0}].
-lifecycle.error.custom-contextualization=Contextualization failure in [{0}]
using custom handler [{1}].
-
-#
-# ServiceManager
-# --------------
-
-service.error.null-provider = A valid request was received for a service
using the key [{0}] but the supplied dependency model returned a null
provider. This is an internal system error reflecting an inconsistent
assembly state.
-
-#
-# DefaultBlock
-# ------------
-block.error.resolve.non-commission-state=Cannot respond to resolve request
as the block {0} is in a non-commissioned state.
-
-#
-# DefaultAppliance
-# -----
-appliance.error.resolve.non-commission-state=Cannot respond to resolve
request as the appliance {0} is in a non-commissioned state.
-appliance.error.resolve.transient=Service managed by [{0}] return a
transient non-availability status. Projected delay before service resumption
is [{1}] milliseconds.
-
-context.non-compliance-constructor.error=Custom context class [{0}] does not
implement a standard constructor pattern.
+
+#
+# DefaultRuntimeFactory
+# ---------------------
+runtime.error.unknown-model=Deployment model {0} class [{1}] is not
supported.
+runtime.error.lifestyle.no-constructor=The supplied lifestyle factory
artifact references a class [{1}] that does not declare a public constructor.
+runtime.error.unrecognized-runtime-parameter=LifestyleFactory constructor in
[{0}] is requesting an unrecognized parameter [{1}].
+runtime.error.runtime-instantiation=Cannot create lifestyle factory [{0}]
due to an instantiation error.
+
+#
+# DefaultComponentFactory
+# -----------------------
+lifestyle.error.no-constructor=Supplied component class {0} does not declare
a public constructor.
+lifecycle.error.unrecognized-parameter=The constructor argument [{0}] in
component class {1} is not recognized.
+lifecycle.error.instantiation=Component related exception during
instantiation of the class [{0}].
+lifecycle.error.invalid-stage-provider=Assigned stage provider [{0}] is not
a component model.
+lifecycle.error.stage.creator=Creation stage handler error raised by
extension id: [{0}].
+lifestyle.error.new=Unable to create a new component instance in appliance
[{0}] due to a component deployment failure.
+lifestyle.error.contextualization=Internal error while attempting to resolve
contexualization handler from the appliance [{0}].
+lifecycle.error.avalon-contextualization=Contextualization failure in [{0}].
+lifecycle.error.custom-contextualization=Contextualization failure in [{0}]
using custom handler [{1}].
+
+#
+# ServiceManager
+# --------------
+
+service.error.null-provider = A valid request was received for a service
using the key [{0}] but the supplied dependency model returned a null
provider. This is an internal system error reflecting an inconsistent
assembly state.
+
+#
+# DefaultBlock
+# ------------
+block.error.resolve.non-commission-state=Cannot respond to resolve request
as the block {0} is in a non-commissioned state.
+
+#
+# DefaultAppliance
+# -----
+appliance.error.resolve.non-commission-state=Cannot respond to resolve
request as the appliance {0} is in a non-commissioned state.
+appliance.error.resolve.transient=Service managed by [{0}] return a
transient non-availability status. Projected delay before service resumption
is [{1}] milliseconds.
+
+context.non-compliance-constructor.error=Custom context class [{0}] does not
implement a standard constructor pattern.

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/SingletonLifestyleManager.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/SingletonLifestyleManager.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/SingletonLifestyleManager.java
Fri Dec 24 22:19:23 2004
@@ -1,150 +1,150 @@
-/*
- * 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.activation.avalon;
-
-import java.lang.ref.Reference;
-
-import net.dpml.activation.ComponentFactory;
-
-import net.dpml.composition.model.ComponentModel;
-
-/**
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class SingletonLifestyleManager extends AbstractLifestyleManager
-{
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private Reference m_reference;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- public SingletonLifestyleManager( ComponentModel model, ComponentFactory
factory )
- {
- super( model, factory );
- }
-
- //-------------------------------------------------------------------
- // Commissionable
- //-------------------------------------------------------------------
-
- /**
- * Commission the runtime handler.
- *
- * @exception Exception if a hanfdler commissioning error occurs
- */
- public void commission() throws Exception
- {
- if( getComponentModel().getActivationPolicy() )
- {
- refreshReference();
- }
- }
-
- /**
- * Invokes the decommissioning phase. Once a handler is
- * decommissioned it may be re-commissioned.
- */
- public void decommission()
- {
- if( m_reference != null )
- {
- finalize( m_reference.get() );
- m_reference = null;
- }
- }
-
- //-------------------------------------------------------------------
- // Resolver
- //-------------------------------------------------------------------
-
- /**
- * Resolve a object to a value relative to a supplied set of
- * interface classes.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- protected synchronized Object handleResolve() throws Exception
- {
- Object instance = null;
-
- if( m_reference == null )
- {
- return refreshReference();
- }
- else
- {
- instance = m_reference.get();
- if( instance == null )
- {
- return refreshReference();
- }
- else
- {
- return instance;
- }
- }
- }
-
- /**
- * Release an object
- *
- * @param instance the object to be released
- */
- protected synchronized void handleRelease( Object instance )
- {
- // continue with the current singleton reference
- }
-
- //-------------------------------------------------------------------
- // LifecycleManager
- //-------------------------------------------------------------------
-
- /**
- * Release an object
- *
- * @param instance the object to be released
- */
- public synchronized void finalize( Object instance )
- {
- getComponentFactory().etherialize( instance );
- m_reference = null;
- }
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- private Object refreshReference() throws Exception
- {
- ComponentFactory factory = getComponentFactory();
- synchronized( factory )
- {
- Object instance = factory.incarnate();
- m_reference = getReference( instance );
- return instance;
- }
- }
-}
+/*
+ * 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.activation.avalon;
+
+import java.lang.ref.Reference;
+
+import net.dpml.activation.ComponentFactory;
+
+import net.dpml.composition.model.ComponentModel;
+
+/**
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class SingletonLifestyleManager extends AbstractLifestyleManager
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private Reference m_reference;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public SingletonLifestyleManager( ComponentModel model, ComponentFactory
factory )
+ {
+ super( model, factory );
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the runtime handler.
+ *
+ * @exception Exception if a hanfdler commissioning error occurs
+ */
+ public void commission() throws Exception
+ {
+ if( getComponentModel().getActivationPolicy() )
+ {
+ refreshReference();
+ }
+ }
+
+ /**
+ * Invokes the decommissioning phase. Once a handler is
+ * decommissioned it may be re-commissioned.
+ */
+ public void decommission()
+ {
+ if( m_reference != null )
+ {
+ finalize( m_reference.get() );
+ m_reference = null;
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value relative to a supplied set of
+ * interface classes.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ protected synchronized Object handleResolve() throws Exception
+ {
+ Object instance = null;
+
+ if( m_reference == null )
+ {
+ return refreshReference();
+ }
+ else
+ {
+ instance = m_reference.get();
+ if( instance == null )
+ {
+ return refreshReference();
+ }
+ else
+ {
+ return instance;
+ }
+ }
+ }
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ protected synchronized void handleRelease( Object instance )
+ {
+ // continue with the current singleton reference
+ }
+
+ //-------------------------------------------------------------------
+ // LifecycleManager
+ //-------------------------------------------------------------------
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ public synchronized void finalize( Object instance )
+ {
+ getComponentFactory().etherialize( instance );
+ m_reference = null;
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ private Object refreshReference() throws Exception
+ {
+ ComponentFactory factory = getComponentFactory();
+ synchronized( factory )
+ {
+ Object instance = factory.incarnate();
+ m_reference = getReference( instance );
+ return instance;
+ }
+ }
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/ThreadLifestyleManager.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/ThreadLifestyleManager.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/ThreadLifestyleManager.java
Fri Dec 24 22:19:23 2004
@@ -1,147 +1,147 @@
-/*
- * 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.activation.avalon;
-
-import net.dpml.activation.LifestyleRuntimeException;
-import net.dpml.activation.ComponentFactory;
-
-import net.dpml.composition.model.ComponentModel;
-
-/**
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class ThreadLifestyleManager extends AbstractLifestyleManager
-{
- //-------------------------------------------------------------------
- // static
- //-------------------------------------------------------------------
-
- /**
- * Internal utility class to hold the thread local instance.
- */
- private static final class ThreadLocalHolder extends ThreadLocal
- {
- private final ComponentFactory m_factory;
-
- protected ThreadLocalHolder( ComponentFactory factory )
- {
- m_factory = factory;
- }
-
- //
- // TODO: the current implementation is hard coded to HARD
- // collection policy - we need to update the ThreadLocalHolder so
- // it regenerates the value relative to SOFT or WEAK policies
- // (but I just need to check docs on thread local state access
- // semantics)
- //
-
- protected Object initialValue()
- {
- try
- {
- return m_factory.incarnate();
- }
- catch( Exception e )
- {
- final String error =
- "Unable to establish thread local variable.";
- throw new LifestyleRuntimeException( error, e );
- }
- }
- }
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private ThreadLocalHolder m_local;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- public ThreadLifestyleManager( ComponentModel model, ComponentFactory
factory )
- {
- super( model, factory );
- }
-
- //-------------------------------------------------------------------
- // Commissionable
- //-------------------------------------------------------------------
-
- /**
- * Commission the runtime handler.
- *
- * @exception Exception if a hanfdler commissioning error occurs
- */
- public void commission() throws Exception
- {
- if( getComponentModel().getActivationPolicy() )
- {
- resolve();
- }
- }
-
- /**
- * Invokes the decommissioning phase. Once a handler is
- * decommissioned it may be re-commissioned.
- */
- public synchronized void decommission()
- {
- if( m_local != null )
- {
- finalize( m_local.get() );
- m_local = null;
- }
- }
-
- //-------------------------------------------------------------------
- // Resolver
- //-------------------------------------------------------------------
-
- /**
- * Resolve a object to a value relative to a supplied set of
- * interface classes.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- protected Object handleResolve() throws Exception
- {
- if( m_local == null )
- {
- ComponentFactory factory = getComponentFactory();
- m_local = new ThreadLocalHolder( factory );
- }
- return m_local.get();
- }
-
- /**
- * Release an object.
- *
- * @param instance the object to be reclaimed
- */
- protected void handleRelease( Object instance )
- {
- // don't release because this is a shared reference
- }
-
-}
+/*
+ * 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.activation.avalon;
+
+import net.dpml.activation.LifestyleRuntimeException;
+import net.dpml.activation.ComponentFactory;
+
+import net.dpml.composition.model.ComponentModel;
+
+/**
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class ThreadLifestyleManager extends AbstractLifestyleManager
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ /**
+ * Internal utility class to hold the thread local instance.
+ */
+ private static final class ThreadLocalHolder extends ThreadLocal
+ {
+ private final ComponentFactory m_factory;
+
+ protected ThreadLocalHolder( ComponentFactory factory )
+ {
+ m_factory = factory;
+ }
+
+ //
+ // TODO: the current implementation is hard coded to HARD
+ // collection policy - we need to update the ThreadLocalHolder so
+ // it regenerates the value relative to SOFT or WEAK policies
+ // (but I just need to check docs on thread local state access
+ // semantics)
+ //
+
+ protected Object initialValue()
+ {
+ try
+ {
+ return m_factory.incarnate();
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to establish thread local variable.";
+ throw new LifestyleRuntimeException( error, e );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private ThreadLocalHolder m_local;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public ThreadLifestyleManager( ComponentModel model, ComponentFactory
factory )
+ {
+ super( model, factory );
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the runtime handler.
+ *
+ * @exception Exception if a hanfdler commissioning error occurs
+ */
+ public void commission() throws Exception
+ {
+ if( getComponentModel().getActivationPolicy() )
+ {
+ resolve();
+ }
+ }
+
+ /**
+ * Invokes the decommissioning phase. Once a handler is
+ * decommissioned it may be re-commissioned.
+ */
+ public synchronized void decommission()
+ {
+ if( m_local != null )
+ {
+ finalize( m_local.get() );
+ m_local = null;
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value relative to a supplied set of
+ * interface classes.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ protected Object handleResolve() throws Exception
+ {
+ if( m_local == null )
+ {
+ ComponentFactory factory = getComponentFactory();
+ m_local = new ThreadLocalHolder( factory );
+ }
+ return m_local.get();
+ }
+
+ /**
+ * Release an object.
+ *
+ * @param instance the object to be reclaimed
+ */
+ protected void handleRelease( Object instance )
+ {
+ // don't release because this is a shared reference
+ }
+
+}

Modified:
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/TransientLifestyleManager.java
==============================================================================
---
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/TransientLifestyleManager.java
(original)
+++
development/main/metro/activation/providers/avalon/src/main/net/dpml/activation/avalon/TransientLifestyleManager.java
Fri Dec 24 22:19:23 2004
@@ -1,140 +1,140 @@
-/*
- * 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.activation.avalon;
-
-import java.lang.ref.SoftReference;
-import java.lang.ref.WeakReference;
-import java.lang.ref.Reference;
-import java.util.ArrayList;
-
-import net.dpml.activation.ComponentFactory;
-
-import net.dpml.composition.model.ComponentModel;
-
-import net.dpml.meta.info.InfoDescriptor;
-
-/**
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class TransientLifestyleManager extends AbstractLifestyleManager
-{
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private ArrayList m_list = new ArrayList();
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- public TransientLifestyleManager( ComponentModel model, ComponentFactory
factory )
- {
- super( model, factory );
- }
-
- //-------------------------------------------------------------------
- // Commissionable
- //-------------------------------------------------------------------
-
- /**
- * Commission the appliance.
- *
- * @exception Exception if a commissioning error occurs
- */
- public void commission() throws Exception
- {
- // TODO: setup a background thread to check queues for
- // released references and remove them from our list, otherwise we
- // have a memory leak due to accumulation of weak references
-
- if( getComponentModel().getActivationPolicy() )
- {
- handleResolve();
- }
- }
-
- /**
- * Decommission the appliance. Once an appliance is
- * decommissioned it may be re-commissioned.
- */
- public void decommission()
- {
- Reference[] refs = (Reference[]) m_list.toArray( new Reference[0] );
- for( int i=0; i<refs.length; i++ )
- {
- Reference ref = refs[i];
- finalize( ref.get() );
- }
- m_list.clear();
- }
-
- //-------------------------------------------------------------------
- // Resolver
- //-------------------------------------------------------------------
-
- /**
- * Resolve a object to a value relative to a supplied set of
- * interface classes.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- protected Object handleResolve() throws Exception
- {
- Object instance = getComponentFactory().incarnate();
- Reference reference = getReference( instance );
- m_list.add( reference );
- return instance;
- }
-
- /**
- * Release an object
- *
- * @param instance the object to be released
- */
- protected void handleRelease( Object instance )
- {
- finalize( instance );
- }
-
- //-------------------------------------------------------------------
- // LifestyleManager
- //-------------------------------------------------------------------
-
- /**
- * Overriding getReference to ensure that we never return a hard
- * reference for a transient.
- */
- protected Reference getReference( Object instance )
- {
- final int policy = getComponentModel().getCollectionPolicy();
- if( policy == InfoDescriptor.SOFT )
- {
- return new SoftReference( instance );
- }
- else
- {
- return new WeakReference(
- instance,
- getLiberalQueue() );
- }
- }
-}
+/*
+ * 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.activation.avalon;
+
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+import java.lang.ref.Reference;
+import java.util.ArrayList;
+
+import net.dpml.activation.ComponentFactory;
+
+import net.dpml.composition.model.ComponentModel;
+
+import net.dpml.meta.info.InfoDescriptor;
+
+/**
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class TransientLifestyleManager extends AbstractLifestyleManager
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private ArrayList m_list = new ArrayList();
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public TransientLifestyleManager( ComponentModel model, ComponentFactory
factory )
+ {
+ super( model, factory );
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the appliance.
+ *
+ * @exception Exception if a commissioning error occurs
+ */
+ public void commission() throws Exception
+ {
+ // TODO: setup a background thread to check queues for
+ // released references and remove them from our list, otherwise we
+ // have a memory leak due to accumulation of weak references
+
+ if( getComponentModel().getActivationPolicy() )
+ {
+ handleResolve();
+ }
+ }
+
+ /**
+ * Decommission the appliance. Once an appliance is
+ * decommissioned it may be re-commissioned.
+ */
+ public void decommission()
+ {
+ Reference[] refs = (Reference[]) m_list.toArray( new Reference[0] );
+ for( int i=0; i<refs.length; i++ )
+ {
+ Reference ref = refs[i];
+ finalize( ref.get() );
+ }
+ m_list.clear();
+ }
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value relative to a supplied set of
+ * interface classes.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ protected Object handleResolve() throws Exception
+ {
+ Object instance = getComponentFactory().incarnate();
+ Reference reference = getReference( instance );
+ m_list.add( reference );
+ return instance;
+ }
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ protected void handleRelease( Object instance )
+ {
+ finalize( instance );
+ }
+
+ //-------------------------------------------------------------------
+ // LifestyleManager
+ //-------------------------------------------------------------------
+
+ /**
+ * Overriding getReference to ensure that we never return a hard
+ * reference for a transient.
+ */
+ protected Reference getReference( Object instance )
+ {
+ final int policy = getComponentModel().getCollectionPolicy();
+ if( policy == InfoDescriptor.SOFT )
+ {
+ return new SoftReference( instance );
+ }
+ else
+ {
+ return new WeakReference(
+ instance,
+ getLiberalQueue() );
+ }
+ }
+}

Modified: development/main/metro/activation/providers/metro/build.xml
==============================================================================
--- development/main/metro/activation/providers/metro/build.xml (original)
+++ development/main/metro/activation/providers/metro/build.xml Fri Dec 24
22:19:23 2004
@@ -1,13 +1,13 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-activation-metro-provider" default="install" basedir="."
- xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
-
- <magic:import uri="artifact:template:dpml/magic/standard"/>
-
- <target name="package" depends="standard.package">
- <x:export class="net.dpml.activation.metro.DefaultRuntimeFactory"/>
- </target>
-
-</project>
-
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-activation-metro-provider" default="install" basedir="."
+ xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
+
+ <magic:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="package" depends="standard.package">
+ <x:export class="net.dpml.activation.metro.DefaultRuntimeFactory"/>
+ </target>
+
+</project>
+

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/AbstractAppliance.java
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/AbstractAppliance.java
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/AbstractAppliance.java
Fri Dec 24 22:19:23 2004
@@ -1,127 +1,127 @@
-/*
- * 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.activation.metro;
-
-import net.dpml.activation.Appliance;
-
-import net.dpml.composition.model.DeploymentModel;
-
-import net.dpml.logging.Logger;
-
-/**
- * Abstract appliance.
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public abstract class AbstractAppliance implements Appliance
-{
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final DeploymentModel m_model;
-
- private final Logger m_logger;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- public AbstractAppliance( DeploymentModel model )
- {
- if( null == model )
- {
- throw new NullPointerException( "model" );
- }
-
- m_model = model;
- m_logger = model.getLogger();
- }
-
- //-------------------------------------------------------------------
- // Commissionable
- //-------------------------------------------------------------------
-
- /**
- * Commission the appliance.
- *
- * @exception Exception if a commissioning error occurs
- */
- public abstract void commission() throws Exception;
-
- /**
- * Decommission the appliance. Once an appliance is
- * decommissioned it may be re-commissioned.
- */
- public abstract void decommission();
-
- //-------------------------------------------------------------------
- // Resolver
- //-------------------------------------------------------------------
-
- /**
- * Resolve a object to a value.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- public abstract Object resolve() throws Exception;
-
- /**
- * Request resolution of an object from the runtime.
- * @param proxy if TRUE the return value will be proxied if the
- * underlying component typoe suppports proxy representation
- * @exception Exception if a deployment error occurs
- */
- public abstract Object resolve( boolean proxy ) throws Exception;
-
- /**
- * Release an object
- *
- * @param instance the object to be released
- */
- public abstract void release( Object instance );
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- protected Logger getLogger()
- {
- return m_logger;
- }
-
- /**
- * Return the model backing the handler.
- * @return the type that the appliance is managing
- */
- protected DeploymentModel getDeploymentModel()
- {
- return m_model;
- }
-
- //-------------------------------------------------------------------
- // Object
- //-------------------------------------------------------------------
-
- public String toString()
- {
- return "appliance:" + getDeploymentModel().getQualifiedName();
- }
-}
+/*
+ * 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.activation.metro;
+
+import net.dpml.activation.Appliance;
+
+import net.dpml.composition.model.DeploymentModel;
+
+import net.dpml.logging.Logger;
+
+/**
+ * Abstract appliance.
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public abstract class AbstractAppliance implements Appliance
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final DeploymentModel m_model;
+
+ private final Logger m_logger;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public AbstractAppliance( DeploymentModel model )
+ {
+ if( null == model )
+ {
+ throw new NullPointerException( "model" );
+ }
+
+ m_model = model;
+ m_logger = model.getLogger();
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the appliance.
+ *
+ * @exception Exception if a commissioning error occurs
+ */
+ public abstract void commission() throws Exception;
+
+ /**
+ * Decommission the appliance. Once an appliance is
+ * decommissioned it may be re-commissioned.
+ */
+ public abstract void decommission();
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ public abstract Object resolve() throws Exception;
+
+ /**
+ * Request resolution of an object from the runtime.
+ * @param proxy if TRUE the return value will be proxied if the
+ * underlying component typoe suppports proxy representation
+ * @exception Exception if a deployment error occurs
+ */
+ public abstract Object resolve( boolean proxy ) throws Exception;
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ public abstract void release( Object instance );
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ protected Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ /**
+ * Return the model backing the handler.
+ * @return the type that the appliance is managing
+ */
+ protected DeploymentModel getDeploymentModel()
+ {
+ return m_model;
+ }
+
+ //-------------------------------------------------------------------
+ // Object
+ //-------------------------------------------------------------------
+
+ public String toString()
+ {
+ return "appliance:" + getDeploymentModel().getQualifiedName();
+ }
+}

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/AbstractLifestyleManager.java
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/AbstractLifestyleManager.java
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/AbstractLifestyleManager.java
Fri Dec 24 22:19:23 2004
@@ -1,211 +1,211 @@
-/*
- * 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.activation.metro;
-
-import java.lang.ref.Reference;
-import java.lang.ref.ReferenceQueue;
-import java.lang.ref.SoftReference;
-import java.lang.ref.WeakReference;
-
-import net.dpml.activation.ComponentFactory;
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.provider.LifestyleManager;
-import net.dpml.logging.Logger;
-import net.dpml.meta.info.InfoDescriptor;
-
-/**
- * Abstract implentation class for a lifestyle handler.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public abstract class AbstractLifestyleManager implements LifestyleManager
-{
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final ComponentModel m_model;
-
- private final ComponentFactory m_factory;
-
- private final Logger m_logger;
-
- private final ReferenceQueue m_liberals = new ReferenceQueue();
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- /**
- * Creation of a new instance.
- * @param model the component model
- * @param factory the component factory
- */
- public AbstractLifestyleManager( ComponentModel model, ComponentFactory
factory )
- {
- m_factory = factory;
- m_model = model;
- m_logger = model.getLogger();
- }
-
- //-------------------------------------------------------------------
- // Commissionable
- //-------------------------------------------------------------------
-
- /**
- * Commission the runtime handler.
- *
- * @exception Exception if a hanfdler commissioning error occurs
- */
- public abstract void commission() throws Exception;
-
- /**
- * Invokes the decommissioning phase. Once a handler is
- * decommissioned it may be re-commissioned.
- */
- public abstract void decommission();
-
- //-------------------------------------------------------------------
- // Resolver
- //-------------------------------------------------------------------
-
- /**
- * Resolve a object to a value.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- public Object resolve() throws Exception
- {
- return handleResolve();
- }
-
- /**
- * Resolve a object to a value.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- public Object resolve( boolean proxy ) throws Exception
- {
- return resolve();
- }
-
- /**
- * Release an object
- *
- * @param instance the object to be released
- */
- public void release( Object instance )
- {
- handleRelease( instance );
- }
-
- //-------------------------------------------------------------------
- // LifecycleManager
- //-------------------------------------------------------------------
-
- public void finalize( Object instance )
- {
- synchronized( m_factory )
- {
- if( instance != null )
- {
- m_factory.etherialize( instance );
- }
- }
- }
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- protected abstract Object handleResolve() throws Exception;
-
- protected abstract void handleRelease( Object instance );
-
-
- protected Logger getLogger()
- {
- return m_logger;
- }
-
- protected ComponentModel getComponentModel()
- {
- return m_model;
- }
-
- protected ComponentFactory getComponentFactory()
- {
- return m_factory;
- }
-
- /**
- * Return the liberal queue.
- */
- ReferenceQueue getLiberalQueue()
- {
- return m_liberals;
- }
-
- protected Reference getReference( Object instance )
- {
- final int policy = getComponentModel().getCollectionPolicy();
- if( policy == InfoDescriptor.WEAK )
- {
- return new WeakReference( instance, m_liberals );
- }
- else if( policy == InfoDescriptor.SOFT )
- {
- return new SoftReference( instance );
- }
- else
- {
- return new StrongReference( instance );
- }
- }
-
- private class StrongReference extends WeakReference
- {
- private final Object m_instance;
-
- public StrongReference( Object instance )
- {
- super( instance );
- m_instance = instance;
- }
-
- public Object get()
- {
- return m_instance;
- }
- }
-
-
- //-------------------------------------------------------------------
- // Object
- //-------------------------------------------------------------------
-
- public void finalize()
- {
- decommission();
- }
-
-}
+/*
+ * 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.activation.metro;
+
+import java.lang.ref.Reference;
+import java.lang.ref.ReferenceQueue;
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+
+import net.dpml.activation.ComponentFactory;
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.provider.LifestyleManager;
+import net.dpml.logging.Logger;
+import net.dpml.meta.info.InfoDescriptor;
+
+/**
+ * Abstract implentation class for a lifestyle handler.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public abstract class AbstractLifestyleManager implements LifestyleManager
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final ComponentModel m_model;
+
+ private final ComponentFactory m_factory;
+
+ private final Logger m_logger;
+
+ private final ReferenceQueue m_liberals = new ReferenceQueue();
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new instance.
+ * @param model the component model
+ * @param factory the component factory
+ */
+ public AbstractLifestyleManager( ComponentModel model, ComponentFactory
factory )
+ {
+ m_factory = factory;
+ m_model = model;
+ m_logger = model.getLogger();
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the runtime handler.
+ *
+ * @exception Exception if a hanfdler commissioning error occurs
+ */
+ public abstract void commission() throws Exception;
+
+ /**
+ * Invokes the decommissioning phase. Once a handler is
+ * decommissioned it may be re-commissioned.
+ */
+ public abstract void decommission();
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ public Object resolve() throws Exception
+ {
+ return handleResolve();
+ }
+
+ /**
+ * Resolve a object to a value.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ public Object resolve( boolean proxy ) throws Exception
+ {
+ return resolve();
+ }
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ public void release( Object instance )
+ {
+ handleRelease( instance );
+ }
+
+ //-------------------------------------------------------------------
+ // LifecycleManager
+ //-------------------------------------------------------------------
+
+ public void finalize( Object instance )
+ {
+ synchronized( m_factory )
+ {
+ if( instance != null )
+ {
+ m_factory.etherialize( instance );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ protected abstract Object handleResolve() throws Exception;
+
+ protected abstract void handleRelease( Object instance );
+
+
+ protected Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ protected ComponentModel getComponentModel()
+ {
+ return m_model;
+ }
+
+ protected ComponentFactory getComponentFactory()
+ {
+ return m_factory;
+ }
+
+ /**
+ * Return the liberal queue.
+ */
+ ReferenceQueue getLiberalQueue()
+ {
+ return m_liberals;
+ }
+
+ protected Reference getReference( Object instance )
+ {
+ final int policy = getComponentModel().getCollectionPolicy();
+ if( policy == InfoDescriptor.WEAK )
+ {
+ return new WeakReference( instance, m_liberals );
+ }
+ else if( policy == InfoDescriptor.SOFT )
+ {
+ return new SoftReference( instance );
+ }
+ else
+ {
+ return new StrongReference( instance );
+ }
+ }
+
+ private class StrongReference extends WeakReference
+ {
+ private final Object m_instance;
+
+ public StrongReference( Object instance )
+ {
+ super( instance );
+ m_instance = instance;
+ }
+
+ public Object get()
+ {
+ return m_instance;
+ }
+ }
+
+
+ //-------------------------------------------------------------------
+ // Object
+ //-------------------------------------------------------------------
+
+ public void finalize()
+ {
+ decommission();
+ }
+
+}

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/ApplianceInvocationHandler.java
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/ApplianceInvocationHandler.java
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/ApplianceInvocationHandler.java
Fri Dec 24 22:19:23 2004
@@ -1,241 +1,241 @@
-/*
- * 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.activation.metro;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.lang.reflect.Method;
-import java.security.PrivilegedActionException;
-import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
-
-import net.dpml.activation.ApplianceException;
-import net.dpml.activation.TransientApplianceException;
-
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.model.TransientRuntimeException;
-import net.dpml.composition.model.Reclaimer;
-
-import net.dpml.logging.Logger;
-
-/**
- * This makes a dynamic proxy for an object. The object can be represented
- * by one, some or all of it's interfaces.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public final class ApplianceInvocationHandler
- implements InvocationHandler, Reclaimer
-{
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final DefaultAppliance m_appliance;
- private final Logger m_logger;
- private final ComponentModel m_model;
- private final boolean m_secure;
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private Object m_instance;
- private boolean m_destroyed = false;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- /**
- * Create a proxy invocation handler.
- *
- * @param appliance the runtime appliance
- * @param logger the assigned logging channel
- */
- ApplianceInvocationHandler(
- DefaultAppliance appliance, Logger logger, boolean secure )
- {
- assertNotNull( appliance, "appliance" );
- assertNotNull( logger, "logger" );
-
- m_appliance = appliance;
- m_logger = logger;
- m_secure = secure;
- m_model = m_appliance.getComponentModel();
- }
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- /**
- * Invoke the specified method on underlying object.
- * This is called by the proxy object.
- *
- * @param proxy the proxy object
- * @param method the method invoked on proxy object
- * @param args the arguments supplied to method
- * @return the return value of method
- * @throws Throwable if an error occurs
- */
- public Object invoke( final Object proxy,
- final Method method,
- final Object[] args )
- throws Throwable
- {
- if( proxy == null )
- throw new NullPointerException( "proxy" );
- if( method == null )
- throw new NullPointerException( "method" );
- if( m_destroyed )
- throw new IllegalStateException( "destroyed" );
-
- try
- {
- final Object instance = getInstance();
-
- if( m_secure )
- {
- return AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return method.invoke( instance, args );
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- return method.invoke( instance, args );
- }
- }
- catch( Throwable e )
- {
- throw handleInvocationThrowable( e );
- }
- }
-
- //-------------------------------------------------------------------
- // Reclaimer
- //-------------------------------------------------------------------
-
- public void release()
- {
- if( !m_destroyed )
- {
- m_destroyed = true;
- final String message =
- "Releasing component ["
- + System.identityHashCode( m_instance ) + "] ("
- + m_appliance.toString()
- + ").";
- getLogger().debug( message );
- m_appliance.release( m_instance );
- }
- }
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- protected void finalize() throws Throwable
- {
- if( !m_destroyed && ( null != m_instance ) )
- {
- final String message =
- "Finalizing proxy ["
- + System.identityHashCode( m_instance ) + "] ("
- + m_appliance.toString()
- + ").";
- getLogger().debug( message );
- release();
- }
- }
-
- private Logger getLogger()
- {
- return m_logger;
- }
-
- private Object getInstance() throws Exception
- {
- if( m_instance == null )
- m_instance = m_appliance.resolve( false );
- return m_instance;
- }
-
- private Throwable handleInvocationThrowable( Throwable e )
- {
- final String error =
- "Delegation error raised by component: "
- + m_appliance.toString();
- while( true )
- {
- if( e instanceof TransientApplianceException )
- {
- TransientApplianceException t =
- (TransientApplianceException) e;
- return new TransientRuntimeException(
- t.getMessage(), t.getDelay() );
- }
- else if( e instanceof UndeclaredThrowableException )
- {
- Throwable cause =
- ((UndeclaredThrowableException)
e).getUndeclaredThrowable();
- if( cause == null )
- return new ApplianceException( error, e );
- e = cause;
- }
- else if( e instanceof InvocationTargetException )
- {
- Throwable cause =
- ((InvocationTargetException) e).getTargetException();
- if( cause == null )
- return new ApplianceException( error, e );
- e = cause;
- }
- else if( e instanceof PrivilegedActionException )
- {
- Throwable cause =
- ((PrivilegedActionException) e).getException();
- if( cause == null )
- return new ApplianceException( error, e );
- e = cause;
- }
- else
- {
- break;
- }
- }
- return e;
- }
-
- private void assertNotNull( Object object, String key )
- {
- if( null == object )
- {
- throw new NullPointerException( key );
- }
- }
-}
+/*
+ * 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.activation.metro;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.lang.reflect.Method;
+import java.security.PrivilegedActionException;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+
+import net.dpml.activation.ApplianceException;
+import net.dpml.activation.TransientApplianceException;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.TransientRuntimeException;
+import net.dpml.composition.model.Reclaimer;
+
+import net.dpml.logging.Logger;
+
+/**
+ * This makes a dynamic proxy for an object. The object can be represented
+ * by one, some or all of it's interfaces.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public final class ApplianceInvocationHandler
+ implements InvocationHandler, Reclaimer
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final DefaultAppliance m_appliance;
+ private final Logger m_logger;
+ private final ComponentModel m_model;
+ private final boolean m_secure;
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private Object m_instance;
+ private boolean m_destroyed = false;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Create a proxy invocation handler.
+ *
+ * @param appliance the runtime appliance
+ * @param logger the assigned logging channel
+ */
+ ApplianceInvocationHandler(
+ DefaultAppliance appliance, Logger logger, boolean secure )
+ {
+ assertNotNull( appliance, "appliance" );
+ assertNotNull( logger, "logger" );
+
+ m_appliance = appliance;
+ m_logger = logger;
+ m_secure = secure;
+ m_model = m_appliance.getComponentModel();
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Invoke the specified method on underlying object.
+ * This is called by the proxy object.
+ *
+ * @param proxy the proxy object
+ * @param method the method invoked on proxy object
+ * @param args the arguments supplied to method
+ * @return the return value of method
+ * @throws Throwable if an error occurs
+ */
+ public Object invoke( final Object proxy,
+ final Method method,
+ final Object[] args )
+ throws Throwable
+ {
+ if( proxy == null )
+ throw new NullPointerException( "proxy" );
+ if( method == null )
+ throw new NullPointerException( "method" );
+ if( m_destroyed )
+ throw new IllegalStateException( "destroyed" );
+
+ try
+ {
+ final Object instance = getInstance();
+
+ if( m_secure )
+ {
+ return AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return method.invoke( instance, args );
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ return method.invoke( instance, args );
+ }
+ }
+ catch( Throwable e )
+ {
+ throw handleInvocationThrowable( e );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Reclaimer
+ //-------------------------------------------------------------------
+
+ public void release()
+ {
+ if( !m_destroyed )
+ {
+ m_destroyed = true;
+ final String message =
+ "Releasing component ["
+ + System.identityHashCode( m_instance ) + "] ("
+ + m_appliance.toString()
+ + ").";
+ getLogger().debug( message );
+ m_appliance.release( m_instance );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ protected void finalize() throws Throwable
+ {
+ if( !m_destroyed && ( null != m_instance ) )
+ {
+ final String message =
+ "Finalizing proxy ["
+ + System.identityHashCode( m_instance ) + "] ("
+ + m_appliance.toString()
+ + ").";
+ getLogger().debug( message );
+ release();
+ }
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ private Object getInstance() throws Exception
+ {
+ if( m_instance == null )
+ m_instance = m_appliance.resolve( false );
+ return m_instance;
+ }
+
+ private Throwable handleInvocationThrowable( Throwable e )
+ {
+ final String error =
+ "Delegation error raised by component: "
+ + m_appliance.toString();
+ while( true )
+ {
+ if( e instanceof TransientApplianceException )
+ {
+ TransientApplianceException t =
+ (TransientApplianceException) e;
+ return new TransientRuntimeException(
+ t.getMessage(), t.getDelay() );
+ }
+ else if( e instanceof UndeclaredThrowableException )
+ {
+ Throwable cause =
+ ((UndeclaredThrowableException)
e).getUndeclaredThrowable();
+ if( cause == null )
+ return new ApplianceException( error, e );
+ e = cause;
+ }
+ else if( e instanceof InvocationTargetException )
+ {
+ Throwable cause =
+ ((InvocationTargetException) e).getTargetException();
+ if( cause == null )
+ return new ApplianceException( error, e );
+ e = cause;
+ }
+ else if( e instanceof PrivilegedActionException )
+ {
+ Throwable cause =
+ ((PrivilegedActionException) e).getException();
+ if( cause == null )
+ return new ApplianceException( error, e );
+ e = cause;
+ }
+ else
+ {
+ break;
+ }
+ }
+ return e;
+ }
+
+ private void assertNotNull( Object object, String key )
+ {
+ if( null == object )
+ {
+ throw new NullPointerException( key );
+ }
+ }
+}

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/ContainerUtil.java
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/ContainerUtil.java
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/ContainerUtil.java
Fri Dec 24 22:19:23 2004
@@ -1,278 +1,278 @@
-/*
- * Copyright 1997-2003 The Apache Software Foundation
- * 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.activation.metro;
-
-import net.dpml.activity.Disposable;
-import net.dpml.activity.Initializable;
-import net.dpml.activity.Startable;
-import net.dpml.activity.Executable;
-import net.dpml.configuration.Configurable;
-import net.dpml.configuration.Configuration;
-import net.dpml.configuration.ConfigurationException;
-import net.dpml.context.Context;
-import net.dpml.context.ContextException;
-import net.dpml.context.Contextualizable;
-import net.dpml.logging.LogEnabled;
-import net.dpml.logging.Logger;
-import net.dpml.parameters.ParameterException;
-import net.dpml.parameters.Parameterizable;
-import net.dpml.parameters.Parameters;
-import net.dpml.service.ServiceException;
-import net.dpml.service.ServiceManager;
-import net.dpml.service.Serviceable;
-
-/**
- * Utility class that makes it easier to transfer
- * a component throught it's lifecycle stages.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public final class ContainerUtil
-{
- /**
- * Private constructor to block instantiation.
- */
- private ContainerUtil()
- {
- }
-
- /**
- * Run specified object through shutdown lifecycle stages
- * (Stop and Dispose).
- *
- * @param object the object to shutdown
- * @throws Exception if there is a problem stoppping object
- */
- public static void shutdown( final Object object )
- throws Exception
- {
- stop( object );
- dispose( object );
- }
-
- /**
- * Supply specified object with Logger if it implements the
- * {@link LogEnabled} interface.
- *
- * @param object the object to Start
- * @param logger the logger to enable component with. May be null
- * in which case the specified object must not implement
LogEnabled.
- * @throws IllegalArgumentException if the object is LogEnabled but
Logger is null
- */
- public static void enableLogging( final Object object,
- final Logger logger )
- {
- if( object instanceof LogEnabled )
- {
- if( null == logger )
- {
- final String message = "logger is null";
- throw new IllegalArgumentException( message );
- }
- ( (LogEnabled)object ).enableLogging( logger );
- }
- }
-
- /**
- * Supply specified object with a Context object if it implements the
- * {@link Contextualizable} interface.
- *
- * @param object the object to contextualize
- * @param context the context object to use for object.
- * May be null in which case the specified object must not
- * implement Contextualizable.
- * @throws ContextException if there is a problem contextualizing object
- * @throws IllegalArgumentException if the object is Contextualizable but
- * context is null
- */
- public static void contextualize( final Object object,
- final Context context )
- throws ContextException
- {
- if( object instanceof Contextualizable )
- {
- if( null == context )
- {
- final String message = "context is null";
- throw new IllegalArgumentException( message );
- }
- ( (Contextualizable)object ).contextualize( context );
- }
- }
-
- /**
- * Supply specified object with ServiceManager if it implements the
- * {@link Serviceable} interface.
- *
- * @param object the object to service
- * @param serviceManager the serviceManager object to use for object.
- * May be null in which case the specified object must not
- * implement Serviceable.
- * @throws ServiceException if there is a problem servicing object
- * @throws IllegalArgumentException if the object is Servicable but
- * ServiceManager is null
- */
- public static void service( final Object object,
- final ServiceManager serviceManager )
- throws ServiceException
- {
- if( object instanceof Serviceable )
- {
- if( null == serviceManager )
- {
- final String message = "ServiceManager is null";
- throw new IllegalArgumentException( message );
- }
- ( (Serviceable)object ).service( serviceManager );
- }
- }
-
- /**
- * Configure specified object if it implements the
- * {@link Configurable} interface.
- *
- * @param object the object to Start
- * @param configuration the configuration object to use during
- * configuration. May be null in which case the specified object
- * must not implement Configurable
- * @throws ConfigurationException if there is a problem Configuring
object,
- * or the object is Configurable but Configuration is null
- * @throws IllegalArgumentException if the object is Configurable but
- * Configuration is null
- */
- public static void configure( final Object object,
- final Configuration configuration )
- throws ConfigurationException
- {
- if( object instanceof Configurable )
- {
- if( null == configuration )
- {
- final String message = "configuration is null";
- throw new IllegalArgumentException( message );
- }
- ( (Configurable)object ).configure( configuration );
- }
- }
-
- /**
- * Parameterize specified object if it implements the
- * {@link Parameterizable} interface.
- *
- * @param object the object to Parameterize.
- * @param parameters the parameters object to use during
Parameterization.
- * May be null in which case the specified object must not
- * implement Parameterizable.
- * @throws ParameterException if there is a problem Parameterizing object
- * @throws IllegalArgumentException if the object is Parameterizable but
- * parameters is null
- */
- public static void parameterize( final Object object,
- final Parameters parameters )
- throws ParameterException
- {
- if( object instanceof Parameterizable )
- {
- if( null == parameters )
- {
- final String message = "parameters is null";
- throw new IllegalArgumentException( message );
- }
- ( (Parameterizable)object ).parameterize( parameters );
- }
- }
-
- /**
- * Initialize specified object if it implements the
- * {@link Initializable} interface.
- *
- * @param object the object to Initialize
- * @throws Exception if there is a problem Initializing object
- */
- public static void initialize( final Object object )
- throws Exception
- {
- if( object instanceof Initializable )
- {
- ( (Initializable)object ).initialize();
- }
- }
-
- /**
- * Start specified object if it implements the
- * {@link Startable} interface.
- *
- * @param object the object to Start
- * @throws Exception if there is a problem Starting object
- */
- public static void start( final Object object )
- throws Exception
- {
- if( object instanceof Startable )
- {
- ( (Startable)object ).start();
- }
- }
-
- /**
- * Execute the specified object if it implements the
- * {@link Executable} interface.
- *
- * @param object the object to execute
- * @throws Exception if there is a problem executing object
- */
- public static void execute( final Object object )
- throws Exception
- {
- if( object instanceof Executable )
- {
- ( (Executable)object ).execute();
- }
- }
-
- /**
- * Stop specified object if it implements the
- * {@link Startable} interface.
- *
- * @param object the object to stop
- * @throws Exception if there is a problem stoppping object
- */
- public static void stop( final Object object )
- throws Exception
- {
- if( object instanceof Startable )
- {
- ( (Startable)object ).stop();
- }
- }
-
- /**
- * Dispose specified object if it implements the
- * {@link Disposable} interface.
- *
- * @param object the object to dispose
- */
- public static void dispose( final Object object )
- {
- if( object instanceof Disposable )
- {
- ( (Disposable)object ).dispose();
- }
- }
-}
+/*
+ * Copyright 1997-2003 The Apache Software Foundation
+ * 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.activation.metro;
+
+import net.dpml.activity.Disposable;
+import net.dpml.activity.Initializable;
+import net.dpml.activity.Startable;
+import net.dpml.activity.Executable;
+import net.dpml.configuration.Configurable;
+import net.dpml.configuration.Configuration;
+import net.dpml.configuration.ConfigurationException;
+import net.dpml.context.Context;
+import net.dpml.context.ContextException;
+import net.dpml.context.Contextualizable;
+import net.dpml.logging.LogEnabled;
+import net.dpml.logging.Logger;
+import net.dpml.parameters.ParameterException;
+import net.dpml.parameters.Parameterizable;
+import net.dpml.parameters.Parameters;
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+import net.dpml.service.Serviceable;
+
+/**
+ * Utility class that makes it easier to transfer
+ * a component throught it's lifecycle stages.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public final class ContainerUtil
+{
+ /**
+ * Private constructor to block instantiation.
+ */
+ private ContainerUtil()
+ {
+ }
+
+ /**
+ * Run specified object through shutdown lifecycle stages
+ * (Stop and Dispose).
+ *
+ * @param object the object to shutdown
+ * @throws Exception if there is a problem stoppping object
+ */
+ public static void shutdown( final Object object )
+ throws Exception
+ {
+ stop( object );
+ dispose( object );
+ }
+
+ /**
+ * Supply specified object with Logger if it implements the
+ * {@link LogEnabled} interface.
+ *
+ * @param object the object to Start
+ * @param logger the logger to enable component with. May be null
+ * in which case the specified object must not implement
LogEnabled.
+ * @throws IllegalArgumentException if the object is LogEnabled but
Logger is null
+ */
+ public static void enableLogging( final Object object,
+ final Logger logger )
+ {
+ if( object instanceof LogEnabled )
+ {
+ if( null == logger )
+ {
+ final String message = "logger is null";
+ throw new IllegalArgumentException( message );
+ }
+ ( (LogEnabled)object ).enableLogging( logger );
+ }
+ }
+
+ /**
+ * Supply specified object with a Context object if it implements the
+ * {@link Contextualizable} interface.
+ *
+ * @param object the object to contextualize
+ * @param context the context object to use for object.
+ * May be null in which case the specified object must not
+ * implement Contextualizable.
+ * @throws ContextException if there is a problem contextualizing object
+ * @throws IllegalArgumentException if the object is Contextualizable but
+ * context is null
+ */
+ public static void contextualize( final Object object,
+ final Context context )
+ throws ContextException
+ {
+ if( object instanceof Contextualizable )
+ {
+ if( null == context )
+ {
+ final String message = "context is null";
+ throw new IllegalArgumentException( message );
+ }
+ ( (Contextualizable)object ).contextualize( context );
+ }
+ }
+
+ /**
+ * Supply specified object with ServiceManager if it implements the
+ * {@link Serviceable} interface.
+ *
+ * @param object the object to service
+ * @param serviceManager the serviceManager object to use for object.
+ * May be null in which case the specified object must not
+ * implement Serviceable.
+ * @throws ServiceException if there is a problem servicing object
+ * @throws IllegalArgumentException if the object is Servicable but
+ * ServiceManager is null
+ */
+ public static void service( final Object object,
+ final ServiceManager serviceManager )
+ throws ServiceException
+ {
+ if( object instanceof Serviceable )
+ {
+ if( null == serviceManager )
+ {
+ final String message = "ServiceManager is null";
+ throw new IllegalArgumentException( message );
+ }
+ ( (Serviceable)object ).service( serviceManager );
+ }
+ }
+
+ /**
+ * Configure specified object if it implements the
+ * {@link Configurable} interface.
+ *
+ * @param object the object to Start
+ * @param configuration the configuration object to use during
+ * configuration. May be null in which case the specified object
+ * must not implement Configurable
+ * @throws ConfigurationException if there is a problem Configuring
object,
+ * or the object is Configurable but Configuration is null
+ * @throws IllegalArgumentException if the object is Configurable but
+ * Configuration is null
+ */
+ public static void configure( final Object object,
+ final Configuration configuration )
+ throws ConfigurationException
+ {
+ if( object instanceof Configurable )
+ {
+ if( null == configuration )
+ {
+ final String message = "configuration is null";
+ throw new IllegalArgumentException( message );
+ }
+ ( (Configurable)object ).configure( configuration );
+ }
+ }
+
+ /**
+ * Parameterize specified object if it implements the
+ * {@link Parameterizable} interface.
+ *
+ * @param object the object to Parameterize.
+ * @param parameters the parameters object to use during
Parameterization.
+ * May be null in which case the specified object must not
+ * implement Parameterizable.
+ * @throws ParameterException if there is a problem Parameterizing object
+ * @throws IllegalArgumentException if the object is Parameterizable but
+ * parameters is null
+ */
+ public static void parameterize( final Object object,
+ final Parameters parameters )
+ throws ParameterException
+ {
+ if( object instanceof Parameterizable )
+ {
+ if( null == parameters )
+ {
+ final String message = "parameters is null";
+ throw new IllegalArgumentException( message );
+ }
+ ( (Parameterizable)object ).parameterize( parameters );
+ }
+ }
+
+ /**
+ * Initialize specified object if it implements the
+ * {@link Initializable} interface.
+ *
+ * @param object the object to Initialize
+ * @throws Exception if there is a problem Initializing object
+ */
+ public static void initialize( final Object object )
+ throws Exception
+ {
+ if( object instanceof Initializable )
+ {
+ ( (Initializable)object ).initialize();
+ }
+ }
+
+ /**
+ * Start specified object if it implements the
+ * {@link Startable} interface.
+ *
+ * @param object the object to Start
+ * @throws Exception if there is a problem Starting object
+ */
+ public static void start( final Object object )
+ throws Exception
+ {
+ if( object instanceof Startable )
+ {
+ ( (Startable)object ).start();
+ }
+ }
+
+ /**
+ * Execute the specified object if it implements the
+ * {@link Executable} interface.
+ *
+ * @param object the object to execute
+ * @throws Exception if there is a problem executing object
+ */
+ public static void execute( final Object object )
+ throws Exception
+ {
+ if( object instanceof Executable )
+ {
+ ( (Executable)object ).execute();
+ }
+ }
+
+ /**
+ * Stop specified object if it implements the
+ * {@link Startable} interface.
+ *
+ * @param object the object to stop
+ * @throws Exception if there is a problem stoppping object
+ */
+ public static void stop( final Object object )
+ throws Exception
+ {
+ if( object instanceof Startable )
+ {
+ ( (Startable)object ).stop();
+ }
+ }
+
+ /**
+ * Dispose specified object if it implements the
+ * {@link Disposable} interface.
+ *
+ * @param object the object to dispose
+ */
+ public static void dispose( final Object object )
+ {
+ if( object instanceof Disposable )
+ {
+ ( (Disposable)object ).dispose();
+ }
+ }
+}

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultAppliance.java
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultAppliance.java
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultAppliance.java
Fri Dec 24 22:19:23 2004
@@ -1,244 +1,244 @@
-/*
- * 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.activation.metro;
-
-import java.lang.reflect.Proxy;
-
-import net.dpml.activation.ApplianceException;
-
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.model.TransientRuntimeException;
-import net.dpml.composition.provider.LifestyleManager;
-import net.dpml.composition.util.DefaultState;
-
-import net.dpml.logging.Logger;
-
-import net.dpml.i18n.ResourceManager;
-import net.dpml.i18n.Resources;
-
-/**
- * Abstract appliance.
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class DefaultAppliance extends AbstractAppliance
-{
- //-------------------------------------------------------------------
- // static
- //-------------------------------------------------------------------
-
- private static final Resources REZ =
- ResourceManager.getPackageResources(
- DefaultAppliance.class );
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final ComponentModel m_model;
-
- private final LifestyleManager m_lifestyle;
-
- private final DefaultState m_commissioned = new DefaultState();
-
- private long m_delay = 0;
-
- private final boolean m_secure;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- public DefaultAppliance(
- ComponentModel model, LifestyleManager lifestyle )
- {
- super( model );
- m_model = model;
- m_lifestyle = lifestyle;
- m_secure = model.isCodeSecurityEnabled();
- }
-
- //-------------------------------------------------------------------
- // Commissionable
- //-------------------------------------------------------------------
-
- /**
- * Commission the appliance.
- *
- * @exception Exception if a commissioning error occurs
- */
- public void commission() throws Exception
- {
- synchronized( m_commissioned )
- {
- if( m_commissioned.isEnabled() ) return;
-
- try
- {
- m_delay = m_model.getDeploymentTimeout();
- m_lifestyle.commission();
- m_delay = 0;
- m_commissioned.setEnabled( true );
- }
- finally
- {
- m_delay = 0;
- }
- }
- }
-
- /**
- * Decommission the appliance. Once an appliance is
- * decommissioned it may be re-commissioned.
- */
- public void decommission()
- {
- synchronized( m_commissioned )
- {
- if( !m_commissioned.isEnabled() ) return;
- m_lifestyle.decommission();
- m_commissioned.setEnabled( false );
- }
- }
-
- //-------------------------------------------------------------------
- // Resolver
- //-------------------------------------------------------------------
-
-
- /**
- * Resolve a object to a value.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- public Object resolve() throws Exception
- {
- //
- // handle the legacy 3.3.0 usage of the "urn:activation:proxy" key
- // if after handle the 3.4.0 semantics for resolution against the
model
- //
-
- if( getComponentModel().getType().getInfo().
- getAttribute( "urn:activation:proxy", "true" ).equals( "false"
) )
- {
- final String message =
- "Component type references the deprecated
'urn:activation:proxy' key."
- + " Please update to the key '" + ComponentModel.PROXY_KEY +
"'.";
- getLogger().warn( message );
- return resolve( false );
- }
- else
- {
- return resolve( getComponentModel().getProxyPolicy() );
- }
- }
-
- public Object resolve( boolean proxy ) throws Exception
- {
- if( !proxy )
- {
- if( m_delay > 0 )
- {
- final String error =
- REZ.getString(
- "appliance.error.resolve.transient",
- this.toString(),
- "" + m_delay );
- throw new TransientRuntimeException( error, m_delay );
- }
- else if( !m_commissioned.isEnabled() )
- {
- final String error =
- REZ.getString(
- "appliance.error.resolve.non-commission-state",
- this.toString() );
- throw new IllegalStateException( error );
- }
- else
- {
- return m_lifestyle.resolve();
- }
- }
- else
- {
- ComponentModel model = getComponentModel();
- Logger logger = model.getLogger().getChildLogger( "proxy" );
- ApplianceInvocationHandler handler =
- new ApplianceInvocationHandler( this, logger, m_secure );
-
- try
- {
- return Proxy.newProxyInstance(
- model.getDeploymentClass().getClassLoader(),
- model.getInterfaces(),
- handler );
- }
- catch( Throwable e )
- {
- final String error =
- "Proxy establishment failure in appliance: " + this;
- throw new ApplianceException( error, e );
- }
- }
- }
-
- /**
- * Release an object
- *
- * @param instance the object to be released
- */
- public void release( Object instance )
- {
- if( null == instance ) return;
- if( !m_commissioned.isEnabled() ) return;
- if( Proxy.isProxyClass( instance.getClass() ) )
- {
- ApplianceInvocationHandler handler =
- (ApplianceInvocationHandler) Proxy.getInvocationHandler(
instance );
- handler.release();
- }
- else
- {
- m_lifestyle.release( instance );
- }
- }
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- /**
- * Return the model backing the handler.
- * @return the type that the appliance is managing
- */
- protected ComponentModel getComponentModel()
- {
- return m_model;
- }
-
- //-------------------------------------------------------------------
- // Object
- //-------------------------------------------------------------------
-
- public String toString()
- {
- return "appliance:" + getComponentModel().getQualifiedName();
- }
-}
+/*
+ * 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.activation.metro;
+
+import java.lang.reflect.Proxy;
+
+import net.dpml.activation.ApplianceException;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.TransientRuntimeException;
+import net.dpml.composition.provider.LifestyleManager;
+import net.dpml.composition.util.DefaultState;
+
+import net.dpml.logging.Logger;
+
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+
+/**
+ * Abstract appliance.
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class DefaultAppliance extends AbstractAppliance
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources(
+ DefaultAppliance.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final ComponentModel m_model;
+
+ private final LifestyleManager m_lifestyle;
+
+ private final DefaultState m_commissioned = new DefaultState();
+
+ private long m_delay = 0;
+
+ private final boolean m_secure;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public DefaultAppliance(
+ ComponentModel model, LifestyleManager lifestyle )
+ {
+ super( model );
+ m_model = model;
+ m_lifestyle = lifestyle;
+ m_secure = model.isCodeSecurityEnabled();
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the appliance.
+ *
+ * @exception Exception if a commissioning error occurs
+ */
+ public void commission() throws Exception
+ {
+ synchronized( m_commissioned )
+ {
+ if( m_commissioned.isEnabled() ) return;
+
+ try
+ {
+ m_delay = m_model.getDeploymentTimeout();
+ m_lifestyle.commission();
+ m_delay = 0;
+ m_commissioned.setEnabled( true );
+ }
+ finally
+ {
+ m_delay = 0;
+ }
+ }
+ }
+
+ /**
+ * Decommission the appliance. Once an appliance is
+ * decommissioned it may be re-commissioned.
+ */
+ public void decommission()
+ {
+ synchronized( m_commissioned )
+ {
+ if( !m_commissioned.isEnabled() ) return;
+ m_lifestyle.decommission();
+ m_commissioned.setEnabled( false );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+
+ /**
+ * Resolve a object to a value.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ public Object resolve() throws Exception
+ {
+ //
+ // handle the legacy 3.3.0 usage of the "urn:activation:proxy" key
+ // if after handle the 3.4.0 semantics for resolution against the
model
+ //
+
+ if( getComponentModel().getType().getInfo().
+ getAttribute( "urn:activation:proxy", "true" ).equals( "false"
) )
+ {
+ final String message =
+ "Component type references the deprecated
'urn:activation:proxy' key."
+ + " Please update to the key '" + ComponentModel.PROXY_KEY +
"'.";
+ getLogger().warn( message );
+ return resolve( false );
+ }
+ else
+ {
+ return resolve( getComponentModel().getProxyPolicy() );
+ }
+ }
+
+ public Object resolve( boolean proxy ) throws Exception
+ {
+ if( !proxy )
+ {
+ if( m_delay > 0 )
+ {
+ final String error =
+ REZ.getString(
+ "appliance.error.resolve.transient",
+ this.toString(),
+ "" + m_delay );
+ throw new TransientRuntimeException( error, m_delay );
+ }
+ else if( !m_commissioned.isEnabled() )
+ {
+ final String error =
+ REZ.getString(
+ "appliance.error.resolve.non-commission-state",
+ this.toString() );
+ throw new IllegalStateException( error );
+ }
+ else
+ {
+ return m_lifestyle.resolve();
+ }
+ }
+ else
+ {
+ ComponentModel model = getComponentModel();
+ Logger logger = model.getLogger().getChildLogger( "proxy" );
+ ApplianceInvocationHandler handler =
+ new ApplianceInvocationHandler( this, logger, m_secure );
+
+ try
+ {
+ return Proxy.newProxyInstance(
+ model.getDeploymentClass().getClassLoader(),
+ model.getInterfaces(),
+ handler );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Proxy establishment failure in appliance: " + this;
+ throw new ApplianceException( error, e );
+ }
+ }
+ }
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ public void release( Object instance )
+ {
+ if( null == instance ) return;
+ if( !m_commissioned.isEnabled() ) return;
+ if( Proxy.isProxyClass( instance.getClass() ) )
+ {
+ ApplianceInvocationHandler handler =
+ (ApplianceInvocationHandler) Proxy.getInvocationHandler(
instance );
+ handler.release();
+ }
+ else
+ {
+ m_lifestyle.release( instance );
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Return the model backing the handler.
+ * @return the type that the appliance is managing
+ */
+ protected ComponentModel getComponentModel()
+ {
+ return m_model;
+ }
+
+ //-------------------------------------------------------------------
+ // Object
+ //-------------------------------------------------------------------
+
+ public String toString()
+ {
+ return "appliance:" + getComponentModel().getQualifiedName();
+ }
+}

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultComponentFactory.java
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultComponentFactory.java
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultComponentFactory.java
Fri Dec 24 22:19:23 2004
@@ -1,941 +1,941 @@
-/*
- * 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.activation.metro;
-
-import java.lang.reflect.Constructor;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedExceptionAction;
-import java.util.Map;
-
-import net.dpml.activation.ComponentFactory;
-import net.dpml.activation.LifecycleException;
-import net.dpml.activity.Disposable;
-import net.dpml.activity.Executable;
-import net.dpml.activity.Initializable;
-import net.dpml.activity.Startable;
-import net.dpml.composition.info.DeliveryDescriptor;
-import net.dpml.composition.info.NativeDeliveryDescriptor;
-import net.dpml.composition.info.StagedDeliveryDescriptor;
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.model.ContextModel;
-import net.dpml.composition.model.ContextualizationHandler;
-import net.dpml.composition.model.DeploymentModel;
-import net.dpml.composition.model.LifecycleCreateExtension;
-import net.dpml.composition.model.LifecycleDestroyExtension;
-import net.dpml.composition.model.ModelException;
-import net.dpml.composition.model.StageModel;
-import net.dpml.configuration.Configurable;
-import net.dpml.configuration.Configuration;
-import net.dpml.context.Context;
-import net.dpml.context.Contextualizable;
-import net.dpml.context.impl.DefaultContext;
-import net.dpml.i18n.ResourceManager;
-import net.dpml.i18n.Resources;
-import net.dpml.logging.LogEnabled;
-import net.dpml.logging.Logger;
-import net.dpml.meta.info.StageDescriptor;
-import net.dpml.parameters.Parameterizable;
-import net.dpml.parameters.Parameters;
-import net.dpml.service.ServiceManager;
-import net.dpml.service.Serviceable;
-
-
-
-/**
- * A factory enabling the establishment of component instances.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class DefaultComponentFactory
- implements ComponentFactory
-{
- //-------------------------------------------------------------------
- // static
- //-------------------------------------------------------------------
-
- private static final Resources REZ =
- ResourceManager.getPackageResources(
- DefaultComponentFactory.class );
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final ComponentModel m_model;
-
- private final Logger m_logger;
-
- private final boolean m_secure;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- /**
- * Creation of a new component factory.
- * @param model the component model
- */
- public DefaultComponentFactory( ComponentModel model )
- {
- m_model = model;
-
- m_secure = model.isCodeSecurityEnabled();
- m_logger = model.getLogger().getChildLogger( "lifecycle" );
- }
-
- //-------------------------------------------------------------------
- // ComponentFactory
- //-------------------------------------------------------------------
-
- /**
- * Creation of a new instance including all deployment stage handling.
- * @return the new incarnated instance
- */
- public Object incarnate() throws LifecycleException
- {
- if( getLogger().isDebugEnabled() )
- {
- final String message =
- "incarnation";
- getLogger().debug( message );
- }
-
- ClassLoader current = Thread.currentThread().getContextClassLoader();
- ClassLoader classloader =
- m_model.getDeploymentClass().getClassLoader();
- Thread.currentThread().setContextClassLoader( classloader );
-
- try
- {
- Object instance = incarnation();
- if( getLogger().isDebugEnabled() )
- {
- final String message =
- "incarnation complete";
- getLogger().debug( message );
- }
- return instance;
- }
- finally
- {
- Thread.currentThread().setContextClassLoader( current );
- }
- }
-
- /**
- * Termination of the instance including all end-of-life processing.
- * @param instance the component instance to etherialize
- */
- public void etherialize( final Object instance )
- {
- if( getLogger().isDebugEnabled() )
- {
- final String message =
- "etherialization";
- getLogger().debug( message );
- }
-
- try
- {
- applyCreateStage( instance, false );
- }
- catch( Throwable e )
- {
- // will not happen
- }
- finally
- {
- if( instance instanceof Startable )
- {
- getLogger().debug( "applying shutdown" );
- try
- {
- if( m_secure )
- {
- AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- ((Startable)instance).stop();
- return null;
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- ContainerUtil.stop( instance );
- }
- }
- catch( Throwable e )
- {
- if( getLogger().isWarnEnabled() )
- {
- final String warning =
- "Ignoring component source shutdown error.";
- getLogger().warn( warning, e );
- }
- }
- }
-
- if( instance instanceof Disposable )
- {
- getLogger().debug( "applying disposal" );
- try
- {
- if( m_secure )
- {
- AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- ((Disposable)instance).dispose();
- return null;
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- ContainerUtil.dispose( instance );
- }
- }
- catch( Throwable e )
- {
- if( getLogger().isWarnEnabled() )
- {
- final String warning =
- "Ignoring component source disposal error.";
- getLogger().warn( warning, e );
- }
- }
- }
- }
- }
-
- //-------------------------------------------------------------------
- // protected implementation
- //-------------------------------------------------------------------
-
- protected Logger getLogger()
- {
- return m_logger;
- }
-
- //-------------------------------------------------------------------
- // private implementation
- //-------------------------------------------------------------------
-
- /**
- * Creation of a new instance including all deployment stage handling.
- * @return the new instance
- */
- private Object incarnation() throws LifecycleException
- {
- Class clazz = m_model.getDeploymentClass();
- final Logger logger = m_model.getLogger();
- final Configuration config = m_model.getConfiguration();
- final Parameters params = m_model.getParameters();
- final ServiceManager manager = new DefaultServiceManager( m_model );
- final Object context = getTargetContext();
- final Class contextClass = getContextCastingClass();
-
- final Object instance =
- instantiate(
- clazz, logger, config, params, context, contextClass, manager );
-
- try
- {
- if( instance instanceof LogEnabled )
- {
- getLogger().debug( "applying logger" );
- if( m_secure )
- {
- AccessController.doPrivileged(
- new PrivilegedAction()
- {
- public Object run()
- {
- ((LogEnabled)instance).enableLogging( logger );
- return null;
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- ContainerUtil.enableLogging( instance, logger );
- }
- }
-
- if( instance instanceof Contextualizable )
- {
- getLogger().debug( "applying context" );
- if( m_secure )
- {
- AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- ((Contextualizable)instance).contextualize(
(Context) context );
- return null;
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- ContainerUtil.contextualize( instance, (Context) context
);
- }
- }
-
- if( instance instanceof Serviceable )
- {
- getLogger().debug( "applying service manager" );
- if( m_secure )
- {
- AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- ((Serviceable)instance).service( manager );
- return null;
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- ContainerUtil.service( instance, manager );
- }
- }
-
- if( instance instanceof Configurable )
- {
- getLogger().debug( "applying configuration" );
- if( m_secure )
- {
- AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- ((Configurable)instance).configure( config );
- return null;
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- ContainerUtil.configure( instance, config );
- }
- }
-
- if( instance instanceof Parameterizable )
- {
- getLogger().debug( "applying parameters" );
- if( m_secure )
- {
- AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- ((Parameterizable)instance).parameterize(
params );
- return null;
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- ContainerUtil.parameterize( instance, params );
- }
- }
-
- //
- // handle lifecycle extensions
- //
-
- applyCreateStage( instance, true );
-
- //
- // complete intialization
- //
-
- if( instance instanceof Initializable )
- {
- getLogger().debug( "applying initialization" );
- if( m_secure )
- {
- AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- ((Initializable)instance).initialize();
- return null;
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- ContainerUtil.initialize( instance );
- }
- }
-
- if( Startable.class.isAssignableFrom( clazz ) )
- {
- getLogger().debug( "applying startup" );
- if( m_secure )
- {
- AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- ((Startable)instance).start();
- return null;
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- ContainerUtil.start( instance );
- }
- getLogger().debug( "component startup completed" );
- }
- else if( Executable.class.isAssignableFrom( clazz ) )
- {
- getLogger().debug( "applying execution" );
- if( m_secure )
- {
- AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- ((Executable)instance).execute();
- return null;
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- ContainerUtil.execute( instance );
- }
- getLogger().debug( "component execution completed" );
- }
- }
- catch( Throwable e )
- {
- final String error =
- REZ.getString(
- "lifestyle.error.new",
- m_model.getQualifiedName() );
- throw new LifecycleException( error, e );
- }
-
- return instance;
- }
-
- private Class getContextCastingClass()
- throws LifecycleException
- {
- String casting = m_model.getContextModel().getCastingClassname();
-
- if( null == casting )
- {
- return Context.class;
- }
- else
- {
- try
- {
- return
m_model.getDeploymentClass().getClassLoader().loadClass( casting );
- }
- catch( Throwable e )
- {
- final String error =
- "Could not load the custom context casting class ["
- + casting
- + "].";
- throw new LifecycleException( error, e );
- }
- }
- }
-
- private Object getTargetContext()
- throws LifecycleException
- {
- ContextModel model = m_model.getContextModel();
- Class impl = getContextImplementationClass( model );
- return createComponentContext( impl, model.getContextMap() );
- }
-
- private Class getContextImplementationClass( ContextModel model ) throws
LifecycleException
- {
- String classname = model.getImplementationClassname();
-
- if( null == classname )
- {
- return DefaultContext.class;
- }
- else
- {
- try
- {
- return
m_model.getDeploymentClass().getClassLoader().loadClass( classname );
- }
- catch( Throwable e )
- {
- final String error =
- "Could not load the custom context implementation class ["
- + classname
- + "].";
- throw new LifecycleException( error, e );
- }
- }
- }
-
- /**
- * Creates a component context instance.
- *
- * @return the context object compliant with the context casting
- * constraints declared by the component type
- * @exception LifecycleException if an error occurs while attempting to
- * construct the context instance
- */
- private Object createComponentContext( Class clazz, Map map )
- throws LifecycleException
- {
- //
- // its a custom context object so we need to create it
- // using the classic context object as the constructor
- // argument
- //
-
- try
- {
- Constructor constructor = clazz.getConstructor(
- new Class[]{ Map.class } );
- return constructor.newInstance( new Object[]{ map } );
- }
- catch( NoSuchMethodException e )
- {
- final String error =
- REZ.getString( "context.non-compliance-constructor.error",
clazz.getName() );
- throw new LifecycleException( error, e );
- }
- catch( Throwable e )
- {
- final String error =
- REZ.getString( "context.custom-unexpected.error",
clazz.getName() );
- throw new LifecycleException( error, e );
- }
- }
-
-
- private Object instantiate(
- Class clazz, Logger logger, Configuration config, Parameters params,
- Object context, Class contextClass, ServiceManager manager )
- throws LifecycleException
- {
- Constructor constructor = getConstructor( clazz );
-
- Class[] classes = constructor.getParameterTypes();
- Object[] args = new Object[ classes.length ];
- for( int i=0; i<classes.length; i++ )
- {
- Class c = classes[i];
- if( Logger.class.isAssignableFrom( c ) )
- {
- if( null == logger )
- {
- throw new NullPointerException( "logger" );
- }
- args[i] = logger;
- }
- else if( ( null != contextClass ) &&
contextClass.isAssignableFrom( c ) )
- {
- if( null == context )
- {
- throw new NullPointerException( "context" );
- }
- args[i] = context;
- }
- else if( Configuration.class.isAssignableFrom( c ) )
- {
- if( null == config )
- {
- throw new NullPointerException( "config" );
- }
- args[i] = config;
- }
- else if( Parameters.class.isAssignableFrom( c ) )
- {
- if( null == params )
- {
- throw new NullPointerException( "params" );
- }
- args[i] = params;
- }
- else if( ServiceManager.class.isAssignableFrom( c ) )
- {
- if( null == manager )
- {
- throw new NullPointerException( "manager" );
- }
- args[i] = manager;
- }
- else
- {
- final String error =
- REZ.getString(
- "lifecycle.error.unrecognized-parameter",
- c.getName(),
- clazz.getName() );
- throw new LifecycleException( error );
- }
- }
-
- //
- // instantiate the factory
- //
-
- return instantiateComponent( constructor, args );
- }
-
- private Constructor getConstructor( Class clazz ) throws
LifecycleException
- {
- Constructor[] constructors = clazz.getConstructors();
- if( constructors.length < 1 )
- {
- final String error =
- REZ.getString(
- "lifecycle.error.no-constructor",
- clazz.getName() );
- throw new LifecycleException( error );
- }
-
- if( constructors.length > 1 )
- {
- //
- // we risk conflicting with an object designed for 4.1.2 or
- // earlier that has a null arg constructor - so if this class
- // has a null arg constructor then invoke it, otherwise we
- // we are dealing with an ambigouse object
- //
-
- try
- {
- return clazz.getConstructor( new Class[0] );
- }
- catch( NoSuchMethodException e )
- {
- final String error =
- "Multiple constructor ambiguity in the component model "
- + m_model
- + ". The component class [" + clazz.getName()
- + "] declares "
- + constructors.length
- + " public constructors.";
- throw new LifecycleException( error );
- }
- }
- else
- {
- return constructors[0];
- }
- }
-
- /**
- * Instantiation of a component instance using a supplied constructor
- * and arguments.
- *
- * @param constructor the component constructor
- * @param args the constructor arguments
- * @return the component instance
- * @exception LifecycleException if an instantiation error occurs
- */
- private Object instantiateComponent(
- final Constructor constructor, final Object[] args )
- throws LifecycleException
- {
- try
- {
- if( args.length == 0 )
- {
- getLogger().debug(
- "instantiating component with a null constructor" );
- }
- else
- {
- int n = args.length;
- getLogger().debug(
- "instantiating component with "
- + n + " arguments." );
- }
-
- if( m_secure )
- {
- return AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return constructor.newInstance( args );
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- return constructor.newInstance( args );
- }
- }
- catch( Throwable e )
- {
- Class clazz = constructor.getDeclaringClass();
- final String error =
- REZ.getString(
- "lifecycle.error.instantiation",
- clazz.getName() );
- throw new LifecycleException( error, e );
- }
- }
-
- private void applyCreateStage( Object instance, boolean flag )
- throws LifecycleException
- {
- StageDescriptor[] stages = m_model.getType().getStages();
- if( ( stages.length > 0 ) && getLogger().isDebugEnabled() )
- {
- getLogger().debug( "stage count: " + stages.length );
- }
-
- for( int i=0; i<stages.length; i++ )
- {
- StageDescriptor stage = stages[i];
- ComponentModel provider = getStageProvider( stage );
- Class c = provider.getDeploymentClass();
-
- if( flag && LifecycleCreateExtension.class.isAssignableFrom( c )
)
- {
- LifecycleCreateExtension handler =
- getLifecycleCreateExtension( provider );
-
- try
- {
- if( getLogger().isDebugEnabled() )
- {
- int id = System.identityHashCode( instance );
- getLogger().debug( "applying model create stage to:
" + id );
- }
- handler.create( m_model, stage, instance );
- }
- catch( Throwable e )
- {
- final String error =
- "Create stage extension error.";
- throw new LifecycleException( error, e );
- }
- finally
- {
- provider.release( handler );
- }
- }
- else if( !flag &&
LifecycleDestroyExtension.class.isAssignableFrom( c ) )
- {
- LifecycleDestroyExtension handler =
- getLifecycleDestroyExtension( provider );
-
- try
- {
- if( getLogger().isDebugEnabled() )
- {
- int id = System.identityHashCode( instance );
- getLogger().debug( "applying model destroy stage to:
" + id );
- }
- handler.destroy( m_model, stage, instance );
- }
- catch( Throwable e )
- {
- if( getLogger().isWarnEnabled() )
- {
- final String error =
- "Ignoring destroy stage error";
- getLogger().warn( error, e );
- }
- }
- finally
- {
- provider.release( handler );
- }
- }
- }
- }
-
- private LifecycleCreateExtension getLifecycleCreateExtension(
- DeploymentModel provider ) throws LifecycleException
- {
- try
- {
- return (LifecycleCreateExtension) provider.resolve();
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to resolve lifecycle creation extension provider.";
- throw new LifecycleException( error, e );
- }
- }
-
- private LifecycleDestroyExtension getLifecycleDestroyExtension(
- DeploymentModel provider ) throws LifecycleException
- {
- try
- {
- return (LifecycleDestroyExtension) provider.resolve();
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to resolve lifecycle destroy extension provider.";
- throw new LifecycleException( error, e );
- }
- }
-
- private ComponentModel getStageProvider( StageDescriptor stage )
- throws IllegalStateException
- {
- final String key = stage.getKey();
- StageModel model = m_model.getStageModel( stage );
- DeploymentModel provider = model.getProvider();
- if( provider instanceof ComponentModel )
- {
- return (ComponentModel) provider;
- }
- else
- {
- final String error =
- REZ.getString(
- "lifecycle.error.invalid-stage-provider",
- key );
- throw new IllegalStateException( error );
- }
- }
-
- private void applyContext(
- final Object instance, DeliveryDescriptor delivery, final Object
context )
- throws LifecycleException
- {
- if( null == context ) return;
-
- final ContextModel model = m_model.getContextModel();
-
- if( delivery instanceof NativeDeliveryDescriptor )
- {
- getLogger().debug( "applying context" );
-
- //
- // its classic avalon
- //
-
- if( context instanceof Context )
- {
- try
- {
- if( m_secure )
- {
- AccessController.doPrivileged(
- new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
-
((Contextualizable)instance).contextualize(
- (Context) context );
- return null;
- }
- },
- m_model.getAccessControlContext() );
- }
- else
- {
- ContainerUtil.contextualize( instance, (Context)
context );
- }
- }
- catch( Throwable e )
- {
- final String error =
- REZ.getString(
- "lifecycle.error.avalon-contextualization",
- m_model.getQualifiedName() );
- throw new LifecycleException( error, e );
- }
- }
- else
- {
- final String error =
- "Supplied context class ["
- + context.getClass().getName()
- + "] does not implement the Avalon Context interface.";
- throw new LifecycleException( error );
- }
- }
- else if( delivery instanceof StagedDeliveryDescriptor )
- {
- getLogger().warn( "applying custom context: " +
delivery.getClass().getName() );
- final DeploymentModel provider = model.getProvider();
- try
- {
- ContextualizationHandler handler =
- (ContextualizationHandler) provider.resolve();
- handler.contextualize( instance, (Context) context );
- }
- catch( Throwable e )
- {
- final String error =
- REZ.getString(
- "lifecycle.error.custom-contextualization",
- m_model.getQualifiedName(),
- provider.toString() );
- throw new LifecycleException( error, e );
- }
- }
- else
- {
- final String error =
- "Unrecognized delivery strategy: ["
- + delivery.getClass().getName()
- + "].";
- throw new IllegalStateException( error );
- }
- }
-}
+/*
+ * 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.activation.metro;
+
+import java.lang.reflect.Constructor;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedExceptionAction;
+import java.util.Map;
+
+import net.dpml.activation.ComponentFactory;
+import net.dpml.activation.LifecycleException;
+import net.dpml.activity.Disposable;
+import net.dpml.activity.Executable;
+import net.dpml.activity.Initializable;
+import net.dpml.activity.Startable;
+import net.dpml.composition.info.DeliveryDescriptor;
+import net.dpml.composition.info.NativeDeliveryDescriptor;
+import net.dpml.composition.info.StagedDeliveryDescriptor;
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.ContextModel;
+import net.dpml.composition.model.ContextualizationHandler;
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.model.LifecycleCreateExtension;
+import net.dpml.composition.model.LifecycleDestroyExtension;
+import net.dpml.composition.model.ModelException;
+import net.dpml.composition.model.StageModel;
+import net.dpml.configuration.Configurable;
+import net.dpml.configuration.Configuration;
+import net.dpml.context.Context;
+import net.dpml.context.Contextualizable;
+import net.dpml.context.impl.DefaultContext;
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+import net.dpml.logging.LogEnabled;
+import net.dpml.logging.Logger;
+import net.dpml.meta.info.StageDescriptor;
+import net.dpml.parameters.Parameterizable;
+import net.dpml.parameters.Parameters;
+import net.dpml.service.ServiceManager;
+import net.dpml.service.Serviceable;
+
+
+
+/**
+ * A factory enabling the establishment of component instances.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class DefaultComponentFactory
+ implements ComponentFactory
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources(
+ DefaultComponentFactory.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final ComponentModel m_model;
+
+ private final Logger m_logger;
+
+ private final boolean m_secure;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new component factory.
+ * @param model the component model
+ */
+ public DefaultComponentFactory( ComponentModel model )
+ {
+ m_model = model;
+
+ m_secure = model.isCodeSecurityEnabled();
+ m_logger = model.getLogger().getChildLogger( "lifecycle" );
+ }
+
+ //-------------------------------------------------------------------
+ // ComponentFactory
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new instance including all deployment stage handling.
+ * @return the new incarnated instance
+ */
+ public Object incarnate() throws LifecycleException
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "incarnation";
+ getLogger().debug( message );
+ }
+
+ ClassLoader current = Thread.currentThread().getContextClassLoader();
+ ClassLoader classloader =
+ m_model.getDeploymentClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader( classloader );
+
+ try
+ {
+ Object instance = incarnation();
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "incarnation complete";
+ getLogger().debug( message );
+ }
+ return instance;
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader( current );
+ }
+ }
+
+ /**
+ * Termination of the instance including all end-of-life processing.
+ * @param instance the component instance to etherialize
+ */
+ public void etherialize( final Object instance )
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "etherialization";
+ getLogger().debug( message );
+ }
+
+ try
+ {
+ applyCreateStage( instance, false );
+ }
+ catch( Throwable e )
+ {
+ // will not happen
+ }
+ finally
+ {
+ if( instance instanceof Startable )
+ {
+ getLogger().debug( "applying shutdown" );
+ try
+ {
+ if( m_secure )
+ {
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ ((Startable)instance).stop();
+ return null;
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ ContainerUtil.stop( instance );
+ }
+ }
+ catch( Throwable e )
+ {
+ if( getLogger().isWarnEnabled() )
+ {
+ final String warning =
+ "Ignoring component source shutdown error.";
+ getLogger().warn( warning, e );
+ }
+ }
+ }
+
+ if( instance instanceof Disposable )
+ {
+ getLogger().debug( "applying disposal" );
+ try
+ {
+ if( m_secure )
+ {
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ ((Disposable)instance).dispose();
+ return null;
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ ContainerUtil.dispose( instance );
+ }
+ }
+ catch( Throwable e )
+ {
+ if( getLogger().isWarnEnabled() )
+ {
+ final String warning =
+ "Ignoring component source disposal error.";
+ getLogger().warn( warning, e );
+ }
+ }
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // protected implementation
+ //-------------------------------------------------------------------
+
+ protected Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ //-------------------------------------------------------------------
+ // private implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new instance including all deployment stage handling.
+ * @return the new instance
+ */
+ private Object incarnation() throws LifecycleException
+ {
+ Class clazz = m_model.getDeploymentClass();
+ final Logger logger = m_model.getLogger();
+ final Configuration config = m_model.getConfiguration();
+ final Parameters params = m_model.getParameters();
+ final ServiceManager manager = new DefaultServiceManager( m_model );
+ final Object context = getTargetContext();
+ final Class contextClass = getContextCastingClass();
+
+ final Object instance =
+ instantiate(
+ clazz, logger, config, params, context, contextClass, manager );
+
+ try
+ {
+ if( instance instanceof LogEnabled )
+ {
+ getLogger().debug( "applying logger" );
+ if( m_secure )
+ {
+ AccessController.doPrivileged(
+ new PrivilegedAction()
+ {
+ public Object run()
+ {
+ ((LogEnabled)instance).enableLogging( logger );
+ return null;
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ ContainerUtil.enableLogging( instance, logger );
+ }
+ }
+
+ if( instance instanceof Contextualizable )
+ {
+ getLogger().debug( "applying context" );
+ if( m_secure )
+ {
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ ((Contextualizable)instance).contextualize(
(Context) context );
+ return null;
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ ContainerUtil.contextualize( instance, (Context) context
);
+ }
+ }
+
+ if( instance instanceof Serviceable )
+ {
+ getLogger().debug( "applying service manager" );
+ if( m_secure )
+ {
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ ((Serviceable)instance).service( manager );
+ return null;
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ ContainerUtil.service( instance, manager );
+ }
+ }
+
+ if( instance instanceof Configurable )
+ {
+ getLogger().debug( "applying configuration" );
+ if( m_secure )
+ {
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ ((Configurable)instance).configure( config );
+ return null;
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ ContainerUtil.configure( instance, config );
+ }
+ }
+
+ if( instance instanceof Parameterizable )
+ {
+ getLogger().debug( "applying parameters" );
+ if( m_secure )
+ {
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ ((Parameterizable)instance).parameterize(
params );
+ return null;
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ ContainerUtil.parameterize( instance, params );
+ }
+ }
+
+ //
+ // handle lifecycle extensions
+ //
+
+ applyCreateStage( instance, true );
+
+ //
+ // complete intialization
+ //
+
+ if( instance instanceof Initializable )
+ {
+ getLogger().debug( "applying initialization" );
+ if( m_secure )
+ {
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ ((Initializable)instance).initialize();
+ return null;
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ ContainerUtil.initialize( instance );
+ }
+ }
+
+ if( Startable.class.isAssignableFrom( clazz ) )
+ {
+ getLogger().debug( "applying startup" );
+ if( m_secure )
+ {
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ ((Startable)instance).start();
+ return null;
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ ContainerUtil.start( instance );
+ }
+ getLogger().debug( "component startup completed" );
+ }
+ else if( Executable.class.isAssignableFrom( clazz ) )
+ {
+ getLogger().debug( "applying execution" );
+ if( m_secure )
+ {
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ ((Executable)instance).execute();
+ return null;
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ ContainerUtil.execute( instance );
+ }
+ getLogger().debug( "component execution completed" );
+ }
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString(
+ "lifestyle.error.new",
+ m_model.getQualifiedName() );
+ throw new LifecycleException( error, e );
+ }
+
+ return instance;
+ }
+
+ private Class getContextCastingClass()
+ throws LifecycleException
+ {
+ String casting = m_model.getContextModel().getCastingClassname();
+
+ if( null == casting )
+ {
+ return Context.class;
+ }
+ else
+ {
+ try
+ {
+ return
m_model.getDeploymentClass().getClassLoader().loadClass( casting );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Could not load the custom context casting class ["
+ + casting
+ + "].";
+ throw new LifecycleException( error, e );
+ }
+ }
+ }
+
+ private Object getTargetContext()
+ throws LifecycleException
+ {
+ ContextModel model = m_model.getContextModel();
+ Class impl = getContextImplementationClass( model );
+ return createComponentContext( impl, model.getContextMap() );
+ }
+
+ private Class getContextImplementationClass( ContextModel model ) throws
LifecycleException
+ {
+ String classname = model.getImplementationClassname();
+
+ if( null == classname )
+ {
+ return DefaultContext.class;
+ }
+ else
+ {
+ try
+ {
+ return
m_model.getDeploymentClass().getClassLoader().loadClass( classname );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Could not load the custom context implementation class ["
+ + classname
+ + "].";
+ throw new LifecycleException( error, e );
+ }
+ }
+ }
+
+ /**
+ * Creates a component context instance.
+ *
+ * @return the context object compliant with the context casting
+ * constraints declared by the component type
+ * @exception LifecycleException if an error occurs while attempting to
+ * construct the context instance
+ */
+ private Object createComponentContext( Class clazz, Map map )
+ throws LifecycleException
+ {
+ //
+ // its a custom context object so we need to create it
+ // using the classic context object as the constructor
+ // argument
+ //
+
+ try
+ {
+ Constructor constructor = clazz.getConstructor(
+ new Class[]{ Map.class } );
+ return constructor.newInstance( new Object[]{ map } );
+ }
+ catch( NoSuchMethodException e )
+ {
+ final String error =
+ REZ.getString( "context.non-compliance-constructor.error",
clazz.getName() );
+ throw new LifecycleException( error, e );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString( "context.custom-unexpected.error",
clazz.getName() );
+ throw new LifecycleException( error, e );
+ }
+ }
+
+
+ private Object instantiate(
+ Class clazz, Logger logger, Configuration config, Parameters params,
+ Object context, Class contextClass, ServiceManager manager )
+ throws LifecycleException
+ {
+ Constructor constructor = getConstructor( clazz );
+
+ Class[] classes = constructor.getParameterTypes();
+ Object[] args = new Object[ classes.length ];
+ for( int i=0; i<classes.length; i++ )
+ {
+ Class c = classes[i];
+ if( Logger.class.isAssignableFrom( c ) )
+ {
+ if( null == logger )
+ {
+ throw new NullPointerException( "logger" );
+ }
+ args[i] = logger;
+ }
+ else if( ( null != contextClass ) &&
contextClass.isAssignableFrom( c ) )
+ {
+ if( null == context )
+ {
+ throw new NullPointerException( "context" );
+ }
+ args[i] = context;
+ }
+ else if( Configuration.class.isAssignableFrom( c ) )
+ {
+ if( null == config )
+ {
+ throw new NullPointerException( "config" );
+ }
+ args[i] = config;
+ }
+ else if( Parameters.class.isAssignableFrom( c ) )
+ {
+ if( null == params )
+ {
+ throw new NullPointerException( "params" );
+ }
+ args[i] = params;
+ }
+ else if( ServiceManager.class.isAssignableFrom( c ) )
+ {
+ if( null == manager )
+ {
+ throw new NullPointerException( "manager" );
+ }
+ args[i] = manager;
+ }
+ else
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.unrecognized-parameter",
+ c.getName(),
+ clazz.getName() );
+ throw new LifecycleException( error );
+ }
+ }
+
+ //
+ // instantiate the factory
+ //
+
+ return instantiateComponent( constructor, args );
+ }
+
+ private Constructor getConstructor( Class clazz ) throws
LifecycleException
+ {
+ Constructor[] constructors = clazz.getConstructors();
+ if( constructors.length < 1 )
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.no-constructor",
+ clazz.getName() );
+ throw new LifecycleException( error );
+ }
+
+ if( constructors.length > 1 )
+ {
+ //
+ // we risk conflicting with an object designed for 4.1.2 or
+ // earlier that has a null arg constructor - so if this class
+ // has a null arg constructor then invoke it, otherwise we
+ // we are dealing with an ambigouse object
+ //
+
+ try
+ {
+ return clazz.getConstructor( new Class[0] );
+ }
+ catch( NoSuchMethodException e )
+ {
+ final String error =
+ "Multiple constructor ambiguity in the component model "
+ + m_model
+ + ". The component class [" + clazz.getName()
+ + "] declares "
+ + constructors.length
+ + " public constructors.";
+ throw new LifecycleException( error );
+ }
+ }
+ else
+ {
+ return constructors[0];
+ }
+ }
+
+ /**
+ * Instantiation of a component instance using a supplied constructor
+ * and arguments.
+ *
+ * @param constructor the component constructor
+ * @param args the constructor arguments
+ * @return the component instance
+ * @exception LifecycleException if an instantiation error occurs
+ */
+ private Object instantiateComponent(
+ final Constructor constructor, final Object[] args )
+ throws LifecycleException
+ {
+ try
+ {
+ if( args.length == 0 )
+ {
+ getLogger().debug(
+ "instantiating component with a null constructor" );
+ }
+ else
+ {
+ int n = args.length;
+ getLogger().debug(
+ "instantiating component with "
+ + n + " arguments." );
+ }
+
+ if( m_secure )
+ {
+ return AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return constructor.newInstance( args );
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ return constructor.newInstance( args );
+ }
+ }
+ catch( Throwable e )
+ {
+ Class clazz = constructor.getDeclaringClass();
+ final String error =
+ REZ.getString(
+ "lifecycle.error.instantiation",
+ clazz.getName() );
+ throw new LifecycleException( error, e );
+ }
+ }
+
+ private void applyCreateStage( Object instance, boolean flag )
+ throws LifecycleException
+ {
+ StageDescriptor[] stages = m_model.getType().getStages();
+ if( ( stages.length > 0 ) && getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( "stage count: " + stages.length );
+ }
+
+ for( int i=0; i<stages.length; i++ )
+ {
+ StageDescriptor stage = stages[i];
+ ComponentModel provider = getStageProvider( stage );
+ Class c = provider.getDeploymentClass();
+
+ if( flag && LifecycleCreateExtension.class.isAssignableFrom( c )
)
+ {
+ LifecycleCreateExtension handler =
+ getLifecycleCreateExtension( provider );
+
+ try
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "applying model create stage to:
" + id );
+ }
+ handler.create( m_model, stage, instance );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Create stage extension error.";
+ throw new LifecycleException( error, e );
+ }
+ finally
+ {
+ provider.release( handler );
+ }
+ }
+ else if( !flag &&
LifecycleDestroyExtension.class.isAssignableFrom( c ) )
+ {
+ LifecycleDestroyExtension handler =
+ getLifecycleDestroyExtension( provider );
+
+ try
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ int id = System.identityHashCode( instance );
+ getLogger().debug( "applying model destroy stage to:
" + id );
+ }
+ handler.destroy( m_model, stage, instance );
+ }
+ catch( Throwable e )
+ {
+ if( getLogger().isWarnEnabled() )
+ {
+ final String error =
+ "Ignoring destroy stage error";
+ getLogger().warn( error, e );
+ }
+ }
+ finally
+ {
+ provider.release( handler );
+ }
+ }
+ }
+ }
+
+ private LifecycleCreateExtension getLifecycleCreateExtension(
+ DeploymentModel provider ) throws LifecycleException
+ {
+ try
+ {
+ return (LifecycleCreateExtension) provider.resolve();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to resolve lifecycle creation extension provider.";
+ throw new LifecycleException( error, e );
+ }
+ }
+
+ private LifecycleDestroyExtension getLifecycleDestroyExtension(
+ DeploymentModel provider ) throws LifecycleException
+ {
+ try
+ {
+ return (LifecycleDestroyExtension) provider.resolve();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to resolve lifecycle destroy extension provider.";
+ throw new LifecycleException( error, e );
+ }
+ }
+
+ private ComponentModel getStageProvider( StageDescriptor stage )
+ throws IllegalStateException
+ {
+ final String key = stage.getKey();
+ StageModel model = m_model.getStageModel( stage );
+ DeploymentModel provider = model.getProvider();
+ if( provider instanceof ComponentModel )
+ {
+ return (ComponentModel) provider;
+ }
+ else
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.invalid-stage-provider",
+ key );
+ throw new IllegalStateException( error );
+ }
+ }
+
+ private void applyContext(
+ final Object instance, DeliveryDescriptor delivery, final Object
context )
+ throws LifecycleException
+ {
+ if( null == context ) return;
+
+ final ContextModel model = m_model.getContextModel();
+
+ if( delivery instanceof NativeDeliveryDescriptor )
+ {
+ getLogger().debug( "applying context" );
+
+ //
+ // its classic avalon
+ //
+
+ if( context instanceof Context )
+ {
+ try
+ {
+ if( m_secure )
+ {
+ AccessController.doPrivileged(
+ new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+
((Contextualizable)instance).contextualize(
+ (Context) context );
+ return null;
+ }
+ },
+ m_model.getAccessControlContext() );
+ }
+ else
+ {
+ ContainerUtil.contextualize( instance, (Context)
context );
+ }
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.avalon-contextualization",
+ m_model.getQualifiedName() );
+ throw new LifecycleException( error, e );
+ }
+ }
+ else
+ {
+ final String error =
+ "Supplied context class ["
+ + context.getClass().getName()
+ + "] does not implement the Avalon Context interface.";
+ throw new LifecycleException( error );
+ }
+ }
+ else if( delivery instanceof StagedDeliveryDescriptor )
+ {
+ getLogger().warn( "applying custom context: " +
delivery.getClass().getName() );
+ final DeploymentModel provider = model.getProvider();
+ try
+ {
+ ContextualizationHandler handler =
+ (ContextualizationHandler) provider.resolve();
+ handler.contextualize( instance, (Context) context );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ REZ.getString(
+ "lifecycle.error.custom-contextualization",
+ m_model.getQualifiedName(),
+ provider.toString() );
+ throw new LifecycleException( error, e );
+ }
+ }
+ else
+ {
+ final String error =
+ "Unrecognized delivery strategy: ["
+ + delivery.getClass().getName()
+ + "].";
+ throw new IllegalStateException( error );
+ }
+ }
+}

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultLifestyleFactory.java
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultLifestyleFactory.java
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultLifestyleFactory.java
Fri Dec 24 22:19:23 2004
@@ -1,91 +1,91 @@
-/*
- * 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.activation.metro;
-
-import net.dpml.activation.ComponentFactory;
-
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.provider.LifestyleFactory;
-import net.dpml.composition.provider.LifestyleManager;
-
-import net.dpml.meta.info.InfoDescriptor;
-
-
-/**
- * A factory enabling the establishment of runtime handlers.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class DefaultLifestyleFactory implements LifestyleFactory
-{
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- /**
- * Creation of a new default lifestyle factory.
- */
- public DefaultLifestyleFactory()
- {
- }
-
- //-------------------------------------------------------------------
- // LifestyleFactory
- //-------------------------------------------------------------------
-
-
- /**
- * Create a new lifestyle manager.
- * @param model the component model
- * @return the lifestyle manager
- */
- public LifestyleManager createLifestyleManager( ComponentModel model )
- {
- ComponentFactory factory = createComponentFactory( model );
-
- final String lifestyle =
- model.getType().getInfo().getLifestyle();
-
- if( lifestyle.equals( InfoDescriptor.SINGLETON ) )
- {
- return new SingletonLifestyleManager( model, factory );
- }
- else if( lifestyle.equals( InfoDescriptor.THREAD ) )
- {
- return new ThreadLifestyleManager( model, factory );
- }
- else if( lifestyle.equals( InfoDescriptor.TRANSIENT ) )
- {
- return new TransientLifestyleManager( model, factory );
- }
- else
- {
- final String error =
- "Unsupported lifestyle [" + lifestyle + "].";
- throw new IllegalArgumentException( error );
- }
- }
-
- private ComponentFactory createComponentFactory( ComponentModel model )
- {
- return new DefaultComponentFactory( model );
- }
-}
+/*
+ * 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.activation.metro;
+
+import net.dpml.activation.ComponentFactory;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.provider.LifestyleFactory;
+import net.dpml.composition.provider.LifestyleManager;
+
+import net.dpml.meta.info.InfoDescriptor;
+
+
+/**
+ * A factory enabling the establishment of runtime handlers.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class DefaultLifestyleFactory implements LifestyleFactory
+{
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Creation of a new default lifestyle factory.
+ */
+ public DefaultLifestyleFactory()
+ {
+ }
+
+ //-------------------------------------------------------------------
+ // LifestyleFactory
+ //-------------------------------------------------------------------
+
+
+ /**
+ * Create a new lifestyle manager.
+ * @param model the component model
+ * @return the lifestyle manager
+ */
+ public LifestyleManager createLifestyleManager( ComponentModel model )
+ {
+ ComponentFactory factory = createComponentFactory( model );
+
+ final String lifestyle =
+ model.getType().getInfo().getLifestyle();
+
+ if( lifestyle.equals( InfoDescriptor.SINGLETON ) )
+ {
+ return new SingletonLifestyleManager( model, factory );
+ }
+ else if( lifestyle.equals( InfoDescriptor.THREAD ) )
+ {
+ return new ThreadLifestyleManager( model, factory );
+ }
+ else if( lifestyle.equals( InfoDescriptor.TRANSIENT ) )
+ {
+ return new TransientLifestyleManager( model, factory );
+ }
+ else
+ {
+ final String error =
+ "Unsupported lifestyle [" + lifestyle + "].";
+ throw new IllegalArgumentException( error );
+ }
+ }
+
+ private ComponentFactory createComponentFactory( ComponentModel model )
+ {
+ return new DefaultComponentFactory( model );
+ }
+}

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultRuntimeFactory.java
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultRuntimeFactory.java
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultRuntimeFactory.java
Fri Dec 24 22:19:23 2004
@@ -1,152 +1,152 @@
-/*
- * 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.activation.metro;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import net.dpml.activation.Appliance;
-import net.dpml.activation.RuntimeFactory;
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.model.DeploymentModel;
-import net.dpml.composition.model.ModelRuntimeException;
-import net.dpml.composition.provider.LifestyleFactory;
-import net.dpml.composition.provider.LifestyleManager;
-import net.dpml.i18n.ResourceManager;
-import net.dpml.i18n.Resources;
-import net.dpml.system.SystemContext;
-
-/**
- * A factory enabling the establishment of runtime handlers.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class DefaultRuntimeFactory implements RuntimeFactory
-{
- //-------------------------------------------------------------------
- // static
- //-------------------------------------------------------------------
-
- private static final Resources REZ =
- ResourceManager.getPackageResources(
- DefaultRuntimeFactory.class );
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final SystemContext m_system;
-
- private final Map m_map = new Hashtable();
-
- //-------------------------------------------------------------------
- // mutable state
- //-------------------------------------------------------------------
-
- private LifestyleFactory m_factory;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- public DefaultRuntimeFactory( SystemContext system )
- {
- m_system = system;
- m_factory = new DefaultLifestyleFactory();
- }
-
- //-------------------------------------------------------------------
- // RuntimeFactory
- //-------------------------------------------------------------------
-
- /**
- * Resolve a runtime handler for a model.
- * @param model the deployment model
- * @return the runtime appliance
- */
- public Appliance getRuntime( DeploymentModel model )
- {
- synchronized( m_map )
- {
- Appliance runtime = getRegisteredRuntime( model );
- if( null != runtime )
- {
- return runtime;
- }
-
- //
- // create the runtime
- //
-
- if( model instanceof ComponentModel )
- {
- m_system.getLogger().debug( "creating metro runtime for " +
model );
-
- ComponentModel component = (ComponentModel) model;
- LifestyleManager manager =
- m_factory.createLifestyleManager( component );
- runtime = newComponentRuntime( component, manager );
- }
- else
- {
- final String error =
- REZ.getString(
- "runtime.error.unknown-model",
- model.toString(),
- model.getClass().getName() );
- throw new ModelRuntimeException( error );
- }
-
- registerRuntime( model, runtime );
- return runtime;
- }
- }
-
- //-------------------------------------------------------------------
- // private implementation
- //-------------------------------------------------------------------
-
- /**
- * Resolve a runtime handler for a component model.
- * @param model the containment model
- * @return the runtime handler
- */
- protected Appliance newComponentRuntime( ComponentModel model,
LifestyleManager manager )
- {
- return new DefaultAppliance( model, manager );
- }
-
- /**
- * Lookup a runtime relative to the model name.
- * @param model the deployment model
- * @return the matching runtime (possibly null)
- */
- private Appliance getRegisteredRuntime( DeploymentModel model )
- {
- String name = model.getQualifiedName();
- return (Appliance) m_map.get( name );
- }
-
- private void registerRuntime( DeploymentModel model, Appliance runtime )
- {
- String name = model.getQualifiedName();
- m_map.put( name, runtime );
- }
-}
+/*
+ * 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.activation.metro;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import net.dpml.activation.Appliance;
+import net.dpml.activation.RuntimeFactory;
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.model.ModelRuntimeException;
+import net.dpml.composition.provider.LifestyleFactory;
+import net.dpml.composition.provider.LifestyleManager;
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+import net.dpml.system.SystemContext;
+
+/**
+ * A factory enabling the establishment of runtime handlers.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class DefaultRuntimeFactory implements RuntimeFactory
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources(
+ DefaultRuntimeFactory.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final SystemContext m_system;
+
+ private final Map m_map = new Hashtable();
+
+ //-------------------------------------------------------------------
+ // mutable state
+ //-------------------------------------------------------------------
+
+ private LifestyleFactory m_factory;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public DefaultRuntimeFactory( SystemContext system )
+ {
+ m_system = system;
+ m_factory = new DefaultLifestyleFactory();
+ }
+
+ //-------------------------------------------------------------------
+ // RuntimeFactory
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a runtime handler for a model.
+ * @param model the deployment model
+ * @return the runtime appliance
+ */
+ public Appliance getRuntime( DeploymentModel model )
+ {
+ synchronized( m_map )
+ {
+ Appliance runtime = getRegisteredRuntime( model );
+ if( null != runtime )
+ {
+ return runtime;
+ }
+
+ //
+ // create the runtime
+ //
+
+ if( model instanceof ComponentModel )
+ {
+ m_system.getLogger().debug( "creating metro runtime for " +
model );
+
+ ComponentModel component = (ComponentModel) model;
+ LifestyleManager manager =
+ m_factory.createLifestyleManager( component );
+ runtime = newComponentRuntime( component, manager );
+ }
+ else
+ {
+ final String error =
+ REZ.getString(
+ "runtime.error.unknown-model",
+ model.toString(),
+ model.getClass().getName() );
+ throw new ModelRuntimeException( error );
+ }
+
+ registerRuntime( model, runtime );
+ return runtime;
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // private implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a runtime handler for a component model.
+ * @param model the containment model
+ * @return the runtime handler
+ */
+ protected Appliance newComponentRuntime( ComponentModel model,
LifestyleManager manager )
+ {
+ return new DefaultAppliance( model, manager );
+ }
+
+ /**
+ * Lookup a runtime relative to the model name.
+ * @param model the deployment model
+ * @return the matching runtime (possibly null)
+ */
+ private Appliance getRegisteredRuntime( DeploymentModel model )
+ {
+ String name = model.getQualifiedName();
+ return (Appliance) m_map.get( name );
+ }
+
+ private void registerRuntime( DeploymentModel model, Appliance runtime )
+ {
+ String name = model.getQualifiedName();
+ m_map.put( name, runtime );
+ }
+}

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultServiceManager.java
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultServiceManager.java
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultServiceManager.java
Fri Dec 24 22:19:23 2004
@@ -1,325 +1,325 @@
-/*
- * 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.activation.metro;
-
-import java.util.Map;
-import java.util.Hashtable;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.InvocationHandler;
-
-import net.dpml.composition.model.ComponentModel;
-import net.dpml.composition.model.DeploymentModel;
-import net.dpml.composition.model.DependencyModel;
-
-import net.dpml.logging.Logger;
-
-import net.dpml.service.ServiceException;
-import net.dpml.service.ServiceManager;
-import net.dpml.service.FatalServiceException;
-
-import net.dpml.i18n.ResourceManager;
-import net.dpml.i18n.Resources;
-
-/**
- * Default implementation of the framework {@link ServiceManager} interface.
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- */
-class DefaultServiceManager implements ServiceManager
-{
- //-------------------------------------------------------------------
- // static
- //-------------------------------------------------------------------
-
- private static final Resources REZ =
- ResourceManager.getPackageResources(
- DefaultServiceManager.class );
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private final Logger m_logger;
-
- /**
- * A table of identity hashcode integers of established objects
- * that map to the lookup key that was uased to establish the object.
- * Used to track which model is providing an object when we
- * handle release of objects.
- */
- private final Hashtable m_table = new Hashtable();
-
- /**
- * A table of dependency models keyed by lookup key.
- */
- private final Map m_map;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- /**
- * Construct a new ServiceManager.
- * @param model component model of the component that is
- * to be serviced.
- */
- public DefaultServiceManager( ComponentModel model )
- {
- if( model == null )
- {
- throw new NullPointerException( "model" );
- }
-
- m_logger = model.getLogger();
-
- m_map = new Hashtable();
- DependencyModel[] dependencies = model.getDependencyModels();
- for( int i=0; i < dependencies.length; i++ )
- {
- final DependencyModel dependency = dependencies[i];
-
- DeploymentModel provider = dependency.getProvider();
- if( provider != null )
- {
- final String key = dependency.getDependency().getKey();
- m_map.put( key, dependency );
- }
- }
- }
-
- //-------------------------------------------------------------------
- // ServiceManager
- //-------------------------------------------------------------------
-
- /**
- * Returns true if a provider exists for the supplied role.
- * @param key the service identifier key
- * @return boolean TRUE if the service is available else FALSE
- */
- public boolean hasService( String key )
- {
- if( key == null )
- {
- return false;
- }
- return ( m_map.get( key ) != null );
- }
-
- /**
- * Retrieve Object by key.
- * @param key the role
- * @return the Object
- * @throws ServiceException if an error occurs
- * @throws NullPointerException if the supplied key is null
- */
- public Object lookup( String key ) throws ServiceException
- {
- return lookup( key, -1 );
- }
-
- /**
- * Retrieve Object by key.
- * @param key the role
- * @return the Object or null if the Object doesn't exist
- * @throws ServiceException if an error occurs
- * @throws NullPointerException if the supplied key is null
- */
- public Object lookup( String key, long timeout ) throws ServiceException
- {
- if( key == null )
- {
- throw new NullPointerException( "key" );
- }
-
- if( !hasService( key ) )
- {
- final String error =
- "Unknown key: " + key;
- throw new ServiceException( key, error );
- }
-
- //
- // locate the provider model that is prividing components
- // for this dependency
- //
-
- DependencyModel dependency = (DependencyModel) m_map.get( key );
- final DeploymentModel provider = dependency.getProvider();
-
- if( null == provider )
- {
- final String error =
- REZ.getString( "service.error.null-provider", key );
- throw new IllegalStateException( error );
- }
-
- //
- // get a proxy to the service from the provider
- // (note that it is up to a provider to determine if
- // a proxy if generated based on its service export
- // parameters)
- //
-
- try
- {
- Object instance = provider.resolve();
- if( Proxy.isProxyClass( instance.getClass() ) )
- {
- return instance;
- }
-
- //
- // otherwise we need to hold a reference linking the
- // object with the source provider
- //
-
- String id = "" + System.identityHashCode( instance );
- m_table.put( id, key );
- if( getLogger().isDebugEnabled() )
- {
- final String message =
- "resolved service ["
- + id
- + "] for the key ["
- + key
- + "].";
- getLogger().debug( message );
- }
-
- return instance;
- }
- /*
- catch( TransientApplianceException e )
- {
- long delay = e.getDelay();
- if(( timeout == -1 ) || (( delay < timeout ) && ( delay > 0 )) )
- {
- try
- {
- Thread.currentThread().sleep( delay );
- }
- catch( Throwable interrupted )
- {
- // ignore
- }
- return lookup( key, delay );
- }
- else
- {
- final String error =
- "Requested service is not responding.";
- throw new TransientServiceException( key, error, delay );
- }
- }
- */
- catch( Throwable e )
- {
- //
- // TODO: framework states that ServiceException is thrown
- // if the service is not found - and in this case that isn't
- // the issue - in effect we have a good key, but we simply
- // have not been able to go from key to instance -
- // should look into some more concrete subtypes of
- // ServiceException
-
- final String error =
- "Unexpected runtime error while attempting to resolve service
for key: "
- + key;
- throw new FatalServiceException( key, error, e );
- }
- }
-
- /**
- * Release a service back to the manager.
- * @param instance the object to release
- */
- public void release( Object instance )
- {
- if( instance == null ) return;
-
- if( Proxy.isProxyClass( instance.getClass() ) )
- {
- InvocationHandler handler =
- Proxy.getInvocationHandler( instance );
- if( handler instanceof ApplianceInvocationHandler )
- {
- ApplianceInvocationHandler aic =
- (ApplianceInvocationHandler) handler;
- aic.release();
- return;
- }
- return;
- }
-
- //
- // otherwise we need to locate the source ourselves
- //
-
- String id = "" + System.identityHashCode( instance );
- final String key = (String) m_table.get( id );
- if( key == null )
- {
- if( getLogger().isWarnEnabled() )
- {
- final String warning =
- "Unrecognized object identity ["
- + id
- + "]. "
- + "Either this object was not provided by this service
manager "
- + "or it has already been released.";
- getLogger().warn( warning );
- }
- return;
- }
-
- DependencyModel dependency = (DependencyModel) m_map.get( key );
- final DeploymentModel provider = dependency.getProvider();
- if( provider == null )
- {
- if( getLogger().isErrorEnabled() )
- {
- final String error =
- "Unable to release component as no provider could be found
for the key ["
- + key
- + "].";
- getLogger().warn( error );
- }
- return;
- }
-
- provider.release( instance );
- if( getLogger().isDebugEnabled() )
- {
- final String message =
- "released service ["
- + id
- + "] from the key ["
- + key
- + "].";
- getLogger().debug( message );
- }
-
- m_table.remove( id );
- }
-
- private Logger getLogger()
- {
- return m_logger;
- }
-}
-
+/*
+ * 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.activation.metro;
+
+import java.util.Map;
+import java.util.Hashtable;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.InvocationHandler;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.model.DependencyModel;
+
+import net.dpml.logging.Logger;
+
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+import net.dpml.service.FatalServiceException;
+
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+
+/**
+ * Default implementation of the framework {@link ServiceManager} interface.
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+class DefaultServiceManager implements ServiceManager
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources(
+ DefaultServiceManager.class );
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private final Logger m_logger;
+
+ /**
+ * A table of identity hashcode integers of established objects
+ * that map to the lookup key that was uased to establish the object.
+ * Used to track which model is providing an object when we
+ * handle release of objects.
+ */
+ private final Hashtable m_table = new Hashtable();
+
+ /**
+ * A table of dependency models keyed by lookup key.
+ */
+ private final Map m_map;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Construct a new ServiceManager.
+ * @param model component model of the component that is
+ * to be serviced.
+ */
+ public DefaultServiceManager( ComponentModel model )
+ {
+ if( model == null )
+ {
+ throw new NullPointerException( "model" );
+ }
+
+ m_logger = model.getLogger();
+
+ m_map = new Hashtable();
+ DependencyModel[] dependencies = model.getDependencyModels();
+ for( int i=0; i < dependencies.length; i++ )
+ {
+ final DependencyModel dependency = dependencies[i];
+
+ DeploymentModel provider = dependency.getProvider();
+ if( provider != null )
+ {
+ final String key = dependency.getDependency().getKey();
+ m_map.put( key, dependency );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // ServiceManager
+ //-------------------------------------------------------------------
+
+ /**
+ * Returns true if a provider exists for the supplied role.
+ * @param key the service identifier key
+ * @return boolean TRUE if the service is available else FALSE
+ */
+ public boolean hasService( String key )
+ {
+ if( key == null )
+ {
+ return false;
+ }
+ return ( m_map.get( key ) != null );
+ }
+
+ /**
+ * Retrieve Object by key.
+ * @param key the role
+ * @return the Object
+ * @throws ServiceException if an error occurs
+ * @throws NullPointerException if the supplied key is null
+ */
+ public Object lookup( String key ) throws ServiceException
+ {
+ return lookup( key, -1 );
+ }
+
+ /**
+ * Retrieve Object by key.
+ * @param key the role
+ * @return the Object or null if the Object doesn't exist
+ * @throws ServiceException if an error occurs
+ * @throws NullPointerException if the supplied key is null
+ */
+ public Object lookup( String key, long timeout ) throws ServiceException
+ {
+ if( key == null )
+ {
+ throw new NullPointerException( "key" );
+ }
+
+ if( !hasService( key ) )
+ {
+ final String error =
+ "Unknown key: " + key;
+ throw new ServiceException( key, error );
+ }
+
+ //
+ // locate the provider model that is prividing components
+ // for this dependency
+ //
+
+ DependencyModel dependency = (DependencyModel) m_map.get( key );
+ final DeploymentModel provider = dependency.getProvider();
+
+ if( null == provider )
+ {
+ final String error =
+ REZ.getString( "service.error.null-provider", key );
+ throw new IllegalStateException( error );
+ }
+
+ //
+ // get a proxy to the service from the provider
+ // (note that it is up to a provider to determine if
+ // a proxy if generated based on its service export
+ // parameters)
+ //
+
+ try
+ {
+ Object instance = provider.resolve();
+ if( Proxy.isProxyClass( instance.getClass() ) )
+ {
+ return instance;
+ }
+
+ //
+ // otherwise we need to hold a reference linking the
+ // object with the source provider
+ //
+
+ String id = "" + System.identityHashCode( instance );
+ m_table.put( id, key );
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "resolved service ["
+ + id
+ + "] for the key ["
+ + key
+ + "].";
+ getLogger().debug( message );
+ }
+
+ return instance;
+ }
+ /*
+ catch( TransientApplianceException e )
+ {
+ long delay = e.getDelay();
+ if(( timeout == -1 ) || (( delay < timeout ) && ( delay > 0 )) )
+ {
+ try
+ {
+ Thread.currentThread().sleep( delay );
+ }
+ catch( Throwable interrupted )
+ {
+ // ignore
+ }
+ return lookup( key, delay );
+ }
+ else
+ {
+ final String error =
+ "Requested service is not responding.";
+ throw new TransientServiceException( key, error, delay );
+ }
+ }
+ */
+ catch( Throwable e )
+ {
+ //
+ // TODO: framework states that ServiceException is thrown
+ // if the service is not found - and in this case that isn't
+ // the issue - in effect we have a good key, but we simply
+ // have not been able to go from key to instance -
+ // should look into some more concrete subtypes of
+ // ServiceException
+
+ final String error =
+ "Unexpected runtime error while attempting to resolve service
for key: "
+ + key;
+ throw new FatalServiceException( key, error, e );
+ }
+ }
+
+ /**
+ * Release a service back to the manager.
+ * @param instance the object to release
+ */
+ public void release( Object instance )
+ {
+ if( instance == null ) return;
+
+ if( Proxy.isProxyClass( instance.getClass() ) )
+ {
+ InvocationHandler handler =
+ Proxy.getInvocationHandler( instance );
+ if( handler instanceof ApplianceInvocationHandler )
+ {
+ ApplianceInvocationHandler aic =
+ (ApplianceInvocationHandler) handler;
+ aic.release();
+ return;
+ }
+ return;
+ }
+
+ //
+ // otherwise we need to locate the source ourselves
+ //
+
+ String id = "" + System.identityHashCode( instance );
+ final String key = (String) m_table.get( id );
+ if( key == null )
+ {
+ if( getLogger().isWarnEnabled() )
+ {
+ final String warning =
+ "Unrecognized object identity ["
+ + id
+ + "]. "
+ + "Either this object was not provided by this service
manager "
+ + "or it has already been released.";
+ getLogger().warn( warning );
+ }
+ return;
+ }
+
+ DependencyModel dependency = (DependencyModel) m_map.get( key );
+ final DeploymentModel provider = dependency.getProvider();
+ if( provider == null )
+ {
+ if( getLogger().isErrorEnabled() )
+ {
+ final String error =
+ "Unable to release component as no provider could be found
for the key ["
+ + key
+ + "].";
+ getLogger().warn( error );
+ }
+ return;
+ }
+
+ provider.release( instance );
+ if( getLogger().isDebugEnabled() )
+ {
+ final String message =
+ "released service ["
+ + id
+ + "] from the key ["
+ + key
+ + "].";
+ getLogger().debug( message );
+ }
+
+ m_table.remove( id );
+ }
+
+ private Logger getLogger()
+ {
+ return m_logger;
+ }
+}
+

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/Resources.properties
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/Resources.properties
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/Resources.properties
Fri Dec 24 22:19:23 2004
@@ -1,39 +1,39 @@
-
-#
-# DefaultRuntimeFactory
-# ---------------------
-runtime.error.unknown-model=Deployment model {0} class [{1}] is not
supported.
-runtime.error.lifestyle.no-constructor=The supplied lifestyle factory
artifact references a class [{1}] that does not declare a public constructor.
-runtime.error.unrecognized-runtime-parameter=LifestyleFactory constructor in
[{0}] is requesting an unrecognized parameter [{1}].
-runtime.error.runtime-instantiation=Cannot create lifestyle factory [{0}]
due to an instantiation error.
-
-#
-# DefaultComponentFactory
-# -----------------------
-lifestyle.error.no-constructor=Supplied component class {0} does not declare
a public constructor.
-lifecycle.error.unrecognized-parameter=The constructor argument [{0}] in
component class {1} is not recognized.
-lifecycle.error.instantiation=Component related exception during
instantiation of the class [{0}].
-lifecycle.error.invalid-stage-provider=Assigned stage provider [{0}] is not
a component model.
-lifecycle.error.stage.creator=Creation stage handler error raised by
extension id: [{0}].
-lifestyle.error.new=Unable to create a new component instance in appliance
[{0}] due to a component deployment failure.
-lifestyle.error.contextualization=Internal error while attempting to resolve
contexualization handler from the appliance [{0}].
-lifecycle.error.avalon-contextualization=Contextualization failure in [{0}].
-lifecycle.error.custom-contextualization=Contextualization failure in [{0}]
using custom handler [{1}].
-
-#
-# ServiceManager
-# --------------
-
-service.error.null-provider = A valid request was received for a service
using the key [{0}] but the supplied dependency model returned a null
provider. This is an internal system error reflecting an inconsistent
assembly state.
-
-#
-# DefaultBlock
-# ------------
-block.error.resolve.non-commission-state=Cannot respond to resolve request
as the block {0} is in a non-commissioned state.
-
-#
-# DefaultAppliance
-# -----
-appliance.error.resolve.non-commission-state=Cannot respond to resolve
request as the appliance {0} is in a non-commissioned state.
-appliance.error.resolve.transient=Service managed by [{0}] return a
transient non-availability status. Projected delay before service resumption
is [{1}] milliseconds.
-
+
+#
+# DefaultRuntimeFactory
+# ---------------------
+runtime.error.unknown-model=Deployment model {0} class [{1}] is not
supported.
+runtime.error.lifestyle.no-constructor=The supplied lifestyle factory
artifact references a class [{1}] that does not declare a public constructor.
+runtime.error.unrecognized-runtime-parameter=LifestyleFactory constructor in
[{0}] is requesting an unrecognized parameter [{1}].
+runtime.error.runtime-instantiation=Cannot create lifestyle factory [{0}]
due to an instantiation error.
+
+#
+# DefaultComponentFactory
+# -----------------------
+lifestyle.error.no-constructor=Supplied component class {0} does not declare
a public constructor.
+lifecycle.error.unrecognized-parameter=The constructor argument [{0}] in
component class {1} is not recognized.
+lifecycle.error.instantiation=Component related exception during
instantiation of the class [{0}].
+lifecycle.error.invalid-stage-provider=Assigned stage provider [{0}] is not
a component model.
+lifecycle.error.stage.creator=Creation stage handler error raised by
extension id: [{0}].
+lifestyle.error.new=Unable to create a new component instance in appliance
[{0}] due to a component deployment failure.
+lifestyle.error.contextualization=Internal error while attempting to resolve
contexualization handler from the appliance [{0}].
+lifecycle.error.avalon-contextualization=Contextualization failure in [{0}].
+lifecycle.error.custom-contextualization=Contextualization failure in [{0}]
using custom handler [{1}].
+
+#
+# ServiceManager
+# --------------
+
+service.error.null-provider = A valid request was received for a service
using the key [{0}] but the supplied dependency model returned a null
provider. This is an internal system error reflecting an inconsistent
assembly state.
+
+#
+# DefaultBlock
+# ------------
+block.error.resolve.non-commission-state=Cannot respond to resolve request
as the block {0} is in a non-commissioned state.
+
+#
+# DefaultAppliance
+# -----
+appliance.error.resolve.non-commission-state=Cannot respond to resolve
request as the appliance {0} is in a non-commissioned state.
+appliance.error.resolve.transient=Service managed by [{0}] return a
transient non-availability status. Projected delay before service resumption
is [{1}] milliseconds.
+

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/SingletonLifestyleManager.java
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/SingletonLifestyleManager.java
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/SingletonLifestyleManager.java
Fri Dec 24 22:19:23 2004
@@ -1,147 +1,147 @@
-/*
- * 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.activation.metro;
-
-import java.lang.ref.Reference;
-
-import net.dpml.activation.ComponentFactory;
-
-import net.dpml.composition.model.ComponentModel;
-
-/**
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class SingletonLifestyleManager extends AbstractLifestyleManager
-{
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private Reference m_reference;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- public SingletonLifestyleManager( ComponentModel model, ComponentFactory
factory )
- {
- super( model, factory );
- }
-
- //-------------------------------------------------------------------
- // Commissionable
- //-------------------------------------------------------------------
-
- /**
- * Commission the runtime handler.
- *
- * @exception Exception if a handler commissioning error occurs
- */
- public void commission() throws Exception
- {
- handleResolve();
- }
-
- /**
- * Invokes the decommissioning phase. Once a handler is
- * decommissioned it may be re-commissioned.
- */
- public void decommission()
- {
- if( m_reference != null )
- {
- finalize( m_reference.get() );
- m_reference = null;
- }
- }
-
- //-------------------------------------------------------------------
- // Resolver
- //-------------------------------------------------------------------
-
- /**
- * Resolve a object to a value relative to a supplied set of
- * interface classes.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- protected synchronized Object handleResolve() throws Exception
- {
- Object instance = null;
-
- if( m_reference == null )
- {
- return refreshReference();
- }
- else
- {
- instance = m_reference.get();
- if( instance == null )
- {
- return refreshReference();
- }
- else
- {
- return instance;
- }
- }
- }
-
- /**
- * Release an object
- *
- * @param instance the object to be released
- */
- protected synchronized void handleRelease( Object instance )
- {
- // continue with the current singleton reference
- }
-
- //-------------------------------------------------------------------
- // LifecycleManager
- //-------------------------------------------------------------------
-
- /**
- * Release an object
- *
- * @param instance the object to be released
- */
- public synchronized void finalize( Object instance )
- {
- getComponentFactory().etherialize( instance );
- m_reference = null;
- }
-
- //-------------------------------------------------------------------
- // implementation
- //-------------------------------------------------------------------
-
- private Object refreshReference() throws Exception
- {
- ComponentFactory factory = getComponentFactory();
- synchronized( factory )
- {
- Object instance = factory.incarnate();
- m_reference = getReference( instance );
- return instance;
- }
- }
-}
+/*
+ * 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.activation.metro;
+
+import java.lang.ref.Reference;
+
+import net.dpml.activation.ComponentFactory;
+
+import net.dpml.composition.model.ComponentModel;
+
+/**
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class SingletonLifestyleManager extends AbstractLifestyleManager
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private Reference m_reference;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public SingletonLifestyleManager( ComponentModel model, ComponentFactory
factory )
+ {
+ super( model, factory );
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the runtime handler.
+ *
+ * @exception Exception if a handler commissioning error occurs
+ */
+ public void commission() throws Exception
+ {
+ handleResolve();
+ }
+
+ /**
+ * Invokes the decommissioning phase. Once a handler is
+ * decommissioned it may be re-commissioned.
+ */
+ public void decommission()
+ {
+ if( m_reference != null )
+ {
+ finalize( m_reference.get() );
+ m_reference = null;
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value relative to a supplied set of
+ * interface classes.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ protected synchronized Object handleResolve() throws Exception
+ {
+ Object instance = null;
+
+ if( m_reference == null )
+ {
+ return refreshReference();
+ }
+ else
+ {
+ instance = m_reference.get();
+ if( instance == null )
+ {
+ return refreshReference();
+ }
+ else
+ {
+ return instance;
+ }
+ }
+ }
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ protected synchronized void handleRelease( Object instance )
+ {
+ // continue with the current singleton reference
+ }
+
+ //-------------------------------------------------------------------
+ // LifecycleManager
+ //-------------------------------------------------------------------
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ public synchronized void finalize( Object instance )
+ {
+ getComponentFactory().etherialize( instance );
+ m_reference = null;
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ private Object refreshReference() throws Exception
+ {
+ ComponentFactory factory = getComponentFactory();
+ synchronized( factory )
+ {
+ Object instance = factory.incarnate();
+ m_reference = getReference( instance );
+ return instance;
+ }
+ }
+}

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/ThreadLifestyleManager.java
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/ThreadLifestyleManager.java
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/ThreadLifestyleManager.java
Fri Dec 24 22:19:23 2004
@@ -1,147 +1,147 @@
-/*
- * 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.activation.metro;
-
-import net.dpml.activation.LifestyleRuntimeException;
-import net.dpml.activation.ComponentFactory;
-
-import net.dpml.composition.model.ComponentModel;
-
-/**
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class ThreadLifestyleManager extends AbstractLifestyleManager
-{
- //-------------------------------------------------------------------
- // static
- //-------------------------------------------------------------------
-
- /**
- * Internal utility class to hold the thread local instance.
- */
- private static final class ThreadLocalHolder extends ThreadLocal
- {
- private final ComponentFactory m_factory;
-
- protected ThreadLocalHolder( ComponentFactory factory )
- {
- m_factory = factory;
- }
-
- //
- // TODO: the current implementation is hard coded to HARD
- // collection policy - we need to update the ThreadLocalHolder so
- // it regenerates the value relative to SOFT or WEAK policies
- // (but I just need to check docs on thread local state access
- // semantics)
- //
-
- protected Object initialValue()
- {
- try
- {
- return m_factory.incarnate();
- }
- catch( Exception e )
- {
- final String error =
- "Unable to establish thread local variable.";
- throw new LifestyleRuntimeException( error, e );
- }
- }
- }
-
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private ThreadLocalHolder m_local;
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- public ThreadLifestyleManager( ComponentModel model, ComponentFactory
factory )
- {
- super( model, factory );
- }
-
- //-------------------------------------------------------------------
- // Commissionable
- //-------------------------------------------------------------------
-
- /**
- * Commission the runtime handler.
- *
- * @exception Exception if a hanfdler commissioning error occurs
- */
- public void commission() throws Exception
- {
- if( getComponentModel().getActivationPolicy() )
- {
- resolve();
- }
- }
-
- /**
- * Invokes the decommissioning phase. Once a handler is
- * decommissioned it may be re-commissioned.
- */
- public synchronized void decommission()
- {
- if( m_local != null )
- {
- finalize( m_local.get() );
- m_local = null;
- }
- }
-
- //-------------------------------------------------------------------
- // Resolver
- //-------------------------------------------------------------------
-
- /**
- * Resolve a object to a value relative to a supplied set of
- * interface classes.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- protected Object handleResolve() throws Exception
- {
- if( m_local == null )
- {
- ComponentFactory factory = getComponentFactory();
- m_local = new ThreadLocalHolder( factory );
- }
- return m_local.get();
- }
-
- /**
- * Release an object.
- *
- * @param instance the object to be reclaimed
- */
- protected void handleRelease( Object instance )
- {
- // don't release because this is a shared reference
- }
-
-}
+/*
+ * 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.activation.metro;
+
+import net.dpml.activation.LifestyleRuntimeException;
+import net.dpml.activation.ComponentFactory;
+
+import net.dpml.composition.model.ComponentModel;
+
+/**
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class ThreadLifestyleManager extends AbstractLifestyleManager
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ /**
+ * Internal utility class to hold the thread local instance.
+ */
+ private static final class ThreadLocalHolder extends ThreadLocal
+ {
+ private final ComponentFactory m_factory;
+
+ protected ThreadLocalHolder( ComponentFactory factory )
+ {
+ m_factory = factory;
+ }
+
+ //
+ // TODO: the current implementation is hard coded to HARD
+ // collection policy - we need to update the ThreadLocalHolder so
+ // it regenerates the value relative to SOFT or WEAK policies
+ // (but I just need to check docs on thread local state access
+ // semantics)
+ //
+
+ protected Object initialValue()
+ {
+ try
+ {
+ return m_factory.incarnate();
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to establish thread local variable.";
+ throw new LifestyleRuntimeException( error, e );
+ }
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private ThreadLocalHolder m_local;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public ThreadLifestyleManager( ComponentModel model, ComponentFactory
factory )
+ {
+ super( model, factory );
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the runtime handler.
+ *
+ * @exception Exception if a hanfdler commissioning error occurs
+ */
+ public void commission() throws Exception
+ {
+ if( getComponentModel().getActivationPolicy() )
+ {
+ resolve();
+ }
+ }
+
+ /**
+ * Invokes the decommissioning phase. Once a handler is
+ * decommissioned it may be re-commissioned.
+ */
+ public synchronized void decommission()
+ {
+ if( m_local != null )
+ {
+ finalize( m_local.get() );
+ m_local = null;
+ }
+ }
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value relative to a supplied set of
+ * interface classes.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ protected Object handleResolve() throws Exception
+ {
+ if( m_local == null )
+ {
+ ComponentFactory factory = getComponentFactory();
+ m_local = new ThreadLocalHolder( factory );
+ }
+ return m_local.get();
+ }
+
+ /**
+ * Release an object.
+ *
+ * @param instance the object to be reclaimed
+ */
+ protected void handleRelease( Object instance )
+ {
+ // don't release because this is a shared reference
+ }
+
+}

Modified:
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/TransientLifestyleManager.java
==============================================================================
---
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/TransientLifestyleManager.java
(original)
+++
development/main/metro/activation/providers/metro/src/main/net/dpml/activation/metro/TransientLifestyleManager.java
Fri Dec 24 22:19:23 2004
@@ -1,140 +1,140 @@
-/*
- * 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.activation.metro;
-
-import java.lang.ref.SoftReference;
-import java.lang.ref.WeakReference;
-import java.lang.ref.Reference;
-import java.util.ArrayList;
-
-import net.dpml.activation.ComponentFactory;
-
-import net.dpml.composition.model.ComponentModel;
-
-import net.dpml.meta.info.InfoDescriptor;
-
-/**
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class TransientLifestyleManager extends AbstractLifestyleManager
-{
- //-------------------------------------------------------------------
- // immutable state
- //-------------------------------------------------------------------
-
- private ArrayList m_list = new ArrayList();
-
- //-------------------------------------------------------------------
- // constructor
- //-------------------------------------------------------------------
-
- public TransientLifestyleManager( ComponentModel model, ComponentFactory
factory )
- {
- super( model, factory );
- }
-
- //-------------------------------------------------------------------
- // Commissionable
- //-------------------------------------------------------------------
-
- /**
- * Commission the appliance.
- *
- * @exception Exception if a commissioning error occurs
- */
- public void commission() throws Exception
- {
- // TODO: setup a background thread to check queues for
- // released references and remove them from our list, otherwise we
- // have a memory leak due to accumulation of weak references
-
- if( getComponentModel().getActivationPolicy() )
- {
- handleResolve();
- }
- }
-
- /**
- * Decommission the appliance. Once an appliance is
- * decommissioned it may be re-commissioned.
- */
- public void decommission()
- {
- Reference[] refs = (Reference[]) m_list.toArray( new Reference[0] );
- for( int i=0; i<refs.length; i++ )
- {
- Reference ref = refs[i];
- finalize( ref.get() );
- }
- m_list.clear();
- }
-
- //-------------------------------------------------------------------
- // Resolver
- //-------------------------------------------------------------------
-
- /**
- * Resolve a object to a value relative to a supplied set of
- * interface classes.
- *
- * @return the resolved object
- * @throws Exception if an error occurs
- */
- protected Object handleResolve() throws Exception
- {
- Object instance = getComponentFactory().incarnate();
- Reference reference = getReference( instance );
- m_list.add( reference );
- return instance;
- }
-
- /**
- * Release an object
- *
- * @param instance the object to be released
- */
- protected void handleRelease( Object instance )
- {
- finalize( instance );
- }
-
- //-------------------------------------------------------------------
- // LifestyleManager
- //-------------------------------------------------------------------
-
- /**
- * Overriding getReference to ensure that we never return a hard
- * reference for a transient.
- */
- protected Reference getReference( Object instance )
- {
- final int policy = getComponentModel().getCollectionPolicy();
- if( policy == InfoDescriptor.SOFT )
- {
- return new SoftReference( instance );
- }
- else
- {
- return new WeakReference(
- instance,
- getLiberalQueue() );
- }
- }
-}
+/*
+ * 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.activation.metro;
+
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+import java.lang.ref.Reference;
+import java.util.ArrayList;
+
+import net.dpml.activation.ComponentFactory;
+
+import net.dpml.composition.model.ComponentModel;
+
+import net.dpml.meta.info.InfoDescriptor;
+
+/**
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class TransientLifestyleManager extends AbstractLifestyleManager
+{
+ //-------------------------------------------------------------------
+ // immutable state
+ //-------------------------------------------------------------------
+
+ private ArrayList m_list = new ArrayList();
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ public TransientLifestyleManager( ComponentModel model, ComponentFactory
factory )
+ {
+ super( model, factory );
+ }
+
+ //-------------------------------------------------------------------
+ // Commissionable
+ //-------------------------------------------------------------------
+
+ /**
+ * Commission the appliance.
+ *
+ * @exception Exception if a commissioning error occurs
+ */
+ public void commission() throws Exception
+ {
+ // TODO: setup a background thread to check queues for
+ // released references and remove them from our list, otherwise we
+ // have a memory leak due to accumulation of weak references
+
+ if( getComponentModel().getActivationPolicy() )
+ {
+ handleResolve();
+ }
+ }
+
+ /**
+ * Decommission the appliance. Once an appliance is
+ * decommissioned it may be re-commissioned.
+ */
+ public void decommission()
+ {
+ Reference[] refs = (Reference[]) m_list.toArray( new Reference[0] );
+ for( int i=0; i<refs.length; i++ )
+ {
+ Reference ref = refs[i];
+ finalize( ref.get() );
+ }
+ m_list.clear();
+ }
+
+ //-------------------------------------------------------------------
+ // Resolver
+ //-------------------------------------------------------------------
+
+ /**
+ * Resolve a object to a value relative to a supplied set of
+ * interface classes.
+ *
+ * @return the resolved object
+ * @throws Exception if an error occurs
+ */
+ protected Object handleResolve() throws Exception
+ {
+ Object instance = getComponentFactory().incarnate();
+ Reference reference = getReference( instance );
+ m_list.add( reference );
+ return instance;
+ }
+
+ /**
+ * Release an object
+ *
+ * @param instance the object to be released
+ */
+ protected void handleRelease( Object instance )
+ {
+ finalize( instance );
+ }
+
+ //-------------------------------------------------------------------
+ // LifestyleManager
+ //-------------------------------------------------------------------
+
+ /**
+ * Overriding getReference to ensure that we never return a hard
+ * reference for a transient.
+ */
+ protected Reference getReference( Object instance )
+ {
+ final int policy = getComponentModel().getCollectionPolicy();
+ if( policy == InfoDescriptor.SOFT )
+ {
+ return new SoftReference( instance );
+ }
+ else
+ {
+ return new WeakReference(
+ instance,
+ getLiberalQueue() );
+ }
+ }
+}

Modified: development/main/metro/activation/test/build.xml
==============================================================================
--- development/main/metro/activation/test/build.xml (original)
+++ development/main/metro/activation/test/build.xml Fri Dec 24 22:19:23
2004
@@ -1,28 +1,28 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-activation-test" default="install" basedir="."
- xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
-
- <magic:import uri="artifact:template:dpml/magic/standard"/>
-
- <target name="init" depends="standard.init">
- <x:filter key="dpml-activation-impl" feature="plugin"
- token="ACTIVATION-RUNTIME-IMPL-SPEC"/>
- <x:filter key="dpml-test-playground" feature="uri"
- token="TEST-PLAYGROUND-SPEC"/>
- <x:filter key="dpml-test-components" feature="uri"
- token="TEST-COMPONENTS-SPEC"/>
- <x:filter key="avalon-framework-api" feature="uri"
- token="AVALON-API-SPEC"/>
- <x:filter key="avalon-framework-impl" feature="uri"
- token="AVALON-IMPL-SPEC"/>
- <x:filter key="dpml-logging-api" feature="uri"
- token="LOGGING-API-SPEC"/>
- <x:filter key="dpml-context-api" feature="uri"
- token="CONTEXT-API-SPEC"/>
- <x:filter key="dpml-service-api" feature="uri"
- token="SERVICE-API-SPEC"/>
- </target>
-
-</project>
-
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-activation-test" default="install" basedir="."
+ xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
+
+ <magic:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="init" depends="standard.init">
+ <x:filter key="dpml-activation-impl" feature="plugin"
+ token="ACTIVATION-RUNTIME-IMPL-SPEC"/>
+ <x:filter key="dpml-test-playground" feature="uri"
+ token="TEST-PLAYGROUND-SPEC"/>
+ <x:filter key="dpml-test-components" feature="uri"
+ token="TEST-COMPONENTS-SPEC"/>
+ <x:filter key="avalon-framework-api" feature="uri"
+ token="AVALON-API-SPEC"/>
+ <x:filter key="avalon-framework-impl" feature="uri"
+ token="AVALON-IMPL-SPEC"/>
+ <x:filter key="dpml-logging-api" feature="uri"
+ token="LOGGING-API-SPEC"/>
+ <x:filter key="dpml-context-api" feature="uri"
+ token="CONTEXT-API-SPEC"/>
+ <x:filter key="dpml-service-api" feature="uri"
+ token="SERVICE-API-SPEC"/>
+ </target>
+
+</project>
+

Modified: development/main/metro/activation/test/etc/test/kernel.xml
==============================================================================
--- development/main/metro/activation/test/etc/test/kernel.xml (original)
+++ development/main/metro/activation/test/etc/test/kernel.xml Fri Dec 24
22:19:23 2004
@@ -1,75 +1,75 @@
-<!--
-Configuration used to validate the
-populatation of registered artifacts with the initial context.
--->
-
-<kernel>
-
- <security>
- <profile name="default">
- <permissions>
- <permission class="java.util.PropertyPermission" name="java.*">
- <action>read</action>
- </permission>
- <permission class="java.util.PropertyPermission" name="os.*">
- <action>read</action>
- </permission>
- <permission class="java.util.PropertyPermission"
name="file.separator">
- <action>read</action>
- </permission>
- <permission class="java.util.PropertyPermission"
name="path.separator">
- <action>read</action>
- </permission>
- <permission class="java.util.PropertyPermission"
name="line.separator">
- <action>read</action>
- </permission>
- <permission class="java.util.PropertyPermission" name="user.name">
- <action>read</action>
- </permission>
- </permissions>
- </profile>
- </security>
-
-<!--
-Example block deployment descriptor.
--->
-
-<container name="root">
-
- <classloader>
- <classpath>
- <artifact>@LOGGING-API-SPEC@</artifact>
- <artifact>@CONTEXT-API-SPEC@</artifact>
- <artifact>@SERVICE-API-SPEC@</artifact>
- <artifact>@TEST-COMPONENTS-SPEC@</artifact>
- </classpath>
- <grant>
- <permission class="java.util.PropertyPermission" name="java.*" >
- <action>read</action>
- </permission>
- <permission class="java.util.PropertyPermission" name="org.apache.*" >
- <action>read</action>
- <action>write</action>
- </permission>
- <permission class="java.lang.RuntimePermission" name="getClassLoader"
/>
- </grant>
- </classloader>
-
- <container name="Component1" >
- <services>
- <service type="net.dpml.test.components.TestService">
- <source>test</source>
- </service>
- </services>
- <component name="test"
- class="net.dpml.test.components.TestComponent"/>
- </container>
-
- <container name="Component2" >
- <component name="anothertest"
- class="net.dpml.test.components.AnotherTestComponent"/>
- </container>
-</container>
-
-
+<!--
+Configuration used to validate the
+populatation of registered artifacts with the initial context.
+-->
+
+<kernel>
+
+ <security>
+ <profile name="default">
+ <permissions>
+ <permission class="java.util.PropertyPermission" name="java.*">
+ <action>read</action>
+ </permission>
+ <permission class="java.util.PropertyPermission" name="os.*">
+ <action>read</action>
+ </permission>
+ <permission class="java.util.PropertyPermission"
name="file.separator">
+ <action>read</action>
+ </permission>
+ <permission class="java.util.PropertyPermission"
name="path.separator">
+ <action>read</action>
+ </permission>
+ <permission class="java.util.PropertyPermission"
name="line.separator">
+ <action>read</action>
+ </permission>
+ <permission class="java.util.PropertyPermission" name="user.name">
+ <action>read</action>
+ </permission>
+ </permissions>
+ </profile>
+ </security>
+
+<!--
+Example block deployment descriptor.
+-->
+
+<container name="root">
+
+ <classloader>
+ <classpath>
+ <artifact>@LOGGING-API-SPEC@</artifact>
+ <artifact>@CONTEXT-API-SPEC@</artifact>
+ <artifact>@SERVICE-API-SPEC@</artifact>
+ <artifact>@TEST-COMPONENTS-SPEC@</artifact>
+ </classpath>
+ <grant>
+ <permission class="java.util.PropertyPermission" name="java.*" >
+ <action>read</action>
+ </permission>
+ <permission class="java.util.PropertyPermission" name="org.apache.*" >
+ <action>read</action>
+ <action>write</action>
+ </permission>
+ <permission class="java.lang.RuntimePermission" name="getClassLoader"
/>
+ </grant>
+ </classloader>
+
+ <container name="Component1" >
+ <services>
+ <service type="net.dpml.test.components.TestService">
+ <source>test</source>
+ </service>
+ </services>
+ <component name="test"
+ class="net.dpml.test.components.TestComponent"/>
+ </container>
+
+ <container name="Component2" >
+ <component name="anothertest"
+ class="net.dpml.test.components.AnotherTestComponent"/>
+ </container>
+</container>
+
+
</kernel>
\ No newline at end of file

Modified: development/main/metro/activation/test/etc/test/logging.xml
==============================================================================
--- development/main/metro/activation/test/etc/test/logging.xml (original)
+++ development/main/metro/activation/test/etc/test/logging.xml Fri Dec 24
22:19:23 2004
@@ -1,26 +1,26 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!--
-Logging configuration for testing.
-Not in use yet.
--->
-
-<logging>
-
- <factories>
- <factory type="file"
- class="org.apache.avalon.logging.logkit.factory.FileTargetFactory"/>
- </factories>
-
- <targets>
- <file id="simple">
- <filename>../testing.log</filename>
- <append>true</append>
- </file>
- </targets>
-
- <categories priority="info" target="simple"/>
-
- <logger name="kernel.logger"/>
-
-</logging>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+Logging configuration for testing.
+Not in use yet.
+-->
+
+<logging>
+
+ <factories>
+ <factory type="file"
+ class="org.apache.avalon.logging.logkit.factory.FileTargetFactory"/>
+ </factories>
+
+ <targets>
+ <file id="simple">
+ <filename>../testing.log</filename>
+ <append>true</append>
+ </file>
+ </targets>
+
+ <categories priority="info" target="simple"/>
+
+ <logger name="kernel.logger"/>
+
+</logging>

Modified: development/main/metro/activation/test/etc/test/metro.properties
==============================================================================
--- development/main/metro/activation/test/etc/test/metro.properties
(original)
+++ development/main/metro/activation/test/etc/test/metro.properties Fri
Dec 24 22:19:23 2004
@@ -1,8 +1,8 @@
-#
-# properties used to configure the composition context used during test
execution
-#
-
-metro.online = false
-metro.logging.configuration.path = logging.xml
-metro.debug = true
-metro.info = true
+#
+# properties used to configure the composition context used during test
execution
+#
+
+metro.online = false
+metro.logging.configuration.path = logging.xml
+metro.debug = true
+metro.info = true

Modified: development/main/metro/activation/test/etc/test/playground.xml
==============================================================================
--- development/main/metro/activation/test/etc/test/playground.xml
(original)
+++ development/main/metro/activation/test/etc/test/playground.xml Fri
Dec 24 22:19:23 2004
@@ -1,30 +1,30 @@
-
-<!--
-Example block deployment descriptor.
--->
-
-<container name="playground">
-
- <classloader>
- <classpath>
- <artifact>@TEST-PLAYGROUND-SPEC@</artifact>
- </classpath>
- </classloader>
-
- <services>
- <service type="net.dpml.test.playground.basic.BasicService"
version="1.1"/>
- </services>
-
- <container name="subsidiary">
-
- <component name="complex"
- class="net.dpml.test.playground.ComplexComponent">
- </component>
-
- <container name="test">
- <component name="simple"
class="net.dpml.test.playground.SimpleComponent"/>
- </container>
-
- </container>
-
-</container>
+
+<!--
+Example block deployment descriptor.
+-->
+
+<container name="playground">
+
+ <classloader>
+ <classpath>
+ <artifact>@TEST-PLAYGROUND-SPEC@</artifact>
+ </classpath>
+ </classloader>
+
+ <services>
+ <service type="net.dpml.test.playground.basic.BasicService"
version="1.1"/>
+ </services>
+
+ <container name="subsidiary">
+
+ <component name="complex"
+ class="net.dpml.test.playground.ComplexComponent">
+ </component>
+
+ <container name="test">
+ <component name="simple"
class="net.dpml.test.playground.SimpleComponent"/>
+ </container>
+
+ </container>
+
+</container>

Modified:
development/main/metro/activation/test/src/test/net/dpml/activation/impl/test/CodeSecurityDisabledTestCase.java
==============================================================================
---
development/main/metro/activation/test/src/test/net/dpml/activation/impl/test/CodeSecurityDisabledTestCase.java
(original)
+++
development/main/metro/activation/test/src/test/net/dpml/activation/impl/test/CodeSecurityDisabledTestCase.java
Fri Dec 24 22:19:23 2004
@@ -1,148 +1,148 @@
-/*
- * 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.activation.impl.test;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import net.dpml.composition.model.ContainmentModel;
-import net.dpml.composition.model.DeploymentModel;
-import net.dpml.composition.provider.CompositionHelper;
-import net.dpml.composition.test.CompositionTestCase;
-import net.dpml.exception.ExceptionHelper;
-import net.dpml.test.components.TestService;
-
-/**
- * CompositionFactoryTestCase
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class CodeSecurityDisabledTestCase extends CompositionTestCase
-{
- //------------------------------------------------------------------
- // static
- //------------------------------------------------------------------
-
- private static final String ACTIVATION_RUNTIME =
"@ACTIVATION-RUNTIME-IMPL-SPEC@";
-
- //------------------------------------------------------------------
- // state
- //------------------------------------------------------------------
-
- private ContainmentModel m_model;
- DeploymentModel m_test;
-
- //------------------------------------------------------------------
- // TestCase
- //------------------------------------------------------------------
-
- protected void setUp() throws Exception
- {
- File kernel = new File( WORK, "kernel.xml" );
-
- Map map = new HashMap();
- map.put( "dpml.composition.runtime", ACTIVATION_RUNTIME );
- map.put( "dpml.composition.kernel", kernel.getAbsolutePath() );
- m_model = createCompositionRoot( map );
- m_test = m_model.getModel( "/Component1/test" );
- m_model.commission();
- }
-
- public void tearDown()
- {
- m_model.decommission();
- }
-
- private TestService getTestService() throws Exception
- {
- return (TestService) m_test.resolve();
- }
-
- private void releaseTestService( TestService service )
- {
- m_test.release( service );
- }
-
- //------------------------------------------------------------------
- // tests
- //------------------------------------------------------------------
-
- /**
- * Create, assembly, deploy and decommission the block
- * defined by getPath().
- */
- public void testCodeSecurity() throws Exception
- {
- TestService test = getTestService();
-
- assertNotNull( "test", test );
-
- try
- {
- System.out.println( CompositionHelper.toString( m_model ) );
- test.createDirectory();
- }
- catch( Throwable e )
- {
- releaseTestService( test );
- final String error = "CodeSecurityTest primary failure.";
- final String message = ExceptionHelper.packException( error, e,
true );
- throw new Exception( message );
- }
-
- try
- {
- test.deleteDirectory();
- }
- catch( Throwable e )
- {
- releaseTestService( test );
- final String error = "CodeSecurityTest secondary failure.";
- final String message = ExceptionHelper.packException( error, e,
true );
- throw new Exception( message );
- }
-
- try
- {
- String ver = test.getJavaVersion();
- }
- catch( Throwable e )
- {
- releaseTestService( test );
- final String error = "CodeSecurityTest secondary failure.";
- final String message = ExceptionHelper.packException( error, e,
true );
- throw new Exception( message );
- }
-
- try
- {
- test.setJavaVersion( "1.0.2" );
- }
- catch( Throwable e )
- {
- releaseTestService( test );
- final String error = "CodeSecurityTest primary failure.";
- final String message = ExceptionHelper.packException( error, e,
true );
- throw new Exception( message );
- }
-
- releaseTestService( test );
- }
-}
+/*
+ * 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.activation.impl.test;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.provider.CompositionHelper;
+import net.dpml.composition.test.CompositionTestCase;
+import net.dpml.exception.ExceptionHelper;
+import net.dpml.test.components.TestService;
+
+/**
+ * CompositionFactoryTestCase
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class CodeSecurityDisabledTestCase extends CompositionTestCase
+{
+ //------------------------------------------------------------------
+ // static
+ //------------------------------------------------------------------
+
+ private static final String ACTIVATION_RUNTIME =
"@ACTIVATION-RUNTIME-IMPL-SPEC@";
+
+ //------------------------------------------------------------------
+ // state
+ //------------------------------------------------------------------
+
+ private ContainmentModel m_model;
+ DeploymentModel m_test;
+
+ //------------------------------------------------------------------
+ // TestCase
+ //------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ File kernel = new File( WORK, "kernel.xml" );
+
+ Map map = new HashMap();
+ map.put( "dpml.composition.runtime", ACTIVATION_RUNTIME );
+ map.put( "dpml.composition.kernel", kernel.getAbsolutePath() );
+ m_model = createCompositionRoot( map );
+ m_test = m_model.getModel( "/Component1/test" );
+ m_model.commission();
+ }
+
+ public void tearDown()
+ {
+ m_model.decommission();
+ }
+
+ private TestService getTestService() throws Exception
+ {
+ return (TestService) m_test.resolve();
+ }
+
+ private void releaseTestService( TestService service )
+ {
+ m_test.release( service );
+ }
+
+ //------------------------------------------------------------------
+ // tests
+ //------------------------------------------------------------------
+
+ /**
+ * Create, assembly, deploy and decommission the block
+ * defined by getPath().
+ */
+ public void testCodeSecurity() throws Exception
+ {
+ TestService test = getTestService();
+
+ assertNotNull( "test", test );
+
+ try
+ {
+ System.out.println( CompositionHelper.toString( m_model ) );
+ test.createDirectory();
+ }
+ catch( Throwable e )
+ {
+ releaseTestService( test );
+ final String error = "CodeSecurityTest primary failure.";
+ final String message = ExceptionHelper.packException( error, e,
true );
+ throw new Exception( message );
+ }
+
+ try
+ {
+ test.deleteDirectory();
+ }
+ catch( Throwable e )
+ {
+ releaseTestService( test );
+ final String error = "CodeSecurityTest secondary failure.";
+ final String message = ExceptionHelper.packException( error, e,
true );
+ throw new Exception( message );
+ }
+
+ try
+ {
+ String ver = test.getJavaVersion();
+ }
+ catch( Throwable e )
+ {
+ releaseTestService( test );
+ final String error = "CodeSecurityTest secondary failure.";
+ final String message = ExceptionHelper.packException( error, e,
true );
+ throw new Exception( message );
+ }
+
+ try
+ {
+ test.setJavaVersion( "1.0.2" );
+ }
+ catch( Throwable e )
+ {
+ releaseTestService( test );
+ final String error = "CodeSecurityTest primary failure.";
+ final String message = ExceptionHelper.packException( error, e,
true );
+ throw new Exception( message );
+ }
+
+ releaseTestService( test );
+ }
+}

Modified:
development/main/metro/activation/test/src/test/net/dpml/activation/impl/test/CodeSecurityEnabledTestCase.java
==============================================================================
---
development/main/metro/activation/test/src/test/net/dpml/activation/impl/test/CodeSecurityEnabledTestCase.java
(original)
+++
development/main/metro/activation/test/src/test/net/dpml/activation/impl/test/CodeSecurityEnabledTestCase.java
Fri Dec 24 22:19:23 2004
@@ -1,199 +1,199 @@
-/*
- * 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.activation.impl.test;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import net.dpml.composition.model.ContainmentModel;
-import net.dpml.composition.model.DeploymentModel;
-import net.dpml.composition.test.CompositionTestCase;
-import net.dpml.exception.ExceptionHelper;
-import net.dpml.test.components.TestService;
-
-
-/**
- * CompositionFactoryTestCase
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class CodeSecurityEnabledTestCase extends CompositionTestCase
-{
- //------------------------------------------------------------------
- // static
- //------------------------------------------------------------------
-
- private static final String ACTIVATION_RUNTIME =
"@ACTIVATION-RUNTIME-IMPL-SPEC@";
-
- //------------------------------------------------------------------
- // state
- //------------------------------------------------------------------
-
- private ContainmentModel m_model;
- private DeploymentModel m_test;
-
- //------------------------------------------------------------------
- // constructor
- //------------------------------------------------------------------
-
- public CodeSecurityEnabledTestCase()
- {
- super();
- }
-
- //------------------------------------------------------------------
- // TestCase
- //------------------------------------------------------------------
-
- protected void setUp() throws Exception
- {
- File kernel = new File( WORK, "kernel.xml" );
-
- Map map = new HashMap();
- map.put( "dpml.composition.runtime", ACTIVATION_RUNTIME );
- map.put( "dpml.composition.secure", "true" );
- map.put( "dpml.composition.kernel", kernel.getAbsolutePath() );
- m_model = createCompositionRoot( map );
-
- try
- {
- m_model.assemble();
- m_model.commission();
- m_test = m_model.getModel( "/Component1/test" );
- }
- catch( Throwable e )
- {
- final String error = ExceptionHelper.packException( "Setup
error.", e, true );
- System.out.println( error );
- throw new Exception( error, e );
- }
- }
-
- public void tearDown()
- {
- m_model.decommission();
- }
-
- private TestService getTestService() throws Exception
- {
- try
- {
- return (TestService) m_test.resolve();
- }
- catch( Throwable e )
- {
- final String error = ExceptionHelper.packException( "TestService
resolution failure", e, true );
- System.out.println( error );
- throw new Exception( error, e );
- }
- }
-
- private void releaseTestService( TestService service )
- {
- m_test.release( service );
- }
-
- //------------------------------------------------------------------
- // tests
- //------------------------------------------------------------------
-
- /**
- * Create, assembly, deploy and decommission the block
- * defined by getPath().
- */
- public void testInterfaceMethods() throws Exception
- {
- TestService test = getTestService();
- try
- {
- test.createDirectory();
-
-// TODO::::
-// fail( "CodeSecurityTest primary failure: This operation should
not be allowed." );
- }
- catch( SecurityException e )
- {
- // ignore, expected
- }
- catch( Throwable e )
- {
- releaseTestService( test );
- final String error = "CodeSecurityTest primary failure.";
- final String message = ExceptionHelper.packException( error, e,
true );
- System.out.println( message );
- throw new Exception( message );
- }
-
- try
- {
- test.deleteDirectory();
-// TODO::::
-// fail( "CodeSecurityTest secondary failure: This operation
should not be allowed." );
- }
- catch( SecurityException e )
- {
- // ignore, expected
- }
- catch( Throwable e )
- {
- releaseTestService( test );
- final String error = "CodeSecurityTest primary failure.";
- final String message = ExceptionHelper.packException( error, e,
true );
- System.out.println( message );
- throw new Exception( message );
- }
-
- try
- {
- // This should succeed since there is a read permission for
- // system properties in the security policy.
-
- String ver = test.getJavaVersion();
- }
- catch( Throwable e )
- {
- releaseTestService( test );
- final String error = "CodeSecurityTest secondary failure.";
- final String message = ExceptionHelper.packException( error, e,
true );
- System.out.println( message );
- throw new Exception( message );
- }
-
- try
- {
- test.setJavaVersion( "1.0.2" );
- fail( "CodeSecurityTest failure: This operation should not be
allowed." );
- }
- catch( SecurityException e )
- {
- // ignore, expected
- }
- catch( Throwable e )
- {
- releaseTestService( test );
- final String error = "CodeSecurityTest primary failure.";
- final String message = ExceptionHelper.packException( error, e,
true );
- System.out.println( message );
- throw new Exception( message );
- }
-
- releaseTestService( test );
- }
-}
+/*
+ * 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.activation.impl.test;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.test.CompositionTestCase;
+import net.dpml.exception.ExceptionHelper;
+import net.dpml.test.components.TestService;
+
+
+/**
+ * CompositionFactoryTestCase
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class CodeSecurityEnabledTestCase extends CompositionTestCase
+{
+ //------------------------------------------------------------------
+ // static
+ //------------------------------------------------------------------
+
+ private static final String ACTIVATION_RUNTIME =
"@ACTIVATION-RUNTIME-IMPL-SPEC@";
+
+ //------------------------------------------------------------------
+ // state
+ //------------------------------------------------------------------
+
+ private ContainmentModel m_model;
+ private DeploymentModel m_test;
+
+ //------------------------------------------------------------------
+ // constructor
+ //------------------------------------------------------------------
+
+ public CodeSecurityEnabledTestCase()
+ {
+ super();
+ }
+
+ //------------------------------------------------------------------
+ // TestCase
+ //------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ File kernel = new File( WORK, "kernel.xml" );
+
+ Map map = new HashMap();
+ map.put( "dpml.composition.runtime", ACTIVATION_RUNTIME );
+ map.put( "dpml.composition.secure", "true" );
+ map.put( "dpml.composition.kernel", kernel.getAbsolutePath() );
+ m_model = createCompositionRoot( map );
+
+ try
+ {
+ m_model.assemble();
+ m_model.commission();
+ m_test = m_model.getModel( "/Component1/test" );
+ }
+ catch( Throwable e )
+ {
+ final String error = ExceptionHelper.packException( "Setup
error.", e, true );
+ System.out.println( error );
+ throw new Exception( error, e );
+ }
+ }
+
+ public void tearDown()
+ {
+ m_model.decommission();
+ }
+
+ private TestService getTestService() throws Exception
+ {
+ try
+ {
+ return (TestService) m_test.resolve();
+ }
+ catch( Throwable e )
+ {
+ final String error = ExceptionHelper.packException( "TestService
resolution failure", e, true );
+ System.out.println( error );
+ throw new Exception( error, e );
+ }
+ }
+
+ private void releaseTestService( TestService service )
+ {
+ m_test.release( service );
+ }
+
+ //------------------------------------------------------------------
+ // tests
+ //------------------------------------------------------------------
+
+ /**
+ * Create, assembly, deploy and decommission the block
+ * defined by getPath().
+ */
+ public void testInterfaceMethods() throws Exception
+ {
+ TestService test = getTestService();
+ try
+ {
+ test.createDirectory();
+
+// TODO::::
+// fail( "CodeSecurityTest primary failure: This operation should
not be allowed." );
+ }
+ catch( SecurityException e )
+ {
+ // ignore, expected
+ }
+ catch( Throwable e )
+ {
+ releaseTestService( test );
+ final String error = "CodeSecurityTest primary failure.";
+ final String message = ExceptionHelper.packException( error, e,
true );
+ System.out.println( message );
+ throw new Exception( message );
+ }
+
+ try
+ {
+ test.deleteDirectory();
+// TODO::::
+// fail( "CodeSecurityTest secondary failure: This operation
should not be allowed." );
+ }
+ catch( SecurityException e )
+ {
+ // ignore, expected
+ }
+ catch( Throwable e )
+ {
+ releaseTestService( test );
+ final String error = "CodeSecurityTest primary failure.";
+ final String message = ExceptionHelper.packException( error, e,
true );
+ System.out.println( message );
+ throw new Exception( message );
+ }
+
+ try
+ {
+ // This should succeed since there is a read permission for
+ // system properties in the security policy.
+
+ String ver = test.getJavaVersion();
+ }
+ catch( Throwable e )
+ {
+ releaseTestService( test );
+ final String error = "CodeSecurityTest secondary failure.";
+ final String message = ExceptionHelper.packException( error, e,
true );
+ System.out.println( message );
+ throw new Exception( message );
+ }
+
+ try
+ {
+ test.setJavaVersion( "1.0.2" );
+ fail( "CodeSecurityTest failure: This operation should not be
allowed." );
+ }
+ catch( SecurityException e )
+ {
+ // ignore, expected
+ }
+ catch( Throwable e )
+ {
+ releaseTestService( test );
+ final String error = "CodeSecurityTest primary failure.";
+ final String message = ExceptionHelper.packException( error, e,
true );
+ System.out.println( message );
+ throw new Exception( message );
+ }
+
+ releaseTestService( test );
+ }
+}

Modified:
development/main/metro/activation/test/src/test/net/dpml/activation/impl/test/PlaygroundTestCase.java
==============================================================================
---
development/main/metro/activation/test/src/test/net/dpml/activation/impl/test/PlaygroundTestCase.java
(original)
+++
development/main/metro/activation/test/src/test/net/dpml/activation/impl/test/PlaygroundTestCase.java
Fri Dec 24 22:19:23 2004
@@ -1,80 +1,80 @@
-/*
- * 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.activation.impl.test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import net.dpml.composition.model.ContainmentModel;
-import net.dpml.composition.test.CompositionTestCase;
-import net.dpml.exception.ExceptionHelper;
-
-/**
- * CompositionFactoryTestCase
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class PlaygroundTestCase extends CompositionTestCase
-{
- //------------------------------------------------------------------
- // static
- //------------------------------------------------------------------
-
- private static final String PATH = "playground.xml";
- private static final String ACTIVATION_RUNTIME =
"@ACTIVATION-RUNTIME-IMPL-SPEC@";
-
- //------------------------------------------------------------------
- // state
- //------------------------------------------------------------------
-
- private ContainmentModel m_model;
-
- //------------------------------------------------------------------
- // TestCase
- //------------------------------------------------------------------
-
- protected void setUp() throws Exception
- {
- Map map = new HashMap();
- map.put( "dpml.composition.runtime", ACTIVATION_RUNTIME );
- ContainmentModel root = createCompositionRoot( map );
- m_model = createContainmentModel( root, PATH );
- }
-
- //------------------------------------------------------------------
- // tests
- //------------------------------------------------------------------
-
- public void testSomething() throws Exception
- {
- try
- {
- m_model.assemble();
- m_model.commission();
- m_model.decommission();
- m_model.disassemble();
- }
- catch( Throwable e )
- {
- String error = ExceptionHelper.packException( "test failure", e,
true );
- System.err.println( error );
- throw new Exception( error );
- }
- }
-}
+/*
+ * 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.activation.impl.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.test.CompositionTestCase;
+import net.dpml.exception.ExceptionHelper;
+
+/**
+ * CompositionFactoryTestCase
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class PlaygroundTestCase extends CompositionTestCase
+{
+ //------------------------------------------------------------------
+ // static
+ //------------------------------------------------------------------
+
+ private static final String PATH = "playground.xml";
+ private static final String ACTIVATION_RUNTIME =
"@ACTIVATION-RUNTIME-IMPL-SPEC@";
+
+ //------------------------------------------------------------------
+ // state
+ //------------------------------------------------------------------
+
+ private ContainmentModel m_model;
+
+ //------------------------------------------------------------------
+ // TestCase
+ //------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ Map map = new HashMap();
+ map.put( "dpml.composition.runtime", ACTIVATION_RUNTIME );
+ ContainmentModel root = createCompositionRoot( map );
+ m_model = createContainmentModel( root, PATH );
+ }
+
+ //------------------------------------------------------------------
+ // tests
+ //------------------------------------------------------------------
+
+ public void testSomething() throws Exception
+ {
+ try
+ {
+ m_model.assemble();
+ m_model.commission();
+ m_model.decommission();
+ m_model.disassemble();
+ }
+ catch( Throwable e )
+ {
+ String error = ExceptionHelper.packException( "test failure", e,
true );
+ System.err.println( error );
+ throw new Exception( error );
+ }
+ }
+}

Modified: development/main/metro/build.xml
==============================================================================
--- development/main/metro/build.xml (original)
+++ development/main/metro/build.xml Fri Dec 24 22:19:23 2004
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-runtime" default="default" basedir="."
- xmlns:magic="antlib:net.dpml.magic">
-
- <magic:import uri="artifact:template:dpml/magic/reactor"/>
-
-</project>
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-runtime" default="default" basedir="."
+ xmlns:magic="antlib:net.dpml.magic">
+
+ <magic:import uri="artifact:template:dpml/magic/reactor"/>
+
+</project>

Modified: development/main/metro/composition/impl/etc/main/kernel.xml
==============================================================================
--- development/main/metro/composition/impl/etc/main/kernel.xml (original)
+++ development/main/metro/composition/impl/etc/main/kernel.xml Fri Dec 24
22:19:23 2004
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<kernel>
-
- <container/>
-
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<kernel>
+
+ <container/>
+
</kernel>
\ No newline at end of file

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionController.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionController.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionController.java
Fri Dec 24 22:19:23 2004
@@ -1,391 +1,391 @@
-/*
- * 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.composition.model.impl;
-
-import net.dpml.activity.Disposable;
-import net.dpml.activity.Startable;
-
-import net.dpml.composition.model.ContainmentModel;
-import net.dpml.composition.model.ModelException;
-import net.dpml.composition.provider.SecurityModel ;
-import net.dpml.composition.provider.ContainmentContext;
-import net.dpml.composition.provider.CompositionException;
-import net.dpml.composition.provider.CompositionRuntimeException;
-import net.dpml.composition.provider.CompositionContext;
-import net.dpml.composition.provider.CompositionHelper;
-
-import net.dpml.i18n.ResourceManager;
-import net.dpml.i18n.Resources;
-
-/**
- * Containment model implmentation within which composite models are
aggregated
- * as a part of a containment deployment model.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class DefaultCompositionController extends DefaultContainmentModel
- implements Startable
-{
- //--------------------------------------------------------------
- // static
- //--------------------------------------------------------------
-
- private static final Resources REZ =
- ResourceManager.getPackageResources(
DefaultCompositionController.class );
-
- static private final String[] STATE_NAMES =
- {
- "state: initializing",
- "state: initialized",
- "state: starting",
- "state: assembly",
- "state: deployment",
- "state: started",
- "state: stopping",
- "state: decommissioning",
- "state: dissassembly",
- "state: stopped"
- };
-
- static final int INITIALIZING = 0;
- static final int INITIALIZED = 1;
- static final int STARTING = 2;
- static final int ASSEMBLY = 3;
- static final int DEPLOYMENT = 4;
- static final int STARTED = 5;
- static final int STOPPING = 6;
- static final int DECOMMISSIONING = 7;
- static final int DISSASSEMBLY = 8;
- static final int STOPPED = 9;
-
- //--------------------------------------------------------------
- // immutable state
- //--------------------------------------------------------------
-
- private final State m_state;
- private CompositionContext m_composition;
-
- //--------------------------------------------------------------
- // constructor
- //--------------------------------------------------------------
-
- public DefaultCompositionController(
- final CompositionContext composition, final ContainmentContext
context, final SecurityModel security )
- throws ModelException
- {
- super( context, security );
-
- m_composition = composition;
- m_state = new State( this );
-
- if( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "controller established" );
- }
-
- setState( INITIALIZED );
- }
-
- //--------------------------------------------------------------
- // Startable
- //--------------------------------------------------------------
-
- /**
- * Start the model.
- * @exception if a startup failure occurs
- */
- public void start() throws Exception
- {
- //
- // instantiate the runtime root application block
- //
-
- synchronized( m_state )
- {
- if( !isStartable() ) return;
- if( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "initiating assembly" );
- }
-
- try
- {
- setState( ASSEMBLY );
- super.assemble();
- if( m_composition.isAuditEnabled() )
- {
- String listing = CompositionHelper.toString( this );
- getLogger().info( listing );
- }
- }
- catch( Exception e )
- {
- setState( INITIALIZED );
- final String error =
- "Cannot assemble application due to exception.";
- throw new CompositionException( error, e );
- }
- catch( Throwable e )
- {
- setState( INITIALIZED );
- final String error =
- "Cannot assemble application due to throwable.";
- throw new CompositionRuntimeException( error, e );
- }
-
- if( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "application deployment" );
- }
-
- try
- {
- setState( DEPLOYMENT );
- super.commission();
- }
- catch( Exception e )
- {
- setState( INITIALIZED );
- final String error =
- "Cannot deploy application.";
- throw new CompositionException( error, e );
- }
- catch( Throwable e )
- {
- setState( INITIALIZED );
- final String error =
- "Cannot deploy application.";
- throw new CompositionRuntimeException( error, e );
- }
-
- setState( STARTED );
- }
- }
-
- /**
- * Stop the model.
- * @exception if a shutdown failure occurs
- */
- public void stop() throws Exception
- {
- synchronized( m_state )
- {
- if( !isStoppable() ) return;
-
- setState( STOPPING );
-
- try
- {
- setState( DECOMMISSIONING );
- super.decommission();
- }
- catch( Throwable e )
- {
- if( getLogger().isWarnEnabled() )
- {
- final String error =
- "Ignoring block decommissioning error.";
- getLogger().warn( error, e );
- }
- }
-
- setState( STOPPED );
- }
- }
-
- //------------------------------------------------------------------
- // internals
- //------------------------------------------------------------------
-
- private boolean isStartable()
- {
- synchronized( m_state )
- {
- int state = m_state.getState();
- if( state == INITIALIZED ) return true;
- if( state == STOPPED ) return true;
- return false;
- }
- }
-
- private boolean isStoppable()
- {
- synchronized( m_state )
- {
- int state = m_state.getState();
- if( state == STARTED ) return true;
- return false;
- }
- }
-
- /**
- * Set the state of the controller. The method also triggers the
- * emmission of a attribute change notification containing the
- * old and new state value.
- *
- * @param state a string representing the new controller state
- */
- private void setState( int state )
- {
- m_state.setState( state );
- }
-
- //private class State implements Runnable, Disposable
- private class State implements Disposable
- {
- private int m_state = INITIALIZING;
-
- //private LinkedList m_listeners = new LinkedList();
-
- //private final Controller m_controller;
-
- //private final SimpleFIFO m_events = new SimpleFIFO();
-
- //private Thread m_notification;
-
- State( ContainmentModel controller )
- {
- //m_controller = controller;
- //m_notification = new Thread( this );
- //m_notification.start();
- }
-
- //public void addCompositionEventListener( CompositionEventListener
listener )
- //{
- // synchronized( m_listeners )
- // {
- // m_listeners.add( listener );
- // }
- //}
-
- //public void removeCompositionEventListener(
CompositionEventListener listener )
- //{
- // synchronized( m_listeners )
- // {
- // m_listeners.remove( listener );
- // }
- //}
-
- public int getState()
- {
- return m_state;
- }
-
- public synchronized void setState( int state )
- {
- int oldValue = m_state;
- int newValue = state;
-
- m_state = newValue;
-
- if( getLogger().isDebugEnabled() )
- {
- getLogger().debug( this.toString() );
- }
-
- //CompositionStateEvent event =
- // new CompositionStateEvent( m_controller, oldValue, newValue
);
- //m_events.put( event );
- }
-
- //public void run()
- //{
- // try
- // {
- // while( true )
- // {
- // CompositionStateEvent event = (CompositionStateEvent)
m_events.get();
- // fireStateChangedEvent( event );
- // }
- // }
- // catch( InterruptedException e )
- // {
- // // trigger by disposal
- // }
- // m_notification = null;
- //}
-
- //private void fireStateChangedEvent( final CompositionStateEvent
event )
- //{
- // Iterator iterator = m_listeners.iterator();
- // while( iterator.hasNext() )
- // {
- // final CompositionEventListener listener =
- // (CompositionEventListener) iterator.next();
- // try
- // {
- // listener.stateChanged( event );
- // }
- // catch( Throwable e )
- // {
- // final String error =
- // "Controller listener raised an exception.";
- // getLogger().warn( error, e );
- // }
- // }
- //}
-
- public void dispose()
- {
- //if( null != m_notification )
- //{
- // m_notification.interrupt();
- //}
- }
-
- public String toString()
- {
- int s = m_state;
- if( s < STATE_NAMES.length )
- {
- return STATE_NAMES[ s ];
- }
- else
- {
- return "state: " + s;
- }
- }
- }
-
- public void dispose()
- {
- if( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "disposal" );
- }
-
- try
- {
- stop();
- }
- catch( Throwable e )
- {
- if( getLogger().isWarnEnabled() )
- {
- final String error =
- "Ignoring controller shutdown error.";
- getLogger().warn( error, e );
- }
- }
- m_state.dispose();
- }
-
-
-}
+/*
+ * 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.composition.model.impl;
+
+import net.dpml.activity.Disposable;
+import net.dpml.activity.Startable;
+
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.model.ModelException;
+import net.dpml.composition.provider.SecurityModel ;
+import net.dpml.composition.provider.ContainmentContext;
+import net.dpml.composition.provider.CompositionException;
+import net.dpml.composition.provider.CompositionRuntimeException;
+import net.dpml.composition.provider.CompositionContext;
+import net.dpml.composition.provider.CompositionHelper;
+
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+
+/**
+ * Containment model implmentation within which composite models are
aggregated
+ * as a part of a containment deployment model.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class DefaultCompositionController extends DefaultContainmentModel
+ implements Startable
+{
+ //--------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------
+
+ private static final Resources REZ =
+ ResourceManager.getPackageResources(
DefaultCompositionController.class );
+
+ static private final String[] STATE_NAMES =
+ {
+ "state: initializing",
+ "state: initialized",
+ "state: starting",
+ "state: assembly",
+ "state: deployment",
+ "state: started",
+ "state: stopping",
+ "state: decommissioning",
+ "state: dissassembly",
+ "state: stopped"
+ };
+
+ static final int INITIALIZING = 0;
+ static final int INITIALIZED = 1;
+ static final int STARTING = 2;
+ static final int ASSEMBLY = 3;
+ static final int DEPLOYMENT = 4;
+ static final int STARTED = 5;
+ static final int STOPPING = 6;
+ static final int DECOMMISSIONING = 7;
+ static final int DISSASSEMBLY = 8;
+ static final int STOPPED = 9;
+
+ //--------------------------------------------------------------
+ // immutable state
+ //--------------------------------------------------------------
+
+ private final State m_state;
+ private CompositionContext m_composition;
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ public DefaultCompositionController(
+ final CompositionContext composition, final ContainmentContext
context, final SecurityModel security )
+ throws ModelException
+ {
+ super( context, security );
+
+ m_composition = composition;
+ m_state = new State( this );
+
+ if( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( "controller established" );
+ }
+
+ setState( INITIALIZED );
+ }
+
+ //--------------------------------------------------------------
+ // Startable
+ //--------------------------------------------------------------
+
+ /**
+ * Start the model.
+ * @exception if a startup failure occurs
+ */
+ public void start() throws Exception
+ {
+ //
+ // instantiate the runtime root application block
+ //
+
+ synchronized( m_state )
+ {
+ if( !isStartable() ) return;
+ if( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( "initiating assembly" );
+ }
+
+ try
+ {
+ setState( ASSEMBLY );
+ super.assemble();
+ if( m_composition.isAuditEnabled() )
+ {
+ String listing = CompositionHelper.toString( this );
+ getLogger().info( listing );
+ }
+ }
+ catch( Exception e )
+ {
+ setState( INITIALIZED );
+ final String error =
+ "Cannot assemble application due to exception.";
+ throw new CompositionException( error, e );
+ }
+ catch( Throwable e )
+ {
+ setState( INITIALIZED );
+ final String error =
+ "Cannot assemble application due to throwable.";
+ throw new CompositionRuntimeException( error, e );
+ }
+
+ if( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( "application deployment" );
+ }
+
+ try
+ {
+ setState( DEPLOYMENT );
+ super.commission();
+ }
+ catch( Exception e )
+ {
+ setState( INITIALIZED );
+ final String error =
+ "Cannot deploy application.";
+ throw new CompositionException( error, e );
+ }
+ catch( Throwable e )
+ {
+ setState( INITIALIZED );
+ final String error =
+ "Cannot deploy application.";
+ throw new CompositionRuntimeException( error, e );
+ }
+
+ setState( STARTED );
+ }
+ }
+
+ /**
+ * Stop the model.
+ * @exception if a shutdown failure occurs
+ */
+ public void stop() throws Exception
+ {
+ synchronized( m_state )
+ {
+ if( !isStoppable() ) return;
+
+ setState( STOPPING );
+
+ try
+ {
+ setState( DECOMMISSIONING );
+ super.decommission();
+ }
+ catch( Throwable e )
+ {
+ if( getLogger().isWarnEnabled() )
+ {
+ final String error =
+ "Ignoring block decommissioning error.";
+ getLogger().warn( error, e );
+ }
+ }
+
+ setState( STOPPED );
+ }
+ }
+
+ //------------------------------------------------------------------
+ // internals
+ //------------------------------------------------------------------
+
+ private boolean isStartable()
+ {
+ synchronized( m_state )
+ {
+ int state = m_state.getState();
+ if( state == INITIALIZED ) return true;
+ if( state == STOPPED ) return true;
+ return false;
+ }
+ }
+
+ private boolean isStoppable()
+ {
+ synchronized( m_state )
+ {
+ int state = m_state.getState();
+ if( state == STARTED ) return true;
+ return false;
+ }
+ }
+
+ /**
+ * Set the state of the controller. The method also triggers the
+ * emmission of a attribute change notification containing the
+ * old and new state value.
+ *
+ * @param state a string representing the new controller state
+ */
+ private void setState( int state )
+ {
+ m_state.setState( state );
+ }
+
+ //private class State implements Runnable, Disposable
+ private class State implements Disposable
+ {
+ private int m_state = INITIALIZING;
+
+ //private LinkedList m_listeners = new LinkedList();
+
+ //private final Controller m_controller;
+
+ //private final SimpleFIFO m_events = new SimpleFIFO();
+
+ //private Thread m_notification;
+
+ State( ContainmentModel controller )
+ {
+ //m_controller = controller;
+ //m_notification = new Thread( this );
+ //m_notification.start();
+ }
+
+ //public void addCompositionEventListener( CompositionEventListener
listener )
+ //{
+ // synchronized( m_listeners )
+ // {
+ // m_listeners.add( listener );
+ // }
+ //}
+
+ //public void removeCompositionEventListener(
CompositionEventListener listener )
+ //{
+ // synchronized( m_listeners )
+ // {
+ // m_listeners.remove( listener );
+ // }
+ //}
+
+ public int getState()
+ {
+ return m_state;
+ }
+
+ public synchronized void setState( int state )
+ {
+ int oldValue = m_state;
+ int newValue = state;
+
+ m_state = newValue;
+
+ if( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( this.toString() );
+ }
+
+ //CompositionStateEvent event =
+ // new CompositionStateEvent( m_controller, oldValue, newValue
);
+ //m_events.put( event );
+ }
+
+ //public void run()
+ //{
+ // try
+ // {
+ // while( true )
+ // {
+ // CompositionStateEvent event = (CompositionStateEvent)
m_events.get();
+ // fireStateChangedEvent( event );
+ // }
+ // }
+ // catch( InterruptedException e )
+ // {
+ // // trigger by disposal
+ // }
+ // m_notification = null;
+ //}
+
+ //private void fireStateChangedEvent( final CompositionStateEvent
event )
+ //{
+ // Iterator iterator = m_listeners.iterator();
+ // while( iterator.hasNext() )
+ // {
+ // final CompositionEventListener listener =
+ // (CompositionEventListener) iterator.next();
+ // try
+ // {
+ // listener.stateChanged( event );
+ // }
+ // catch( Throwable e )
+ // {
+ // final String error =
+ // "Controller listener raised an exception.";
+ // getLogger().warn( error, e );
+ // }
+ // }
+ //}
+
+ public void dispose()
+ {
+ //if( null != m_notification )
+ //{
+ // m_notification.interrupt();
+ //}
+ }
+
+ public String toString()
+ {
+ int s = m_state;
+ if( s < STATE_NAMES.length )
+ {
+ return STATE_NAMES[ s ];
+ }
+ else
+ {
+ return "state: " + s;
+ }
+ }
+ }
+
+ public void dispose()
+ {
+ if( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( "disposal" );
+ }
+
+ try
+ {
+ stop();
+ }
+ catch( Throwable e )
+ {
+ if( getLogger().isWarnEnabled() )
+ {
+ final String error =
+ "Ignoring controller shutdown error.";
+ getLogger().warn( error, e );
+ }
+ }
+ m_state.dispose();
+ }
+
+
+}

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionCriteria.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionCriteria.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultCompositionCriteria.java
Fri Dec 24 22:19:23 2004
@@ -1,390 +1,390 @@
-/*
- * 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.composition.model.impl;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Properties;
-
-import net.dpml.composition.provider.CompositionCriteria;
-import net.dpml.composition.provider.CompositionRuntimeException;
-import net.dpml.criteria.Criteria;
-import net.dpml.criteria.PackedParameter;
-import net.dpml.criteria.Parameter;
-import net.dpml.system.SystemContext;
-import net.dpml.transit.artifact.Handler;
-
-/**
- * The criteria class provides support for the registration of parameters
- * for supply to a composition context factory.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-class DefaultCompositionCriteria extends Criteria implements
CompositionCriteria
-{
- //--------------------------------------------------------------
- // static
- //--------------------------------------------------------------
-
- private static Parameter[] buildParameters( SystemContext context )
- {
- Properties properties = context.getProperties();
- return new Parameter[] {
- new Parameter(
- SECURITY_ENABLED_KEY,
- Boolean.class,
- getBooleanDefault( properties, SECURITY_ENABLED_KEY, false ) ),
- new Parameter(
- AUDIT_ENABLED_KEY,
- Boolean.class,
- getBooleanDefault( properties, AUDIT_ENABLED_KEY, false ) ),
- new Parameter(
- RUNTIME_ARTIFACT_KEY,
- String.class,
- properties.getProperty( RUNTIME_ARTIFACT_KEY ) ),
- new Parameter(
- DEPLOYMENT_TIMEOUT_KEY,
- Long.class,
- properties.getProperty( DEPLOYMENT_TIMEOUT_KEY) ),
- new Parameter(
- KERNEL_KEY,
- String.class,
- properties.getProperty( KERNEL_KEY ) ),
- new Parameter(
- OVERRIDE_KEY,
- String.class,
- properties.getProperty( OVERRIDE_KEY ) ),
- new PackedParameter(
- DEPLOYMENT_KEY, ",",
- getDefaultDeployment( properties.getProperty( OVERRIDE_KEY ) )
)
- };
- }
-
- private static Boolean getBooleanDefault( Properties properties, String
key, boolean fallback )
- {
- String value = properties.getProperty( key );
- if( null != value )
- {
- return new Boolean( value );
- }
- else
- {
- return new Boolean( fallback );
- }
- }
-
- private static String[] getDefaultDeployment( String value )
- {
- String[] result = PackedParameter.convert( value, "," );
- if( null == result )
- {
- return new String[0];
- }
- else
- {
- return result;
- }
- }
-
- //--------------------------------------------------------------
- // constructor
- //--------------------------------------------------------------
-
- DefaultCompositionCriteria( SystemContext system )
- {
- super( buildParameters( system ) );
- }
-
- //--------------------------------------------------------------
- // criteria setters
- //--------------------------------------------------------------
-
- /**
- * Set the security enabled policy
- * @param mode TRUE to enabled security mode else FALSE
- */
- public void setSecurityMode( boolean mode )
- {
- put( SECURITY_ENABLED_KEY, new Boolean( mode ) );
- }
-
- /**
- * Set the audit enabled policy
- * @param mode TRUE to enabled audit mode else FALSE
- */
- public void setAuditMode( boolean mode )
- {
- put( AUDIT_ENABLED_KEY, new Boolean( mode ) );
- }
-
- /**
- * Set the runtime artifact specification.
- * @param spec and artifact uri referencing an plugin runtime factory
- */
- public void setRuntimeSpecification( String spec )
- {
- put( RUNTIME_ARTIFACT_KEY, spec );
- }
-
- /**
- * Set the default deployment timeout value.
- * @param timeout and default deployment timeout
- */
- public void setDefaultDeploymentTimeout( long timeout )
- {
- put( DEPLOYMENT_TIMEOUT_KEY, new Long( timeout ) );
- }
-
- /**
- * Set the path to the root kernel container directive.
- * @param path the kernel container directive path
- */
- public void setKernelPath( String path )
- {
- put( KERNEL_KEY, path );
- }
-
- /**
- * Set the path to the deployment override configuration.
- * @param path the override path
- */
- public void setOverridePath( String path )
- {
- put( OVERRIDE_KEY, path );
- }
-
- /**
- * Set the set of paths to the deployment targets.
- * @param values an array of paths referencing deployment targets
- */
- public void setDeploymentPath( String[] values )
- {
- put( DEPLOYMENT_KEY, values );
- }
-
- //--------------------------------------------------------------
- // criteria getters
- //--------------------------------------------------------------
-
- /**
- * Get the security enabled policy
- * @return TRUE if security is enabled else FALSE
- */
- public Boolean getSecurityMode()
- {
- return (Boolean) get( SECURITY_ENABLED_KEY );
- }
-
- /**
- * Get the audit enabled policy
- * @return TRUE if audit is enabled else FALSE
- */
- public Boolean getAuditMode()
- {
- return (Boolean) get( AUDIT_ENABLED_KEY );
- }
-
- /**
- * Get the runtime artifact specification.
- * @return the artifact referencing a runtime factory plugin
- */
- public String getRuntimeSpecification()
- {
- return (String) get( RUNTIME_ARTIFACT_KEY );
- }
-
- /**
- * Get the default deployment timeout value.
- * @return the default deployment timeout
- */
- public Long getDefaultDeploymentTimeout()
- {
- return (Long) get( DEPLOYMENT_TIMEOUT_KEY );
- }
-
- /**
- * Get the root container directive url
- * @return the url to the root container
- */
- public String getKernelPath()
- {
- return (String) get( KERNEL_KEY );
- }
-
- /**
- * Get the deployment override path
- * @return the path to the override configuration
- */
- public String getOverridePath()
- {
- return (String) get( OVERRIDE_KEY );
- }
-
- /**
- * Return the sequence of deployment urls
- * @return the block urls
- */
- public URL[] getDeploymentURLs( File base )
- {
- String[] blocks = getDeploymentPaths();
-
- ArrayList list = new ArrayList();
- for( int i=0; i<blocks.length; i++ )
- {
- String path = blocks[i];
- try
- {
- if( path.length() > 0 )
- {
- URL url = resolveURL( base, path );
- list.add( url );
- }
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to transform the token: ["
- + path
- + "] due to an unexpected error.";
- throw new CompositionRuntimeException( error, e );
- }
- }
- return (URL[]) list.toArray( new URL[0] );
- }
-
- /**
- * Get the deployment sequence.
- * @return a sequence of deployment targets
- */
- private String[] getDeploymentPaths()
- {
- return (String[]) get( DEPLOYMENT_KEY );
- }
-
-
- private URL resolveURL( File base, String value )
- {
- if( null == base )
- {
- throw new NullPointerException( "base" );
- }
- if( value.startsWith( "block:" ) )
- {
- return resolveURL( base, "artifact:" + value );
- }
- else if( value.startsWith( "artifact:" ) )
- {
- return artifactSpecToURL( value );
- }
-
- try
- {
- return new URL( value );
- }
- catch( Exception e )
- {
- File target = new File( value );
- if( target.exists() )
- {
- return toURL( target );
- }
- else
- {
- target = new File( base, value );
- if( target.exists() )
- {
- return toURL( target );
- }
- else
- {
- if( e instanceof MalformedURLException )
- {
- FileNotFoundException fnfe = new
FileNotFoundException( value );
- final String error =
- "Unable to resolve the block path [" + value +
"].";
- throw new CompositionRuntimeException( error, fnfe );
- }
- else
- {
- final String error =
- "Unable to resolve the block path [" + value +
"].";
- throw new CompositionRuntimeException( error, e );
- }
- }
- }
- }
- }
-
- private URL toURL( File file )
- {
- if( null == file ) throw new NullPointerException( "file" );
- try
- {
- return file.getCanonicalFile().toURL();
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to transform the file ["
- + file.toString()
- + "] to a URL.";
- throw new CompositionRuntimeException( error, e );
- }
- }
-
- private URL artifactSpecToURL( String spec )
- {
- if( null == spec ) throw new NullPointerException( "spec" );
- try
- {
- return new URL( null, spec, new Handler() );
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to transform the artifact specification ["
- + spec
- + "] to a URL.";
- throw new CompositionRuntimeException( error, e );
- }
- }
-/* Never used. TODO Remove.
- private URL toURL( String spec )
- {
- if( null == spec ) throw new NullPointerException( "spec" );
-
- try
- {
- return new URL( spec );
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to construct url from spec ["
- + spec
- + "].";
- throw new CompositionRuntimeException( error, e );
- }
- }
-*/
-}
+/*
+ * 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.composition.model.impl;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Properties;
+
+import net.dpml.composition.provider.CompositionCriteria;
+import net.dpml.composition.provider.CompositionRuntimeException;
+import net.dpml.criteria.Criteria;
+import net.dpml.criteria.PackedParameter;
+import net.dpml.criteria.Parameter;
+import net.dpml.system.SystemContext;
+import net.dpml.transit.artifact.Handler;
+
+/**
+ * The criteria class provides support for the registration of parameters
+ * for supply to a composition context factory.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+class DefaultCompositionCriteria extends Criteria implements
CompositionCriteria
+{
+ //--------------------------------------------------------------
+ // static
+ //--------------------------------------------------------------
+
+ private static Parameter[] buildParameters( SystemContext context )
+ {
+ Properties properties = context.getProperties();
+ return new Parameter[] {
+ new Parameter(
+ SECURITY_ENABLED_KEY,
+ Boolean.class,
+ getBooleanDefault( properties, SECURITY_ENABLED_KEY, false ) ),
+ new Parameter(
+ AUDIT_ENABLED_KEY,
+ Boolean.class,
+ getBooleanDefault( properties, AUDIT_ENABLED_KEY, false ) ),
+ new Parameter(
+ RUNTIME_ARTIFACT_KEY,
+ String.class,
+ properties.getProperty( RUNTIME_ARTIFACT_KEY ) ),
+ new Parameter(
+ DEPLOYMENT_TIMEOUT_KEY,
+ Long.class,
+ properties.getProperty( DEPLOYMENT_TIMEOUT_KEY) ),
+ new Parameter(
+ KERNEL_KEY,
+ String.class,
+ properties.getProperty( KERNEL_KEY ) ),
+ new Parameter(
+ OVERRIDE_KEY,
+ String.class,
+ properties.getProperty( OVERRIDE_KEY ) ),
+ new PackedParameter(
+ DEPLOYMENT_KEY, ",",
+ getDefaultDeployment( properties.getProperty( OVERRIDE_KEY ) )
)
+ };
+ }
+
+ private static Boolean getBooleanDefault( Properties properties, String
key, boolean fallback )
+ {
+ String value = properties.getProperty( key );
+ if( null != value )
+ {
+ return new Boolean( value );
+ }
+ else
+ {
+ return new Boolean( fallback );
+ }
+ }
+
+ private static String[] getDefaultDeployment( String value )
+ {
+ String[] result = PackedParameter.convert( value, "," );
+ if( null == result )
+ {
+ return new String[0];
+ }
+ else
+ {
+ return result;
+ }
+ }
+
+ //--------------------------------------------------------------
+ // constructor
+ //--------------------------------------------------------------
+
+ DefaultCompositionCriteria( SystemContext system )
+ {
+ super( buildParameters( system ) );
+ }
+
+ //--------------------------------------------------------------
+ // criteria setters
+ //--------------------------------------------------------------
+
+ /**
+ * Set the security enabled policy
+ * @param mode TRUE to enabled security mode else FALSE
+ */
+ public void setSecurityMode( boolean mode )
+ {
+ put( SECURITY_ENABLED_KEY, new Boolean( mode ) );
+ }
+
+ /**
+ * Set the audit enabled policy
+ * @param mode TRUE to enabled audit mode else FALSE
+ */
+ public void setAuditMode( boolean mode )
+ {
+ put( AUDIT_ENABLED_KEY, new Boolean( mode ) );
+ }
+
+ /**
+ * Set the runtime artifact specification.
+ * @param spec and artifact uri referencing an plugin runtime factory
+ */
+ public void setRuntimeSpecification( String spec )
+ {
+ put( RUNTIME_ARTIFACT_KEY, spec );
+ }
+
+ /**
+ * Set the default deployment timeout value.
+ * @param timeout and default deployment timeout
+ */
+ public void setDefaultDeploymentTimeout( long timeout )
+ {
+ put( DEPLOYMENT_TIMEOUT_KEY, new Long( timeout ) );
+ }
+
+ /**
+ * Set the path to the root kernel container directive.
+ * @param path the kernel container directive path
+ */
+ public void setKernelPath( String path )
+ {
+ put( KERNEL_KEY, path );
+ }
+
+ /**
+ * Set the path to the deployment override configuration.
+ * @param path the override path
+ */
+ public void setOverridePath( String path )
+ {
+ put( OVERRIDE_KEY, path );
+ }
+
+ /**
+ * Set the set of paths to the deployment targets.
+ * @param values an array of paths referencing deployment targets
+ */
+ public void setDeploymentPath( String[] values )
+ {
+ put( DEPLOYMENT_KEY, values );
+ }
+
+ //--------------------------------------------------------------
+ // criteria getters
+ //--------------------------------------------------------------
+
+ /**
+ * Get the security enabled policy
+ * @return TRUE if security is enabled else FALSE
+ */
+ public Boolean getSecurityMode()
+ {
+ return (Boolean) get( SECURITY_ENABLED_KEY );
+ }
+
+ /**
+ * Get the audit enabled policy
+ * @return TRUE if audit is enabled else FALSE
+ */
+ public Boolean getAuditMode()
+ {
+ return (Boolean) get( AUDIT_ENABLED_KEY );
+ }
+
+ /**
+ * Get the runtime artifact specification.
+ * @return the artifact referencing a runtime factory plugin
+ */
+ public String getRuntimeSpecification()
+ {
+ return (String) get( RUNTIME_ARTIFACT_KEY );
+ }
+
+ /**
+ * Get the default deployment timeout value.
+ * @return the default deployment timeout
+ */
+ public Long getDefaultDeploymentTimeout()
+ {
+ return (Long) get( DEPLOYMENT_TIMEOUT_KEY );
+ }
+
+ /**
+ * Get the root container directive url
+ * @return the url to the root container
+ */
+ public String getKernelPath()
+ {
+ return (String) get( KERNEL_KEY );
+ }
+
+ /**
+ * Get the deployment override path
+ * @return the path to the override configuration
+ */
+ public String getOverridePath()
+ {
+ return (String) get( OVERRIDE_KEY );
+ }
+
+ /**
+ * Return the sequence of deployment urls
+ * @return the block urls
+ */
+ public URL[] getDeploymentURLs( File base )
+ {
+ String[] blocks = getDeploymentPaths();
+
+ ArrayList list = new ArrayList();
+ for( int i=0; i<blocks.length; i++ )
+ {
+ String path = blocks[i];
+ try
+ {
+ if( path.length() > 0 )
+ {
+ URL url = resolveURL( base, path );
+ list.add( url );
+ }
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to transform the token: ["
+ + path
+ + "] due to an unexpected error.";
+ throw new CompositionRuntimeException( error, e );
+ }
+ }
+ return (URL[]) list.toArray( new URL[0] );
+ }
+
+ /**
+ * Get the deployment sequence.
+ * @return a sequence of deployment targets
+ */
+ private String[] getDeploymentPaths()
+ {
+ return (String[]) get( DEPLOYMENT_KEY );
+ }
+
+
+ private URL resolveURL( File base, String value )
+ {
+ if( null == base )
+ {
+ throw new NullPointerException( "base" );
+ }
+ if( value.startsWith( "block:" ) )
+ {
+ return resolveURL( base, "artifact:" + value );
+ }
+ else if( value.startsWith( "artifact:" ) )
+ {
+ return artifactSpecToURL( value );
+ }
+
+ try
+ {
+ return new URL( value );
+ }
+ catch( Exception e )
+ {
+ File target = new File( value );
+ if( target.exists() )
+ {
+ return toURL( target );
+ }
+ else
+ {
+ target = new File( base, value );
+ if( target.exists() )
+ {
+ return toURL( target );
+ }
+ else
+ {
+ if( e instanceof MalformedURLException )
+ {
+ FileNotFoundException fnfe = new
FileNotFoundException( value );
+ final String error =
+ "Unable to resolve the block path [" + value +
"].";
+ throw new CompositionRuntimeException( error, fnfe );
+ }
+ else
+ {
+ final String error =
+ "Unable to resolve the block path [" + value +
"].";
+ throw new CompositionRuntimeException( error, e );
+ }
+ }
+ }
+ }
+ }
+
+ private URL toURL( File file )
+ {
+ if( null == file ) throw new NullPointerException( "file" );
+ try
+ {
+ return file.getCanonicalFile().toURL();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to transform the file ["
+ + file.toString()
+ + "] to a URL.";
+ throw new CompositionRuntimeException( error, e );
+ }
+ }
+
+ private URL artifactSpecToURL( String spec )
+ {
+ if( null == spec ) throw new NullPointerException( "spec" );
+ try
+ {
+ return new URL( null, spec, new Handler() );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to transform the artifact specification ["
+ + spec
+ + "] to a URL.";
+ throw new CompositionRuntimeException( error, e );
+ }
+ }
+/* Never used. TODO Remove.
+ private URL toURL( String spec )
+ {
+ if( null == spec ) throw new NullPointerException( "spec" );
+
+ try
+ {
+ return new URL( spec );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to construct url from spec ["
+ + spec
+ + "].";
+ throw new CompositionRuntimeException( error, e );
+ }
+ }
+*/
+}

Modified:
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultState.java
==============================================================================
---
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultState.java
(original)
+++
development/main/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultState.java
Fri Dec 24 22:19:23 2004
@@ -1,62 +1,62 @@
-/*
- * 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.composition.model.impl;
-
-/**
- * The State class desribes a enabled versus disabled state.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id: DefaultState.java 187 2004-10-23 17:10:53Z niclas $
- */
-
-class DefaultState
-{
-
-
//---------------------------------------------------------------------------
- // state
-
//---------------------------------------------------------------------------
-
- private boolean m_enabled = false;
-
-
//---------------------------------------------------------------------------
- // State
-
//---------------------------------------------------------------------------
-
- /**
- * Return the enabled state of the state.
- * @return TRUE if the state has been enabled else FALSE
- */
- public boolean isEnabled()
- {
- return m_enabled;
- }
-
-
//---------------------------------------------------------------------------
- // implementation
-
//---------------------------------------------------------------------------
-
- /**
- * Set the enabled state of the state.
- * @param enabled the enabled state to assign
- */
- public void setEnabled( boolean enabled ) throws IllegalStateException
- {
- m_enabled = enabled;
- }
-}
+/*
+ * 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.composition.model.impl;
+
+/**
+ * The State class desribes a enabled versus disabled state.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: DefaultState.java 187 2004-10-23 17:10:53Z niclas $
+ */
+
+class DefaultState
+{
+
+
//---------------------------------------------------------------------------
+ // state
+
//---------------------------------------------------------------------------
+
+ private boolean m_enabled = false;
+
+
//---------------------------------------------------------------------------
+ // State
+
//---------------------------------------------------------------------------
+
+ /**
+ * Return the enabled state of the state.
+ * @return TRUE if the state has been enabled else FALSE
+ */
+ public boolean isEnabled()
+ {
+ return m_enabled;
+ }
+
+
//---------------------------------------------------------------------------
+ // implementation
+
//---------------------------------------------------------------------------
+
+ /**
+ * Set the enabled state of the state.
+ * @param enabled the enabled state to assign
+ */
+ public void setEnabled( boolean enabled ) throws IllegalStateException
+ {
+ m_enabled = enabled;
+ }
+}

Modified:
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionCriteria.java
==============================================================================
---
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionCriteria.java
(original)
+++
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionCriteria.java
Fri Dec 24 22:19:23 2004
@@ -1,181 +1,181 @@
-/*
- * 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.composition.provider;
-
-import java.io.File;
-import java.util.Map;
-import java.net.URL;
-
-import net.dpml.system.SystemContext;
-
-/**
- * CompositionCriteria is convinience interface that extends Map with
- * a set of operations that enable easy manipulation of the composition
- * context parameters.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public interface CompositionCriteria extends Map
-{
-
- //--------------------------------------------------------------
- // criteria keys
- //--------------------------------------------------------------
-
- /**
- * The security enabled policy key.
- */
- String GROUP = SystemContext.DOMAIN + ".composition";
-
- /**
- * The security enabled policy key.
- */
- String AUDIT_ENABLED_KEY = GROUP + ".audit";
-
- /**
- * The security enabled policy key.
- */
- String SECURITY_ENABLED_KEY = GROUP + ".secure";
-
- /**
- * The activation runtime artifact key.
- */
- String RUNTIME_ARTIFACT_KEY = GROUP + ".runtime";
-
- /**
- * The default deployment timeout key.
- */
- String DEPLOYMENT_TIMEOUT_KEY = GROUP + ".timeout";
-
- /**
- * The root container path key.
- */
- String KERNEL_KEY = GROUP + ".kernel";
-
- /**
- * The deployment blocks sequence.
- */
- String DEPLOYMENT_KEY = GROUP + ".deployment";
-
- /**
- * The deployment blocks sequence.
- */
- String OVERRIDE_KEY = GROUP + ".override";
-
- String[] KEYS =
- new String[]{
- SECURITY_ENABLED_KEY, AUDIT_ENABLED_KEY,
- RUNTIME_ARTIFACT_KEY, DEPLOYMENT_TIMEOUT_KEY, KERNEL_KEY,
- DEPLOYMENT_KEY, OVERRIDE_KEY };
-
-
- //--------------------------------------------------------------
- // criteria setters
- //--------------------------------------------------------------
-
- /**
- * Set the security enabled policy
- * @param mode TRUE to enabled security mode else FALSE
- */
- void setSecurityMode( boolean mode );
-
- /**
- * Set the audit enabled policy
- * @param mode TRUE to enabled audit mode else FALSE
- */
- void setAuditMode( boolean mode );
-
- /**
- * Set the runtime artifact specification.
- * @param spec and artifact uri referencing a plugin runtime factory
- */
- void setRuntimeSpecification( String spec );
-
- /**
- * Set the default deployment timeout value.
- * @param timeout and default deployment timeout
- */
- void setDefaultDeploymentTimeout( long timeout );
-
- /**
- * Set the path to the kernel directive.
- * @param path the kernel path
- */
- void setKernelPath( String path );
-
- /**
- * Set the path to the deployment override configuration.
- * @param path the override path
- */
- void setOverridePath( String path );
-
- /**
- * Set the set of paths to the deployment targets.
- * @param values an array of paths referencing deployment targets
- */
- void setDeploymentPath( String[] values );
-
- //--------------------------------------------------------------
- // criteria getters
- //--------------------------------------------------------------
-
- /**
- * Get the audit enabled policy
- * @return TRUE if audit is enabled else FALSE
- */
- Boolean getAuditMode();
-
- /**
- * Get the security enabled policy
- * @return TRUE if security is enabled else FALSE
- */
- Boolean getSecurityMode();
-
- /**
- * Get the runtime artifact.
- * @return the artifact referencing a runtime factory plugin
- */
- String getRuntimeSpecification();
-
- /**
- * Get the default deployment timeout value.
- * @return the default deployment timeout
- */
- Long getDefaultDeploymentTimeout();
-
- /**
- * Get the kernel directive path
- * @return the url to the kernel directive
- */
- String getKernelPath();
-
- /**
- * Get the deployment override path
- * @return the path to the override configuration
- */
- String getOverridePath();
-
- /**
- * Return the sequence of deployment urls
- * @return the block urls
- */
- URL[] getDeploymentURLs( File base );
-
-}
+/*
+ * 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.composition.provider;
+
+import java.io.File;
+import java.util.Map;
+import java.net.URL;
+
+import net.dpml.system.SystemContext;
+
+/**
+ * CompositionCriteria is convinience interface that extends Map with
+ * a set of operations that enable easy manipulation of the composition
+ * context parameters.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public interface CompositionCriteria extends Map
+{
+
+ //--------------------------------------------------------------
+ // criteria keys
+ //--------------------------------------------------------------
+
+ /**
+ * The security enabled policy key.
+ */
+ String GROUP = SystemContext.DOMAIN + ".composition";
+
+ /**
+ * The security enabled policy key.
+ */
+ String AUDIT_ENABLED_KEY = GROUP + ".audit";
+
+ /**
+ * The security enabled policy key.
+ */
+ String SECURITY_ENABLED_KEY = GROUP + ".secure";
+
+ /**
+ * The activation runtime artifact key.
+ */
+ String RUNTIME_ARTIFACT_KEY = GROUP + ".runtime";
+
+ /**
+ * The default deployment timeout key.
+ */
+ String DEPLOYMENT_TIMEOUT_KEY = GROUP + ".timeout";
+
+ /**
+ * The root container path key.
+ */
+ String KERNEL_KEY = GROUP + ".kernel";
+
+ /**
+ * The deployment blocks sequence.
+ */
+ String DEPLOYMENT_KEY = GROUP + ".deployment";
+
+ /**
+ * The deployment blocks sequence.
+ */
+ String OVERRIDE_KEY = GROUP + ".override";
+
+ String[] KEYS =
+ new String[]{
+ SECURITY_ENABLED_KEY, AUDIT_ENABLED_KEY,
+ RUNTIME_ARTIFACT_KEY, DEPLOYMENT_TIMEOUT_KEY, KERNEL_KEY,
+ DEPLOYMENT_KEY, OVERRIDE_KEY };
+
+
+ //--------------------------------------------------------------
+ // criteria setters
+ //--------------------------------------------------------------
+
+ /**
+ * Set the security enabled policy
+ * @param mode TRUE to enabled security mode else FALSE
+ */
+ void setSecurityMode( boolean mode );
+
+ /**
+ * Set the audit enabled policy
+ * @param mode TRUE to enabled audit mode else FALSE
+ */
+ void setAuditMode( boolean mode );
+
+ /**
+ * Set the runtime artifact specification.
+ * @param spec and artifact uri referencing a plugin runtime factory
+ */
+ void setRuntimeSpecification( String spec );
+
+ /**
+ * Set the default deployment timeout value.
+ * @param timeout and default deployment timeout
+ */
+ void setDefaultDeploymentTimeout( long timeout );
+
+ /**
+ * Set the path to the kernel directive.
+ * @param path the kernel path
+ */
+ void setKernelPath( String path );
+
+ /**
+ * Set the path to the deployment override configuration.
+ * @param path the override path
+ */
+ void setOverridePath( String path );
+
+ /**
+ * Set the set of paths to the deployment targets.
+ * @param values an array of paths referencing deployment targets
+ */
+ void setDeploymentPath( String[] values );
+
+ //--------------------------------------------------------------
+ // criteria getters
+ //--------------------------------------------------------------
+
+ /**
+ * Get the audit enabled policy
+ * @return TRUE if audit is enabled else FALSE
+ */
+ Boolean getAuditMode();
+
+ /**
+ * Get the security enabled policy
+ * @return TRUE if security is enabled else FALSE
+ */
+ Boolean getSecurityMode();
+
+ /**
+ * Get the runtime artifact.
+ * @return the artifact referencing a runtime factory plugin
+ */
+ String getRuntimeSpecification();
+
+ /**
+ * Get the default deployment timeout value.
+ * @return the default deployment timeout
+ */
+ Long getDefaultDeploymentTimeout();
+
+ /**
+ * Get the kernel directive path
+ * @return the url to the kernel directive
+ */
+ String getKernelPath();
+
+ /**
+ * Get the deployment override path
+ * @return the path to the override configuration
+ */
+ String getOverridePath();
+
+ /**
+ * Return the sequence of deployment urls
+ * @return the block urls
+ */
+ URL[] getDeploymentURLs( File base );
+
+}

Modified:
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionException.java
==============================================================================
---
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionException.java
(original)
+++
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionException.java
Fri Dec 24 22:19:23 2004
@@ -1,51 +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.composition.provider;
-
-import net.dpml.composition.model.ModelException;
-
-/**
- * Exception to indicate that there was a composition system related error.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- */
-public class CompositionException extends ModelException
-{
- /**
- * Construct a new <code>CompositionException</code> instance.
- *
- * @param message The detail message for this exception.
- */
- public CompositionException( final String message )
- {
- this( message, null );
- }
-
- /**
- * Construct a new <code>SystemException</code> instance.
- *
- * @param message The detail message for this exception.
- * @param cause the root cause of the exception
- */
- public CompositionException( final String message, final Throwable cause
)
- {
- super( message, cause );
- }
-}
-
+/*
+ * 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.composition.provider;
+
+import net.dpml.composition.model.ModelException;
+
+/**
+ * Exception to indicate that there was a composition system related error.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class CompositionException extends ModelException
+{
+ /**
+ * Construct a new <code>CompositionException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ */
+ public CompositionException( final String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * Construct a new <code>SystemException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ * @param cause the root cause of the exception
+ */
+ public CompositionException( final String message, final Throwable cause
)
+ {
+ super( message, cause );
+ }
+}
+

Modified:
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionFactory.java
==============================================================================
---
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionFactory.java
(original)
+++
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionFactory.java
Fri Dec 24 22:19:23 2004
@@ -1,52 +1,52 @@
-/*
- * Copyright 2004 Apache Software Foundation
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.composition.provider;
-
-import java.util.Map;
-
-import net.dpml.composition.model.ContainmentModel;
-
-/**
- * Factory that establishes a root containment model.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id: DefaultSystemContext.java 30977 2004-07-30 08:57:54Z niclas
$
- */
-public interface CompositionFactory
-{
- /**
- * Return the default criteria map.
- *
- * @return a new instance of the default factory criteria
- */
- CompositionCriteria createCompositionCriteria();
-
- /**
- * Creation of a new root containment model.
- * @return the root container
- */
- ContainmentModel createContainmentModel() throws CompositionException;
-
- /**
- * Creation of a new root containment model.
- * @param map the composition criteria
- * @return the root container
- */
- ContainmentModel createContainmentModel( Map map ) throws
CompositionException;
-
-}
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.composition.provider;
+
+import java.util.Map;
+
+import net.dpml.composition.model.ContainmentModel;
+
+/**
+ * Factory that establishes a root containment model.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: DefaultSystemContext.java 30977 2004-07-30 08:57:54Z niclas
$
+ */
+public interface CompositionFactory
+{
+ /**
+ * Return the default criteria map.
+ *
+ * @return a new instance of the default factory criteria
+ */
+ CompositionCriteria createCompositionCriteria();
+
+ /**
+ * Creation of a new root containment model.
+ * @return the root container
+ */
+ ContainmentModel createContainmentModel() throws CompositionException;
+
+ /**
+ * Creation of a new root containment model.
+ * @param map the composition criteria
+ * @return the root container
+ */
+ ContainmentModel createContainmentModel( Map map ) throws
CompositionException;
+
+}

Modified:
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionHelper.java
==============================================================================
---
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionHelper.java
(original)
+++
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionHelper.java
Fri Dec 24 22:19:23 2004
@@ -1,155 +1,155 @@
-/*
- * 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.composition.provider;
-
-import net.dpml.composition.model.DeploymentModel;
-import net.dpml.composition.model.ContainmentModel;
-import net.dpml.composition.model.ComponentModel;
-
-import net.dpml.system.SystemContext;
-
-/**
- * Utility class that supports the listing of a composition tree.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class CompositionHelper
-{
- private CompositionHelper()
- {
- }
-
- public static String toString( DeploymentModel model )
- {
- StringBuffer buffer = new StringBuffer( "audit report" );
- buffer.append( SystemContext.LINE );
- buffer.append( "\nComposition Model" );
- buffer.append( SystemContext.LINE );
- buffer.append( "\n" );
- printModel( buffer, " ", model );
- buffer.append( "\n" );
- buffer.append( SystemContext.LINE );
- return buffer.toString();
- }
-
- private static void printModel( StringBuffer buffer, String lead,
DeploymentModel model )
- {
- if( model instanceof ContainmentModel )
- {
- printContainmentModel( buffer, lead, (ContainmentModel) model );
- }
- else if( model instanceof ComponentModel )
- {
- printComponentModel( buffer, lead, (ComponentModel) model );
- }
- }
-
- private static void printContainmentModel(
- StringBuffer buffer, String lead, ContainmentModel model )
- {
- buffer.append(
- "\n" + lead
- + "container:"
- + model
- + ")" );
- printDeploymentModel( buffer, lead, model );
- DeploymentModel[] models = model.getModels();
- if( models.length > 0 )
- {
- buffer.append( "\n" + lead + " children:" );
- for( int i=0; i<models.length; i++ )
- {
- DeploymentModel m = models[i];
- printModel( buffer, " " + lead, m );
- }
- }
- models = model.getStartupGraph();
- if( models.length > 0 )
- {
- buffer.append( "\n" + lead + " startup:" );
- for( int i=0; i<models.length; i++ )
- {
- DeploymentModel m = models[i];
- buffer.append( "\n" + " " + lead + (i+1) + ": " + m );
- }
- }
- models = ((ContainmentModel)model).getShutdownGraph();
- if( models.length > 0 )
- {
- buffer.append( "\n" + lead + " shutdown:" );
- for( int i=0; i<models.length; i++ )
- {
- DeploymentModel m = models[i];
- buffer.append( "\n" + " " + lead + (i+1) + ": " + m );
- }
- }
- }
-
- private static void printComponentModel(
- StringBuffer buffer, String lead, ComponentModel model )
- {
- buffer.append(
- "\n" + lead
- + "component:"
- + model + "("
- + model.getDeploymentTimeout()
- + ")" );
- printDeploymentModel( buffer, lead, model );
- }
-
- private static void printDeploymentModel(
- StringBuffer buffer, String lead, DeploymentModel model )
- {
- DeploymentModel[] providers = model.getProviders();
- DeploymentModel[] consumers = model.getConsumerGraph();
-
- if(( providers.length == 0 ) && ( consumers.length == 0 ))
- {
- return;
- }
-
- if( providers.length > 0 ) for( int i=0; i<providers.length; i++ )
- {
- DeploymentModel m = providers[i];
- buffer.append( "\n" + lead + " <-- consumes: " + m );
- }
-
- if( consumers.length > 0 ) for( int i=0; i<consumers.length; i++ )
- {
- DeploymentModel m = consumers[i];
- if( isDirectProvider( m, model ) )
- {
- buffer.append( "\n" + lead + " --> supplies: " + m );
- }
- }
- }
-
- private static boolean isDirectProvider( DeploymentModel consumer,
DeploymentModel model )
- {
- String name = model.getQualifiedName();
- DeploymentModel[] providers = consumer.getProviders();
- for( int i=0; i<providers.length; i++ )
- {
- DeploymentModel m = providers[i];
- if( m.getQualifiedName().equals( name ) ) return true;
- }
- return false;
- }
-}
+/*
+ * 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.composition.provider;
+
+import net.dpml.composition.model.DeploymentModel;
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.composition.model.ComponentModel;
+
+import net.dpml.system.SystemContext;
+
+/**
+ * Utility class that supports the listing of a composition tree.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class CompositionHelper
+{
+ private CompositionHelper()
+ {
+ }
+
+ public static String toString( DeploymentModel model )
+ {
+ StringBuffer buffer = new StringBuffer( "audit report" );
+ buffer.append( SystemContext.LINE );
+ buffer.append( "\nComposition Model" );
+ buffer.append( SystemContext.LINE );
+ buffer.append( "\n" );
+ printModel( buffer, " ", model );
+ buffer.append( "\n" );
+ buffer.append( SystemContext.LINE );
+ return buffer.toString();
+ }
+
+ private static void printModel( StringBuffer buffer, String lead,
DeploymentModel model )
+ {
+ if( model instanceof ContainmentModel )
+ {
+ printContainmentModel( buffer, lead, (ContainmentModel) model );
+ }
+ else if( model instanceof ComponentModel )
+ {
+ printComponentModel( buffer, lead, (ComponentModel) model );
+ }
+ }
+
+ private static void printContainmentModel(
+ StringBuffer buffer, String lead, ContainmentModel model )
+ {
+ buffer.append(
+ "\n" + lead
+ + "container:"
+ + model
+ + ")" );
+ printDeploymentModel( buffer, lead, model );
+ DeploymentModel[] models = model.getModels();
+ if( models.length > 0 )
+ {
+ buffer.append( "\n" + lead + " children:" );
+ for( int i=0; i<models.length; i++ )
+ {
+ DeploymentModel m = models[i];
+ printModel( buffer, " " + lead, m );
+ }
+ }
+ models = model.getStartupGraph();
+ if( models.length > 0 )
+ {
+ buffer.append( "\n" + lead + " startup:" );
+ for( int i=0; i<models.length; i++ )
+ {
+ DeploymentModel m = models[i];
+ buffer.append( "\n" + " " + lead + (i+1) + ": " + m );
+ }
+ }
+ models = ((ContainmentModel)model).getShutdownGraph();
+ if( models.length > 0 )
+ {
+ buffer.append( "\n" + lead + " shutdown:" );
+ for( int i=0; i<models.length; i++ )
+ {
+ DeploymentModel m = models[i];
+ buffer.append( "\n" + " " + lead + (i+1) + ": " + m );
+ }
+ }
+ }
+
+ private static void printComponentModel(
+ StringBuffer buffer, String lead, ComponentModel model )
+ {
+ buffer.append(
+ "\n" + lead
+ + "component:"
+ + model + "("
+ + model.getDeploymentTimeout()
+ + ")" );
+ printDeploymentModel( buffer, lead, model );
+ }
+
+ private static void printDeploymentModel(
+ StringBuffer buffer, String lead, DeploymentModel model )
+ {
+ DeploymentModel[] providers = model.getProviders();
+ DeploymentModel[] consumers = model.getConsumerGraph();
+
+ if(( providers.length == 0 ) && ( consumers.length == 0 ))
+ {
+ return;
+ }
+
+ if( providers.length > 0 ) for( int i=0; i<providers.length; i++ )
+ {
+ DeploymentModel m = providers[i];
+ buffer.append( "\n" + lead + " <-- consumes: " + m );
+ }
+
+ if( consumers.length > 0 ) for( int i=0; i<consumers.length; i++ )
+ {
+ DeploymentModel m = consumers[i];
+ if( isDirectProvider( m, model ) )
+ {
+ buffer.append( "\n" + lead + " --> supplies: " + m );
+ }
+ }
+ }
+
+ private static boolean isDirectProvider( DeploymentModel consumer,
DeploymentModel model )
+ {
+ String name = model.getQualifiedName();
+ DeploymentModel[] providers = consumer.getProviders();
+ for( int i=0; i<providers.length; i++ )
+ {
+ DeploymentModel m = providers[i];
+ if( m.getQualifiedName().equals( name ) ) return true;
+ }
+ return false;
+ }
+}

Modified:
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionRuntimeException.java
==============================================================================
---
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionRuntimeException.java
(original)
+++
development/main/metro/composition/spi/src/main/net/dpml/composition/provider/CompositionRuntimeException.java
Fri Dec 24 22:19:23 2004
@@ -1,52 +1,52 @@
-/*
- * 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.composition.provider;
-
-import net.dpml.composition.model.ModelRuntimeException;
-
-/**
- * Exception to indicate that there was a composition system related error.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- */
-public class CompositionRuntimeException extends ModelRuntimeException
-{
- /**
- * Construct a new <code>CompositionRuntimeException</code> instance.
- *
- * @param message The detail message for this exception.
- */
- public CompositionRuntimeException( final String message )
- {
- this( message, null );
- }
-
- /**
- * Construct a new <code>CompositionRuntimeException</code> instance.
- *
- * @param message The detail message for this exception.
- * @param cause the root cause of the exception
- */
- public CompositionRuntimeException( final String message, final
Throwable cause )
- {
- super( message, cause );
- }
-
-}
-
+/*
+ * 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.composition.provider;
+
+import net.dpml.composition.model.ModelRuntimeException;
+
+/**
+ * Exception to indicate that there was a composition system related error.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ */
+public class CompositionRuntimeException extends ModelRuntimeException
+{
+ /**
+ * Construct a new <code>CompositionRuntimeException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ */
+ public CompositionRuntimeException( final String message )
+ {
+ this( message, null );
+ }
+
+ /**
+ * Construct a new <code>CompositionRuntimeException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ * @param cause the root cause of the exception
+ */
+ public CompositionRuntimeException( final String message, final
Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
+

Modified: development/main/metro/composition/test/etc/test/metro.properties
==============================================================================
--- development/main/metro/composition/test/etc/test/metro.properties
(original)
+++ development/main/metro/composition/test/etc/test/metro.properties Fri
Dec 24 22:19:23 2004
@@ -1,4 +1,4 @@
-
-metro.info = false
-metro.avalon = true
+
+metro.info = false
+metro.avalon = true
color = red
\ No newline at end of file

Modified:
development/main/metro/composition/test/src/main/net/dpml/composition/test/CompositionTestCase.java
==============================================================================
---
development/main/metro/composition/test/src/main/net/dpml/composition/test/CompositionTestCase.java
(original)
+++
development/main/metro/composition/test/src/main/net/dpml/composition/test/CompositionTestCase.java
Fri Dec 24 22:19:23 2004
@@ -1,138 +1,138 @@
-/*
- * 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.composition.test;
-
-import java.io.File;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-
-import junit.framework.TestCase;
-import net.dpml.composition.model.ContainmentModel;
-import net.dpml.exception.ExceptionHelper;
-import net.dpml.system.Factory;
-import net.dpml.system.SystemContext;
-import net.dpml.transit.artifact.Artifact;
-import net.dpml.transit.repository.Repository;
-import net.dpml.transit.repository.StandardLoader;
-import net.dpml.transit.monitors.Monitor;
-
-
-/**
- * AbstractCompositionTestCase
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public abstract class CompositionTestCase extends TestCase
-{
- //------------------------------------------------------------------
- // static
- //------------------------------------------------------------------
-
- /**
- * The working test directory.
- */
- public static final File WORK =
- new File( System.getProperty( "project.dir" ) );
-
- //------------------------------------------------------------------
- // AbstractCompositionTestCase
- //------------------------------------------------------------------
-
- /**
- * Creation of a new composition context with a cache directory assigned
- * to the value returned from the project.cache system
- * property and relative path references resolved relative to the
project.dir
- * system property.
- *
- * @return the composition context
- */
- protected ContainmentModel createCompositionRoot()
- throws Exception
- {
- return createCompositionRoot( new HashMap() );
- }
-
- /**
- * Creation of a new composition context with a cache directory assigned
- * to the value returned from the project.cache system
- * property and relative path references resolved relative to the
project.dir
- * system property.
- *
- * @param map a map of supplimentary factory criteria that will be
- * applied to the composition context factory
- * @return the composition context
- */
- protected ContainmentModel createCompositionRoot( Map map )
- throws Exception
- {
- //
- // use magic's cache and the test working directory
- //
- Repository repo = new StandardLoader();
-
- //
- // create the system context
- //
-
- URI uri = new URI( "@TRANSIT-IMPL-SPEC@" );
- ClassLoader classloader = CompositionTestCase.class.getClassLoader();
- Map data = new Hashtable();
- data.put( "urn:transit.debug.policy", new Boolean( false ) );
- Factory systemfactory = (Factory) repo.getPlugin( classloader, uri,
new Object[]{data} );
- Map systemCriteria = systemfactory.createDefaultCriteria();
- systemCriteria.put( "dpml.system.dir", WORK );
- SystemContext system = (SystemContext) systemfactory.create(
systemCriteria );
-
- //
- // create the composition context
- //
-
- uri = new URI( "@COMPOSITION_IMPL_URI@" );
- Object[] params = new Object[]{ system };
- Factory modelFactory =
- (Factory) system.getRepository().getPlugin( classloader, uri,
params );
- return (ContainmentModel) modelFactory.create( map );
- }
-
- protected ContainmentModel createContainmentModel( String path )
- throws Exception
- {
- ContainmentModel root = createCompositionRoot();
- return createContainmentModel( root, path );
- }
-
- protected ContainmentModel createContainmentModel( ContainmentModel
root, String path )
- throws Exception
- {
- try
- {
- File source = new File( WORK, path );
- return root.addContainmentModel( source.toURL() );
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to establish containment model.";
- final String message = ExceptionHelper.packException( error, e,
true );
- throw new Exception( message );
- }
- }
-}
+/*
+ * 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.composition.test;
+
+import java.io.File;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import junit.framework.TestCase;
+import net.dpml.composition.model.ContainmentModel;
+import net.dpml.exception.ExceptionHelper;
+import net.dpml.system.Factory;
+import net.dpml.system.SystemContext;
+import net.dpml.transit.artifact.Artifact;
+import net.dpml.transit.repository.Repository;
+import net.dpml.transit.repository.StandardLoader;
+import net.dpml.transit.monitors.Monitor;
+
+
+/**
+ * AbstractCompositionTestCase
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public abstract class CompositionTestCase extends TestCase
+{
+ //------------------------------------------------------------------
+ // static
+ //------------------------------------------------------------------
+
+ /**
+ * The working test directory.
+ */
+ public static final File WORK =
+ new File( System.getProperty( "project.dir" ) );
+
+ //------------------------------------------------------------------
+ // AbstractCompositionTestCase
+ //------------------------------------------------------------------
+
+ /**
+ * Creation of a new composition context with a cache directory assigned
+ * to the value returned from the project.cache system
+ * property and relative path references resolved relative to the
project.dir
+ * system property.
+ *
+ * @return the composition context
+ */
+ protected ContainmentModel createCompositionRoot()
+ throws Exception
+ {
+ return createCompositionRoot( new HashMap() );
+ }
+
+ /**
+ * Creation of a new composition context with a cache directory assigned
+ * to the value returned from the project.cache system
+ * property and relative path references resolved relative to the
project.dir
+ * system property.
+ *
+ * @param map a map of supplimentary factory criteria that will be
+ * applied to the composition context factory
+ * @return the composition context
+ */
+ protected ContainmentModel createCompositionRoot( Map map )
+ throws Exception
+ {
+ //
+ // use magic's cache and the test working directory
+ //
+ Repository repo = new StandardLoader();
+
+ //
+ // create the system context
+ //
+
+ URI uri = new URI( "@TRANSIT-IMPL-SPEC@" );
+ ClassLoader classloader = CompositionTestCase.class.getClassLoader();
+ Map data = new Hashtable();
+ data.put( "urn:transit.debug.policy", new Boolean( false ) );
+ Factory systemfactory = (Factory) repo.getPlugin( classloader, uri,
new Object[]{data} );
+ Map systemCriteria = systemfactory.createDefaultCriteria();
+ systemCriteria.put( "dpml.system.dir", WORK );
+ SystemContext system = (SystemContext) systemfactory.create(
systemCriteria );
+
+ //
+ // create the composition context
+ //
+
+ uri = new URI( "@COMPOSITION_IMPL_URI@" );
+ Object[] params = new Object[]{ system };
+ Factory modelFactory =
+ (Factory) system.getRepository().getPlugin( classloader, uri,
params );
+ return (ContainmentModel) modelFactory.create( map );
+ }
+
+ protected ContainmentModel createContainmentModel( String path )
+ throws Exception
+ {
+ ContainmentModel root = createCompositionRoot();
+ return createContainmentModel( root, path );
+ }
+
+ protected ContainmentModel createContainmentModel( ContainmentModel
root, String path )
+ throws Exception
+ {
+ try
+ {
+ File source = new File( WORK, path );
+ return root.addContainmentModel( source.toURL() );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unable to establish containment model.";
+ final String message = ExceptionHelper.packException( error, e,
true );
+ throw new Exception( message );
+ }
+ }
+}

Modified: development/main/metro/index.xml
==============================================================================
--- development/main/metro/index.xml (original)
+++ development/main/metro/index.xml Fri Dec 24 22:19:23 2004
@@ -1,931 +1,931 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<index>
-
- <import index="../magic/index.xml"
- uri="artifact:module:dpml/magic/dpml-magic#SNAPSHOT"/>
-
-
- <!--
- Metro Modules
- -->
-
- <project file="module.xml">
- <info>
- <group>dpml/metro</group>
- <name>dpml-metro</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- <type>module</type>
- </info>
- <plugins>
- <include key="dpml-magic-checkstyle"/>
- </plugins>
- <dependencies>
- <include key="dpml-magic"/>
- <include key="dpml-transit"/>
- <include key="dpml-util"/>
- </dependencies>
- </project>
-
- <!-- FROM PUBLIC INDEX -->
-
- <!-- Activity -->
-
- <project basedir="activity/api">
- <info>
- <group>dpml/metro/public</group>
- <name>dpml-activity-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- </project>
-
- <!-- Configuration -->
-
- <project basedir="configuration/api">
- <info>
- <group>dpml/metro/public</group>
- <name>dpml-configuration-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- </project>
-
- <project basedir="configuration/impl">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-configuration-impl</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-configuration-api"/>
- </dependencies>
- </project>
-
- <!-- Parameters -->
-
- <project basedir="parameters/api">
- <info>
- <group>dpml/metro/public</group>
- <name>dpml-parameters-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- </project>
-
- <project basedir="parameters/impl">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-parameters-impl</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-parameters-api"/>
- <include key="dpml-configuration-api"/>
- </dependencies>
- </project>
-
- <!-- Context -->
-
- <project basedir="context/api">
- <info>
- <group>dpml/metro/public</group>
- <name>dpml-context-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- </project>
-
- <project basedir="context/impl">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-context-impl</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-context-api"/>
- </dependencies>
- </project>
-
- <!-- Service -->
-
- <project basedir="service/api">
- <info>
- <group>dpml/metro/public</group>
- <name>dpml-service-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- </project>
-
- <!-- Logging -->
-
- <project basedir="logging/api">
- <info>
- <group>dpml/metro/public</group>
- <name>dpml-logging-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- </project>
-
- <!-- Meta -->
-
- <project basedir="meta/api">
- <info>
- <group>dpml/metro/protected</group>
- <name>dpml-meta-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-parameters-api"/>
- <include key="dpml-configuration-api"/>
- <include key="dpml-configuration-impl" build="false" test="true"
runtime="false"/>
- <include key="dpml-parameters-impl" build="false" test="true"
runtime="false"/>
- </dependencies>
- </project>
-
- <project basedir="meta/spi">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-meta-spi</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-meta-api"/>
- <include key="dpml-configuration-api"/>
- <include key="dpml-parameters-api"/>
- </dependencies>
- </project>
-
- <project basedir="meta/impl">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-meta-impl</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-meta-spi"/>
- <include key="dpml-util-i18n"/>
- <include key="dpml-configuration-impl"/>
- <include key="dpml-parameters-impl"/>
- <include key="dpml-service-api"/>
- </dependencies>
- </project>
-
- <project basedir="meta/tools">
- <info>
- <group>dpml/metro/tools</group>
- <name>dpml-meta-tools</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-meta-impl"/>
- <include key="qdox"/>
- <include key="ant"/>
- <include key="ant-junit"/>
- </dependencies>
- </project>
-
- <!-- Metro -->
-
- <project basedir="main">
- <info>
- <group>dpml/metro/tools</group>
- <name>dpml-metro-main</name>
- <version>1.0.0</version>
- <type>jar</type>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-logging-api" tag="api"/>
- <include key="dpml-activity-api" tag="api"/>
- <include key="dpml-context-api" tag="api"/>
- <include key="dpml-transit-main" tag="api"/>
- <include key="dpml-system-spi" tag="spi"/>
- <include key="dpml-logging-spi" tag="spi"/>
- <include key="dpml-util-i18n"/>
- <include key="dpml-util-exception"/>
- <include key="dpml-util-criteria"/>
- <include key="dpml-util-cli"/>
- <include key="dpml-system-impl" build="false"/>
- <include key="dpml-composition-impl" build="false"/>
- <include key="commons-cli"/>
- </dependencies>
- </project>
-
- <project basedir="unit">
- <info>
- <group>dpml/metro/tools</group>
- <name>dpml-metro-unit</name>
- <version>1.0.0</version>
- <type>jar</type>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-composition-spi"/>
- <include key="dpml-util-exception"/>
- <include key="dpml-composition-impl" build="false"/>
- <include key="dpml-system-impl" build="false"/>
- </dependencies>
- </project>
-
- <!-- FROM PROTECTED INDEX -->
-
- <!-- Extension -->
-
- <project basedir="extension/api">
- <info>
- <group>dpml/metro/protected</group>
- <name>dpml-extension-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- </project>
-
- <project basedir="extension/impl">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-extension-impl</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-extension-api"/>
- </dependencies>
- </project>
-
- <!-- Composition -->
-
- <project basedir="composition/api">
- <info>
- <group>dpml/metro/protected</group>
- <name>dpml-composition-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-transit-main"/>
- <include key="dpml-meta-api"/>
- <include key="dpml-util-i18n"/>
- <include key="dpml-configuration-api"/>
- <include key="dpml-context-api"/>
- <include key="dpml-service-api"/>
- <include key="dpml-parameters-api"/>
- <include key="dpml-logging-api"/>
- <include key="dpml-logging-data"/>
- <include key="dpml-extension-api"/>
- <include key="dpml-configuration-impl" build="false" test="true"
runtime="false"/>
- <include key="dpml-parameters-impl" build="false" test="true"
runtime="false"/>
- </dependencies>
- </project>
-
- <!-- Composition -->
-
- <project basedir="composition/spi">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-composition-spi</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-system-spi"/>
- <include key="dpml-composition-api"/>
- <include key="dpml-logging-spi"/>
- </dependencies>
- </project>
-
- <project basedir="composition/impl">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-composition-impl</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-transit-main" tag="api"/>
- <include key="dpml-logging-api" tag="api"/>
- <include key="dpml-activity-api" tag="api"/>
- <include key="dpml-parameters-api" tag="api"/>
- <include key="dpml-composition-api" tag="api"/>
- <include key="dpml-configuration-api" tag="api"/>
- <include key="dpml-service-api" tag="api"/>
- <include key="dpml-meta-api" tag="api"/>
- <include key="dpml-extension-api" tag="api"/>
- <include key="dpml-composition-spi" tag="spi"/>
- <include key="dpml-meta-spi" tag="spi"/>
- <include key="dpml-configuration-impl"/>
- <include key="dpml-meta-impl"/>
- <include key="dpml-extension-api" tag="spi"/>
- <include key="dpml-extension-impl"/>
- <include key="dpml-util-exception"/>
- <include key="dpml-context-impl"/>
- <include key="dpml-util-criteria"/>
- <include key="dpml-util-cli"/>
- <include key="dpml-activation-impl" build="false"/>
- <include key="dpml-test-playground" build="false"/>
- </dependencies>
- </project>
-
- <project basedir="composition/test">
- <info>
- <group>dpml/test</group>
- <name>dpml-composition-test</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-system-spi"/>
- <include key="dpml-composition-spi"/>
- <include key="dpml-composition-impl"/>
- <include key="dpml-system-impl" test="false"/>
- <include key="dpml-composition-impl" test="false"/>
- <include key="dpml-util-exception"/>
- <include key="dpml-test-testa" test="false"/>
- <include key="dpml-test-testb" test="false"/>
- <include key="dpml-test-testc" test="false"/>
- <include key="dpml-test-testcyclic" test="false"/>
- <include key="dpml-test-includes" test="false"/>
- <include key="dpml-test-dynamics" test="false"/>
- <include key="dpml-system-impl" build="false"/>
- <include key="dpml-logging-logkit-impl" build="false"/>
- <include key="dpml-test-testschema"/>
- </dependencies>
- </project>
-
- <!-- Utitlities -->
-
- <project basedir="util/defaults">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-util-defaults</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- <type>jar</type>
- </info>
- </project>
-
- <!-- Extension -->
-
- <!-- System -->
-
- <project basedir="system/api">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-system-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-transit-main" tag="api"/>
- </dependencies>
- </project>
-
- <project basedir="system/spi">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-system-spi</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-context-api"/>
- <include key="dpml-logging-spi"/>
- <include key="dpml-transit-main"/>
- </dependencies>
- </project>
-
- <project basedir="system/impl">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-system-impl</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-system-spi" tag="spi"/>
- <include key="dpml-context-impl"/>
- <include key="dpml-util-criteria"/>
- <include key="dpml-util-defaults"/>
- <include key="dpml-util-i18n"/>
- <include key="dpml-util-cli"/>
- </dependencies>
- </project>
-
- <project basedir="system/test">
- <info>
- <group>dpml/test</group>
- <name>dpml-system-test</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-system-spi"/>
- <include key="dpml-system-impl" build="false"/>
- </dependencies>
- </project>
-
- <!-- Logging -->
-
- <project basedir="logging/data">
- <info>
- <group>dpml/metro/protected</group>
- <name>dpml-logging-data</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- </project>
-
- <project basedir="logging/spi">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-logging-spi</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-logging-api" tag="api"/>
- <include key="dpml-logging-data" tag="api"/>
- <include key="dpml-system-api" tag="api"/>
- <include key="dpml-transit-main" tag="api"/>
- </dependencies>
- </project>
-
- <project basedir="logging/criteria">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-logging-criteria</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-logging-spi"/>
- <include key="dpml-util-i18n"/>
- <include key="dpml-util-criteria"/>
- <include key="dpml-util-defaults"/>
- </dependencies>
- </project>
-
- <project basedir="logging/providers/log4j/impl">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-logging-log4j</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-logging-spi" tag="spi"/>
- <include key="dpml-util-i18n"/>
- <include key="dpml-logging-criteria"/>
- <include key="dpml-configuration-api"/>
- <include key="log4j"/>
- </dependencies>
- </project>
-
- <project basedir="logging/providers/log4j/test">
- <info>
- <group>dpml/test</group>
- <name>dpml-logging-log4j-test</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-logging-logkit-api"/>
- <include key="dpml-logging-log4j" test="false"/>
- <include key="dpml-transit-main"/>
- </dependencies>
- </project>
-
- <project basedir="logging/providers/logkit/api">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-logging-logkit-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-logging-spi"/>
- <include key="dpml-configuration-api"/>
- </dependencies>
- </project>
-
- <project basedir="logging/providers/logkit/impl">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-logging-logkit-impl</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-transit-main" runtime="false" tag="api"/>
- <include key="dpml-logging-spi" tag="spi"/>
- <include key="dpml-util-i18n"/>
- <include key="dpml-util-exception"/>
- <include key="dpml-logging-criteria"/>
- <include key="dpml-logging-logkit-api"/>
- <include key="dpml-configuration-impl"/>
- </dependencies>
- </project>
-
- <project basedir="logging/providers/logkit/plugins/datagram">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-logging-logkit-datagram</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-util-i18n"/>
- <include key="dpml-logging-logkit-impl"/>
- <include key="dpml-configuration-impl"/>
- </dependencies>
- </project>
-
- <project basedir="logging/providers/logkit/plugins/socket">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-logging-logkit-socket</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-util-i18n"/>
- <include key="dpml-logging-logkit-impl"/>
- <include key="dpml-configuration-impl"/>
- </dependencies>
- </project>
-
- <project basedir="logging/providers/logkit/plugins/syslog">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-logging-logkit-syslog</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-util-i18n"/>
- <include key="dpml-configuration-impl"/>
- <include key="dpml-logging-logkit-api"/>
- <include key="dpml-logging-logkit-datagram"/>
- </dependencies>
- </project>
-
- <project basedir="logging/providers/logkit/test">
- <info>
- <group>dpml/test</group>
- <name>dpml-logging-logkit-test</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-logging-logkit-impl" build="false" test="false"/>
- <include key="dpml-logging-logkit-datagram" build="false"
test="false"/>
- <include key="dpml-logging-logkit-socket" build="false" test="false"/>
- <include key="dpml-logging-logkit-syslog" build="false" test="false"/>
- <include key="dpml-transit-main"/>
- <include key="dpml-logging-logkit-api"/>
- </dependencies>
- </project>
-
- <!--
- DPML Activation.
- -->
-
- <project basedir="activation/api">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-activation-api</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-composition-spi"/>
- </dependencies>
- </project>
-
- <project basedir="activation/providers/metro">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-activation-metro-provider</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-activation-api" tag="api"/>
- <include key="dpml-activity-api" tag="api"/>
- <include key="dpml-composition-api" tag="api"/>
- <include key="dpml-composition-spi" tag="spi"/>
- <include key="dpml-util-i18n"/>
- <include key="dpml-util-defaults"/>
- <include key="dpml-system-spi"/>
- <include key="dpml-context-impl"/>
- </dependencies>
- </project>
-
- <project basedir="activation/providers/avalon">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-activation-avalon-provider</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-activity-api" tag="api"/>
- <include key="dpml-composition-api" tag="api"/>
- <include key="avalon-framework-api" tag="api"/>
- <include key="dpml-activation-api" tag="api"/>
- <include key="dpml-system-spi" tag="spi"/>
- <include key="dpml-composition-spi" tag="spi"/>
- <include key="avalon-util-lifecycle" tag="api"/>
- <include key="dpml-util-i18n"/>
- <include key="dpml-util-defaults"/>
- <include key="dpml-context-impl"/>
- <include key="dpml-parameters-impl"/>
- <include key="avalon-framework-impl"/>
- </dependencies>
- </project>
-
- <project basedir="activation/impl">
- <info>
- <group>dpml/metro/private</group>
- <name>dpml-activation-impl</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-transit-main" tag="api"/>
- <include key="dpml-activation-api" tag="api"/>
- <include key="dpml-composition-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"/>
- </dependencies>
- </project>
-
- <project basedir="activation/test">
- <info>
- <group>dpml/test</group>
- <name>dpml-activation-test</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- </info>
- <dependencies>
- <include key="dpml-composition-test"/>
- <include key="dpml-activation-impl"/>
- <include key="dpml-test-components"/>
- </dependencies>
- </project>
-
- <!--
- Metro Test.
- -->
-
- <project basedir="testing/dynamics">
- <info>
- <group>dpml/test</group>
- <name>dpml-test-dynamics</name>
- <type>jar</type>
- </info>
- <dependencies>
- <include key="dpml-logging-api"/>
- <include key="dpml-service-api"/>
- </dependencies>
- <plugins>
- <include key="dpml-meta-tools"/>
- </plugins>
- </project>
-
- <project basedir="testing/playground">
- <info>
- <group>dpml/test</group>
- <name>dpml-test-playground</name>
- <type>jar</type>
- </info>
- <dependencies>
- <include key="dpml-logging-api"/>
- <include key="dpml-context-api"/>
- <include key="dpml-configuration-api"/>
- <include key="dpml-service-api"/>
- <include key="dpml-activity-api"/>
- <include key="dpml-composition-api"/>
- <include key="dpml-context-impl"/>
- </dependencies>
- <plugins>
- <include key="dpml-meta-tools"/>
- </plugins>
- </project>
-
- <project basedir="testing/testa">
- <info>
- <group>dpml/test</group>
- <name>dpml-test-testa</name>
- <type>jar</type>
- </info>
- <dependencies>
- <include key="dpml-activity-api"/>
- <include key="dpml-logging-api"/>
- <include key="dpml-context-api"/>
- <include key="dpml-configuration-api"/>
- </dependencies>
- <plugins>
- <include key="dpml-meta-tools"/>
- </plugins>
- </project>
-
- <project basedir="testing/testb">
- <info>
- <group>dpml/test</group>
- <name>dpml-test-testb</name>
- <type>jar</type>
- </info>
- <dependencies>
- <include key="dpml-activity-api"/>
- <include key="dpml-logging-api"/>
- </dependencies>
- <plugins>
- <include key="dpml-meta-tools"/>
- </plugins>
- </project>
-
- <project basedir="testing/testc">
- <info>
- <group>dpml/test</group>
- <name>dpml-test-testc</name>
- <type>jar</type>
- </info>
- <dependencies>
- <include key="dpml-test-testa"/>
- <include key="dpml-test-testb"/>
- <include key="dpml-activity-api"/>
- <include key="dpml-logging-api"/>
- <include key="dpml-service-api"/>
- </dependencies>
- <plugins>
- <include key="dpml-meta-tools"/>
- </plugins>
- </project>
-
- <project basedir="testing/testd">
- <info>
- <group>dpml/test</group>
- <name>dpml-test-testd</name>
- <type>jar</type>
- </info>
- <dependencies>
- <include key="dpml-test-testa"/>
- <include key="dpml-activity-api"/>
- <include key="dpml-logging-api"/>
- <include key="dpml-service-api"/>
- </dependencies>
- <plugins>
- <include key="dpml-meta-tools"/>
- </plugins>
- </project>
-
- <project basedir="testing/teste">
- <info>
- <group>dpml/test</group>
- <name>dpml-test-teste</name>
- <type>jar</type>
- </info>
- <dependencies>
- <include key="dpml-test-testa"/>
- <include key="dpml-activity-api"/>
- <include key="dpml-logging-api"/>
- <include key="dpml-service-api"/>
- </dependencies>
- <plugins>
- <include key="dpml-meta-tools"/>
- </plugins>
- </project>
-
- <project basedir="testing/testcyclic">
- <info>
- <group>dpml/test</group>
- <name>dpml-test-testcyclic</name>
- <type>jar</type>
- </info>
- <dependencies>
- <include key="dpml-logging-api"/>
- <include key="dpml-service-api"/>
- </dependencies>
- <plugins>
- <include key="dpml-meta-tools"/>
- </plugins>
- </project>
-
- <project basedir="testing/testschema">
- <info>
- <group>dpml/test</group>
- <name>dpml-test-testschema</name>
- <type>jar</type>
- </info>
- <dependencies>
- <include key="dpml-logging-api"/>
- <include key="dpml-configuration-api"/>
- </dependencies>
- <plugins>
- <include key="dpml-meta-tools"/>
- </plugins>
- </project>
-
- <project basedir="testing/includes">
- <info>
- <group>dpml/test</group>
- <name>dpml-test-includes</name>
- <type>jar</type>
- </info>
- <dependencies>
- <include key="dpml-test-playground" build="false" runtime="false"/>
- <include key="dpml-test-testa" build="false" runtime="false"/>
- <include key="dpml-test-testb" build="false" runtime="false"/>
- <include key="dpml-test-testc" build="false" runtime="false"/>
- <include key="dpml-test-testd" build="false" runtime="false"/>
- <include key="dpml-test-teste" build="false" runtime="false"/>
- </dependencies>
- </project>
-
- <project basedir="testing/components">
- <info>
- <group>dpml/test</group>
- <name>dpml-test-components</name>
- <type>jar</type>
- </info>
- <dependencies>
- <include key="dpml-logging-api"/>
- <include key="dpml-context-api"/>
- <include key="dpml-service-api"/>
- </dependencies>
- <plugins>
- <include key="dpml-meta-tools"/>
- </plugins>
- </project>
-
-
- <!-- EXTERNAL RESOURCES -->
-
- <resource>
- <info>
- <group>qdox</group>
- <name>qdox</name>
- <version>1.4</version>
- <type>jar</type>
- </info>
- </resource>
-
- <resource>
- <info>
- <group>log4j</group>
- <name>log4j</name>
- <version>1.2.8</version>
- <type>jar</type>
- </info>
- <gump>
- <alias>logging-log4j-12</alias>
- </gump>
- </resource>
-
- <resource>
- <info>
- <group>qdox</group>
- <name>qdox</name>
- <version>1.4</version>
- <type>jar</type>
- </info>
- </resource>
-
- <resource>
- <info>
- <group>avalon-framework</group>
- <name>avalon-framework-api</name>
- <version>4.2.0</version>
- </info>
- </resource>
-
- <resource>
- <info>
- <group>avalon-framework</group>
- <name>avalon-framework-impl</name>
- <version>4.2.0</version>
- </info>
- </resource>
-
- <resource>
- <info>
- <group>avalon/util</group>
- <name>avalon-util-lifecycle</name>
- <version>1.1.1</version>
- </info>
- </resource>
-
-
-</index>
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<index>
+
+ <import index="../magic/index.xml"
+ uri="artifact:module:dpml/magic/dpml-magic#SNAPSHOT"/>
+
+
+ <!--
+ Metro Modules
+ -->
+
+ <project file="module.xml">
+ <info>
+ <group>dpml/metro</group>
+ <name>dpml-metro</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <type>module</type>
+ </info>
+ <plugins>
+ <include key="dpml-magic-checkstyle"/>
+ </plugins>
+ <dependencies>
+ <include key="dpml-magic"/>
+ <include key="dpml-transit"/>
+ <include key="dpml-util"/>
+ </dependencies>
+ </project>
+
+ <!-- FROM PUBLIC INDEX -->
+
+ <!-- Activity -->
+
+ <project basedir="activity/api">
+ <info>
+ <group>dpml/metro/public</group>
+ <name>dpml-activity-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ </project>
+
+ <!-- Configuration -->
+
+ <project basedir="configuration/api">
+ <info>
+ <group>dpml/metro/public</group>
+ <name>dpml-configuration-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ </project>
+
+ <project basedir="configuration/impl">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-configuration-impl</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-configuration-api"/>
+ </dependencies>
+ </project>
+
+ <!-- Parameters -->
+
+ <project basedir="parameters/api">
+ <info>
+ <group>dpml/metro/public</group>
+ <name>dpml-parameters-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ </project>
+
+ <project basedir="parameters/impl">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-parameters-impl</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-parameters-api"/>
+ <include key="dpml-configuration-api"/>
+ </dependencies>
+ </project>
+
+ <!-- Context -->
+
+ <project basedir="context/api">
+ <info>
+ <group>dpml/metro/public</group>
+ <name>dpml-context-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ </project>
+
+ <project basedir="context/impl">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-context-impl</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-context-api"/>
+ </dependencies>
+ </project>
+
+ <!-- Service -->
+
+ <project basedir="service/api">
+ <info>
+ <group>dpml/metro/public</group>
+ <name>dpml-service-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ </project>
+
+ <!-- Logging -->
+
+ <project basedir="logging/api">
+ <info>
+ <group>dpml/metro/public</group>
+ <name>dpml-logging-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ </project>
+
+ <!-- Meta -->
+
+ <project basedir="meta/api">
+ <info>
+ <group>dpml/metro/protected</group>
+ <name>dpml-meta-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-parameters-api"/>
+ <include key="dpml-configuration-api"/>
+ <include key="dpml-configuration-impl" build="false" test="true"
runtime="false"/>
+ <include key="dpml-parameters-impl" build="false" test="true"
runtime="false"/>
+ </dependencies>
+ </project>
+
+ <project basedir="meta/spi">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-meta-spi</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-meta-api"/>
+ <include key="dpml-configuration-api"/>
+ <include key="dpml-parameters-api"/>
+ </dependencies>
+ </project>
+
+ <project basedir="meta/impl">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-meta-impl</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-meta-spi"/>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-configuration-impl"/>
+ <include key="dpml-parameters-impl"/>
+ <include key="dpml-service-api"/>
+ </dependencies>
+ </project>
+
+ <project basedir="meta/tools">
+ <info>
+ <group>dpml/metro/tools</group>
+ <name>dpml-meta-tools</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-meta-impl"/>
+ <include key="qdox"/>
+ <include key="ant"/>
+ <include key="ant-junit"/>
+ </dependencies>
+ </project>
+
+ <!-- Metro -->
+
+ <project basedir="main">
+ <info>
+ <group>dpml/metro/tools</group>
+ <name>dpml-metro-main</name>
+ <version>1.0.0</version>
+ <type>jar</type>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-api" tag="api"/>
+ <include key="dpml-activity-api" tag="api"/>
+ <include key="dpml-context-api" tag="api"/>
+ <include key="dpml-transit-main" tag="api"/>
+ <include key="dpml-system-spi" tag="spi"/>
+ <include key="dpml-logging-spi" tag="spi"/>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-util-exception"/>
+ <include key="dpml-util-criteria"/>
+ <include key="dpml-util-cli"/>
+ <include key="dpml-system-impl" build="false"/>
+ <include key="dpml-composition-impl" build="false"/>
+ <include key="commons-cli"/>
+ </dependencies>
+ </project>
+
+ <project basedir="unit">
+ <info>
+ <group>dpml/metro/tools</group>
+ <name>dpml-metro-unit</name>
+ <version>1.0.0</version>
+ <type>jar</type>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-composition-spi"/>
+ <include key="dpml-util-exception"/>
+ <include key="dpml-composition-impl" build="false"/>
+ <include key="dpml-system-impl" build="false"/>
+ </dependencies>
+ </project>
+
+ <!-- FROM PROTECTED INDEX -->
+
+ <!-- Extension -->
+
+ <project basedir="extension/api">
+ <info>
+ <group>dpml/metro/protected</group>
+ <name>dpml-extension-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ </project>
+
+ <project basedir="extension/impl">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-extension-impl</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-extension-api"/>
+ </dependencies>
+ </project>
+
+ <!-- Composition -->
+
+ <project basedir="composition/api">
+ <info>
+ <group>dpml/metro/protected</group>
+ <name>dpml-composition-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-transit-main"/>
+ <include key="dpml-meta-api"/>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-configuration-api"/>
+ <include key="dpml-context-api"/>
+ <include key="dpml-service-api"/>
+ <include key="dpml-parameters-api"/>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-logging-data"/>
+ <include key="dpml-extension-api"/>
+ <include key="dpml-configuration-impl" build="false" test="true"
runtime="false"/>
+ <include key="dpml-parameters-impl" build="false" test="true"
runtime="false"/>
+ </dependencies>
+ </project>
+
+ <!-- Composition -->
+
+ <project basedir="composition/spi">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-composition-spi</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-system-spi"/>
+ <include key="dpml-composition-api"/>
+ <include key="dpml-logging-spi"/>
+ </dependencies>
+ </project>
+
+ <project basedir="composition/impl">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-composition-impl</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-transit-main" tag="api"/>
+ <include key="dpml-logging-api" tag="api"/>
+ <include key="dpml-activity-api" tag="api"/>
+ <include key="dpml-parameters-api" tag="api"/>
+ <include key="dpml-composition-api" tag="api"/>
+ <include key="dpml-configuration-api" tag="api"/>
+ <include key="dpml-service-api" tag="api"/>
+ <include key="dpml-meta-api" tag="api"/>
+ <include key="dpml-extension-api" tag="api"/>
+ <include key="dpml-composition-spi" tag="spi"/>
+ <include key="dpml-meta-spi" tag="spi"/>
+ <include key="dpml-configuration-impl"/>
+ <include key="dpml-meta-impl"/>
+ <include key="dpml-extension-api" tag="spi"/>
+ <include key="dpml-extension-impl"/>
+ <include key="dpml-util-exception"/>
+ <include key="dpml-context-impl"/>
+ <include key="dpml-util-criteria"/>
+ <include key="dpml-util-cli"/>
+ <include key="dpml-activation-impl" build="false"/>
+ <include key="dpml-test-playground" build="false"/>
+ </dependencies>
+ </project>
+
+ <project basedir="composition/test">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-composition-test</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-system-spi"/>
+ <include key="dpml-composition-spi"/>
+ <include key="dpml-composition-impl"/>
+ <include key="dpml-system-impl" test="false"/>
+ <include key="dpml-composition-impl" test="false"/>
+ <include key="dpml-util-exception"/>
+ <include key="dpml-test-testa" test="false"/>
+ <include key="dpml-test-testb" test="false"/>
+ <include key="dpml-test-testc" test="false"/>
+ <include key="dpml-test-testcyclic" test="false"/>
+ <include key="dpml-test-includes" test="false"/>
+ <include key="dpml-test-dynamics" test="false"/>
+ <include key="dpml-system-impl" build="false"/>
+ <include key="dpml-logging-logkit-impl" build="false"/>
+ <include key="dpml-test-testschema"/>
+ </dependencies>
+ </project>
+
+ <!-- Utitlities -->
+
+ <project basedir="util/defaults">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-util-defaults</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <type>jar</type>
+ </info>
+ </project>
+
+ <!-- Extension -->
+
+ <!-- System -->
+
+ <project basedir="system/api">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-system-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-transit-main" tag="api"/>
+ </dependencies>
+ </project>
+
+ <project basedir="system/spi">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-system-spi</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-context-api"/>
+ <include key="dpml-logging-spi"/>
+ <include key="dpml-transit-main"/>
+ </dependencies>
+ </project>
+
+ <project basedir="system/impl">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-system-impl</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-system-spi" tag="spi"/>
+ <include key="dpml-context-impl"/>
+ <include key="dpml-util-criteria"/>
+ <include key="dpml-util-defaults"/>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-util-cli"/>
+ </dependencies>
+ </project>
+
+ <project basedir="system/test">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-system-test</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-system-spi"/>
+ <include key="dpml-system-impl" build="false"/>
+ </dependencies>
+ </project>
+
+ <!-- Logging -->
+
+ <project basedir="logging/data">
+ <info>
+ <group>dpml/metro/protected</group>
+ <name>dpml-logging-data</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ </project>
+
+ <project basedir="logging/spi">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-logging-spi</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-api" tag="api"/>
+ <include key="dpml-logging-data" tag="api"/>
+ <include key="dpml-system-api" tag="api"/>
+ <include key="dpml-transit-main" tag="api"/>
+ </dependencies>
+ </project>
+
+ <project basedir="logging/criteria">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-logging-criteria</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-spi"/>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-util-criteria"/>
+ <include key="dpml-util-defaults"/>
+ </dependencies>
+ </project>
+
+ <project basedir="logging/providers/log4j/impl">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-logging-log4j</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-spi" tag="spi"/>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-logging-criteria"/>
+ <include key="dpml-configuration-api"/>
+ <include key="log4j"/>
+ </dependencies>
+ </project>
+
+ <project basedir="logging/providers/log4j/test">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-logging-log4j-test</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-logkit-api"/>
+ <include key="dpml-logging-log4j" test="false"/>
+ <include key="dpml-transit-main"/>
+ </dependencies>
+ </project>
+
+ <project basedir="logging/providers/logkit/api">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-logging-logkit-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-spi"/>
+ <include key="dpml-configuration-api"/>
+ </dependencies>
+ </project>
+
+ <project basedir="logging/providers/logkit/impl">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-logging-logkit-impl</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-transit-main" runtime="false" tag="api"/>
+ <include key="dpml-logging-spi" tag="spi"/>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-util-exception"/>
+ <include key="dpml-logging-criteria"/>
+ <include key="dpml-logging-logkit-api"/>
+ <include key="dpml-configuration-impl"/>
+ </dependencies>
+ </project>
+
+ <project basedir="logging/providers/logkit/plugins/datagram">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-logging-logkit-datagram</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-logging-logkit-impl"/>
+ <include key="dpml-configuration-impl"/>
+ </dependencies>
+ </project>
+
+ <project basedir="logging/providers/logkit/plugins/socket">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-logging-logkit-socket</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-logging-logkit-impl"/>
+ <include key="dpml-configuration-impl"/>
+ </dependencies>
+ </project>
+
+ <project basedir="logging/providers/logkit/plugins/syslog">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-logging-logkit-syslog</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-configuration-impl"/>
+ <include key="dpml-logging-logkit-api"/>
+ <include key="dpml-logging-logkit-datagram"/>
+ </dependencies>
+ </project>
+
+ <project basedir="logging/providers/logkit/test">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-logging-logkit-test</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-logkit-impl" build="false" test="false"/>
+ <include key="dpml-logging-logkit-datagram" build="false"
test="false"/>
+ <include key="dpml-logging-logkit-socket" build="false" test="false"/>
+ <include key="dpml-logging-logkit-syslog" build="false" test="false"/>
+ <include key="dpml-transit-main"/>
+ <include key="dpml-logging-logkit-api"/>
+ </dependencies>
+ </project>
+
+ <!--
+ DPML Activation.
+ -->
+
+ <project basedir="activation/api">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-activation-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-composition-spi"/>
+ </dependencies>
+ </project>
+
+ <project basedir="activation/providers/metro">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-activation-metro-provider</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-activation-api" tag="api"/>
+ <include key="dpml-activity-api" tag="api"/>
+ <include key="dpml-composition-api" tag="api"/>
+ <include key="dpml-composition-spi" tag="spi"/>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-util-defaults"/>
+ <include key="dpml-system-spi"/>
+ <include key="dpml-context-impl"/>
+ </dependencies>
+ </project>
+
+ <project basedir="activation/providers/avalon">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-activation-avalon-provider</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-activity-api" tag="api"/>
+ <include key="dpml-composition-api" tag="api"/>
+ <include key="avalon-framework-api" tag="api"/>
+ <include key="dpml-activation-api" tag="api"/>
+ <include key="dpml-system-spi" tag="spi"/>
+ <include key="dpml-composition-spi" tag="spi"/>
+ <include key="avalon-util-lifecycle" tag="api"/>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-util-defaults"/>
+ <include key="dpml-context-impl"/>
+ <include key="dpml-parameters-impl"/>
+ <include key="avalon-framework-impl"/>
+ </dependencies>
+ </project>
+
+ <project basedir="activation/impl">
+ <info>
+ <group>dpml/metro/private</group>
+ <name>dpml-activation-impl</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-transit-main" tag="api"/>
+ <include key="dpml-activation-api" tag="api"/>
+ <include key="dpml-composition-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"/>
+ </dependencies>
+ </project>
+
+ <project basedir="activation/test">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-activation-test</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-composition-test"/>
+ <include key="dpml-activation-impl"/>
+ <include key="dpml-test-components"/>
+ </dependencies>
+ </project>
+
+ <!--
+ Metro Test.
+ -->
+
+ <project basedir="testing/dynamics">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-test-dynamics</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-service-api"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="testing/playground">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-test-playground</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-context-api"/>
+ <include key="dpml-configuration-api"/>
+ <include key="dpml-service-api"/>
+ <include key="dpml-activity-api"/>
+ <include key="dpml-composition-api"/>
+ <include key="dpml-context-impl"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="testing/testa">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-test-testa</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-activity-api"/>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-context-api"/>
+ <include key="dpml-configuration-api"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="testing/testb">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-test-testb</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-activity-api"/>
+ <include key="dpml-logging-api"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="testing/testc">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-test-testc</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-test-testa"/>
+ <include key="dpml-test-testb"/>
+ <include key="dpml-activity-api"/>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-service-api"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="testing/testd">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-test-testd</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-test-testa"/>
+ <include key="dpml-activity-api"/>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-service-api"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="testing/teste">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-test-teste</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-test-testa"/>
+ <include key="dpml-activity-api"/>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-service-api"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="testing/testcyclic">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-test-testcyclic</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-service-api"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="testing/testschema">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-test-testschema</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-configuration-api"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="testing/includes">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-test-includes</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-test-playground" build="false" runtime="false"/>
+ <include key="dpml-test-testa" build="false" runtime="false"/>
+ <include key="dpml-test-testb" build="false" runtime="false"/>
+ <include key="dpml-test-testc" build="false" runtime="false"/>
+ <include key="dpml-test-testd" build="false" runtime="false"/>
+ <include key="dpml-test-teste" build="false" runtime="false"/>
+ </dependencies>
+ </project>
+
+ <project basedir="testing/components">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-test-components</name>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-context-api"/>
+ <include key="dpml-service-api"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+
+ <!-- EXTERNAL RESOURCES -->
+
+ <resource>
+ <info>
+ <group>qdox</group>
+ <name>qdox</name>
+ <version>1.4</version>
+ <type>jar</type>
+ </info>
+ </resource>
+
+ <resource>
+ <info>
+ <group>log4j</group>
+ <name>log4j</name>
+ <version>1.2.8</version>
+ <type>jar</type>
+ </info>
+ <gump>
+ <alias>logging-log4j-12</alias>
+ </gump>
+ </resource>
+
+ <resource>
+ <info>
+ <group>qdox</group>
+ <name>qdox</name>
+ <version>1.4</version>
+ <type>jar</type>
+ </info>
+ </resource>
+
+ <resource>
+ <info>
+ <group>avalon-framework</group>
+ <name>avalon-framework-api</name>
+ <version>4.2.0</version>
+ </info>
+ </resource>
+
+ <resource>
+ <info>
+ <group>avalon-framework</group>
+ <name>avalon-framework-impl</name>
+ <version>4.2.0</version>
+ </info>
+ </resource>
+
+ <resource>
+ <info>
+ <group>avalon/util</group>
+ <name>avalon-util-lifecycle</name>
+ <version>1.1.1</version>
+ </info>
+ </resource>
+
+
+</index>

Modified: development/main/metro/main/build.xml
==============================================================================
--- development/main/metro/main/build.xml (original)
+++ development/main/metro/main/build.xml Fri Dec 24 22:19:23 2004
@@ -1,68 +1,68 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-metro-main" default="install" basedir="."
- xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
-
- <magic:import uri="artifact:template:dpml/magic/standard"/>
-
- <target name="init" depends="standard.init">
- <x:filter feature="plugin" token="METRO-PLUGIN-URI"/>
- <x:filter feature="plugin" key="dpml-system-impl"
token="SYSTEM-PLUGIN-URI"/>
- <x:filter feature="plugin" key="dpml-composition-impl"
token="COMPOSITION-IMPL-ARTIFACT-URI"/>
- <x:filter feature="plugin" key="dpml-activation-impl"
token="RUNTIME-IMPL-ARTIFACT-URI"/>
- <x:filter feature="version" key="dpml-transit-main"
token="TRANSIT_VERSION"/>
- </target>
-
- <target name="package" depends="standard.package">
- <x:export class="net.dpml.metro.Metro"/>
- </target>
-
- <target name="install" depends="bin,update,standard.install"/>
-
- <target name="update" depends="package">
- <x:replicate/>
- <copy todir="target/replicate/${project.group}/jars">
- <fileset dir="target/deliverables/jars">
- <include name="${project.filename}"/>
- </fileset>
- </copy>
- </target>
-
- <target name="bin" depends="prepare">
- <mkdir dir="${dpml.home}/bin"/>
- <copy todir="${dpml.home}/bin">
- <fileset dir="target/deliverables/bin"/>
- </copy>
- <chmod file="${dpml.home}/bin/metro" perm="755"/>
- <chmod file="${dpml.home}/bin/transit" perm="755"/>
- <chmod dir="${dpml.home}/bin" includes="*.sh" perm="755"/>
- </target>
-
- <!--
- <target name="binary" depends="package-system">
- <property name="project.zip" value="${project.short-filename}.zip"/>
- <mkdir dir="target/deliverables/dist"/>
- <zip zipfile="target/deliverables/dist/${project.zip}">
- <zipfileset dir="target/deliverables" prefix="metro" filemode="755" >
- <include name="bin/metro"/>
- <include name="bin/transit"/>
- <include name="bin/*.sh"/>
- </zipfileset>
- <zipfileset dir="target/deliverables" prefix="metro">
- <include name="bin/**" />
- <include name="config/**" />
- <include name="lib/**" />
- <exclude name="jars/**"/>
- <exclude name="dist/**"/>
- <exclude name="bin/metro"/>
- <exclude name="bin/transit"/>
- <exclude name="bin/*.sh"/>
- </zipfileset>
- <zipfileset dir="target/replicate" prefix="metro/system">
- <include name="**" />
- </zipfileset>
- </zip>
- </target>
- -->
-
-</project>
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-metro-main" default="install" basedir="."
+ xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
+
+ <magic:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="init" depends="standard.init">
+ <x:filter feature="plugin" token="METRO-PLUGIN-URI"/>
+ <x:filter feature="plugin" key="dpml-system-impl"
token="SYSTEM-PLUGIN-URI"/>
+ <x:filter feature="plugin" key="dpml-composition-impl"
token="COMPOSITION-IMPL-ARTIFACT-URI"/>
+ <x:filter feature="plugin" key="dpml-activation-impl"
token="RUNTIME-IMPL-ARTIFACT-URI"/>
+ <x:filter feature="version" key="dpml-transit-main"
token="TRANSIT_VERSION"/>
+ </target>
+
+ <target name="package" depends="standard.package">
+ <x:export class="net.dpml.metro.Metro"/>
+ </target>
+
+ <target name="install" depends="bin,update,standard.install"/>
+
+ <target name="update" depends="package">
+ <x:replicate/>
+ <copy todir="target/replicate/${project.group}/jars">
+ <fileset dir="target/deliverables/jars">
+ <include name="${project.filename}"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="bin" depends="prepare">
+ <mkdir dir="${dpml.home}/bin"/>
+ <copy todir="${dpml.home}/bin">
+ <fileset dir="target/deliverables/bin"/>
+ </copy>
+ <chmod file="${dpml.home}/bin/metro" perm="755"/>
+ <chmod file="${dpml.home}/bin/transit" perm="755"/>
+ <chmod dir="${dpml.home}/bin" includes="*.sh" perm="755"/>
+ </target>
+
+ <!--
+ <target name="binary" depends="package-system">
+ <property name="project.zip" value="${project.short-filename}.zip"/>
+ <mkdir dir="target/deliverables/dist"/>
+ <zip zipfile="target/deliverables/dist/${project.zip}">
+ <zipfileset dir="target/deliverables" prefix="metro" filemode="755" >
+ <include name="bin/metro"/>
+ <include name="bin/transit"/>
+ <include name="bin/*.sh"/>
+ </zipfileset>
+ <zipfileset dir="target/deliverables" prefix="metro">
+ <include name="bin/**" />
+ <include name="config/**" />
+ <include name="lib/**" />
+ <exclude name="jars/**"/>
+ <exclude name="dist/**"/>
+ <exclude name="bin/metro"/>
+ <exclude name="bin/transit"/>
+ <exclude name="bin/*.sh"/>
+ </zipfileset>
+ <zipfileset dir="target/replicate" prefix="metro/system">
+ <include name="**" />
+ </zipfileset>
+ </zip>
+ </target>
+ -->
+
+</project>

Modified:
development/main/metro/main/src/main/net/dpml/metro/Resources.properties
==============================================================================
--- development/main/metro/main/src/main/net/dpml/metro/Resources.properties
(original)
+++ development/main/metro/main/src/main/net/dpml/metro/Resources.properties
Fri Dec 24 22:19:23 2004
@@ -1,16 +1,16 @@
-
-url=url
-directory=directory
-file=file
-artifact=artifact
-host=host
-
-cli-language-description=A two-letter language code.
-cli-help-description=Prints this message.
-cli-version-description=Print version information.
-cli-load-description=A uri of a single plugin artifact to be executed by the
controller.
-cli-get-description=A comma separated sequence of artifact uris to load into
the local cache.
-
-cli-server-description=Run the controller as a server (default)
-cli-execute-description=On completion of deployment initiate a shutdown.
-cli-avalon-description=Include the avalon component api in the root
container classloader.
+
+url=url
+directory=directory
+file=file
+artifact=artifact
+host=host
+
+cli-language-description=A two-letter language code.
+cli-help-description=Prints this message.
+cli-version-description=Print version information.
+cli-load-description=A uri of a single plugin artifact to be executed by the
controller.
+cli-get-description=A comma separated sequence of artifact uris to load into
the local cache.
+
+cli-server-description=Run the controller as a server (default)
+cli-execute-description=On completion of deployment initiate a shutdown.
+cli-avalon-description=Include the avalon component api in the root
container classloader.

Modified: development/main/metro/system/impl/build.xml
==============================================================================
--- development/main/metro/system/impl/build.xml (original)
+++ development/main/metro/system/impl/build.xml Fri Dec 24 22:19:23
2004
@@ -1,17 +1,17 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-system-impl" default="install" basedir="."
- xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
-
- <magic:import uri="artifact:template:dpml/magic/standard"/>
-
- <target name="init" depends="standard.init">
- <x:filter key="dpml-logging-logkit-impl" feature="plugin"
token="DEFAULT_LOGGING_PLUGIN"/>
- <x:filter feature="plugin" token="SYSTEM_PLUGIN_URI"/>
- </target>
-
- <target name="package" depends="standard.package">
- <x:export class="net.dpml.system.impl.DefaultSystemContextFactory"/>
- </target>
-
-</project>
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-system-impl" default="install" basedir="."
+ xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
+
+ <magic:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="init" depends="standard.init">
+ <x:filter key="dpml-logging-logkit-impl" feature="plugin"
token="DEFAULT_LOGGING_PLUGIN"/>
+ <x:filter feature="plugin" token="SYSTEM_PLUGIN_URI"/>
+ </target>
+
+ <target name="package" depends="standard.package">
+ <x:export class="net.dpml.system.impl.DefaultSystemContextFactory"/>
+ </target>
+
+</project>

Modified:
development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContext.java
==============================================================================
---
development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContext.java
(original)
+++
development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContext.java
Fri Dec 24 22:19:23 2004
@@ -1,313 +1,313 @@
-/*
- * 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.system.impl;
-
-import java.io.File;
-import java.util.Properties;
-
-import net.dpml.context.impl.DefaultContext;
-import net.dpml.logging.Logger;
-import net.dpml.logging.provider.LoggingManager;
-import net.dpml.system.SystemContext;
-
-import net.dpml.transit.repository.Repository;
-
-
-/**
- * The system context class provides access to a logging manager,
- * repository, working and temporary directories, and system level flags and
- * services supporting the deployment of plugins.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class DefaultSystemContext extends DefaultContext implements
SystemContext
-{
- //
------------------------------------------------------------------------
- // immutable state
- //
------------------------------------------------------------------------
-
- private final File m_home;
- private final File m_dir;
- private final File m_anchor;
- private final File m_temp;
- private final boolean m_info;
- private final boolean m_debug;
- private final Logger m_logger;
- private final LoggingManager m_logging;
- private final Repository m_repository;
- private final boolean m_isolate;
- private final String[] m_remainder;
- private final Properties m_properties;
-
- //
------------------------------------------------------------------------
- // constructors
- //
------------------------------------------------------------------------
-
- DefaultSystemContext(
- final Repository repository, final LoggingManager logging,
- final Logger logger, final File home, final File work, final File
anchor, final File temp,
- final boolean info, final boolean debug, final boolean isolate,
String[] remainder, Properties properties )
- {
- super();
- assertNotNull( "repository", repository );
- assertNotNull( "logging", logging );
- assertNotNull( "logger", logger );
- assertNotNull( "home", home );
- assertNotNull( "work", work );
- assertNotNull( "anchor", anchor );
- assertNotNull( "temp", temp );
- assertNotNull( "properties", properties );
-
- logger.debug( "system context initialization" );
-
- m_repository = repository;
- m_logging = logging;
- m_logger = logger;
- m_home = home;
- m_dir = work;
- m_anchor = anchor;
- m_temp = temp;
- m_info = info;
- m_debug = debug;
- m_isolate = isolate;
- m_remainder = remainder;
- m_properties = properties;
-
- }
-
- //
------------------------------------------------------------------------
- // SystemContext
- //
------------------------------------------------------------------------
-
- public boolean getInfoMode()
- {
- return m_info;
- }
-
- public boolean getDebugMode()
- {
- return m_debug;
- }
-
- /**
- * Return the application home directory.
- *
- * @return the home directory
- */
- public File getHomeDirectory()
- {
- return m_home;
- }
-
- /**
- * Return the library anchor directory.
- *
- * @return the anchor directory
- */
- public File getAnchorDirectory()
- {
- return m_anchor;
- }
-
-
- /**
- * Return the working directory from which containers may establish
- * persistent content between sessions.
- *
- * @return the working directory
- */
- public File getWorkingDirectory()
- {
- return m_dir;
- }
-
- /**
- * Return the temp directory from which containers may establish
- * transient non-persistent content.
- *
- * @return the temp directory
- */
- public File getTempDirectory()
- {
- return m_temp;
- }
-
- /**
- * Return the info status flag. If TRUE plugins should list information
- * concerning initialization parameters during establishment.
- *
- * @return the info policy flag
- */
- public boolean getInfoPolicy()
- {
- return m_info;
- }
-
- /**
- * Return the system logging channel.
- *
- * @return the system logging channel.
- */
- public Logger getLogger()
- {
- return m_logger;
- }
-
- /**
- * Return the system wide logging manager.
- *
- * @return the logging manager.
- */
- public LoggingManager getLoggingManager()
- {
- return m_logging;
- }
-
- /**
- * Return the application repository cache controller.
- *
- * @return the repository
- */
- public Repository getRepository()
- {
- return m_repository;
- }
-
- /**
- * Return the system proxy enablement flag.
- *
- * @return the proxy flag
- */
- public boolean isProxyEnabled()
- {
- return m_isolate;
- }
-
- /**
- * Return the unprocessed command line arguments.
- *
- * @return the remaining cli arguments
- */
- public String[] getArgs()
- {
- return m_remainder;
- }
-
- /**
- * Return the application properties.
- *
- * @return the properties
- */
- public Properties getProperties()
- {
- return m_properties;
- }
-
- /**
- * Prepare a string representation of an object for presentation.
- * @param object the object to parse
- * @return the presentation string
- */
- public String toString( Object object )
- {
- if( object == null ) return "";
-
- if( object instanceof String )
- {
- return processString( (String) object );
- }
- else
- {
- return processString( object.toString() );
- }
- }
-
- /**
- * Prepare a string representation of an object array for presentation.
- * @param objects the array of objects
- * @return the presentation string
- */
- public String toString( Object[] objects )
- {
- StringBuffer buffer = new StringBuffer();
- for( int i=0; i<objects.length; i++ )
- {
- if( i > 0 ) buffer.append( ";" );
- buffer.append( toString( objects[i] ) );
- }
- return buffer.toString();
- }
-
- //
------------------------------------------------------------------------
- // internal
- //
------------------------------------------------------------------------
-
- /**
- * Prepare a string representation of an object for presentation.
- * @param name the value to parse
- * @return the presentation string
- */
- private String processString( String name )
- {
- if( name == null ) return "";
-
- String str = name.replace( '\\', '/' );
-
- String base = getWorkingDirectory().toString().replace( '\\', '/' );
- if( str.indexOf( base ) > -1 )
- {
- return getString( str, base, "${merlin.dir}" );
- }
-
- final String dir =
- System.getProperty( "user.dir" ).replace( '\\', '/' );
- if( str.indexOf( dir ) > -1 )
- {
- return getString( str, dir, "${user.dir}" );
- }
-
- return name;
- }
-
- private String getString( String name, String pattern, String
replacement )
- {
- final int n = name.indexOf( pattern );
- if( n == -1 ) return name;
- if( name.startsWith( pattern ) )
- {
- return replacement + name.substring( pattern.length() );
- }
- else
- {
- String header = name.substring( 0, n );
- String tail = name.substring( n + pattern.length() );
- return header + replacement + tail;
- }
- }
-
- private void assertNotNull( String key, Object instance )
- {
- if( null == instance )
- {
- throw new NullPointerException( key );
- }
- }
-}
-
+/*
+ * 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.system.impl;
+
+import java.io.File;
+import java.util.Properties;
+
+import net.dpml.context.impl.DefaultContext;
+import net.dpml.logging.Logger;
+import net.dpml.logging.provider.LoggingManager;
+import net.dpml.system.SystemContext;
+
+import net.dpml.transit.repository.Repository;
+
+
+/**
+ * The system context class provides access to a logging manager,
+ * repository, working and temporary directories, and system level flags and
+ * services supporting the deployment of plugins.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class DefaultSystemContext extends DefaultContext implements
SystemContext
+{
+ //
------------------------------------------------------------------------
+ // immutable state
+ //
------------------------------------------------------------------------
+
+ private final File m_home;
+ private final File m_dir;
+ private final File m_anchor;
+ private final File m_temp;
+ private final boolean m_info;
+ private final boolean m_debug;
+ private final Logger m_logger;
+ private final LoggingManager m_logging;
+ private final Repository m_repository;
+ private final boolean m_isolate;
+ private final String[] m_remainder;
+ private final Properties m_properties;
+
+ //
------------------------------------------------------------------------
+ // constructors
+ //
------------------------------------------------------------------------
+
+ DefaultSystemContext(
+ final Repository repository, final LoggingManager logging,
+ final Logger logger, final File home, final File work, final File
anchor, final File temp,
+ final boolean info, final boolean debug, final boolean isolate,
String[] remainder, Properties properties )
+ {
+ super();
+ assertNotNull( "repository", repository );
+ assertNotNull( "logging", logging );
+ assertNotNull( "logger", logger );
+ assertNotNull( "home", home );
+ assertNotNull( "work", work );
+ assertNotNull( "anchor", anchor );
+ assertNotNull( "temp", temp );
+ assertNotNull( "properties", properties );
+
+ logger.debug( "system context initialization" );
+
+ m_repository = repository;
+ m_logging = logging;
+ m_logger = logger;
+ m_home = home;
+ m_dir = work;
+ m_anchor = anchor;
+ m_temp = temp;
+ m_info = info;
+ m_debug = debug;
+ m_isolate = isolate;
+ m_remainder = remainder;
+ m_properties = properties;
+
+ }
+
+ //
------------------------------------------------------------------------
+ // SystemContext
+ //
------------------------------------------------------------------------
+
+ public boolean getInfoMode()
+ {
+ return m_info;
+ }
+
+ public boolean getDebugMode()
+ {
+ return m_debug;
+ }
+
+ /**
+ * Return the application home directory.
+ *
+ * @return the home directory
+ */
+ public File getHomeDirectory()
+ {
+ return m_home;
+ }
+
+ /**
+ * Return the library anchor directory.
+ *
+ * @return the anchor directory
+ */
+ public File getAnchorDirectory()
+ {
+ return m_anchor;
+ }
+
+
+ /**
+ * Return the working directory from which containers may establish
+ * persistent content between sessions.
+ *
+ * @return the working directory
+ */
+ public File getWorkingDirectory()
+ {
+ return m_dir;
+ }
+
+ /**
+ * Return the temp directory from which containers may establish
+ * transient non-persistent content.
+ *
+ * @return the temp directory
+ */
+ public File getTempDirectory()
+ {
+ return m_temp;
+ }
+
+ /**
+ * Return the info status flag. If TRUE plugins should list information
+ * concerning initialization parameters during establishment.
+ *
+ * @return the info policy flag
+ */
+ public boolean getInfoPolicy()
+ {
+ return m_info;
+ }
+
+ /**
+ * Return the system logging channel.
+ *
+ * @return the system logging channel.
+ */
+ public Logger getLogger()
+ {
+ return m_logger;
+ }
+
+ /**
+ * Return the system wide logging manager.
+ *
+ * @return the logging manager.
+ */
+ public LoggingManager getLoggingManager()
+ {
+ return m_logging;
+ }
+
+ /**
+ * Return the application repository cache controller.
+ *
+ * @return the repository
+ */
+ public Repository getRepository()
+ {
+ return m_repository;
+ }
+
+ /**
+ * Return the system proxy enablement flag.
+ *
+ * @return the proxy flag
+ */
+ public boolean isProxyEnabled()
+ {
+ return m_isolate;
+ }
+
+ /**
+ * Return the unprocessed command line arguments.
+ *
+ * @return the remaining cli arguments
+ */
+ public String[] getArgs()
+ {
+ return m_remainder;
+ }
+
+ /**
+ * Return the application properties.
+ *
+ * @return the properties
+ */
+ public Properties getProperties()
+ {
+ return m_properties;
+ }
+
+ /**
+ * Prepare a string representation of an object for presentation.
+ * @param object the object to parse
+ * @return the presentation string
+ */
+ public String toString( Object object )
+ {
+ if( object == null ) return "";
+
+ if( object instanceof String )
+ {
+ return processString( (String) object );
+ }
+ else
+ {
+ return processString( object.toString() );
+ }
+ }
+
+ /**
+ * Prepare a string representation of an object array for presentation.
+ * @param objects the array of objects
+ * @return the presentation string
+ */
+ public String toString( Object[] objects )
+ {
+ StringBuffer buffer = new StringBuffer();
+ for( int i=0; i<objects.length; i++ )
+ {
+ if( i > 0 ) buffer.append( ";" );
+ buffer.append( toString( objects[i] ) );
+ }
+ return buffer.toString();
+ }
+
+ //
------------------------------------------------------------------------
+ // internal
+ //
------------------------------------------------------------------------
+
+ /**
+ * Prepare a string representation of an object for presentation.
+ * @param name the value to parse
+ * @return the presentation string
+ */
+ private String processString( String name )
+ {
+ if( name == null ) return "";
+
+ String str = name.replace( '\\', '/' );
+
+ String base = getWorkingDirectory().toString().replace( '\\', '/' );
+ if( str.indexOf( base ) > -1 )
+ {
+ return getString( str, base, "${merlin.dir}" );
+ }
+
+ final String dir =
+ System.getProperty( "user.dir" ).replace( '\\', '/' );
+ if( str.indexOf( dir ) > -1 )
+ {
+ return getString( str, dir, "${user.dir}" );
+ }
+
+ return name;
+ }
+
+ private String getString( String name, String pattern, String
replacement )
+ {
+ final int n = name.indexOf( pattern );
+ if( n == -1 ) return name;
+ if( name.startsWith( pattern ) )
+ {
+ return replacement + name.substring( pattern.length() );
+ }
+ else
+ {
+ String header = name.substring( 0, n );
+ String tail = name.substring( n + pattern.length() );
+ return header + replacement + tail;
+ }
+ }
+
+ private void assertNotNull( String key, Object instance )
+ {
+ if( null == instance )
+ {
+ throw new NullPointerException( key );
+ }
+ }
+}
+

Modified:
development/main/metro/system/impl/src/main/net/dpml/system/impl/Resources.properties
==============================================================================
---
development/main/metro/system/impl/src/main/net/dpml/system/impl/Resources.properties
(original)
+++
development/main/metro/system/impl/src/main/net/dpml/system/impl/Resources.properties
Fri Dec 24 22:19:23 2004
@@ -1,32 +1,32 @@
-
-url=url
-directory=directory
-file=file
-artifact=artifact
-uri=uri
-host=host
-
-cli-fast-description=Disables timestamp checking (default).
-cli-snapshot-description=Restricts timestamp evaluation to snapshot
artifacts.
-cli-timestamp-description=Enable timestamp evaluation on all artifacts.
-cli-overwrite-description=Force downloading of resources when remote content
is available.
-
-cli-offline-description=Disable remote connections.
-cli-online-description=Enable remote connections (default).
-
-cli-proxy-description=Enable isolation of services via proxy (default)
-cli-noproxy-description=Disable proxy based service isolation.
-
-cli-server-description=Run the controller as a server (default)
-cli-execute-description=On completion of deployment initiate a shutdown.
-
-cli-debug-description=Enables debug mode.
-cli-info-description=Lists info about the controller context.
-
-cli-logging-description=An artifact uri identifying a logging manager
factory.
-
-cli-dir-description=A relative or absolute path to a working directory. If
not supplied, the system will default to the current directory.
-cli-temp-description=A relative or absolute path to a temporary directory.
-
-cli-cache-description=An absolute or relative path to a cache directory.
-cli-hosts-description=A comma separated sequence of remote host urls.
+
+url=url
+directory=directory
+file=file
+artifact=artifact
+uri=uri
+host=host
+
+cli-fast-description=Disables timestamp checking (default).
+cli-snapshot-description=Restricts timestamp evaluation to snapshot
artifacts.
+cli-timestamp-description=Enable timestamp evaluation on all artifacts.
+cli-overwrite-description=Force downloading of resources when remote content
is available.
+
+cli-offline-description=Disable remote connections.
+cli-online-description=Enable remote connections (default).
+
+cli-proxy-description=Enable isolation of services via proxy (default)
+cli-noproxy-description=Disable proxy based service isolation.
+
+cli-server-description=Run the controller as a server (default)
+cli-execute-description=On completion of deployment initiate a shutdown.
+
+cli-debug-description=Enables debug mode.
+cli-info-description=Lists info about the controller context.
+
+cli-logging-description=An artifact uri identifying a logging manager
factory.
+
+cli-dir-description=A relative or absolute path to a working directory. If
not supplied, the system will default to the current directory.
+cli-temp-description=A relative or absolute path to a temporary directory.
+
+cli-cache-description=An absolute or relative path to a cache directory.
+cli-hosts-description=A comma separated sequence of remote host urls.

Modified: development/main/metro/testing/cli/build.xml
==============================================================================
--- development/main/metro/testing/cli/build.xml (original)
+++ development/main/metro/testing/cli/build.xml Fri Dec 24 22:19:23
2004
@@ -1,13 +1,13 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-metro-test" default="install" basedir="."
- xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
-
- <magic:import uri="artifact:template:dpml/magic/standard"/>
-
- <target name="init" depends="standard.init">
- <x:filter feature="plugin" key="dpml-metro-cli" token="METRO-CLI-SPEC"/>
- <x:filter feature="block" key="dpml-test-playground"
token="PLAYGROUND-SPEC"/>
- </target>
-
-</project>
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-metro-test" default="install" basedir="."
+ xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
+
+ <magic:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="init" depends="standard.init">
+ <x:filter feature="plugin" key="dpml-metro-cli" token="METRO-CLI-SPEC"/>
+ <x:filter feature="block" key="dpml-test-playground"
token="PLAYGROUND-SPEC"/>
+ </target>
+
+</project>

Modified: development/main/metro/testing/cli/etc/test/metro.properties
==============================================================================
--- development/main/metro/testing/cli/etc/test/metro.properties
(original)
+++ development/main/metro/testing/cli/etc/test/metro.properties Fri
Dec 24 22:19:23 2004
@@ -1 +1 @@
-dpml.debug = true
+dpml.debug = true

Modified:
development/main/metro/testing/cli/src/test/net/dpml/metro/test/MetroTestCase.java
==============================================================================
---
development/main/metro/testing/cli/src/test/net/dpml/metro/test/MetroTestCase.java
(original)
+++
development/main/metro/testing/cli/src/test/net/dpml/metro/test/MetroTestCase.java
Fri Dec 24 22:19:23 2004
@@ -1,80 +1,80 @@
-/*
- * Copyright 2004 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.metro.test;
-
-import java.net.URI;
-
-import junit.framework.TestCase;
-import net.dpml.exception.ExceptionHelper;
-import net.dpml.transit.artifact.Artifact;
-import net.dpml.transit.repository.Repository;
-import net.dpml.transit.repository.StandardLoader;
-
-/**
- * SystemContextFactoryTestCase
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class MetroTestCase extends TestCase
-{
- private Throwable m_error = null;
-
- protected void setUp()
- {
- try
- {
- setUpMetro();
- }
- catch( Throwable e )
- {
- m_error = e;
- }
- }
-
- protected void setUpMetro() throws Exception
- {
- Repository repository = new StandardLoader();
-
- //
- // create the metro plugin
- //
-
- String[] args =
- new String[]{
- "-info", "-execute", "@PLAYGROUND-SPEC@" };
-
- URI uri = Artifact.createArtifact( "@METRO-CLI-SPEC@" ).toURI();
- Artifact artifact = Artifact.createArtifact( uri );
- ClassLoader classloader = MetroTestCase.class.getClassLoader();
- repository.getPlugin( classloader, artifact, new Object[]{ args } );
- System.gc();
- }
-
- public void testMetroCLIDeployment()
- {
- if( null != m_error )
- {
- final String message = "Test failure.";
- final String error = ExceptionHelper.packException( message,
m_error, true );
- System.out.println( error );
- fail( error );
- }
- }
-}
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.metro.test;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+import net.dpml.exception.ExceptionHelper;
+import net.dpml.transit.artifact.Artifact;
+import net.dpml.transit.repository.Repository;
+import net.dpml.transit.repository.StandardLoader;
+
+/**
+ * SystemContextFactoryTestCase
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class MetroTestCase extends TestCase
+{
+ private Throwable m_error = null;
+
+ protected void setUp()
+ {
+ try
+ {
+ setUpMetro();
+ }
+ catch( Throwable e )
+ {
+ m_error = e;
+ }
+ }
+
+ protected void setUpMetro() throws Exception
+ {
+ Repository repository = new StandardLoader();
+
+ //
+ // create the metro plugin
+ //
+
+ String[] args =
+ new String[]{
+ "-info", "-execute", "@PLAYGROUND-SPEC@" };
+
+ URI uri = Artifact.createArtifact( "@METRO-CLI-SPEC@" ).toURI();
+ Artifact artifact = Artifact.createArtifact( uri );
+ ClassLoader classloader = MetroTestCase.class.getClassLoader();
+ repository.getPlugin( classloader, artifact, new Object[]{ args } );
+ System.gc();
+ }
+
+ public void testMetroCLIDeployment()
+ {
+ if( null != m_error )
+ {
+ final String message = "Test failure.";
+ final String error = ExceptionHelper.packException( message,
m_error, true );
+ System.out.println( error );
+ fail( error );
+ }
+ }
+}

Modified: development/main/metro/testing/testschema/build.xml
==============================================================================
--- development/main/metro/testing/testschema/build.xml (original)
+++ development/main/metro/testing/testschema/build.xml Fri Dec 24 22:19:23
2004
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-test-testschema" default="install" basedir="."
- xmlns:magic="antlib:net.dpml.magic">
-
- <magic:import uri="artifact:template:dpml/magic/standard"/>
-
-</project>
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-test-testschema" default="install" basedir="."
+ xmlns:magic="antlib:net.dpml.magic">
+
+ <magic:import uri="artifact:template:dpml/magic/standard"/>
+
+</project>

Modified: development/main/metro/unit/build.xml
==============================================================================
--- development/main/metro/unit/build.xml (original)
+++ development/main/metro/unit/build.xml Fri Dec 24 22:19:23 2004
@@ -1,26 +1,26 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-metro-unit" default="install" basedir="."
- xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
-
- <magic:import uri="artifact:template:dpml/magic/standard"/>
-
- <target name="init" depends="standard.init">
- <x:filter feature="plugin" key="dpml-composition-impl"
token="COMPOSITION_PLUGIN_URI"/>
- <x:filter feature="plugin" key="dpml-system-impl"
token="SYSTEM-PLUGIN-URI"/>
- </target>
-
- <target name="documentation" depends="install">
- <x:property name="mdoc.spec" feature="plugin" key="dpml-magic-mdoc"/>
- <magic:plugin uri="${mdoc.spec}">
- <task class="net.dpml.magic.mdoc.ModuleDocTask" name="doc"/>
- </magic:plugin>
- <doc>
- <link href="http://java.sun.com/j2se/1.4/docs/api"/>
- <link href="http://www.dpml.net/asf/ant/1.6.2/api"/>
- <link href="http://www.dpml.net/junit/junit/3.8.1/api"/>
- <link host="http://www.dpml.net"; key="dpml-metro-protected"/>
- </doc>
- </target>
-
-</project>
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-metro-unit" default="install" basedir="."
+ xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
+
+ <magic:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="init" depends="standard.init">
+ <x:filter feature="plugin" key="dpml-composition-impl"
token="COMPOSITION_PLUGIN_URI"/>
+ <x:filter feature="plugin" key="dpml-system-impl"
token="SYSTEM-PLUGIN-URI"/>
+ </target>
+
+ <target name="documentation" depends="install">
+ <x:property name="mdoc.spec" feature="plugin" key="dpml-magic-mdoc"/>
+ <magic:plugin uri="${mdoc.spec}">
+ <task class="net.dpml.magic.mdoc.ModuleDocTask" name="doc"/>
+ </magic:plugin>
+ <doc>
+ <link href="http://java.sun.com/j2se/1.4/docs/api"/>
+ <link href="http://www.dpml.net/asf/ant/1.6.2/api"/>
+ <link href="http://www.dpml.net/junit/junit/3.8.1/api"/>
+ <link host="http://www.dpml.net"; key="dpml-metro-protected"/>
+ </doc>
+ </target>
+
+</project>

Modified: development/main/transit/plugin/build.xml
==============================================================================
--- development/main/transit/plugin/build.xml (original)
+++ development/main/transit/plugin/build.xml Fri Dec 24 22:19:23 2004
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>

-<project name="dpml-transit-plugin" default="bin" basedir="."
+<project name="dpml-transit-plugin" default="dist" basedir="."
xmlns:magic="antlib:net.dpml.magic"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >

<magic:import uri="artifact:template:dpml/magic/standard"/>
@@ -35,4 +35,20 @@
<chmod dir="${dpml.home}/bin" includes="*.sh" perm="755"/>
</target>

+ <target name="dist" depends="bin">
+ <jar
jarfile="${basedir}/target/deliverables/jars/dpml-transit-LATEST.jar" >
+ <fileset dir="${dpml.home}" >
+ <include name="bin/**" />
+ <include name="bin/transit*" />
+ <include name="bin/internal*" />
+ <include name="bin/security.policy" />
+ <include name="transit/**" />
+ <include name="docs/dpml/transit/**" />
+ </fileset>
+ <fileset dir="${user.home}" >
+ <include name=".ant/lib/dpml-transit-main.jar" />
+ </fileset>
+ </jar>
+ </target>
+
</project>

Modified: development/main/util/cli/build.xml
==============================================================================
--- development/main/util/cli/build.xml (original)
+++ development/main/util/cli/build.xml Fri Dec 24 22:19:23 2004
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<project name="dpml-util-cli" default="install" basedir="."
- xmlns:magic="antlib:net.dpml.magic">
-
- <magic:import uri="artifact:template:dpml/magic/standard"/>
-
-</project>
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-util-cli" default="install" basedir="."
+ xmlns:magic="antlib:net.dpml.magic">
+
+ <magic:import uri="artifact:template:dpml/magic/standard"/>
+
+</project>

Modified: development/main/util/cli/src/main/net/dpml/cli/ArgumentHandler.java
==============================================================================
--- development/main/util/cli/src/main/net/dpml/cli/ArgumentHandler.java
(original)
+++ development/main/util/cli/src/main/net/dpml/cli/ArgumentHandler.java
Fri Dec 24 22:19:23 2004
@@ -1,215 +1,215 @@
-/*
- * 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.cli;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.cli.MissingArgumentException;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-
-/**
- * Command line parser that handles the establishment of metro cli options
- * and separation of supplimentary parameters.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class ArgumentHandler
-{
- /**
- * The complete arguments.
- */
- private final String[] m_args;
-
- /**
- * Creation of a new argument splitter.
- * @param args the commandline args
- */
- public ArgumentHandler( String[] args )
- {
- m_args = args;
- }
-
- /**
- * Split the arguments into a pair based on the supplied options arugment.
- * @param options the options argument
- * @return a pair instance holding the selection of arguments based on
the
- * supplied options and the remaining argument as a separate sequence
- * @exception ParseException is an error occurs
- */
- public Pair split( Options options )
- throws ParseException
- {
- ArrayList arguments = new ArrayList();
- for( int j=0; j < m_args.length; j++ )
- {
- arguments.add( m_args[j] );
- }
-
- List local = new ArrayList();
-
- Option[] opts = (Option[]) options.getOptions().toArray( new
Option[0] );
- for( int i=0; i < opts.length; i++ )
- {
- Option option = opts[i];
- processOption( option, arguments, local );
- }
-
- String[] selection = (String[]) local.toArray( new String[0] );
- String[] remainder = (String[]) arguments.toArray( new String[0] );
- return new Pair( selection, remainder );
- }
-
- /**
- * Utility datatype holding a selection sequence and a remainder sequence.
- */
- public class Pair
- {
- /**
- * The validated selection.
- */
- private final String[] m_selection;
-
- /**
- * Remaining arguments.
- */
- private final String[] m_remainder;
-
- /**
- * Creation of a new pair instance.
- * @param selection the validated args sequence
- * @param remainder the remaining args
- */
- Pair( String[] selection, String[] remainder )
- {
- m_selection = selection;
- m_remainder = remainder;
- }
-
- /**
- * Return the validated args selection.
- * @return the selected args sequence
- */
- public String[] getSelection()
- {
- return m_selection;
- }
-
- /**
- * Return the remaining non-valid args selection.
- * @return the remaining args sequence
- */
- public String[] getRemainder()
- {
- return m_remainder;
- }
- }
-
- /**
- * Process a list of arguments against a set of valid options.
- * @param option the option to validate against
- * @param arguments the list arguments
- * @param local the local list
- * @exception ParseException is an error occurs
- */
- private void processOption( Option option, List arguments, List local )
- throws ParseException
- {
- int n = lookup( option, arguments );
- if( n > -1 )
- {
- extract( option, n, getSpan( option ), arguments, local );
- }
- }
-
- /**
- * Return the number of arguments that the option represents
- * @param option the commandline option
- * @return the span
- */
- private int getSpan( Option option )
- {
- if( option.getArgs() == -1 )
- {
- return 1;
- }
- else
- {
- return 1 + option.getArgs();
- }
- }
-
- /**
- * Extract the set of arguments representing an option.
- * @param option the option to extract
- * @param index the starting index
- * @param size the option span
- * @param arguments the list of cli arguments
- * @param local the processed arguments
- * @exception ParseException is an error occurs
- */
- private void extract( Option option, int index, int size, List
arguments, List local )
- throws ParseException
- {
- for( int i=0; i < size; i++ )
- {
- String arg = (String) arguments.get( index );
- if( i == 0 )
- {
- local.add( arg );
- }
- else
- {
- if( arg.startsWith( "-" ) )
- {
- final String error =
- "Commandline option ["
- + option.getOpt()
- + "] contains a missing argument (expected "
- + ( size - 1 )
- + " but found "
- + i
- + ").";
- throw new MissingArgumentException( error );
- }
- else
- {
- local.add( arg );
- }
- }
- arguments.remove( index );
- }
- }
-
- /**
- * Lookup the position of an option in a list of arguments.
- * @param option the commandline option
- * @param arguments the list of arguments
- * @return the position
- */
- private int lookup( Option option, List arguments )
- {
- String name = "-" + option.getOpt();
- return arguments.indexOf( name );
- }
-}
-
+/*
+ * 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.cli;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.cli.MissingArgumentException;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+
+/**
+ * Command line parser that handles the establishment of metro cli options
+ * and separation of supplimentary parameters.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class ArgumentHandler
+{
+ /**
+ * The complete arguments.
+ */
+ private final String[] m_args;
+
+ /**
+ * Creation of a new argument splitter.
+ * @param args the commandline args
+ */
+ public ArgumentHandler( String[] args )
+ {
+ m_args = args;
+ }
+
+ /**
+ * Split the arguments into a pair based on the supplied options arugment.
+ * @param options the options argument
+ * @return a pair instance holding the selection of arguments based on
the
+ * supplied options and the remaining argument as a separate sequence
+ * @exception ParseException is an error occurs
+ */
+ public Pair split( Options options )
+ throws ParseException
+ {
+ ArrayList arguments = new ArrayList();
+ for( int j=0; j < m_args.length; j++ )
+ {
+ arguments.add( m_args[j] );
+ }
+
+ List local = new ArrayList();
+
+ Option[] opts = (Option[]) options.getOptions().toArray( new
Option[0] );
+ for( int i=0; i < opts.length; i++ )
+ {
+ Option option = opts[i];
+ processOption( option, arguments, local );
+ }
+
+ String[] selection = (String[]) local.toArray( new String[0] );
+ String[] remainder = (String[]) arguments.toArray( new String[0] );
+ return new Pair( selection, remainder );
+ }
+
+ /**
+ * Utility datatype holding a selection sequence and a remainder sequence.
+ */
+ public class Pair
+ {
+ /**
+ * The validated selection.
+ */
+ private final String[] m_selection;
+
+ /**
+ * Remaining arguments.
+ */
+ private final String[] m_remainder;
+
+ /**
+ * Creation of a new pair instance.
+ * @param selection the validated args sequence
+ * @param remainder the remaining args
+ */
+ Pair( String[] selection, String[] remainder )
+ {
+ m_selection = selection;
+ m_remainder = remainder;
+ }
+
+ /**
+ * Return the validated args selection.
+ * @return the selected args sequence
+ */
+ public String[] getSelection()
+ {
+ return m_selection;
+ }
+
+ /**
+ * Return the remaining non-valid args selection.
+ * @return the remaining args sequence
+ */
+ public String[] getRemainder()
+ {
+ return m_remainder;
+ }
+ }
+
+ /**
+ * Process a list of arguments against a set of valid options.
+ * @param option the option to validate against
+ * @param arguments the list arguments
+ * @param local the local list
+ * @exception ParseException is an error occurs
+ */
+ private void processOption( Option option, List arguments, List local )
+ throws ParseException
+ {
+ int n = lookup( option, arguments );
+ if( n > -1 )
+ {
+ extract( option, n, getSpan( option ), arguments, local );
+ }
+ }
+
+ /**
+ * Return the number of arguments that the option represents
+ * @param option the commandline option
+ * @return the span
+ */
+ private int getSpan( Option option )
+ {
+ if( option.getArgs() == -1 )
+ {
+ return 1;
+ }
+ else
+ {
+ return 1 + option.getArgs();
+ }
+ }
+
+ /**
+ * Extract the set of arguments representing an option.
+ * @param option the option to extract
+ * @param index the starting index
+ * @param size the option span
+ * @param arguments the list of cli arguments
+ * @param local the processed arguments
+ * @exception ParseException is an error occurs
+ */
+ private void extract( Option option, int index, int size, List
arguments, List local )
+ throws ParseException
+ {
+ for( int i=0; i < size; i++ )
+ {
+ String arg = (String) arguments.get( index );
+ if( i == 0 )
+ {
+ local.add( arg );
+ }
+ else
+ {
+ if( arg.startsWith( "-" ) )
+ {
+ final String error =
+ "Commandline option ["
+ + option.getOpt()
+ + "] contains a missing argument (expected "
+ + ( size - 1 )
+ + " but found "
+ + i
+ + ").";
+ throw new MissingArgumentException( error );
+ }
+ else
+ {
+ local.add( arg );
+ }
+ }
+ arguments.remove( index );
+ }
+ }
+
+ /**
+ * Lookup the position of an option in a list of arguments.
+ * @param option the commandline option
+ * @param arguments the list of arguments
+ * @return the position
+ */
+ private int lookup( Option option, List arguments )
+ {
+ String name = "-" + option.getOpt();
+ return arguments.indexOf( name );
+ }
+}
+

Modified:
development/main/util/criteria/src/main/net/dpml/criteria/URLParameter.java
==============================================================================
---
development/main/util/criteria/src/main/net/dpml/criteria/URLParameter.java
(original)
+++
development/main/util/criteria/src/main/net/dpml/criteria/URLParameter.java
Fri Dec 24 22:19:23 2004
@@ -1,101 +1,101 @@
-/*
- * 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.criteria;
-
-import java.io.File;
-import java.net.URL;
-
-/**
- * A parameter descriptor that supports transformation of a
- * a string url to an URL instance.
- *
- * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
- * @version $Id$
- */
-public class URLParameter extends Parameter
-{
- //--------------------------------------------------------------
- // constructors
- //--------------------------------------------------------------
-
- /**
- * Transform a string to a string array.
- * @param key the parameter key
- */
- public URLParameter( final String key )
- {
- super( key, URL.class );
- }
-
- /**
- * Resolve a supplied string to a configuration
- * @param value the value to resolve
- * @return the resolved value
- * @exception CriteriaException if an error occurs
- */
- public Object resolve( Object value )
- throws CriteriaException
- {
- if( value == null )
- {
- return null;
- }
- if( value instanceof URL )
- {
- return value;
- }
- else if( value instanceof String )
- {
- return resolve( super.resolve( URL.class, value ) );
- }
- else if( value instanceof File )
- {
- File file = (File) value;
- if( !file.exists() )
- {
- final String error =
- "Parameter argument ["
- + getKey()
- + "] references an unknown file location ["
- + file.toString()
- + "].";
- throw new CriteriaException( error );
- }
- else
- {
- try
- {
- return file.toURL();
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error while attempting to convert the file
["
- + file.toString()
- + " to a url.";
- throw new CriteriaException( error, e );
- }
- }
- }
- else
- {
- return super.resolve( value );
- }
- }
-}
+/*
+ * 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.criteria;
+
+import java.io.File;
+import java.net.URL;
+
+/**
+ * A parameter descriptor that supports transformation of a
+ * a string url to an URL instance.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id$
+ */
+public class URLParameter extends Parameter
+{
+ //--------------------------------------------------------------
+ // constructors
+ //--------------------------------------------------------------
+
+ /**
+ * Transform a string to a string array.
+ * @param key the parameter key
+ */
+ public URLParameter( final String key )
+ {
+ super( key, URL.class );
+ }
+
+ /**
+ * Resolve a supplied string to a configuration
+ * @param value the value to resolve
+ * @return the resolved value
+ * @exception CriteriaException if an error occurs
+ */
+ public Object resolve( Object value )
+ throws CriteriaException
+ {
+ if( value == null )
+ {
+ return null;
+ }
+ if( value instanceof URL )
+ {
+ return value;
+ }
+ else if( value instanceof String )
+ {
+ return resolve( super.resolve( URL.class, value ) );
+ }
+ else if( value instanceof File )
+ {
+ File file = (File) value;
+ if( !file.exists() )
+ {
+ final String error =
+ "Parameter argument ["
+ + getKey()
+ + "] references an unknown file location ["
+ + file.toString()
+ + "].";
+ throw new CriteriaException( error );
+ }
+ else
+ {
+ try
+ {
+ return file.toURL();
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Unexpected error while attempting to convert the file
["
+ + file.toString()
+ + " to a url.";
+ throw new CriteriaException( error, e );
+ }
+ }
+ }
+ else
+ {
+ return super.resolve( value );
+ }
+ }
+}



  • svn commit: r1288 - in development/main: . central/site/src/docs/about/community/people magic/core magic/spells/cruisecontrol/etc/main metro metro/activation/impl/src/main/net/dpml/activation/impl metro/activation/providers/avalon metro/activation/providers/avalon/src/main/net/dpml/activation/avalon metro/activation/providers/metro metro/activation/providers/metro/src/main/net/dpml/activation/metro metro/activation/test metro/activation/test/etc/test metro/activation/test/src/test/net/dpml/activation/impl/test metro/composition/impl/etc/main metro/composition/impl/src/main/net/dpml/composition/model/impl metro/composition/impl/src/main/net/dpml/composition/util metro/composition/spi/src/main/net/dpml/composition/provider metro/composition/test/etc/test metro/composition/test/src/main/net/dpml/composition/test metro/composition/test/src/test/net/dpml/composition/util metro/main metro/main/src/main/net/dpml/metro metro/system/impl metro/system/impl/etc/test metro/system/impl/src/main/net/dpml/system/impl metro/testing/cli metro/testing/cli/etc/test metro/testing/cli/src/test/net/dpml/metro/test metro/testing/testschema metro/testing/testschema/src/main/net/dpml/test/testschema metro/unit transit/plugin util/cli util/cli/src/main/net/dpml/cli util/criteria/src/main/net/dpml/criteria, niclas, 12/24/2004

Archive powered by MHonArc 2.6.24.

Top of Page