Skip to Content.
Sympa Menu

notify-dpml - r1170 - in trunk/main/transit: . console/etc/bin core core/etc/test core/src/main/net/dpml/lang core/src/main/net/dpml/part core/src/main/net/dpml/transit core/src/main/net/dpml/transit/artifact core/src/main/net/dpml/transit/info core/src/test core/src/test/net/dpml core/src/test/net/dpml/part core/src/test/net/dpml/transit core/src/test/net/dpml/transit/info core/src/test/net/dpml/transit/test tools tools/src/main/net/dpml/transit/tools

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1170 - in trunk/main/transit: . console/etc/bin core core/etc/test core/src/main/net/dpml/lang core/src/main/net/dpml/part core/src/main/net/dpml/transit core/src/main/net/dpml/transit/artifact core/src/main/net/dpml/transit/info core/src/test core/src/test/net/dpml core/src/test/net/dpml/part core/src/test/net/dpml/transit core/src/test/net/dpml/transit/info core/src/test/net/dpml/transit/test tools tools/src/main/net/dpml/transit/tools
  • Date: Tue, 14 Mar 2006 17:00:07 +0100

Author: mcconnell
Date: 2006-03-14 16:59:54 +0100 (Tue, 14 Mar 2006)
New Revision: 1170

Added:
trunk/main/transit/core/etc/test/plugin.xml
trunk/main/transit/core/etc/test/resource.xml
trunk/main/transit/core/src/main/net/dpml/lang/Builder.java
trunk/main/transit/core/src/main/net/dpml/lang/BuilderException.java
trunk/main/transit/core/src/main/net/dpml/lang/DefaultType.java
trunk/main/transit/core/src/main/net/dpml/lang/Type.java
trunk/main/transit/core/src/main/net/dpml/part/AbstractBuilder.java
trunk/main/transit/core/src/main/net/dpml/part/DOM3DocumentBuilder.java
trunk/main/transit/core/src/main/net/dpml/part/DOMDocumentBuilder.java
trunk/main/transit/core/src/main/net/dpml/part/DOMInput.java
trunk/main/transit/core/src/main/net/dpml/part/Info.java
trunk/main/transit/core/src/main/net/dpml/part/Part.java
trunk/main/transit/core/src/main/net/dpml/part/PartBuilder.java
trunk/main/transit/core/src/main/net/dpml/part/PartDirective.java
trunk/main/transit/core/src/main/net/dpml/part/PartHandlerFactory.java
trunk/main/transit/core/src/main/net/dpml/part/PartStrategyBuilder.java
trunk/main/transit/core/src/main/net/dpml/part/PartStrategyWriter.java
trunk/main/transit/core/src/main/net/dpml/part/PartWriter.java
trunk/main/transit/core/src/main/net/dpml/part/Plugin.java
trunk/main/transit/core/src/main/net/dpml/part/Resource.java
trunk/main/transit/core/src/main/net/dpml/part/Strategy.java
trunk/main/transit/core/src/main/net/dpml/part/StrategyBuilder.java

trunk/main/transit/core/src/main/net/dpml/part/UnresolvableHandlerException.java
trunk/main/transit/core/src/main/net/dpml/part/ValueBuilder.java
trunk/main/transit/core/src/main/net/dpml/part/ValueWriter.java
trunk/main/transit/core/src/test/net/dpml/part/
trunk/main/transit/core/src/test/net/dpml/part/PartTestCase.java
Removed:
trunk/main/transit/bootstrap.xml
trunk/main/transit/common.properties
trunk/main/transit/core/src/main/net/dpml/lang/Handler.java
trunk/main/transit/core/src/main/net/dpml/lang/Plugin.java
trunk/main/transit/core/src/main/net/dpml/lang/PluginFactory.java
trunk/main/transit/core/src/main/net/dpml/lang/Strategy.java
trunk/main/transit/core/src/main/net/dpml/transit/ConstructBeanInfo.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultPlugin.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultPluginBuilder.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultPluginFactory.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultStrategy.java
trunk/main/transit/core/src/main/net/dpml/transit/StandardHandler.java

trunk/main/transit/core/src/main/net/dpml/transit/info/ValueDirectiveBeanInfo.java
trunk/main/transit/core/src/test/net/dpml/transit/PluginTestCase.java
trunk/main/transit/core/src/test/plugin.properties
Modified:
trunk/main/transit/console/etc/bin/transit.lap
trunk/main/transit/core/build.properties
trunk/main/transit/core/build.xml
trunk/main/transit/core/src/main/net/dpml/lang/Classpath.java
trunk/main/transit/core/src/main/net/dpml/part/PartHandler.java
trunk/main/transit/core/src/main/net/dpml/part/StandardPartHandler.java
trunk/main/transit/core/src/main/net/dpml/transit/Construct.java
trunk/main/transit/core/src/main/net/dpml/transit/Repository.java

trunk/main/transit/core/src/main/net/dpml/transit/SecuredTransitContext.java
trunk/main/transit/core/src/main/net/dpml/transit/StandardLoader.java
trunk/main/transit/core/src/main/net/dpml/transit/Value.java

trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactURLConnection.java

trunk/main/transit/core/src/test/net/dpml/transit/info/AbstractTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/CacheDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/CodeBaseDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/ContentDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/HostDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/LayoutDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/ProxyDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/TransitDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/ValueDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/test/AbstractEncodingTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/test/ConstructTestCase.java
trunk/main/transit/module.xml
trunk/main/transit/tools/build.properties

trunk/main/transit/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
trunk/main/transit/tools/src/main/net/dpml/transit/tools/PluginTask.java

trunk/main/transit/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
trunk/main/transit/tools/src/main/net/dpml/transit/tools/TransitTask.java
Log:
update transit to include aspects the normalize part management

Deleted: trunk/main/transit/bootstrap.xml
===================================================================
--- trunk/main/transit/bootstrap.xml 2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/bootstrap.xml 2006-03-14 15:59:54 UTC (rev 1170)
@@ -1,483 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Copyright 2004 Stephen J McConnell
- Copyright 2004 Niclas Hedhman
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied.
-
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<project name="bootstrap">
-
- <tstamp/>
-
- <!--
- Environment setup.
- -->
-
- <property environment="ENV"/>
-
- <property file="${user.home}/ant.properties"/>
- <property file="${basedir}/user.properties"/>
- <property file="${home}/user.properties"/>
- <property file="${basedir}/build.properties"/>
- <property file="${home}/common.properties"/>
-
- <property name="junit.url"
value="http://repository.dpml.net/classic/junit/jars/junit-3.8.1.jar"/>
-
- <condition property="dpml.appdata.declared" value="true">
- <isset property="ENV.APPDATA"/>
- </condition>
-
- <condition property="dpml.home.declared" value="true">
- <isset property="ENV.DPML_HOME"/>
- </condition>
-
- <condition property="dpml.system.declared" value="true">
- <isset property="ENV.DPML_SYSTEM"/>
- </condition>
-
- <condition property="gpg.declared" value="true">
- <isset property="project.gpg.exe"/>
- </condition>
-
- <condition property="isWindows" value="true">
- <os family="windows"/>
- </condition>
-
- <target name="setup" depends="dpml-setup,junit-setup"/>
-
- <target name="dpml-setup"
depends="dpml-home,dpml-data,dpml-prefs,dpml-system"/>
-
- <target name="dpml-home-environment" if="dpml.home.declared">
- <property name="dpml.home" location="${ENV.DPML_HOME}"/>
- </target>
-
- <target name="dpml-appdata-environment" depends="dpml-home-environment"
unless="dpml.home.declared" if="dpml.appdata.declared">
- <property name="dpml.home" location="${ENV.APPDATA}/DPML"/>
- </target>
-
- <target name="dpml-home-default" depends="dpml-appdata-environment"
unless="dpml.home.declared">
- <property name="dpml.home" location="${user.home}/.dpml"/>
- </target>
-
- <target name="dpml-home" depends="dpml-home-default">
- <mkdir dir="${dpml.home}"/>
- </target>
-
- <target name="dpml-data" depends="dpml-home">
- <property name="dpml.data" location="${dpml.home}/data"/>
- <echo>$${dpml.data} set to ${dpml.data}</echo>
- <mkdir dir="${dpml.data}"/>
- <property name="dpml.local.cache" location="${dpml.data}/cache"/>
- <property name="dpml.docs" location="${dpml.data}/docs"/>
- <property name="dpml.logs" location="${dpml.data}/logs"/>
- <echo>$${dpml.local.cache} set to ${dpml.local.cache}</echo>
- <echo>$${dpml.docs} set to ${dpml.docs}</echo>
- <echo>$${dpml.logs} set to ${dpml.logs}</echo>
- <mkdir dir="${dpml.local.cache}"/>
- <mkdir dir="${dpml.docs}"/>
- <mkdir dir="${dpml.logs}"/>
- <available property="junit.cache.available"
file="${dpml.local.cache}/junit/jars/${junit.filename}"/>
- </target>
-
- <target name="dpml-prefs" depends="dpml-home">
- <property name="dpml.prefs" location="${dpml.home}/prefs"/>
- <mkdir dir="${dpml.prefs}"/>
- </target>
-
- <target name="dpml-system-environment" if="dpml.system.declared">
- <property name="dpml.system" location="${ENV.DPML_SYSTEM}"/>
- </target>
-
- <target name="dpml-system" depends="dpml-system-environment,dpml-home">
- <property name="dpml.system" location="${dpml.home}/share"/>
- <mkdir dir="${dpml.system}"/>
- </target>
-
- <target name="junit-download" depends="dpml-data"
unless="junit.cache.available">
- <mkdir dir="${dpml.local.cache}/junit/jars"/>
- <get src="${junit.url}" usetimestamp="true"
dest="${dpml.local.cache}/junit/jars/${junit.filename}"/>
- </target>
-
- <target name="junit-test" depends="junit-download">
- <available property="junit.available"
file="${user.home}/.ant/lib/junit.jar"/>
- </target>
-
- <target name="junit-setup" depends="junit-test" unless="junit.available">
- <property name="junit.url"
value="${dpml.repository}/junit/jars/${junit.filename}"/>
- <echo>
-#----------------------------------------------------------------------------------
-# Installing JUnit
-#----------------------------------------------------------------------------------
- </echo>
- <mkdir dir="${dpml.local.cache}/junit/jars"/>
- <get src="${junit.url}" usetimestamp="true"
dest="${dpml.local.cache}/junit/jars/${junit.filename}"/>
- <mkdir dir="${user.home}/.ant/lib"/>
- <copy tofile="${user.home}/.ant/lib/junit.jar"
file="${dpml.local.cache}/junit/jars/${junit.filename}"/>
- <echo>
-#----------------------------------------------------------------------------------
-# The build procedure has updated the contents of the .ant/lib directory.
In order
-# to include the junit file within ant's classloader please restart the
build.
-#----------------------------------------------------------------------------------
- </echo>
- <fail status="99" message="Ant lib updated (restart may be required)."/>
- </target>
-
- <!-- project setup -->
-
- <property name="project.name" value="UNKNOWN"/>
- <property name="project.type" value="jar"/>
- <property name="project.dir" location="${basedir}/target/test"/>
-
- <condition property="signature.declared" value="true">
- <isset property="build.signature"/>
- </condition>
-
- <property name="src" value="src"/>
- <property name="src.main" value="main"/>
- <property name="src.main.dir" value="${src}/${src.main}"/>
- <property name="src.test" value="test"/>
- <property name="src.test.dir" value="${src}/${src.test}"/>
-
- <property name="etc" value="etc"/>
- <property name="etc.main" value="${etc}/main"/>
- <property name="etc.deliverables" value="${etc}/deliverables"/>
- <property name="etc.test" value="${etc}/test"/>
-
- <property name="target" value="target"/>
- <property name="target.dir" location="${basedir}/${target}"/>
-
- <property name="target.build.dir" location="${target.dir}/build"/>
- <property name="target.build.test.dir"
location="${target.build.dir}/test"/>
- <property name="target.build.main.dir"
location="${target.build.dir}/main"/>
-
- <property name="target.classes.dir" location="${target.dir}/classes/main"/>
- <property name="target.test-classes.dir"
location="${target.dir}/classes/test"/>
- <property name="target.test-reports.dir"
location="${target.dir}/reports/test"/>
- <property name="target.test.dir" location="${target.dir}/test"/>
-
- <property name="target.deliverables.dir"
location="${target.dir}/deliverables"/>
- <property name="target.deliverables.jars.dir"
location="${target.deliverables.dir}/jars"/>
-
- <target name="setupReleaseFilename" if="signature.declared">
- <property name="project.version" value="${build.signature}"/>
- </target>
-
- <target name="init" depends="setup,setupReleaseFilename">
- <property name="project.version" value="SNAPSHOT"/>
- <property name="build.signature" value="SNAPSHOT"/>
- <property name="project.filename"
value="${project.name}-${project.version}.${project.type}"/>
- <property name="dpml-transit-handler.filename"
value="dpml-transit-main-${project.version}.jar"/>
- <echo>
-#----------------------------------------------------------------------------------
-# ${project.group}/${project.name}#${project.version}
-#----------------------------------------------------------------------------------
- </echo>
- <filter value="${project.version}" token="PROJECT-VERSION"/>
- <filter value="http://www.dpml.net"; token="PUBLISHER-URL"/>
- <filter value="The Digital Product Meta Library" token="PUBLISHER-NAME"/>
- </target>
-
- <target name="setup-path" depends="init">
- <path id="project.main.path">
- <pathelement location="${ENV.ANT_HOME}/lib/ant.jar"/>
- <pathelement location="${target.classes.dir}"/>
- </path>
- <path id="project.test.path">
- <path refid="project.main.path"/>
- <pathelement location="${ENV.ANT_HOME}/lib/ant-junit.jar"/>
- <pathelement
location="${dpml.local.cache}/junit/jars/${junit.filename}"/>
- </path>
- </target>
-
- <available file="${etc.deliverables}"
property="etc.deliverables.available"/>
- <target name="prepare-etc-deliverable" if="etc.deliverables.available">
- <mkdir dir="${target.deliverables.dir}"/>
- <copy toDir="${target.deliverables.dir}" filtering="on"
failonerror="false">
- <fileset dir="${etc.deliverables}">
- <include name="**/*"/>
- </fileset>
- </copy>
- </target>
-
- <available file="${etc.main}" property="etc.main.available"/>
- <target name="prepare-etc-main" if="etc.main.available">
- <mkdir dir="${target.build.main.dir}"/>
- <copy toDir="${target.build.main.dir}" filtering="on"
failonerror="false">
- <fileset dir="${etc.main}">
- <include name="**/*"/>
- <exclude name="**/*.jpg"/>
- <exclude name="**/*.jpeg"/>
- <exclude name="**/*.png"/>
- <exclude name="**/*.gif"/>
- </fileset>
- </copy>
- <copy toDir="${target.build.main.dir}" filtering="off"
failonerror="false">
- <fileset dir="${etc.main}">
- <include name="**/*.jpg"/>
- <include name="**/*.jpeg"/>
- <include name="**/*.png"/>
- <include name="**/*.gif"/>
- </fileset>
- </copy>
- </target>
-
- <available file="${etc.test}" property="etc.test.available"/>
- <target name="prepare-etc-test" if="etc.test.available">
- <!--
- Any files in etc/test get copied over to target/test with filtering
- applied.
- -->
- <mkdir dir="${target.test.dir}"/>
- <copy toDir="${target.test.dir}" filtering="on" failonerror="false">
- <fileset dir="${etc.test}">
- <include name="**/*"/>
- <exclude name="**/*.jar"/>
- </fileset>
- </copy>
- <copy toDir="${target.test.dir}" filtering="off" failonerror="false">
- <fileset dir="${etc.test}">
- <include name="**/*.jar"/>
- </fileset>
- </copy>
- </target>
-
- <available file="${etc}" property="etc.available"/>
- <target name="prepare-etc" depends="init" if="etc.available">
- <!--
- Any files in etc excluding test, main and deliverables get copied over to
- the target directory.
- -->
- <copy toDir="${target.dir}" filtering="on" failonerror="false">
- <fileset dir="${etc}">
- <exclude name="${etc.main}/*"/>
- <exclude name="${etc.test}/*"/>
- <exclude name="${etc.deliverables}/*"/>
- </fileset>
- </copy>
- </target>
-
- <available file="${src.main.dir}" property="src.main.available"/>
- <target name="prepare-src-main" depends="setup" if="src.main.available">
- <!--
- Any files in src/main get copied over to target/build/main with filtering
- applied.
- -->
- <mkdir dir="${target.build.main.dir}"/>
- <copy toDir="${target.build.main.dir}" filtering="on"
failonerror="false">
- <fileset dir="${src.main.dir}">
- <include name="**/*"/>
- <exclude name="**/*.gif"/>
- <exclude name="**/*.png"/>
- <exclude name="**/*.jpeg"/>
- <exclude name="**/*.jpg"/>
- </fileset>
- </copy>
- <copy toDir="${target.build.main.dir}" filtering="off"
failonerror="false">
- <fileset dir="${src.main.dir}">
- <include name="**/*.gif"/>
- <include name="**/*.png"/>
- <include name="**/*.jpeg"/>
- <include name="**/*.jpg"/>
- </fileset>
- </copy>
- </target>
-
- <available file="${src.test.dir}" property="src.test.available"/>
- <target name="prepare-src-test" if="src.test.available">
- <!--
- Any files in src/test get copied over to target/build/test with filtering
- applied.
- -->
- <mkdir dir="${target.build.test.dir}"/>
- <copy toDir="${target.build.test.dir}" filtering="on"
failonerror="false">
- <fileset dir="${src.test.dir}">
- <include name="**/*"/>
- <exclude name="**/*.gif"/>
- <exclude name="**/*.png"/>
- <exclude name="**/*.jpeg"/>
- <exclude name="**/*.jpg"/>
- </fileset>
- </copy>
- <copy toDir="${target.build.test.dir}" filtering="off"
failonerror="false">
- <fileset dir="${src.test.dir}">
- <include name="**/*.gif"/>
- <include name="**/*.png"/>
- <include name="**/*.jpeg"/>
- <include name="**/*.jpg"/>
- </fileset>
- </copy>
- </target>
-
- <target name="prepare-build-main" if="src.main.available">
- <!--
- Create the target/classes directory and copy into it anything from
target/build/main
- that isn't a java source file.
- -->
- <mkdir dir="${target.classes.dir}"/>
- <copy toDir="${target.classes.dir}" failonerror="false">
- <fileset dir="${target.build.main.dir}">
- <exclude name="**/*.java"/>
- </fileset>
- </copy>
- </target>
-
- <target name="prepare-build-test" if="src.test.available">
- <!--
- Create the target/test-classes directory and copy into it anything from
target/build/test
- that isn't a java source file.
- -->
- <mkdir dir="${target.test-classes.dir}"/>
- <copy toDir="${target.test-classes.dir}" failonerror="false">
- <fileset dir="${target.build.test.dir}">
- <exclude name="**/*.java"/>
- </fileset>
- </copy>
- </target>
-
- <target name="prepare"
depends="init,prepare-etc-deliverable,prepare-etc-main,
- prepare-etc-test,prepare-etc, prepare-src-main, prepare-src-test,
- prepare-build-main, prepare-build-test">
- <tstamp/>
- </target>
-
- <target name="build.setup" depends="prepare" if="src.main.available">
- <available file="${target.build.main.dir}"
property="build.main.available"/>
- </target>
-
- <target name="build" depends="build.setup,setup-path"
if="build.main.available">
- <!--
- Compile sources in target/build/main with oputput classes under
target/classes.
- -->
- <javac srcdir="${target.build.main.dir}" destdir="${target.classes.dir}"
debug="true"
- source="1.4" target="1.4">
- <classpath refid="project.main.path"/>
- </javac>
- </target>
-
- <target name="package.setup" depends="build" if="src.main.available">
- <available file="${target.classes.dir}"
property="target.classes.available"/>
- </target>
-
- <target name="package" depends="jar.asc"/>
-
- <target name="jar" depends="package.setup" if="target.classes.available">
- <mkdir dir="${target.deliverables.jars.dir}"/>
- <jar destfile="${target.deliverables.jars.dir}/${project.filename}"
- basedir="${target.classes.dir}"
- includes="**/*.class,**/*.xml,**/*.properties,**/*.dtd"
- excludes="**/*.html,**/*.gif,**/*.png">
- <manifest>
- <attribute name="Created-By" value="The Digital Product Meta
Library."/>
- <attribute name="Built-By" value="${user.name}"/>
- <attribute name="Extension-Name" value="${project.name}"/>
- <attribute name="Specification-Vendor" value="DPML"/>
- <attribute name="Specification-Version"
value="${project.specification.version}"/>
- <attribute name="Implementation-Vendor" value="DPML"/>
- <attribute name="Implementation-Vendor-Id" value="net.dpml"/>
- <attribute name="Implementation-Version"
value="${project.version}"/>
- </manifest>
- </jar>
- <checksum fileext=".md5"
file="${target.deliverables.jars.dir}/${project.filename}"/>
- </target>
-
- <target name="jar.check" depends="jar">
- <available file="${target.deliverables.jars.dir}/${project.filename}"
property="jar.available"/>
- </target>
-
- <target name="jar.asc" depends="jar.check" if="jar.available">
- <antcall target="execute.jar.asc"/>
- </target>
-
- <target name="execute.jar.asc" if="gpg.declared">
- <echo message="Generating ASC"/>
- <delete file="${target.deliverables.jars.dir}/${project.filename}.asc"/>
- <exec executable="${project.gpg.exe}">
- <arg value="-a"/>
- <arg value="-b"/>
- <arg value="-o"/>
- <arg value="${target.deliverables.jars.dir}/${project.filename}.asc"/>
- <arg value="${target.deliverables.jars.dir}/${project.filename}"/>
- </exec>
- </target>
-
- <!--
- Compile the tests using the classes as the classpath and
- place results into the target/test-classes directory.
- -->
- <target name="build-tests" depends="package" if="src.test.available">
- <mkdir dir="${target.test-classes.dir}"/>
- <javac srcdir="${target.build.test.dir}"
- destdir="${target.test-classes.dir}"
- debug="true"
- source="1.4" target="1.4">
- <classpath refid="project.test.path"/>
- </javac>
- </target>
-
- <!--
- Execute any unit test.
- -->
- <target name="test" depends="build-tests" if="src.test.available">
- <mkdir dir="${target.test.dir}"/>
- <mkdir dir="${target.test-reports.dir}"/>
- <junit fork="true" dir="${basedir}"
- printsummary="yes"
- showoutput="true"
- haltonfailure="yes" failureproperty="junit.failure"
- haltonerror="yes" errorproperty="junit.error">
- <sysproperty key="build.signature" value="${build.signature}"/>
- <sysproperty key="project.test.dir" value="${target.test.dir}"/>
- <classpath>
- <path refid="project.test.path"/>
- <pathelement location="${target.test-classes.dir}"/>
- </classpath>
- <formatter type="plain"/>
- <formatter type="xml"/>
- <batchtest fork="yes" todir="${target.test-reports.dir}">
- <fileset dir="${target.build.test.dir}">
- <include name="**/*TestCase.java"/>
- <exclude name="**/Abstract*.java"/>
- </fileset>
- </batchtest>
- </junit>
- <!--
- <fail message="There were unittest failures." if="junit.failure" />
- <fail message="There were unittest errors." if="junit.error" />
- -->
- </target>
-
- <target name="install.setup" depends="test">
- <available file="${target.deliverables.dir}"
property="deliverables.available"/>
- </target>
-
- <target name="install" depends="install.setup" if="deliverables.available">
- <!--
- Install any deliverables under the project cache relative to the project
group path.
- -->
- <echo>Installing to: ${dpml.local.cache}/${project.group}</echo>
- <mkdir dir="${dpml.local.cache}/${project.group}"/>
- <copy toDir="${dpml.local.cache}/${project.group}" overwrite="true">
- <fileset dir="${target.deliverables.dir}"/>
- </copy>
- </target>
-
- <target name="clean">
- <delete dir="${target.dir}"/>
- </target>
-
-</project>
-
-

Deleted: trunk/main/transit/common.properties
===================================================================
--- trunk/main/transit/common.properties 2006-03-14 15:58:38 UTC (rev
1169)
+++ trunk/main/transit/common.properties 2006-03-14 15:59:54 UTC (rev
1170)
@@ -1,18 +0,0 @@
-
-dpml.repository = http://repository.dpml.net/classic
-
-junit.version = 3.8.1
-junit.filename = junit-${junit.version}.jar
-junit.uri = artifact:jar:junit/junit#${junit.version}
-junit.url = ${dpml.repository}/junit/jars/${junit.filename}
-
-transit-ant.version = 1.6.5
-transit-ant.filename = ant-${transit-ant.version}.jar
-transit-ant.parent = ant/jars
-transit-ant.path = ${transit-ant.parent}/${transit-ant.filename}
-ant.uri = artifact:jar:ant/ant#${transit-ant.version}
-
-ant.junit.filename = ant-junit-${transit-ant.version}.jar
-ant.junit.uri = artifact:jar:ant/ant-junit#${transit-ant.version}
-
-

Modified: trunk/main/transit/console/etc/bin/transit.lap
===================================================================
--- trunk/main/transit/console/etc/bin/transit.lap 2006-03-14 15:58:38
UTC (rev 1169)
+++ trunk/main/transit/console/etc/bin/transit.lap 2006-03-14 15:59:54
UTC (rev 1170)
@@ -4,6 +4,7 @@

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

Modified: trunk/main/transit/core/build.properties
===================================================================
--- trunk/main/transit/core/build.properties 2006-03-14 15:58:38 UTC (rev
1169)
+++ trunk/main/transit/core/build.properties 2006-03-14 15:59:54 UTC (rev
1170)
@@ -1,5 +1,5 @@

-home = ..
+home = ../..
project.test.fork = true
project.jar.main.class=net.dpml.transit.Main
project.specification.version = 1.0

Modified: trunk/main/transit/core/build.xml
===================================================================
--- trunk/main/transit/core/build.xml 2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/build.xml 2006-03-14 15:59:54 UTC (rev 1170)
@@ -37,13 +37,11 @@
</target>

<target name="init" depends="bootstrap.init">
+ <property name="part.xsd.version" value="${project.version}"/>
+ <filter token="PART-XSD-URI"
value="artifact:xsd:dpml/lang/dpml-part#${dpml.xsd.version}"/>
<filter token="PROJECT-NAME" value="${project.name}"/>
<filter token="PROJECT-GROUP" value="${project.group}"/>
<filter token="PROJECT-VERSION" value="${project.version}"/>
- <filter token="PROJECT-URI"
-
value="artifact:plugin:dpml/transit/dpml-transit-main#${project.version}"/>
- <filter token="TRANSIT-CONTROLLER-PLUGIN"
-
value="artifact:plugin:dpml/transit/dpml-transit-plugin#${project.version}"/>
</target>

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

Added: trunk/main/transit/core/etc/test/plugin.xml
===================================================================
--- trunk/main/transit/core/etc/test/plugin.xml 2006-03-14 15:58:38 UTC (rev
1169)
+++ trunk/main/transit/core/etc/test/plugin.xml 2006-03-14 15:59:54 UTC (rev
1170)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<part xmlns="@PART-XSD-URI@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+
+ <info title="Demo Plugin">
+ <description>
+ Plugin descriptor using XMLSchema.
+ </description>
+ </info>
+
+ <!-- <strategy xsi:type="plugin" class="Widget"/>-->
+ <plugin class="Widget"/>
+
+ <classpath>
+ <public>
+ <uri>link:jar:fred/blogs</uri>
+ <uri>link:jar:peter/rabbit</uri>
+ </public>
+ </classpath>
+
+</part>

Added: trunk/main/transit/core/etc/test/resource.xml
===================================================================
--- trunk/main/transit/core/etc/test/resource.xml 2006-03-14 15:58:38
UTC (rev 1169)
+++ trunk/main/transit/core/etc/test/resource.xml 2006-03-14 15:59:54
UTC (rev 1170)
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<part xmlns="@PART-XSD-URI@"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+
+ <info title="Demo Resource">
+ <description>
+ Resource descriptor using XMLSchema.
+ </description>
+ </info>
+
+ <strategy xsi:type="resource" urn="foo:bar" path="org/acme"/>
+
+ <classpath>
+ <public>
+ <uri>link:jar:fred/blogs</uri>
+ <uri>link:jar:peter/rabbit</uri>
+ </public>
+ </classpath>
+
+</part>

Added: trunk/main/transit/core/src/main/net/dpml/lang/Builder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/Builder.java 2006-03-14
15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Builder.java 2006-03-14
15:59:54 UTC (rev 1170)
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.lang;
+
+import org.w3c.dom.Element;
+
+/**
+ * Interface implemented by generic builders.
+ */
+public interface Builder
+{
+ Object build( ClassLoader classoader, Element element ) throws Exception;
+}

Added: trunk/main/transit/core/src/main/net/dpml/lang/BuilderException.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/BuilderException.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/lang/BuilderException.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.lang;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public class BuilderException extends RuntimeException
+{
+ private final Element m_element;
+
+ public BuilderException( Element element, String message )
+ {
+ this( element, message, null );
+ }
+
+ public BuilderException( Element element, String message, Throwable
cause )
+ {
+ super( message, cause );
+ m_element = element;
+ }
+
+ public Element getElement()
+ {
+ return m_element;
+ }
+
+ public String getMessage()
+ {
+ try
+ {
+ String message = super.getMessage();
+ StringBuffer buffer = new StringBuffer( message );
+ Element element = getElement();
+ String tag = element.getTagName();
+ buffer.append( "\nElement: <" );
+ buffer.append( tag );
+ buffer.append( " ...>" );
+ Document document = element.getOwnerDocument();
+ String uri = document.getDocumentURI();
+ if( null != uri )
+ {
+ buffer.append( "\nDocument: " + uri );
+ }
+ return buffer.toString();
+ }
+ catch( Throwable e )
+ {
+ return super.getMessage();
+ }
+ }
+}

Modified: trunk/main/transit/core/src/main/net/dpml/lang/Classpath.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/Classpath.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Classpath.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -33,12 +33,22 @@
*/
public final class Classpath implements Serializable
{
+ private static final URI[] EMPTY = new URI[0];
+
private final URI[] m_system;
private final URI[] m_public;
private final URI[] m_protected;
private final URI[] m_private;

/**
+ * Creation of a empty classpath definition.
+ */
+ public Classpath()
+ {
+ this( EMPTY, EMPTY, EMPTY, EMPTY );
+ }
+
+ /**
* Creation of a new classpath definition.
* @param systemUris an array of uris representing the system classpath
extensions
* @param publicUris an array of uris representing the public classpath
entries
@@ -165,6 +175,20 @@
}

/**
+ * Return the classpath as a string.
+ * @return the string value
+ */
+ public String toString()
+ {
+ return "classpath: ["
+ + m_system.length
+ + ", " + m_public.length
+ + ", " + m_protected.length
+ + ", " + m_private.length
+ + "]";
+ }
+
+ /**
* Utility to hash an array.
* @param array the array
* @return the hash value

Added: trunk/main/transit/core/src/main/net/dpml/lang/DefaultType.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/DefaultType.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/lang/DefaultType.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.lang;
+
+import java.io.Writer;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Map;
+
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.Element;
+
+/**
+ * Utility used to build a plugin strategy from a DOM element.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+
+public class DefaultType implements Type
+{
+ private final String m_type;
+ private final boolean m_alias;
+ private final Object m_data;
+
+ public DefaultType( String type, boolean alias, Object data )
+ {
+ m_type = type;
+ m_alias = alias;
+ m_data = data;
+ }
+
+ public String getID()
+ {
+ return m_type;
+ }
+
+ public boolean getAlias()
+ {
+ return m_alias;
+ }
+
+ public Object getData()
+ {
+ return m_data;
+ }
+}

Deleted: trunk/main/transit/core/src/main/net/dpml/lang/Handler.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/Handler.java 2006-03-14
15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Handler.java 2006-03-14
15:59:54 UTC (rev 1170)
@@ -1,52 +0,0 @@
-/*
- * Copyright 2006 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.lang;
-
-import java.util.Properties;
-
-/**
- * Interface implemented by plugin handlers.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface Handler
-{
- /**
- * Instantiate the plugin.
- *
- * @param classloader the classloader
- * @param strategy the plugin strategy
- * @param args commandline arguments
- * @return the instance
- * @exception Exception if an error occurs
- */
- Object getPlugin(
- ClassLoader classloader, Strategy strategy, Object[] args ) throws
Exception;
-
- /**
- * Get a plugin class.
- *
- * @param classloader the plugin classloader
- * @param strategy the plugin strategy
- * @return the plugin class
- * @exception Exception if an error occurs
- */
- Class getPluginClass( ClassLoader classloader, Strategy strategy )
throws Exception;
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/lang/Plugin.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/Plugin.java 2006-03-14
15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Plugin.java 2006-03-14
15:59:54 UTC (rev 1170)
@@ -1,75 +0,0 @@
-/*
- * Copyright 2006 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.lang;
-
-import java.net.URI;
-import java.io.OutputStream;
-
-/**
- * A Plugin class contains immutable data about a plugin based on a
descriptor resolved
- * from a 'plugin' artifact.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface Plugin
-{
- /**
- * Return the plugin title.
- * @return the plugin title
- */
- String getTitle();
-
- /**
- * Return the plugin description.
- * @return the plugin description
- */
- String getDescription();
-
- /**
- * Return the plugin version.
- * @return the plugin version identifier
- */
- Version getVersion();
-
- /**
- * Return the uri used to establish the plugin.
- * @return the plugin uri
- */
- URI getURI();
-
- /**
- * Return the plugin strategy.
- * @return the plugin strategy
- */
- Strategy getStrategy();
-
- /**
- * Return the classpath definition.
- * @return the classpath
- */
- Classpath getClasspath();
-
- /**
- * Write an XML representation of the plugin to the output stream.
- * @param output the output stream
- * @exception Exception if an error ocucrs during externalization
- */
- void write( OutputStream output ) throws Exception;
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/lang/PluginFactory.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/PluginFactory.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/lang/PluginFactory.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -1,42 +0,0 @@
-/*
- * Copyright 2006 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.lang;
-
-import java.net.URI;
-
-/**
- * Interface implemented by plugins helpers that provide support for the
- * delegation of plugin definition creation from a DOM node.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface PluginFactory
-{
- /**
- * Construct a new plugin description instance using a supplied arguments
- *
- * @param uri the uri identifying the plugin
- * @param element the root element definining the plugin
- * @exception Exception if an error occurs
- */
- Plugin newPlugin(
- String title, String description, URI uri, Strategy strategy,
Classpath classpath )
- throws Exception;
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/lang/Strategy.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/Strategy.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Strategy.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -1,43 +0,0 @@
-/*
- * Copyright 2004-2006 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.lang;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-/**
- * Plugin strategy interface definition.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface Strategy extends Serializable
-{
- /**
- * Return the classname of the custom plugin instantiation handler.
- * @return the handler classname
- */
- String getHandlerClassname();
-
- /**
- * Return the the properties to be supplied to the handler.
- * @return the custom properties
- */
- Properties getProperties();
-}

Added: trunk/main/transit/core/src/main/net/dpml/lang/Type.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/Type.java 2006-03-14
15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Type.java 2006-03-14
15:59:54 UTC (rev 1170)
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.lang;
+
+import org.w3c.dom.Element;
+
+/**
+ * Declaration of a type production.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface Type
+{
+ String getID();
+
+ boolean getAlias();
+
+ Object getData();
+
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/AbstractBuilder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/AbstractBuilder.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/AbstractBuilder.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,402 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.io.OutputStreamWriter;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Map;
+import java.util.Hashtable;
+
+import javax.xml.XMLConstants;
+
+import net.dpml.lang.Category;
+import net.dpml.lang.Classpath;
+import net.dpml.lang.Builder;
+import net.dpml.lang.BuilderException;
+import net.dpml.lang.Type;
+
+import net.dpml.transit.Artifact;
+import net.dpml.transit.Transit;
+import net.dpml.transit.Repository;
+import net.dpml.transit.util.ElementHelper;
+import net.dpml.transit.artifact.ArtifactNotFoundException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.Attr;
+import org.w3c.dom.TypeInfo;
+
+/**
+ * Utility class supporting resolution of element builders.
+ */
+public class AbstractBuilder
+{
+ static final String PART_XSD_URI = "@PART-XSD-URI@";
+
+ static final URI LOCAL_URI = createURI( "local:dpml" );
+
+ private final Map m_map; // maps namespace uris to a builders
+
+ public AbstractBuilder( Map map )
+ {
+ if( null == map )
+ {
+ m_map = new Hashtable();
+ }
+ else
+ {
+ m_map = map;
+ }
+ if( !m_map.containsKey( "dpml/lang/dpml-part" ) )
+ {
+ m_map.put( "dpml/lang/dpml-part", LOCAL_URI );
+ }
+ }
+
+ protected Map getMap()
+ {
+ return m_map;
+ }
+
+ public Builder getBuilder( Element element ) throws Exception
+ {
+ return loadBuilder( element );
+ }
+
+ protected StrategyBuilder getStrategyBuilder( Element element ) throws
Exception
+ {
+ Builder builder = loadBuilder( element );
+ if( builder instanceof StrategyBuilder )
+ {
+ return (StrategyBuilder) builder;
+ }
+ else
+ {
+ final String error =
+ "Builder ["
+ + builder.getClass().getName()
+ + "] is not an instance of "
+ + StrategyBuilder.class.getName()
+ + ".";
+ throw new BuilderException( element, error );
+ }
+ }
+
+ protected Builder loadBuilder( Element element ) throws Exception
+ {
+ URI uri = getBuilderURI( element );
+ if( LOCAL_URI.equals( uri ) )
+ {
+ TypeInfo info = element.getSchemaTypeInfo();
+ String name = info.getTypeName();
+ if( "plugin".equals( name ) || "resource".equals( name ) )
+ {
+ return new PartStrategyBuilder( m_map );
+ }
+ else if( "part".equals( name ) )
+ {
+ return new PartBuilder( m_map );
+ }
+ }
+ return new DelegatingBuilder( uri );
+ }
+
+ protected Object loadObjectFromURI( URI uri, Class clazz ) throws
Exception
+ {
+ if( LOCAL_URI.equals( uri ) )
+ {
+ if( StrategyBuilder.class.isAssignableFrom( clazz ) )
+ {
+ return new PartStrategyBuilder(m_map );
+ }
+ else
+ {
+ final String error =
+ "Unexpected request to load a local object."
+ + "\nClass: " + clazz.getName();
+ throw new IllegalArgumentException( error );
+ }
+ }
+ ClassLoader classloader = getClassLoader();
+ Repository repository = Transit.getInstance().getRepository();
+ Object handler = repository.getPlugin( classloader, uri, new
Object[0] );
+ if( clazz.isAssignableFrom( handler.getClass() ) )
+ {
+ return handler;
+ }
+ else
+ {
+ final String error =
+ "Plugin ["
+ + uri
+ + "] is not assignable to "
+ + clazz.getName()
+ + ".";
+ throw new IllegalArgumentException( error );
+ }
+ }
+
+ protected URI getBuilderURI( Element element ) throws Exception
+ {
+ TypeInfo info = element.getSchemaTypeInfo();
+ String namespace = info.getTypeNamespace();
+ if( PART_XSD_URI.equals( namespace ) )
+ {
+ return LOCAL_URI;
+ }
+ else if( m_map.containsKey( namespace ) )
+ {
+ return (URI) m_map.get( namespace );
+ }
+ else
+ {
+ String name = info.getTypeName();
+ String path = namespace + "#" + name;
+ if( m_map.containsKey( path ) )
+ {
+ return (URI) m_map.get( path );
+ }
+ else
+ {
+ final String error =
+ "Unable to resolve part builder."
+ + "\nNamespace: " + namespace;
+ throw new BuilderException( element, error );
+ /*
+ try
+ {
+ URI uri = new URI( namespace );
+ if( Artifact.isRecognized( uri ) )
+ {
+ Artifact artifact = Artifact.createArtifact( uri );
+ String group = artifact.getGroup();
+ String artifactName = artifact.getName();
+ String spec = group + "/" + artifactName;
+ if( m_map.containsKey( spec ) )
+ {
+ return (URI) m_map.get( spec );
+ }
+ else
+ {
+ return getBuilderFromNamespaceURI( namespace );
+ }
+ }
+ else
+ {
+ final String error =
+ "Namespace format is not a recognized artifact ["
+ + namespace
+ + "].";
+ throw new IllegalArgumentException( error );
+ }
+ }
+ catch( URISyntaxException e )
+ {
+ final String error =
+ "Namespace format is not recognized ["
+ + namespace
+ + "].";
+ throw new BuilderException( element, error );
+ }
+ */
+ }
+ }
+ }
+
+ private class DelegatingBuilder implements Builder
+ {
+ private final URI m_uri;
+ private Object m_delegate = null;
+
+ DelegatingBuilder( URI uri )
+ {
+ m_uri = uri;
+ }
+
+ public Object build( ClassLoader classloader, Element element )
throws Exception
+ {
+ Object delegate = getDelegate();
+ if( delegate instanceof Builder )
+ {
+ Builder builder = (Builder) delegate;
+ return builder.build( classloader, element );
+ }
+ else
+ {
+ final String error =
+ "Builder delegate does not implement build operations."
+ + "\nURI: " + m_uri;
+ throw new UnsupportedOperationException( error );
+ }
+ }
+
+ /*
+ public String getID()
+ {
+ Object delegate = getDelegate();
+ if( delegate instanceof TypeBuilder )
+ {
+ TypeBuilder builder = (TypeBuilder) delegate;
+ return builder.getID();
+ }
+ else
+ {
+ final String error =
+ "Builder delegate does not implement type builder
operations."
+ + "\nURI: " + m_uri;
+ throw new UnsupportedOperationException( error );
+ }
+ }
+
+ public Type buildType( ClassLoader classloader, Element element )
throws Exception
+ {
+ Object delegate = getDelegate();
+ if( delegate instanceof TypeBuilder )
+ {
+ TypeBuilder builder = (TypeBuilder) delegate;
+ return builder.buildType( classloader, element );
+ }
+ else
+ {
+ final String error =
+ "Builder delegate does not implement type builder
operations."
+ + "\nURI: " + m_uri;
+ throw new UnsupportedOperationException( error );
+ }
+ }
+ */
+
+ private Object getDelegate()
+ {
+ if( null != m_delegate )
+ {
+ return m_delegate;
+ }
+ else
+ {
+ try
+ {
+ ClassLoader classloader = getClassLoader();
+ Repository repository =
Transit.getInstance().getRepository();
+ return repository.getPlugin( classloader, m_uri, new
Object[0] );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to establish delegate builder."
+ + "\nURI: " + m_uri;
+ throw new RuntimeException( error );
+ }
+ }
+ }
+
+ private ClassLoader getClassLoader()
+ {
+ ClassLoader classloader =
Thread.currentThread().getContextClassLoader();
+ if( null != classloader )
+ {
+ return classloader;
+ }
+ else
+ {
+ return getClass().getClassLoader();
+ }
+ }
+ }
+
+ private ClassLoader getClassLoader()
+ {
+ ClassLoader classloader =
Thread.currentThread().getContextClassLoader();
+ if( null != classloader )
+ {
+ return classloader;
+ }
+ else
+ {
+ return StrategyBuilder.class.getClassLoader();
+ }
+ }
+
+ private URI getBuilderFromNamespaceURI( String urn ) throws Exception
+ {
+ URI raw = new URI( urn );
+ Artifact artifact = Artifact.createArtifact( raw );
+ String scheme = artifact.getScheme();
+ String group = artifact.getGroup();
+ String name = artifact.getName();
+ String type = artifact.getType();
+ String version = artifact.getVersion();
+
+ String path = "link:part:" + group + "/" + name;
+ Artifact link = Artifact.createArtifact( path );
+ return link.toURI();
+
+ /*
+ try
+ {
+ String path = "link:part:" + group + "/" + name;
+ Artifact link = Artifact.createArtifact( path );
+ URL linkUrl = link.toURL();
+ linkUrl.getContent( new Class[]{File.class} ); // test for
existance
+ return link.toURI();
+ }
+ catch( ArtifactNotFoundException e )
+ {
+ Artifact result = Artifact.createArtifact( group, name, version,
"part" );
+ try
+ {
+ URL url = result.toURL();
+ url.getContent( new Class[]{File.class} );
+ return result.toURI();
+ }
+ catch( ArtifactNotFoundException anfe )
+ {
+ final String error =
+ "Unable to locate a builder for the urn ["
+ + urn
+ + "].";
+ throw new UnresolvableHandlerException( error,
result.toURI() );
+ }
+ }
+ */
+ }
+
+ private static URI createURI( String spec )
+ {
+ try
+ {
+ return new URI( spec );
+ }
+ catch( Throwable e )
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/DOM3DocumentBuilder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/DOM3DocumentBuilder.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/DOM3DocumentBuilder.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,238 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URL;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Map;
+import java.io.Reader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.xml.XMLConstants;
+import javax.xml.validation.Validator;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import net.dpml.transit.Logger;
+import net.dpml.transit.Artifact;
+import net.dpml.transit.util.ExceptionHelper;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+
+import org.w3c.dom.DOMError;
+import org.w3c.dom.DOMLocator;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.DOMErrorHandler;
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSParser;
+import org.w3c.dom.ls.LSParserFilter;
+import org.w3c.dom.ls.LSSerializer;
+import org.w3c.dom.ls.LSResourceResolver;
+import org.w3c.dom.ls.LSInput;
+
+public class DOM3DocumentBuilder
+{
+ private final Map m_map;
+
+ public DOM3DocumentBuilder()
+ {
+ this( new Hashtable() );
+ }
+
+ public DOM3DocumentBuilder( Map map )
+ {
+ m_map = map;
+ }
+
+ public Document parse( URI uri ) throws IOException
+ {
+ if( null == uri )
+ {
+ throw new NullPointerException( "uri" );
+ }
+ try
+ {
+ DOMImplementationRegistry registry =
+ DOMImplementationRegistry.newInstance();
+ DOMImplementationLS impl =
+ (DOMImplementationLS) registry.getDOMImplementation( "LS" );
+ if( null == impl )
+ {
+ final String error =
+ "Unable to locate a DOM3 parser.";
+ throw new IllegalStateException( error );
+ }
+ LSParser builder = impl.createLSParser(
DOMImplementationLS.MODE_SYNCHRONOUS, null );
+ DOMConfiguration config = builder.getDomConfig();
+ config.setParameter( "error-handler", new InternalErrorHandler()
);
+ config.setParameter( "resource-resolver", new
InternalResourceResolver( m_map ) );
+ config.setParameter( "validate", Boolean.TRUE );
+
+ DOMInput input = new DOMInput();
+ URL url = Artifact.toURL( uri );
+ InputStream stream = url.openStream();
+ InputStreamReader reader = new InputStreamReader( stream );
+ input.setCharacterStream( reader );
+
+ return builder.parse( input );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "DOM3 error while attempting to parse document."
+ + "\nSource: " + uri;
+ String message = ExceptionHelper.packException( error, e, true );
+ throw new IOException( message );
+ }
+ }
+
+ public void write( Document doc, OutputStream output ) throws Exception
+ {
+ DOMImplementationRegistry registry =
+ DOMImplementationRegistry.newInstance();
+ DOMImplementationLS impl =
+ (DOMImplementationLS) registry.getDOMImplementation( "LS" );
+ if( null == impl )
+ {
+ final String error =
+ "Unable to locate a DOM3 implementation.";
+ throw new IllegalStateException( error );
+ }
+ LSSerializer domWriter = impl.createLSSerializer();
+ LSOutput lsOut = impl.createLSOutput();
+ lsOut.setByteStream( output );
+ domWriter.write( doc, lsOut );
+ }
+
+ private static class InternalResourceResolver implements
LSResourceResolver
+ {
+ private final Map m_map;
+
+ InternalResourceResolver( Map map )
+ {
+ m_map = map;
+ }
+
+ public LSInput resolveResource( String type, String namespace,
String publicId, String systemId, String base )
+ {
+ if( XMLConstants.W3C_XML_SCHEMA_NS_URI.equals( type ) )
+ {
+ DOMInput input = new DOMInput();
+ input.setPublicId( publicId );
+ input.setSystemId( systemId );
+ input.setBaseURI( base );
+ try
+ {
+ URI uri = resolveURI( namespace );
+ URL url = Artifact.toURL( uri );
+ InputStream stream = url.openStream();
+ InputStreamReader reader = new InputStreamReader( stream
);
+ input.setCharacterStream( reader );
+ }
+ catch( URISyntaxException e )
+ {
+ // ignore
+ }
+ catch( IOException e )
+ {
+ // ignore
+ }
+ return input;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ private URI resolveURI( String namespace ) throws URISyntaxException
+ {
+ if( m_map.containsKey( namespace ) )
+ {
+ return (URI) m_map.get( namespace );
+ }
+ else
+ {
+ return new URI( namespace );
+ }
+ }
+ }
+
+
+
+ private static final class InternalErrorHandler implements
DOMErrorHandler
+ {
+ public boolean handleError( DOMError error )
+ {
+ DOMLocator locator = error.getLocation();
+ int line = locator.getLineNumber();
+ int column = locator.getColumnNumber();
+ String uri = locator.getUri();
+ if( null == uri )
+ {
+ uri = "";
+ }
+ String position = "[" + line + ":" + column + "] " + uri + ", ";
+ Node node = locator.getRelatedNode();
+ if( null != node )
+ {
+ System.out.println( "# NODE: " + node );
+ }
+ String message = error.getMessage();
+ short severity = error.getSeverity();
+ if( severity == DOMError.SEVERITY_ERROR )
+ {
+ System.out.println("[ERROR]: " + position + message );
+ final String notice = "DOM3 Validation Error: " + position +
message;
+ throw new RuntimeException( notice );
+ }
+ else if( severity == DOMError.SEVERITY_WARNING )
+ {
+ System.out.println("[WARNING]: " + position + message );
+ }
+ else
+ {
+ System.out.println("[FATAL]: " + position + message );
+ }
+ return true;
+ }
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/DOMDocumentBuilder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/DOMDocumentBuilder.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/DOMDocumentBuilder.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+
+import javax.xml.validation.Validator;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import net.dpml.transit.Logger;
+import net.dpml.transit.Artifact;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotRecognizedException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+
+import org.w3c.dom.Document;
+
+public class DOMDocumentBuilder
+{
+ private static final String FEATURE_SECURE_PROCESSING =
+ "http://javax.xml.XMLConstants/feature/secure-processing";;
+
+ private static final String W3C_XML_SCHEMA_NS_URI =
+ "http://www.w3.org/2001/XMLSchema";;
+
+ //
+ // implementation
+ //
+
+ public Document parse( String source ) throws Exception
+ {
+ DocumentBuilder db = getDocumentBuilder();
+ return db.parse( source );
+ }
+
+ public Document parse( URI uri ) throws Exception
+ {
+ DocumentBuilder db = getDocumentBuilder();
+ return db.parse( uri.toASCIIString() );
+ }
+
+ private DocumentBuilder getDocumentBuilder() throws Exception
+ {
+ DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware( true );
+ setupBuilderForSchemaValidation( factory );
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ builder.setErrorHandler( new InternalErrorHandler() );
+ return builder;
+ }
+
+ private void setupBuilderForSchemaValidation( DocumentBuilderFactory dbf
)
+ {
+ try
+ {
+ SchemaFactory schemaFactory = SchemaFactory.newInstance(
W3C_XML_SCHEMA_NS_URI );
+ Schema schema = schemaFactory.newSchema();
+ dbf.setSchema( schema );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected error while configuring XML parser for schema
validation.";
+ throw new RuntimeException( error, e );
+ }
+ }
+
+ private URL getURL( URI uri ) throws Exception
+ {
+ if( Artifact.isRecognized( uri ) )
+ {
+ return Artifact.createArtifact( uri ).toURL();
+ }
+ else
+ {
+ return uri.toURL();
+ }
+ }
+
+ private static final class InternalErrorHandler implements ErrorHandler
+ {
+ private final ArrayList m_errors = new ArrayList();
+ //private Logger m_logger;
+
+ public InternalErrorHandler()
+ {
+ //if( null == logger )
+ //{
+ // throw new NullPointerException( "logger" );
+ //}
+ //m_logger = logger;
+ }
+
+ public void error( SAXParseException e ) throws SAXException
+ {
+ final String message = getMessage( e );
+ if( !m_errors.contains( message ) )
+ {
+ m_errors.add( message );
+ System.out.println( message );
+ }
+ //final String message = getMessage( e );
+ //m_logger.warn( message );
+ //System.out.println( message );
+ }
+
+ public void fatalError( SAXParseException e ) throws SAXException
+ {
+ final String message = getMessage( e );
+ if( !m_errors.contains( message ) )
+ {
+ m_errors.add( message );
+ System.out.println( message );
+ }
+ //final String message = getMessage( e );
+ //m_logger.error( message );
+ //System.out.println( message );
+ }
+
+ public void warning( SAXParseException e ) throws SAXException
+ {
+ final String message = getMessage( e );
+ if( !m_errors.contains( message ) )
+ {
+ m_errors.add( message );
+ System.out.println( message );
+ }
+ //final String message = getMessage( e );
+ //m_logger.warn( message );
+ //System.out.println( message );
+ }
+
+ private String getMessage( SAXParseException e )
+ {
+ StringBuffer buffer = new StringBuffer();
+ String systemId = e.getSystemId();
+ if( systemId != null )
+ {
+ int index = systemId.lastIndexOf( '/' );
+ if( index != -1 )
+ {
+ systemId = systemId.substring( index + 1 );
+ }
+ buffer.append( systemId );
+ }
+ buffer.append(':');
+ buffer.append( e.getLineNumber() );
+ buffer.append(':');
+ buffer.append( e.getColumnNumber() );
+ buffer.append(" ");
+ buffer.append( e.getMessage() );
+ return buffer.toString();
+ }
+ }
+
+ private static class ParseError
+ {
+ }
+
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/DOMInput.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/DOMInput.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/DOMInput.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,275 @@
+/*
+ * Copyright 2001, 2002,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.Reader;
+import java.io.InputStream;
+
+import org.w3c.dom.ls.LSInput;
+
+/**
+ * This Class <code>DOMInput</code> represents a single input source for an
XML entity.
+ * <p> This Class allows an application to encapsulate information about
+ * an input source in a single object, which may include a public
+ * identifier, a system identifier, a byte stream (possibly with a specified
+ * encoding), and/or a character stream.
+ * <p> The exact definitions of a byte stream and a character stream are
+ * binding dependent.
+ * <p> There are two places that the application will deliver this input
+ * source to the parser: as the argument to the <code>parse</code> method,
+ * or as the return value of the
<code>DOMResourceResolver.resolveEntity</code>
+ * method.
+ * <p> The <code>DOMParser</code> will use the <code>LSInput</code>
+ * object to determine how to read XML input. If there is a character stream
+ * available, the parser will read that stream directly; if not, the parser
+ * will use a byte stream, if available; if neither a character stream nor a
+ * byte stream is available, the parser will attempt to open a URI
+ * connection to the resource identified by the system identifier.
+ * <p> An <code>LSInput</code> object belongs to the application: the
+ * parser shall never modify it in any way (it may modify a copy if
+ * necessary). Eventhough all attributes in this interface are writable the
+ * DOM implementation is expected to never mutate a LSInput.
+ * <p>See also the <a
href='http://www.w3.org/TR/2001/WD-DOM-Level-3-ASLS-20011025'>Document Object
Model (DOM) Level 3 Abstract Schemas and Load
+and Save Specification</a>.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+
+public class DOMInput implements LSInput
+{
+ private String m_publicId = null;
+ private String m_systemId = null;
+ private String m_base = null;
+ private InputStream m_byteStream = null;
+ private Reader m_reader = null;
+ private String m_data = null;
+ private String m_encoding = null;
+ private boolean m_certified = false;
+
+ /**
+ * Default constructor.
+ */
+ public DOMInput()
+ {
+ }
+
+ /**
+ * An attribute of a language-binding dependent type that represents a
+ * stream of bytes.
+ * <br>The parser will ignore this if there is also a character stream
+ * specified, but it will use a byte stream in preference to opening a
+ * URI connection itself.
+ * <br>If the application knows the character encoding of the byte stream,
+ * it should set the encoding property. Setting the encoding in this way
+ * will override any encoding specified in the XML declaration itself.
+ */
+ public InputStream getByteStream()
+ {
+ return m_byteStream;
+ }
+
+ /**
+ * An attribute of a language-binding dependent type that represents a
+ * stream of bytes.
+ * <br>The parser will ignore this if there is also a character stream
+ * specified, but it will use a byte stream in preference to opening a
+ * URI connection itself.
+ * <br>If the application knows the character encoding of the byte stream,
+ * it should set the encoding property. Setting the encoding in this way
+ * will override any encoding specified in the XML declaration itself.
+ */
+ public void setByteStream( InputStream byteStream )
+ {
+ m_byteStream = byteStream;
+ }
+
+ /**
+ * An attribute of a language-binding dependent type that represents a
+ * stream of 16-bit units. Application must encode the stream using
+ * UTF-16 (defined in and Amendment 1 of ).
+ * <br>If a character stream is specified, the parser will ignore any byte
+ * stream and will not attempt to open a URI connection to the system
+ * identifier.
+ */
+ public Reader getCharacterStream()
+ {
+ return m_reader;
+ }
+ /**
+ * An attribute of a language-binding dependent type that represents a
+ * stream of 16-bit units. Application must encode the stream using
+ * UTF-16 (defined in and Amendment 1 of ).
+ * <br>If a character stream is specified, the parser will ignore any byte
+ * stream and will not attempt to open a URI connection to the system
+ * identifier.
+ */
+ public void setCharacterStream( Reader characterStream )
+ {
+ m_reader = characterStream;
+ }
+
+ /**
+ * A string attribute that represents a sequence of 16 bit units (utf-16
+ * encoded characters).
+ * <br>If string data is available in the input source, the parser will
+ * ignore the character stream and the byte stream and will not attempt
+ * to open a URI connection to the system identifier.
+ */
+ public String getStringData()
+ {
+ return m_data;
+ }
+
+ /**
+ * A string attribute that represents a sequence of 16 bit units (utf-16
+ * encoded characters).
+ * <br>If string data is available in the input source, the parser will
+ * ignore the character stream and the byte stream and will not attempt
+ * to open a URI connection to the system identifier.
+ */
+ public void setStringData( String stringData )
+ {
+ m_data = stringData;
+ }
+
+ /**
+ * The character encoding, if known. The encoding must be a string
+ * acceptable for an XML encoding declaration ( section 4.3.3 "Character
+ * Encoding in Entities").
+ * <br>This attribute has no effect when the application provides a
+ * character stream. For other sources of input, an encoding specified
+ * by means of this attribute will override any encoding specified in
+ * the XML claration or the Text Declaration, or an encoding obtained
+ * from a higher level protocol, such as HTTP .
+ */
+ public String getEncoding()
+ {
+ return m_encoding;
+ }
+
+ /**
+ * The character encoding, if known. The encoding must be a string
+ * acceptable for an XML encoding declaration ( section 4.3.3 "Character
+ * Encoding in Entities").
+ * <br>This attribute has no effect when the application provides a
+ * character stream. For other sources of input, an encoding specified
+ * by means of this attribute will override any encoding specified in
+ * the XML claration or the Text Declaration, or an encoding obtained
+ * from a higher level protocol, such as HTTP .
+ */
+ public void setEncoding( String encoding )
+ {
+ m_encoding = encoding;
+ }
+
+ /**
+ * The public identifier for this input source. The public identifier is
+ * always optional: if the application writer includes one, it will be
+ * provided as part of the location information.
+ */
+ public String getPublicId()
+ {
+ return m_publicId;
+ }
+ /**
+ * The public identifier for this input source. The public identifier is
+ * always optional: if the application writer includes one, it will be
+ * provided as part of the location information.
+ */
+ public void setPublicId( String publicId )
+ {
+ m_publicId = publicId;
+ }
+
+ /**
+ * The system identifier, a URI reference , for this input source. The
+ * system identifier is optional if there is a byte stream or a
+ * character stream, but it is still useful to provide one, since the
+ * application can use it to resolve relative URIs and can include it in
+ * error messages and warnings (the parser will attempt to fetch the
+ * ressource identifier by the URI reference only if there is no byte
+ * stream or character stream specified).
+ * <br>If the application knows the character encoding of the object
+ * pointed to by the system identifier, it can register the encoding by
+ * setting the encoding attribute.
+ * <br>If the system ID is a relative URI reference (see section 5 in ),
+ * the behavior is implementation dependent.
+ */
+ public String getSystemId()
+ {
+ return m_systemId;
+ }
+ /**
+ * The system identifier, a URI reference , for this input source. The
+ * system identifier is optional if there is a byte stream or a
+ * character stream, but it is still useful to provide one, since the
+ * application can use it to resolve relative URIs and can include it in
+ * error messages and warnings (the parser will attempt to fetch the
+ * ressource identifier by the URI reference only if there is no byte
+ * stream or character stream specified).
+ * <br>If the application knows the character encoding of the object
+ * pointed to by the system identifier, it can register the encoding by
+ * setting the encoding attribute.
+ * <br>If the system ID is a relative URI reference (see section 5 in ),
+ * the behavior is implementation dependent.
+ */
+ public void setSystemId( String systemId )
+ {
+ m_systemId = systemId;
+ }
+
+ /**
+ * The base URI to be used (see section 5.1.4 in ) for resolving relative
+ * URIs to absolute URIs. If the baseURI is itself a relative URI, the
+ * behavior is implementation dependent.
+ */
+ public String getBaseURI()
+ {
+ return m_base;
+ }
+
+ /**
+ * The base URI to be used (see section 5.1.4 in ) for resolving relative
+ * URIs to absolute URIs. If the baseURI is itself a relative URI, the
+ * behavior is implementation dependent.
+ */
+ public void setBaseURI( String baseURI )
+ {
+ m_base = baseURI;
+ }
+
+ /**
+ * If set to true, assume that the input is certified (see section 2.13
+ * in [<a href='http://www.w3.org/TR/2002/CR-xml11-20021015/'>XML
1.1</a>]) when
+ * parsing [<a href='http://www.w3.org/TR/2002/CR-xml11-20021015/'>XML
1.1</a>].
+ */
+ public boolean getCertifiedText()
+ {
+ return m_certified;
+ }
+
+ /**
+ * If set to true, assume that the input is certified (see section 2.13
+ * in [<a href='http://www.w3.org/TR/2002/CR-xml11-20021015/'>XML
1.1</a>]) when
+ * parsing [<a href='http://www.w3.org/TR/2002/CR-xml11-20021015/'>XML
1.1</a>].
+ */
+ public void setCertifiedText( boolean certifiedText )
+ {
+ m_certified = certifiedText;
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/Info.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/Info.java 2006-03-14
15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/Info.java 2006-03-14
15:59:54 UTC (rev 1170)
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.Serializable;
+import java.net.URI;
+
+/**
+ * Part info description.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class Info implements Serializable
+{
+ private final String m_title;
+ private final String m_description;
+
+ public Info( String title, String description )
+ {
+ if( null == title )
+ {
+ m_title = "Untitled";
+ }
+ else
+ {
+ m_title = title;
+ }
+ if( null == description )
+ {
+ m_description = "";
+ }
+ else
+ {
+ m_description = description;
+ }
+ }
+
+ /**
+ * Get the part title.
+ *
+ * @return the title
+ */
+ public String getTitle()
+ {
+ return m_title;
+ }
+
+ /**
+ * Get the part description.
+ *
+ * @return the description
+ */
+ public String getDescription()
+ {
+ return m_description;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof Info )
+ {
+ Info info = (Info) other;
+ if( !m_title.equals( info.m_title ) )
+ {
+ return false;
+ }
+ else
+ {
+ return m_description.equals( info.m_description );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public int hashCode()
+ {
+ int hash = m_title.hashCode();
+ hash ^= m_description.hashCode();
+ return hash;
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/Part.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/Part.java 2006-03-14
15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/Part.java 2006-03-14
15:59:54 UTC (rev 1170)
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.Serializable;
+import java.net.URI;
+
+import net.dpml.lang.Classpath;
+
+/**
+ * Interface implemented by part handlers.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class Part implements Serializable
+{
+ private final Info m_info;
+ private final Strategy m_strategy;
+ private final Classpath m_classpath;
+
+ public Part( Info info, Strategy strategy, Classpath classpath )
+ {
+ if( null == info )
+ {
+ throw new NullPointerException( "info" );
+ }
+ if( null == strategy )
+ {
+ throw new NullPointerException( "strategy" );
+ }
+ if( null == classpath )
+ {
+ throw new NullPointerException( "classpath" );
+ }
+ m_info = info;
+ m_strategy = strategy;
+ m_classpath = classpath;
+ }
+
+ /**
+ * Get the part info descriptor.
+ *
+ * @return the part info datastructure
+ */
+ public Info getInfo()
+ {
+ return m_info;
+ }
+
+ /**
+ * Get the part deployment strategy.
+ *
+ * @return the strategy definition
+ */
+ public Strategy getStrategy()
+ {
+ return m_strategy;
+ }
+
+ /**
+ * Get the part classpath definition.
+ *
+ * @return the classpath definition
+ */
+ public Classpath getClasspath()
+ {
+ return m_classpath;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof Part )
+ {
+ Part part = (Part) other;
+ if( !m_info.equals( part.m_info ) )
+ {
+ return false;
+ }
+ else if( !m_strategy.equals( part.m_strategy ) )
+ {
+ return false;
+ }
+ else
+ {
+ return m_classpath.equals( part.m_classpath );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public int hashCode()
+ {
+ int hash = m_info.hashCode();
+ hash ^= m_strategy.hashCode();
+ hash ^= m_classpath.hashCode();
+ return hash;
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/PartBuilder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/PartBuilder.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/PartBuilder.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,230 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.io.OutputStreamWriter;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Map;
+
+import javax.xml.XMLConstants;
+
+import net.dpml.lang.Category;
+import net.dpml.lang.Classpath;
+import net.dpml.lang.Builder;
+import net.dpml.lang.BuilderException;
+
+import net.dpml.transit.Artifact;
+import net.dpml.transit.Transit;
+import net.dpml.transit.Repository;
+import net.dpml.transit.util.ElementHelper;
+import net.dpml.transit.artifact.ArtifactNotFoundException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.Attr;
+import org.w3c.dom.TypeInfo;
+
+/**
+ * Construct a part.
+ */
+public class PartBuilder extends PartWriter implements Builder
+{
+ private static final DOM3DocumentBuilder BUILDER =
+ new DOM3DocumentBuilder();
+
+ public PartBuilder()
+ {
+ this( null );
+ }
+
+ public PartBuilder( Map map )
+ {
+ super( map );
+ }
+
+ public Part loadPart( URI uri ) throws IOException
+ {
+ ClassLoader base = Part.class.getClassLoader();
+ return loadPart( base, uri );
+ }
+
+ public Part loadPart( ClassLoader base, URI uri ) throws IOException
+ {
+ if( null == uri )
+ {
+ throw new NullPointerException( "uri" );
+ }
+ if( null == base )
+ {
+ throw new NullPointerException( "base" );
+ }
+
+ //System.out.println( "# LOAD PART: " + uri );
+
+ try
+ {
+ final Document document = BUILDER.parse( uri );
+ final Element root = document.getDocumentElement();
+ return buildPart( base, root );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "An error while attempting to load a part."
+ + "\nPart URI: " + uri;
+ IOException exception = new IOException( error );
+ exception.initCause( e );
+ throw exception;
+ }
+ }
+
+ public Object build( ClassLoader classloader, Element element ) throws
Exception
+ {
+ return buildPart( classloader, element );
+ }
+
+ public Part buildPart( ClassLoader base, Element root ) throws Exception
+ {
+ if( null == root )
+ {
+ throw new NullPointerException( "root" );
+ }
+ Info info = getInfo( root );
+ Strategy strategy = getStrategy( base, root );
+ Classpath classpath = getClasspath( root );
+ return new Part( info, strategy, classpath );
+ }
+
+ private Strategy getStrategy( ClassLoader loader, Element root ) throws
Exception
+ {
+ Element[] children = ElementHelper.getChildren( root );
+ if( children.length != 3 )
+ {
+ final String error =
+ "Illegal number of child elements in <part>. Expecting 3,
found "
+ + children.length
+ + ".";
+ throw new BuilderException( root, error );
+ }
+
+ Element strategy = children[1];
+ Builder builder = getBuilder( strategy );
+ Object result = builder.build( loader, strategy );
+ if( result instanceof Strategy )
+ {
+ return (Strategy) result;
+ }
+ else
+ {
+ final String error =
+ "Object returned from builder is not a strategy instance.";
+ throw new BuilderException( strategy, error );
+ }
+ //StrategyBuilder builder = getStrategyBuilder( strategy );
+ //return builder.buildStrategy( loader, strategy );
+ }
+
+ private ClassLoader createClassLoader(
+ ClassLoader base, URI uri, Classpath classpath ) throws IOException
+ {
+ Repository repository = Transit.getInstance().getRepository();
+ return repository.createClassLoader( base, uri, classpath );
+ }
+
+ private Info getInfo( Element root )
+ {
+ Element element = ElementHelper.getChild( root, "info" );
+ String title = ElementHelper.getAttribute( element, "title",
"Unknown" );
+ Element descriptionElement = ElementHelper.getChild( element,
"description" );
+ String description = ElementHelper.getValue( descriptionElement );
+ return new Info( title, description );
+ }
+
+ protected Classpath getClasspath( Element root ) throws Exception
+ {
+ Element classpath = ElementHelper.getChild( root, "classpath" );
+ if( null == classpath )
+ {
+ final String error =
+ "Required classpath element is not present in plugin
descriptor.";
+ throw new IllegalStateException( error );
+ }
+
+ Element[] children = ElementHelper.getChildren( classpath );
+ URI[] sys = buildURIs( classpath, "system" );
+ URI[] pub = buildURIs( classpath, "public" );
+ URI[] prot = buildURIs( classpath, "protected" );
+ URI[] priv = buildURIs( classpath, "private" );
+ Classpath cp = new Classpath( sys, pub, prot, priv );
+ return cp;
+ }
+
+ private URI[] buildURIs( Element classpath, String key ) throws Exception
+ {
+ Element category = ElementHelper.getChild( classpath, key );
+ if( null == category )
+ {
+ return new URI[0];
+ }
+ else
+ {
+ Element[] children = ElementHelper.getChildren( category, "uri"
);
+ URI[] uris = new URI[ children.length ];
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ String value = ElementHelper.getValue( child );
+ uris[i] = new URI( value );
+ }
+ return uris;
+ }
+ }
+
+ private Element getSingleNestedElement( Element parent ) throws Exception
+ {
+ if( null == parent )
+ {
+ throw new NullPointerException( "parent" );
+ }
+ else
+ {
+ Element[] children = ElementHelper.getChildren( parent );
+ if( children.length == 1 )
+ {
+ return children[0];
+ }
+ else
+ {
+ final String error =
+ "Parent element does not contain a single child.";
+ throw new IllegalArgumentException( error );
+ }
+ }
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/PartDirective.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/PartDirective.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/PartDirective.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.Serializable;
+import java.net.URI;
+
+import net.dpml.transit.Value;
+
+/**
+ * Immutable part creation directive.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class PartDirective implements Serializable
+{
+ private final URI m_uri;
+ private final Value[] m_params;
+
+ public PartDirective( URI uri )
+ {
+ this( uri, null );
+ }
+
+ public PartDirective( URI uri, Value[] params )
+ {
+ if( null == uri )
+ {
+ throw new NullPointerException( "uri" );
+ }
+ m_uri = uri;
+ if( null == params )
+ {
+ m_params = new Value[0];
+ }
+ else
+ {
+ m_params = params;
+ }
+ }
+
+ /**
+ * Get the part uri.
+ * @return the uri
+ */
+ public URI getURI()
+ {
+ return m_uri;
+ }
+
+ /**
+ * Get the values to be used during part instantiation.
+ * @return the directives
+ */
+ public Value[] getValues()
+ {
+ return m_params;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof PartDirective )
+ {
+ PartDirective part = (PartDirective) other;
+ if( !m_uri.equals( part.m_uri ) )
+ {
+ return false;
+ }
+ else
+ {
+ return m_params.equals( part.m_params );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public int hashCode()
+ {
+ int hash = m_uri.hashCode();
+ for( int i=0; i<m_params.length; i++ )
+ {
+ hash ^= m_params[i].hashCode();
+ }
+ return hash;
+ }
+}

Modified: trunk/main/transit/core/src/main/net/dpml/part/PartHandler.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/PartHandler.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/PartHandler.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -19,12 +19,13 @@
package net.dpml.part;

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

import net.dpml.lang.Classpath;

/**
* Interface implemented by part runtime handlers. Handler are identified
- * by the uri returned from the <tt>Part.getStrategy().getController()</tt>.
+ * by the uri returned from <tt>Part.getStrategy().getControllerURI()</tt>.
*/
public interface PartHandler
{
@@ -43,5 +44,5 @@
* @param args supplimentary arguments
* @exception Exception if a deployment error occurs
*/
- Object getInstance( ClassLoader classloader, Object data, Object[] args
) throws Exception;
+ Object getInstance( ClassLoader anchor, Classpath classpath, Object
data, Object[] args ) throws Exception;
}

Added: trunk/main/transit/core/src/main/net/dpml/part/PartHandlerFactory.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/PartHandlerFactory.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/PartHandlerFactory.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Hashtable;
+
+import net.dpml.lang.Classpath;
+
+import net.dpml.part.PartHandler;
+import net.dpml.part.StandardPartHandler;
+import net.dpml.part.PartDirective;
+
+import net.dpml.transit.Transit;
+import net.dpml.transit.Repository;
+import net.dpml.transit.Value;
+import net.dpml.transit.Construct;
+
+
+/**
+ * Factory used to locate part handlers.
+ */
+public class PartHandlerFactory
+{
+ private static final StandardPartHandler HANDLER = new
StandardPartHandler();
+
+ private Hashtable m_map = new Hashtable();
+
+ private static final PartHandlerFactory FACTORY = new
PartHandlerFactory();
+
+ public static PartHandlerFactory getInstance()
+ {
+ return FACTORY;
+ }
+
+ private PartHandlerFactory()
+ {
+ }
+
+ /**
+ * Locate or resolve a part handler.
+ * @param uri the part uri
+ * @exception Exception if an error occurs during handler resolution
+ */
+ public PartHandler getPartHandler( URI uri ) throws Exception
+ {
+ PartDirective directive = new PartDirective( uri, null );
+ return getPartHandler( directive );
+ }
+
+ /**
+ * Locate or resolve a part handler.
+ * @param directive the part instantiation directive
+ * @exception Exception if an error occurs during handler resolution
+ */
+ public PartHandler getPartHandler( PartDirective directive ) throws
Exception
+ {
+ URI uri = directive.getURI();
+ Value[] params = directive.getValues();
+ Object[] args = Construct.getArgs( null, params, new Object[0] );
+ return getPartHandler( uri, args );
+ }
+
+ /**
+ * Locate or resolve a part handler.
+ * @param uri the part uri
+ * @param args part instantiation arguments
+ * @exception Exception if an error occurs during handler resolution
+ */
+ public PartHandler getPartHandler( URI uri, Object[] args ) throws
Exception
+ {
+ if( AbstractBuilder.LOCAL_URI.equals( uri ) )
+ {
+ return HANDLER;
+ }
+ else
+ {
+ synchronized( m_map )
+ {
+ if( m_map.containsKey( uri ) )
+ {
+ return (PartHandler) m_map.get( uri );
+ }
+ else
+ {
+ PartHandler handler = loadPartHandler( uri, args );
+ m_map.put( uri, handler );
+ return handler;
+ }
+ }
+ }
+ }
+
+ private PartHandler loadPartHandler( URI uri, Object[] args ) throws
Exception
+ {
+ ClassLoader classloader = PartHandler.class.getClassLoader();
+ Repository repository = Transit.getInstance().getRepository();
+ Object instance = repository.getPlugin( classloader, uri, args );
+ if( instance instanceof PartHandler )
+ {
+ return (PartHandler) instance;
+ }
+ else
+ {
+ final String error =
+ "Plugin uri does not resolve to an instance of "
+ + PartHandler.class.getName()
+ + "."
+ + "\nURI: " + uri
+ + "\nCLass: " + instance.getClass().getName();
+ throw new IllegalArgumentException( error );
+ }
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/PartStrategyBuilder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/PartStrategyBuilder.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/PartStrategyBuilder.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.Writer;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Map;
+
+import net.dpml.transit.Value;
+import net.dpml.transit.Construct;
+import net.dpml.transit.util.ElementHelper;
+
+import net.dpml.lang.Type;
+//import net.dpml.lang.TypeBuilder;
+import net.dpml.lang.Builder;
+import net.dpml.lang.DefaultType;
+
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.Element;
+
+/**
+ * Utility used to build a plugin strategy from a DOM element.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class PartStrategyBuilder extends PartStrategyWriter implements
Builder, StrategyBuilder //, TypeBuilder
+{
+ private static final PartDirective TRANSIT_DIRECTIVE =
+ new PartDirective( AbstractBuilder.LOCAL_URI );
+
+ public PartStrategyBuilder()
+ {
+ this( null );
+ }
+
+ public PartStrategyBuilder( Map map )
+ {
+ super( map );
+ }
+
+ public String getID()
+ {
+ return "part";
+ }
+
+ public void writeStrategy( Writer writer, Strategy strategy, String pad
) throws IOException
+ {
+ Object data = strategy.getDeploymentData();
+ if( data instanceof Plugin )
+ {
+ Plugin plugin = (Plugin) data;
+ String classname = plugin.getClassname();
+ writer.write( "\n <strategy xsi:type=\"plugin\" class=\"" );
+ writer.write( classname );
+ writer.write( "\"/>" );
+ }
+ else if( data instanceof Resource )
+ {
+ Resource resource = (Resource) data;
+ String urn = resource.getURN();
+ String path = resource.getPath();
+ writer.write( "\n <strategy xsi:type=\"resource\"" );
+ writer.write( " urn=\"" + urn );
+ writer.write( "\" path=\"" + path );
+ writer.write( "\"/>" );
+ }
+ else
+ {
+ final String error =
+ "Unsupported strategy datatype: " + data.getClass().getName();
+ throw new IllegalArgumentException( error );
+ }
+ }
+
+ /*
+ public Type buildType( ClassLoader classloader, Element element ) throws
Exception
+ {
+ boolean alias = ElementHelper.getBooleanAttribute( element, "alias",
false );
+ Strategy strategy = buildStrategy( classloader, element );
+ return new DefaultType( "part", alias, strategy );
+ }
+ */
+
+ public Object build( ClassLoader classloader, Element element ) throws
Exception
+ {
+ return buildStrategy( classloader, element );
+ }
+
+ public Strategy buildStrategy( ClassLoader classloader, Element element
) throws Exception
+ {
+ TypeInfo info = element.getSchemaTypeInfo();
+ String type = info.getTypeName();
+ boolean alias = ElementHelper.getBooleanAttribute( element, "alias",
false );
+ if( "plugin".equals( type ) )
+ {
+ String classname = ElementHelper.getAttribute( element, "class"
);
+ Element[] elements = ElementHelper.getChildren( element, "param"
);
+ Value[] values = buildValues( elements );
+ Plugin plugin = new Plugin( classname, values );
+ return new Strategy( AbstractBuilder.LOCAL_URI,
TRANSIT_DIRECTIVE, plugin, alias );
+ }
+ else if( "resource".equals( type ) )
+ {
+ String urn = ElementHelper.getAttribute( element, "urn" );
+ String path = ElementHelper.getAttribute( element, "path" );
+ Resource resource = new Resource( urn, path );
+ return new Strategy( AbstractBuilder.LOCAL_URI,
TRANSIT_DIRECTIVE, resource, alias );
+ }
+ else
+ {
+ final String error =
+ "Strategy element ["
+ + type
+ + "] is not recognized.";
+ throw new IllegalArgumentException( error );
+ }
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/PartStrategyWriter.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/PartStrategyWriter.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/PartStrategyWriter.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.Writer;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Map;
+
+import net.dpml.transit.Value;
+import net.dpml.transit.Construct;
+import net.dpml.transit.util.ElementHelper;
+
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.Element;
+
+/**
+ * Utility used to build a plugin strategy from a DOM element.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class PartStrategyWriter extends ValueBuilder
+{
+ public PartStrategyWriter( Map map )
+ {
+ super( map );
+ }
+
+ public void write( Writer writer, Strategy strategy ) throws IOException
+ {
+ Object data = strategy.getDeploymentData();
+ if( data instanceof Plugin )
+ {
+ Plugin plugin = (Plugin) data;
+ String classname = plugin.getClassname();
+ writer.write( "\n <strategy xsi:type=\"plugin\" class=\"" );
+ writer.write( classname );
+ writer.write( "\"" );
+ if( plugin.getValues().length > 0 )
+ {
+ Value[] values = plugin.getValues();
+ writeValues( writer, values, " " );
+ }
+ else
+ {
+ writer.write( "/>" );
+ }
+ }
+ else if( data instanceof Resource )
+ {
+ Resource resource = (Resource) data;
+ String urn = resource.getURN();
+ String path = resource.getPath();
+ writer.write( "\n <strategy xsi:type=\"resource\"" );
+ writer.write( " urn=\"" + urn );
+ writer.write( "\" path=\"" + path );
+ writer.write( "\"/>" );
+ }
+ else
+ {
+ final String error =
+ "Unsupported strategy datatype: "
+ + data.getClass().getName();
+ throw new IOException( error );
+ }
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/PartWriter.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/PartWriter.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/PartWriter.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+import java.io.OutputStreamWriter;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Map;
+
+import javax.xml.XMLConstants;
+
+import net.dpml.lang.Category;
+import net.dpml.lang.Classpath;
+
+import net.dpml.transit.Artifact;
+import net.dpml.transit.Transit;
+import net.dpml.transit.Repository;
+import net.dpml.transit.util.ElementHelper;
+import net.dpml.transit.artifact.ArtifactNotFoundException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.Attr;
+import org.w3c.dom.TypeInfo;
+
+/**
+ * Construct a part.
+ */
+public class PartWriter extends ValueBuilder
+{
+ private static final String XML_HEADER =
+ "<?xml version=\"1.0\"?>";
+
+ private static final String PART_SCHEMA_URN = "@PART-XSD-URI@";
+
+ private static final String PART_HEADER =
+ "<part xmlns=\""
+ + PART_SCHEMA_URN
+ + "\""
+ + "\n xmlns:xsi=\""
+ + XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI
+ + "\">";
+
+ private static final String PART_FOOTER = "</part>";
+
+ public PartWriter( Map map )
+ {
+ super( map );
+ }
+
+ /**
+ * Externalize the part to XML.
+ * @param part the part to externalize
+ * @param output the output stream
+ * @exception IOException if an IO error occurs
+ */
+ public void writePart( Part part, OutputStream output, String pad )
throws IOException
+ {
+ final Writer writer = new OutputStreamWriter( output );
+ writer.write( XML_HEADER );
+ writer.write( "\n\n" );
+ writer.write( PART_HEADER );
+ writer.write( "\n" );
+ writeInfo( writer, part.getInfo() );
+ writer.write( "\n" );
+ writeStrategy( writer, part.getStrategy(), " " );
+ writer.write( "\n" );
+ writeClasspath( writer, part.getClasspath() );
+ writer.write( "\n\n" );
+ writer.write( PART_FOOTER );
+ writer.write( "\n" );
+ writer.flush();
+ output.close();
+ }
+
+ private void writeInfo( Writer writer, Info info ) throws IOException
+ {
+ String title = info.getTitle();
+ String description = info.getDescription();
+ if( null == description )
+ {
+ writer.write( "\n <info title=\"" + title + "\"/>" );
+ }
+ else
+ {
+ writer.write( "\n <info title=\"" + title + "\">" );
+ writer.write( "\n <description>" + description +
"</description>" );
+ writer.write( "\n </info>" );
+ }
+ }
+
+ protected void writeStrategy( Writer writer, Strategy strategy, String
pad ) throws IOException
+ {
+ URI uri = strategy.getBuilderURI();
+ try
+ {
+ StrategyBuilder builder = (StrategyBuilder) loadObjectFromURI(
uri, StrategyBuilder.class );
+ builder.writeStrategy( writer, strategy, pad );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "An error occured during strategy externalization.";
+ IOException ioe = new IOException( error );
+ ioe.initCause( e );
+ throw ioe;
+ }
+ }
+
+ private void writeClasspath( Writer writer, Classpath classpath ) throws
IOException
+ {
+ writer.write( "\n <classpath>" );
+ writeClasspathCategory( writer, classpath, Category.SYSTEM );
+ writeClasspathCategory( writer, classpath, Category.PUBLIC );
+ writeClasspathCategory( writer, classpath, Category.PROTECTED );
+ writeClasspathCategory( writer, classpath, Category.PRIVATE );
+ writer.write( "\n </classpath>" );
+ }
+
+ private void writeClasspathCategory(
+ Writer writer, Classpath classpath, Category category ) throws
IOException
+ {
+ URI[] uris = classpath.getDependencies( category );
+ if( uris.length > 0 )
+ {
+ String name = category.getName();
+ writer.write( "\n <" + name + ">" );
+ for( int i=0; i<uris.length; i++ )
+ {
+ URI uri = uris[i];
+ writer.write( "\n <uri>" + uri.toASCIIString() +
"</uri>" );
+ }
+ writer.write( "\n </" + name + ">" );
+ }
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/Plugin.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/Plugin.java 2006-03-14
15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/Plugin.java 2006-03-14
15:59:54 UTC (rev 1170)
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+import net.dpml.transit.Value;
+
+public class Plugin implements Serializable
+{
+ private final String m_classname;
+ private final Value[] m_params;
+
+ public Plugin( String classname, Value[] params )
+ {
+ if( null == classname )
+ {
+ throw new NullPointerException( "classname" );
+ }
+ if( null == params )
+ {
+ throw new NullPointerException( "params" );
+ }
+ m_classname = classname;
+ m_params = params;
+ }
+
+ public String getClassname()
+ {
+ return m_classname;
+ }
+
+ public Value[] getValues()
+ {
+ return m_params;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof Plugin )
+ {
+ Plugin plugin = (Plugin) other;
+ if( !m_classname.equals( plugin.m_classname ) )
+ {
+ return false;
+ }
+ else
+ {
+
+ return Arrays.equals( m_params, plugin.m_params );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public int hashCode()
+ {
+ int hash = m_classname.hashCode();
+ for( int i=0; i<m_params.length; i++ )
+ {
+ hash ^= m_params[i].hashCode();
+ }
+ return hash;
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/Resource.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/Resource.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/Resource.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.Serializable;
+
+public class Resource implements Serializable
+{
+ private final String m_urn;
+ private final String m_path;
+
+ public Resource( String urn, String path )
+ {
+ if( null == urn )
+ {
+ throw new NullPointerException( "urn" );
+ }
+ if( null == path )
+ {
+ throw new NullPointerException( "path" );
+ }
+ m_urn = urn;
+ m_path = path;
+ }
+
+ public String getURN()
+ {
+ return m_urn;
+ }
+
+ public String getPath()
+ {
+ return m_path;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof Resource )
+ {
+ Resource resource = (Resource) other;
+ if( !m_urn.equals( resource.m_urn ) )
+ {
+ return false;
+ }
+ else
+ {
+ return m_path.equals( resource.m_path );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public int hashCode()
+ {
+ int hash = m_urn.hashCode();
+ hash ^= m_path.hashCode();
+ return hash;
+ }
+}

Modified:
trunk/main/transit/core/src/main/net/dpml/part/StandardPartHandler.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/StandardPartHandler.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/StandardPartHandler.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -28,15 +28,16 @@
import net.dpml.lang.Classpath;

import net.dpml.transit.Artifact;
+import net.dpml.transit.Construct;
import net.dpml.transit.StandardClassLoader;
+import net.dpml.transit.Transit;
+import net.dpml.transit.Value;

/**
* Construct a part.
*/
public class StandardPartHandler implements PartHandler
{
- public static final URI PART_HANDLER_URI = createHandlerURI();
-
/**
* Build a classloader stack.
* @param anchor the anchor classloader to server as the classloader
chain root
@@ -44,28 +45,7 @@
*/
public ClassLoader getClassLoader( ClassLoader anchor, Classpath
classpath ) throws IOException
{
- if( null == anchor )
- {
- throw new NullPointerException( "anchor" );
- }
- if( null == classpath )
- {
- throw new NullPointerException( "classpath" );
- }
-
- URL[] sysUrls = getURLs( classpath, Category.SYSTEM );
- URL[] apis = getURLs( classpath, Category.PUBLIC );
- URL[] spis = getURLs( classpath, Category.PROTECTED );
- URL[] imps = getURLs( classpath, Category.PRIVATE );
- //if( sysUrls.length > 0 )
- //{
- // updateSystemClassLoader( plugin, sysUrls );
- //}
-
- ClassLoader parent = buildClassLoader( Category.PUBLIC, anchor, apis
);
- parent = buildClassLoader( Category.PROTECTED, parent, spis );
- parent = buildClassLoader( Category.PRIVATE, parent, imps );
- return parent;
+ return Transit.getInstance().getRepository().createClassLoader(
anchor, null, classpath );
}

/**
@@ -75,113 +55,30 @@
* @param args supplimentary arguments
* @exception Exception if a deployment error occurs
*/
- public Object getInstance( ClassLoader classloader, Object data,
Object[] args ) throws Exception
+ public Object getInstance( ClassLoader anchor, Classpath classpath,
Object data, Object[] args ) throws Exception
{
- throw new UnsupportedOperationException( "getInstance" );
- }
-
- private URL[] getURLs( Classpath classpath, Category category ) throws
IOException
- {
- URI[] uris = classpath.getDependencies( category );
- return getURLs( uris );
- }
-
- /**
- * Convert a sequncence of URIs to URLs.
- * @param uris the uris to convert
- * @return the corresponding urls
- * @exception IOException of a transformation error occurs
- */
- private URL[] getURLs( URI[] uris ) throws IOException
- {
- URL[] urls = new URL[ uris.length ];
- for( int i=0; i < urls.length; i++ )
+ ClassLoader classloader = getClassLoader( anchor, classpath );
+ if( data instanceof Plugin )
{
- URI uri = uris[i];
- urls[i] = Artifact.toURL( uri );
- }
- return urls;
- }
-
- /**
- * Internal utility class to build a classloader. If the supplied url
- * sequence is zero length the parent classloader is returned directly.
- *
- * @param category the type of classloader (api, spi, impl)
- * @param parent the parent classloader
- * @param urls the urls to assign as classloader content
- * @return the classloader
- */
- private ClassLoader buildClassLoader( Category category, ClassLoader
parent, URL[] urls )
- {
- if( 0 == urls.length )
- {
- return parent;
- }
- ArrayList list = new ArrayList();
- for( int i=0; i < urls.length; i++ )
- {
- if( isaCandidate( parent, urls[i] ) )
+ Plugin plugin = (Plugin) data;
+ String classname = plugin.getClassname();
+ Value[] values = plugin.getValues();
+ ClassLoader context =
Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader( classloader );
+ try
{
- list.add( urls[i] );
+ Object[] params = Construct.getArgs( null, values, args );
+ Class c = classloader.loadClass( classname );
+ return Transit.getInstance().getRepository().instantiate( c,
params );
}
- }
- URL[] qualified = (URL[]) list.toArray( new URL[0] );
- if( qualified.length == 0 )
- {
- return parent;
- }
- else
- {
- return new StandardClassLoader( null, category, qualified,
parent );
- }
- }
-
- /**
- * Test if the supplied url is already present within the supplied
classloader.
- * @param classloader the classloader to validate against
- * @param url to url to check for
- * @return true if the url is not included in the classloader
- */
- private boolean isaCandidate( ClassLoader classloader, URL url )
- {
- if( classloader instanceof URLClassLoader )
- {
- URL[] urls = ( (URLClassLoader) classloader ).getURLs();
- for( int i=0; i < urls.length; i++ )
+ finally
{
- if( urls[i].equals( url ) )
- {
- return false;
- }
+ Thread.currentThread().setContextClassLoader( context );
}
- ClassLoader parent = classloader.getParent();
- if( parent == null )
- {
- return true;
- }
- else
- {
- return isaCandidate( parent, url );
- }
}
else
{
- return true;
+ throw new UnsupportedOperationException( "getInstance/" +
data.getClass().getName() );
}
}
-
- private static URI createHandlerURI()
- {
- try
- {
- return new URI( "internal:transit" );
- }
- catch( Throwable e )
- {
- e.printStackTrace();
- return null;
- }
- }
-
}

Added: trunk/main/transit/core/src/main/net/dpml/part/Strategy.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/Strategy.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/Strategy.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.Serializable;
+import java.net.URI;
+
+/**
+ * Part deployment strategy description.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class Strategy
+{
+ private final PartDirective m_controller;
+ private final Serializable m_data;
+ private final URI m_builder;
+ private final boolean m_alias;
+
+ /**
+ * Creation of a new part instantiation strategy.
+ * @param namespace the strategy namespace
+ * @param controller the runtime controller that will handle part
deployment
+ * @param data the data to tbe supplied to the controller
+ */
+ public Strategy( URI builder, PartDirective controller, Serializable
data )
+ {
+ this( builder, controller, data, false );
+ }
+
+ /**
+ * Creation of a new part instantiation strategy.
+ * @param namespace the strategy namespace
+ * @param controller the runtime controller that will handle part
deployment
+ * @param data the data to tbe supplied to the controller
+ */
+ public Strategy( URI builder, PartDirective controller, Serializable
data, boolean alias )
+ {
+ if( null == controller )
+ {
+ throw new NullPointerException( "controller" );
+ }
+ if( null == data )
+ {
+ throw new NullPointerException( "data" );
+ }
+ if( null == builder )
+ {
+ throw new NullPointerException( "builder" );
+ }
+ m_builder = builder;
+ m_controller = controller;
+ m_data = data;
+ m_alias = alias;
+ }
+
+ /**
+ * Return the datatype id.
+ */
+ public String getID()
+ {
+ return "part";
+ }
+
+ /**
+ * Return the datatype id.
+ */
+ public boolean getAlias()
+ {
+ return m_alias;
+ }
+
+ /**
+ * Get the strategy builder uri.
+ *
+ * @return the builder uri
+ */
+ public URI getBuilderURI()
+ {
+ return m_builder;
+ }
+
+ /**
+ * Get the controller deployment directive.
+ *
+ * @return the deployment controller uri
+ */
+ public PartDirective getPartDirective()
+ {
+ return m_controller;
+ }
+
+ /**
+ * Get the deployment data.
+ *
+ * @return the deployment datastructure
+ */
+ public Object getDeploymentData()
+ {
+ return m_data;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof Strategy )
+ {
+ Strategy strategy = (Strategy) other;
+ if( !m_builder.equals( strategy.m_builder ) )
+ {
+ return false;
+ }
+ else if( !m_controller.equals( strategy.m_controller ) )
+ {
+ return false;
+ }
+ else
+ {
+ return m_data.equals( strategy.m_data );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public int hashCode()
+ {
+ int hash = m_builder.hashCode();
+ hash ^= m_controller.hashCode();
+ hash ^= m_data.hashCode();
+ return hash;
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/StrategyBuilder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/StrategyBuilder.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/StrategyBuilder.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import org.w3c.dom.Element;
+
+/**
+ * Construct an Strategy instance from a DOM Element.
+ */
+public interface StrategyBuilder
+{
+ Strategy buildStrategy( ClassLoader classloader, Element element )
throws Exception;
+
+ void writeStrategy( Writer writer, Strategy strategy, String pad )
throws IOException;
+}

Added:
trunk/main/transit/core/src/main/net/dpml/part/UnresolvableHandlerException.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/part/UnresolvableHandlerException.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/main/net/dpml/part/UnresolvableHandlerException.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.net.URI;
+
+import net.dpml.transit.artifact.ArtifactNotFoundException;
+
+public class UnresolvableHandlerException extends ArtifactNotFoundException
+{
+ public UnresolvableHandlerException( String message, URI uri )
+ {
+ super( message, uri );
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/ValueBuilder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/ValueBuilder.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/ValueBuilder.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.Writer;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Map;
+
+import net.dpml.transit.Value;
+import net.dpml.transit.Construct;
+import net.dpml.transit.util.ElementHelper;
+
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.Element;
+
+/**
+ * Utility used to build a plugin strategy from a DOM element.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ValueBuilder extends ValueWriter
+{
+ //public ValueBuilder()
+ //{
+ // this( null );
+ //}
+
+ public ValueBuilder( Map map )
+ {
+ super( map );
+ }
+
+ protected Value[] buildValues( Element[] elements )
+ {
+ Value[] values = new Value[ elements.length ];
+ for( int i=0; i<elements.length; i++ )
+ {
+ values[i] = buildValue( elements[i] );
+ }
+ return values;
+ }
+
+ protected Value buildValue( Element element )
+ {
+ String classname = ElementHelper.getAttribute( element, "class" );
+ String method = ElementHelper.getAttribute( element, "method" );
+ Element[] elements = ElementHelper.getChildren( element, "param" );
+ if( elements.length > 0 )
+ {
+ Value[] values = buildValues( elements );
+ return new Construct( classname, method, values );
+ }
+ else
+ {
+ String value = ElementHelper.getAttribute( element, "value" );
+ return new Construct( classname, method, value );
+ }
+ }
+}

Added: trunk/main/transit/core/src/main/net/dpml/part/ValueWriter.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/part/ValueWriter.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/part/ValueWriter.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.Writer;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.Map;
+
+import net.dpml.transit.Value;
+import net.dpml.transit.Construct;
+import net.dpml.transit.util.ElementHelper;
+
+import org.w3c.dom.TypeInfo;
+import org.w3c.dom.Element;
+
+/**
+ * Utility used to build a plugin strategy from a DOM element.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ValueWriter extends AbstractBuilder
+{
+ public ValueWriter()
+ {
+ this( null );
+ }
+
+ public ValueWriter( Map map )
+ {
+ super( map );
+ }
+
+ protected void writeValues( Writer writer, Value[] values, String pad )
throws IOException
+ {
+ for( int i=0; i<values.length; i++ )
+ {
+ Value value = values[i];
+ writeValue( writer, value, pad );
+ }
+ }
+
+ protected void writeValue( Writer writer, Value value, String pad )
throws IOException
+ {
+ if( value instanceof Construct )
+ {
+ Construct construct = (Construct) value;
+ String method = construct.getMethodName();
+ String target = construct.getTargetExpression();
+
+ writer.write( "\n" + pad + "<param" );
+ if( null != target )
+ {
+ writer.write( " class=\"" + target + "\"" );
+ }
+ if( null != method )
+ {
+ writer.write( " method=\"" + method + "\"" );
+ }
+ if( construct.isCompound() )
+ {
+ writer.write( ">" );
+ Value[] values = construct.getValues();
+ writeValues( writer, values, pad + " " );
+ writer.write( "\n" + pad + "</param>" );
+ }
+ else
+ {
+ String v = construct.getBaseValue();
+ if( null != value )
+ {
+ writer.write( " value=\"" + v + "\"" );
+ }
+ writer.write( "/>" );
+ }
+ }
+ else
+ {
+ final String error =
+ "Value class ["
+ + value.getClass().getName() +
+ "] not supported.";
+ throw new IOException( error );
+ }
+ }
+}

Modified: trunk/main/transit/core/src/main/net/dpml/transit/Construct.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Construct.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/transit/Construct.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -26,6 +26,10 @@
import java.util.Arrays;
import java.util.Map;

+import net.dpml.part.Strategy;
+import net.dpml.part.PartDirective;
+import net.dpml.part.AbstractBuilder;
+
import net.dpml.transit.info.ValueDirective;
import net.dpml.transit.util.PropertyResolver;

@@ -125,7 +129,7 @@
m_args = new Value[0];
m_compound = false;
}
-
+
/**
* Create a new construct using a supplied target defintion. The target
argument
* may be either a classname or a symbolic reference in the form
${[key]}. If the
@@ -140,7 +144,7 @@
{
this( target, null, args );
}
-
+
/**
* Create a new construct using a supplied target defintion. The target
argument
* may be either a classname or a symbolic reference in the form
${[key]}. If the
@@ -277,10 +281,26 @@
*/
public Object resolve( Map map, boolean isolate ) throws Exception
{
- return resolve( map, null, isolate );
+ return resolve( null, map, null, isolate );
}

/**
+ * Resolve an instance from the value using a supplied context map. If
any
+ * target expressions in immediate or nested values contain a symbolic
+ * expression the value will be resolved using the supplied map.
+ *
+ * @param classname the default classname
+ * @param map the context map
+ * @param isolate the isolation policy
+ * @return the resolved instance
+ * @exception Exception if error occurs during instance resolution
+ */
+ public Object resolve( String classname, Map map, boolean isolate )
throws Exception
+ {
+ return resolve( classname, map, null, isolate );
+ }
+
+ /**
* Resolve an instance from the value.
* @param map the context map
* @param classloader the classloader to use
@@ -288,10 +308,10 @@
* @return the resolved instance
* @exception Exception if an error occurs during value resolution
*/
- public Object resolve( Map map, ClassLoader classloader, boolean isolate
) throws Exception
+ private Object resolve( String classname, Map map, ClassLoader
classloader, boolean isolate ) throws Exception
{
ClassLoader loader = resolveClassLoader( classloader );
- Object target = getTargetObject( map, loader );
+ Object target = getTargetObject( classname, map, loader );
if( isCompound() )
{
if( null == target )
@@ -762,7 +782,7 @@
if( value instanceof Construct )
{
Construct construct = (Construct) value;
- instances[i] = construct.resolve( map, classloader, false );
+ instances[i] = construct.resolve( null, map, classloader,
false );
}
else
{
@@ -814,9 +834,16 @@
* @return the target object or class
* @exception ValueException if target related error occurs
*/
- private Object getTargetObject( Map map, ClassLoader loader ) throws
ValueException
+ private Object getTargetObject( String classname, Map map, ClassLoader
loader ) throws ValueException
{
- return getTargetObject( map, loader, m_target );
+ if( null == m_target )
+ {
+ return getTargetObject( map, loader, classname );
+ }
+ else
+ {
+ return getTargetObject( map, loader, m_target );
+ }
}

/**

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/ConstructBeanInfo.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/ConstructBeanInfo.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/transit/ConstructBeanInfo.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -1,81 +0,0 @@
-/*
- * Copyright 2005 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.dpml.transit;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.Expression;
-import java.beans.Encoder;
-
-/**
- * BeanInfo for the CategoryDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ConstructBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( Construct.class );
- descriptor.setValue(
- "persistenceDelegate",
- new ConstructPersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate.
- */
- private static class ConstructPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Instantiate an expression.
- * @param old the old value
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- Construct construct = (Construct) old;
- Object[] args = new Object[3];
- args[0] = construct.getTargetExpression();
- args[1] = construct.getMethodName();
- if( construct.isCompound() )
- {
- args[2] = construct.getValues();
- }
- else
- {
- args[2] = construct.getBaseValue();
- }
- return new Expression( old, old.getClass(), "new", args );
- }
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/DefaultPlugin.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/DefaultPlugin.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/transit/DefaultPlugin.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -1,328 +0,0 @@
-/*
- * Copyright 2004-2005 Stephen J. McConnell.
- * Copyright 2004 Niclas Hedhman.
- *
- * 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.transit;
-
-import java.net.URI;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.io.IOException;
-import java.util.Properties;
-
-import net.dpml.lang.Plugin;
-import net.dpml.lang.Version;
-import net.dpml.lang.Classpath;
-import net.dpml.lang.Strategy;
-import net.dpml.lang.Category;
-
-/**
- * A Plugin class contains immutable data about a plugin based on a
descriptor resolved
- * from a 'plugin' artifact.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class DefaultPlugin implements Plugin
-{
- /**
- * The plugin builder version value that will be used when reading and
writing
- * plugin defintions.
- */
- public static final Version VERSION = new Version( 1, 0, 0 );
-
- public static final String XML_HEADER =
- "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
-
- public static final String STANDARD_NAME = "plugin";
-
- public static final String STANDARD_PUBLIC_ID =
- "-//DPML//DTD Standard Plugin Version 1.0//EN";
-
- public static final String STANDARD_SYSTEM_ID =
- "http://download.dpml.net/dtds/plugin_1_0.dtd";;
-
- public static final String STANDARD_RESOURCE =
- "net/dpml/lang/plugin_1_0.dtd";
-
- private static final String PLUGIN_DOCTYPE =
- "\n<!DOCTYPE "
- + STANDARD_NAME
- + " PUBLIC \""
- + STANDARD_PUBLIC_ID
- + "\" \""
- + STANDARD_SYSTEM_ID
- + "\" >";
-
- private final String m_title;
- private final String m_description;
- private final URI m_uri;
- private final Strategy m_strategy;
- private final Classpath m_classpath;
-
- /**
- * Creation of a new plugin definition.
- * @param title short title
- * @param description textual description
- * @param uri the uri from which the plugin was resolved
- * @param strategy the plugin instantiation strategy definition
- * @param classpath the classpath defintion
- */
- public DefaultPlugin(
- String title, String description, URI uri, Strategy strategy,
Classpath classpath )
- {
- if( null == uri )
- {
- throw new NullPointerException( "uri" );
- }
- if( null == strategy )
- {
- throw new NullPointerException( "strategy" );
- }
- if( null == classpath )
- {
- throw new NullPointerException( "classpath" );
- }
- m_uri = uri;
- m_strategy = strategy;
- m_title = title;
- m_description = description;
- m_classpath = classpath;
- }
-
- /**
- * Return the plugin title.
- * @return the plugin title
- */
- public String getTitle()
- {
- return m_title;
- }
-
- /**
- * Return the plugin description.
- * @return the plugin description
- */
- public String getDescription()
- {
- return m_description;
- }
-
- /**
- * Return the plugin version.
- * @return the plugin version identifier
- */
- public Version getVersion()
- {
- return VERSION;
- }
-
- /**
- * Return the uri to the plugin descriptor.
- * @return the plugin uri
- */
- public URI getURI()
- {
- return m_uri;
- }
-
- /**
- * Return the plugin strategy.
- * @return the plugin strategy
- */
- public Strategy getStrategy()
- {
- return m_strategy;
- }
-
- /**
- * Return the classpath definition.
- */
- public Classpath getClasspath()
- {
- return m_classpath;
- }
-
- /**
- * Write an XML representation of the plugin to the output stream.
- * @param output the output stream
- * @exception Exception if an error ocucrs during externalization
- */
- public void write( OutputStream output ) throws Exception
- {
- final Writer writer = new OutputStreamWriter( output );
- writer.write( XML_HEADER );
- writer.write( PLUGIN_DOCTYPE );
- writeHeader( writer, "plugin", null, VERSION );
- writeTitle( writer, getTitle() );
- writeDescription( writer, getDescription() );
- writeStrategy( writer, getStrategy() );
- writeClasspath( writer, getClasspath() );
- writeFooter( writer, "plugin" );
- writer.write( "\n" );
- writer.flush();
- writer.close();
- }
-
- protected void writeHeader( Writer writer, String root, String
namespace, Version version ) throws IOException
- {
- if( null == namespace )
- {
- writer.write( "\n\n<" + root + " version=\"" + version + "\">" );
- }
- else
- {
- writer.write( "\n\n<" + root + " xmlns=\"" + namespace + "\"
version=\"" + version + "\">" );
- }
- }
-
- protected void writeFooter( Writer writer, String root ) throws
IOException
- {
- writer.write( "\n</" + root + ">" );
- }
-
- protected void writeTitle( Writer writer, String title ) throws
IOException
- {
- if( null != title )
- {
- writer.write(
- "\n <title>"
- + title
- + "</title>" );
- }
- }
-
- protected void writeDescription( Writer writer, String description )
throws IOException
- {
- if( null != description )
- {
- writer.write(
- "\n <description>"
- + description
- + "</description>" );
- }
- }
-
- protected void writeStrategy( Writer writer, Strategy strategy ) throws
Exception
- {
- String handler = strategy.getHandlerClassname();
- Properties properties = strategy.getProperties();
- String[] keys = (String[]) properties.keySet().toArray( new
String[0] );
- if( StandardHandler.class.getName().equals( handler ) )
- {
- writer.write( "\n <strategy>" );
- }
- else
- {
- writer.write( "\n <strategy class=\"" + handler + "\">" );
- }
- for( int i=0; i<keys.length; i++ )
- {
- String key = keys[i];
- String value = properties.getProperty( key );
- writer.write(
- "\n <property name=\""
- + key
- + "\" value=\""
- + value
- + "\"/>" );
- }
- writer.write( "\n </strategy>" );
- }
-
- protected void writeClasspath( Writer writer, Classpath classpath )
throws Exception
- {
- writer.write( "\n <classpath>" );
- URI[] sysUris = classpath.getDependencies( Category.SYSTEM );
- if( sysUris.length > 0 )
- {
- writer.write( "\n <system>" );
- for( int i=0; i<sysUris.length; i++ )
- {
- URI uri = sysUris[i];
- writer.write( "\n <uri>" + uri + "</uri>" );
- }
- writer.write( "\n </system>" );
- }
- URI[] publicUris = classpath.getDependencies( Category.PUBLIC );
- if( publicUris.length > 0 )
- {
- writer.write( "\n <public>" );
- for( int i=0; i<publicUris.length; i++ )
- {
- URI uri = publicUris[i];
- writer.write( "\n <uri>" + uri + "</uri>" );
- }
- writer.write( "\n </public>" );
- }
- URI[] protectedUris = classpath.getDependencies( Category.PROTECTED
);
- if( protectedUris.length > 0 )
- {
- writer.write( "\n <protected>" );
- for( int i=0; i<protectedUris.length; i++ )
- {
- URI uri = protectedUris[i];
- writer.write( "\n <uri>" + uri + "</uri>" );
- }
- writer.write( "\n </protected>" );
- }
- URI[] privateUris = classpath.getDependencies( Category.PRIVATE );
- if( privateUris.length > 0 )
- {
- writer.write( "\n <private>" );
- for( int i=0; i<privateUris.length; i++ )
- {
- URI uri = privateUris[i];
- writer.write( "\n <uri>" + uri + "</uri>" );
- }
- writer.write( "\n </private>" );
- }
- writer.write( "\n </classpath>" );
- }
-
- /**
- * Compare this object with another for equality.
- * @param other the other object
- * @return TRUE if equal else FALSE
- */
- public boolean equals( Object other )
- {
- if( other instanceof DefaultPlugin )
- {
- DefaultPlugin plugin = (DefaultPlugin) other;
- return m_uri.equals( plugin.getURI() );
- }
- else
- {
- return false;
- }
- }
-
- /**
- * Return the hashcode for the plugin definition.
- * @return the hash code
- */
- public int hashCode()
- {
- return m_uri.hashCode();
- }
-
- private static final URI[] EMPTY_URIS = new URI[0];
-
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultPluginBuilder.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/DefaultPluginBuilder.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/main/net/dpml/transit/DefaultPluginBuilder.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -1,255 +0,0 @@
-/*
- * Copyright 2006 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.transit;
-
-import java.net.URI;
-import java.net.URL;
-import java.net.URLConnection;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.util.Properties;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import net.dpml.transit.util.ElementHelper;
-
-import net.dpml.lang.Plugin;
-import net.dpml.lang.Strategy;
-import net.dpml.lang.Classpath;
-import net.dpml.lang.SaxMonitor;
-import net.dpml.lang.DTD;
-import net.dpml.lang.DTDResolver;
-import net.dpml.lang.PluginFactory;
-
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-
-/**
- * Utility class supporting the reading of standard plugins definitions.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class PluginBuilder
-{
- private static final DTD[] DTDS = new DTD[]
- {
- new DTD(
- DefaultPlugin.STANDARD_PUBLIC_ID,
- DefaultPlugin.STANDARD_SYSTEM_ID,
- DefaultPlugin.STANDARD_RESOURCE, null )
- };
-
- private static final DTDResolver DTD_RESOLVER =
- new DTDResolver( DTDS, PluginBuilder.class.getClassLoader() );
-
-
- private Logger m_logger;
-
- public PluginBuilder( Logger logger )
- {
- m_logger = logger;
- }
-
- /**
- * Construct a plugin from a supplied uri. Plugin construction will be
- * delegated top a plugin helper identified by the xml ns urn of the root
- * document (note - this is subject to review).
- *
- * @param url the plugin url
- * @return the plugin
- * @exception Exception if an error occurs during plugin loading
- */
- public Plugin load( final URL url ) throws Exception
- {
- URLConnection connection = url.openConnection();
- InputStream input = connection.getInputStream();
-
- final DocumentBuilderFactory factory =
- DocumentBuilderFactory.newInstance();
- factory.setValidating( true );
- factory.setNamespaceAware( true );
- factory.setExpandEntityReferences( true );
- DocumentBuilder builder = factory.newDocumentBuilder();
- builder.setEntityResolver( DTD_RESOLVER );
- ErrorHandler errors = new SaxMonitor( m_logger );
- builder.setErrorHandler( errors );
-
- final Document document = builder.parse( input );
- final DocumentType docType = document.getDoctype();
- final Element root = document.getDocumentElement();
-
- String spec = root.getNamespaceURI(); // <------------ review !
-
- String title = getTitle( root );
- String description = getDescription( root );
- URI uri = new URI( url.toString() );
- Strategy strategy = getStrategy( root );
- Classpath classpath = getClasspath( root );
-
- if( null == spec )
- {
- return new DefaultPlugin( title, description, uri, strategy,
classpath );
- }
- else
- {
- PluginFactory pluginFactory = getPluginFactory( spec );
- return pluginFactory.newPlugin( title, description, uri,
strategy, classpath );
- }
- }
-
- private PluginFactory getPluginFactory( String spec ) throws Exception
- {
- URI uri = new URI( spec );
- ClassLoader classloader = Plugin.class.getClassLoader();
- Object[] args = new Object[]{m_logger};
- Object instance =
- Transit.getInstance().getRepository().getPlugin( classloader, uri,
args );
- if( instance instanceof PluginFactory )
- {
- return (PluginFactory) instance;
- }
- else
- {
- final String error =
- "Plugin factory artifact argument ["
- + spec
- + "] established an instance of ["
- + instance.getClass().getName()
- + "] which is not assignable to "
- + PluginFactory.class.getName()
- + ".";
- throw new IllegalArgumentException( error );
- }
- }
-
- protected String getTitle( Element element )
- {
- if( null == element )
- {
- return null;
- }
- else
- {
- Element elem = ElementHelper.getChild( element, "title" );
- if( null == elem )
- {
- return null;
- }
- else
- {
- return ElementHelper.getValue( element );
- }
- }
- }
-
- protected String getDescription( Element element )
- {
- if( null == element )
- {
- return null;
- }
- else
- {
- Element elem = ElementHelper.getChild( element, "description" );
- if( null == elem )
- {
- return null;
- }
- else
- {
- return ElementHelper.getValue( element );
- }
- }
- }
-
- protected Strategy getStrategy( Element root )
- {
- Element strategy = ElementHelper.getChild( root, "strategy" );
- if( null == strategy )
- {
- final String error =
- "Required strategy element is not present in plugin
descriptor.";
- throw new IllegalStateException( error );
- }
-
- String classname = ElementHelper.getAttribute( strategy, "class",
StandardHandler.class.getName() );
- Properties properties = new Properties();
- Element[] elements = ElementHelper.getChildren( strategy, "property"
);
- for( int i=0; i<elements.length; i++ )
- {
- Element element = elements[i];
- String name = ElementHelper.getAttribute( element, "name" );
- String value = ElementHelper.getAttribute( element, "value" );
- properties.setProperty( name, value );
- }
- return new DefaultStrategy( classname, properties );
- }
-
- protected Classpath getClasspath( Element root ) throws Exception
- {
- Element classpath = ElementHelper.getChild( root, "classpath" );
- if( null == classpath )
- {
- final String error =
- "Required classpath element is not present in plugin
descriptor.";
- throw new IllegalStateException( error );
- }
-
- URI[] sys = buildURIs( classpath, "system" );
- URI[] pub = buildURIs( classpath, "public" );
- URI[] prot = buildURIs( classpath, "protected" );
- URI[] priv = buildURIs( classpath, "private" );
- return new Classpath( sys, pub, prot, priv );
- }
-
- public Plugin resolve(
- String title, String description, URI uri, Strategy strategy,
Classpath classpath ) throws Exception
- {
- return new DefaultPlugin( title, description, uri, strategy,
classpath );
- }
-
- private URI[] buildURIs( Element classpath, String key ) throws Exception
- {
- Element category = ElementHelper.getChild( classpath, key );
- if( null == category )
- {
- return null;
- }
- else
- {
- Element[] children = ElementHelper.getChildren( category, "uri"
);
- URI[] uris = new URI[ children.length ];
- for( int i=0; i<children.length; i++ )
- {
- Element child = children[i];
- String value = ElementHelper.getValue( child );
- uris[i] = new URI( value );
- }
- return uris;
- }
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultPluginFactory.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/DefaultPluginFactory.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/main/net/dpml/transit/DefaultPluginFactory.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -1,50 +0,0 @@
-/*
- * Copyright 2006 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.transit;
-
-import java.net.URI;
-
-import net.dpml.lang.Plugin;
-import net.dpml.lang.Strategy;
-import net.dpml.lang.Classpath;
-import net.dpml.lang.PluginFactory;
-
-/**
- * Default plugin factory.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class DefaultPluginFactory implements PluginFactory
-{
- /**
- * Construct a new plugin description instance using a supplied arguments
- *
- * @param uri the uri identifying the plugin
- * @param element the root element definining the plugin
- * @exception Exception if an error occurs
- */
- public Plugin newPlugin(
- String title, String description, URI uri, Strategy strategy,
Classpath classpath )
- throws Exception
- {
- return new DefaultPlugin( title, description, uri, strategy,
classpath );
- }
-}
-

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultStrategy.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/DefaultStrategy.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/transit/DefaultStrategy.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -1,116 +0,0 @@
-/*
- * Copyright 2004-2006 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.transit;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-import net.dpml.lang.Strategy;
-
-/**
- * Plugin strategy.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class DefaultStrategy implements Strategy
-{
- private final String m_handler;
- private final Properties m_properties;
-
- /**
- * Creation of a new strategy definition.
- * @param handler the plugin handler classname
- * @param properties the handler supplimentary properties
- */
- public DefaultStrategy( final String handler, final Properties
properties )
- {
- if( null == handler )
- {
- throw new NullPointerException( "handler" );
- }
- m_handler = handler;
- if( null == properties )
- {
- m_properties = new Properties();
- }
- else
- {
- m_properties = properties;
- }
- }
-
- /**
- * Return the classname of the custom plugin instantiation handler.
- * @return the handler classname
- */
- public String getHandlerClassname()
- {
- return m_handler;
- }
-
- /**
- * Return the the properties to be supplied to the handler.
- * @return the custom properties
- */
- public Properties getProperties()
- {
- return m_properties;
- }
-
- /**
- * Test this object for equality with the supplied object.
- * @param other the other object
- * @return true if the objects are equal
- */
- public boolean equals( Object other )
- {
- if( null == other )
- {
- return false;
- }
- else if( other instanceof Strategy )
- {
- Strategy strategy = (Strategy) other;
- if( !m_handler.equals( strategy.getHandlerClassname() ) )
- {
- return false;
- }
- else
- {
- return m_properties.equals( strategy.getProperties() );
- }
- }
- else
- {
- return false;
- }
- }
-
- /**
- * Return the hashcode for the instance.
- * @return the instance hashcode
- */
- public int hashCode()
- {
- int hash = m_handler.hashCode();
- hash ^= m_properties.hashCode();
- return hash;
- }
-}

Modified: trunk/main/transit/core/src/main/net/dpml/transit/Repository.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Repository.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/transit/Repository.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -24,9 +24,11 @@

import java.net.URI;

-import net.dpml.lang.Plugin;
+//import net.dpml.lang.Plugin;
import net.dpml.lang.Classpath;

+import net.dpml.part.Part;
+
/**
* A service that provides support for the establishment of classloaders and
plugin
* instances based on plugin descriptor describing a classloader chain.
@@ -42,8 +44,8 @@
* @return the plugin descriptor
* @exception IOException if a factory creation error occurs
*/
- Plugin getPluginDescriptor( URI uri )
- throws IOException;
+ //Plugin getPluginDescriptor( URI uri ) throws IOException;
+ Part getPart( URI uri ) throws IOException;

/**
* Get a plugin classloader relative to a supplied uri.
@@ -53,6 +55,17 @@
* @return the plugin classloader
* @exception IOException if plugin loading exception occurs
*/
+ ClassLoader getPluginClassLoader( ClassLoader parent, Part part )
+ throws IOException;
+
+ /**
+ * Get a plugin classloader relative to a supplied uri.
+ *
+ * @param parent the parent classloader
+ * @param uri the plugin uri
+ * @return the plugin classloader
+ * @exception IOException if plugin loading exception occurs
+ */
ClassLoader getPluginClassLoader( ClassLoader parent, URI uri )
throws IOException;

@@ -68,6 +81,17 @@
throws IOException;

/**
+ * Get a plugin class relative to a supplied uri.
+ *
+ * @param parent the parent classloader
+ * @param uri the plugin uri
+ * @return the plugin class
+ * @exception IOException if plugin loading exception occurs
+ */
+ Class getPluginClass( ClassLoader parent, Part part )
+ throws IOException;
+
+ /**
* Creates a plugin from a uri reference.
*
* @param parent the parent classloader

Modified:
trunk/main/transit/core/src/main/net/dpml/transit/SecuredTransitContext.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/SecuredTransitContext.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/main/net/dpml/transit/SecuredTransitContext.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -38,9 +38,12 @@
import net.dpml.transit.model.RequestIdentifier;
import net.dpml.transit.model.DisposalListener;
import net.dpml.transit.model.DisposalEvent;
-import net.dpml.lang.UnknownKeyException;
import net.dpml.transit.monitor.LoggingAdapter;

+import net.dpml.lang.UnknownKeyException;
+
+import net.dpml.part.PartBuilder;
+
/**
* The initial context of the transit system.
*
@@ -296,7 +299,7 @@
{
m_linkManager = new ArtifactLinkManager();
Logger logger = getLogger().getChildLogger( "cache" );
- m_repository = new StandardLoader( logger );
+ m_repository = new StandardLoader( logger, new PartBuilder( null )
); // this needs to be configured
initializeCache();
}


Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/StandardHandler.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/StandardHandler.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/transit/StandardHandler.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -1,441 +0,0 @@
-/*
- * Copyright 2004-2005 Stephen J. McConnell.
- * Copyright 2004 Niclas Hedhman.
- *
- * 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.transit;
-
-import java.io.IOException;
-import java.beans.Expression;
-import java.lang.reflect.Array;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Properties;
-
-import net.dpml.lang.Handler;
-import net.dpml.lang.Strategy;
-
-/**
- * Default plugin instantiation handler.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class StandardHandler implements Handler
-{
- /**
- * Instantiate the plugin.
- *
- * @param classloader the classloader
- * @param strategy the plugin strategy
- * @param args commandline arguments
- * @return the instance
- * @exception Exception if an error occurs
- */
- public Object getPlugin( ClassLoader classloader, Strategy strategy,
Object[] args )
- throws Exception
- {
- Class clazz = getPluginClass( classloader, strategy );
- return instantiate( clazz, args );
- }
-
- /**
- * Get a plugin class.
- *
- * @param classloader the plugin classloader
- * @param strategy the plugin strategy
- * @return the plugin class
- * @exception Exception if an error occurs
- */
- public Class getPluginClass( ClassLoader classloader, Strategy strategy )
- throws Exception
- {
- if( null == classloader )
- {
- throw new NullArgumentException( "classloader" );
- }
- if( null == strategy )
- {
- throw new NullArgumentException( "strategy" );
- }
-
- Properties properties = strategy.getProperties();
- String target = properties.getProperty( "project.plugin.class" );
- if( null == target )
- {
- final String error =
- "Missing 'project.plugin.class' property.";
- throw new RepositoryException( error );
- }
- else
- {
- return loadPluginClass( classloader, target );
- }
- }
-
- /**
- * Instantiate an instance of a class using the supplied arguments.
- * @param clazz the target class
- * @param args the commandline arguments
- * @return the instantiated instance
- * @exception RepositoryException if an unexpected error occurs
- * @exception InvocationTargetException if the plugin instance raises an
exception
- * during instantiation
- */
- public Object instantiate( Class clazz, Object[] args ) throws
RepositoryException, InvocationTargetException
- {
- if( null == clazz )
- {
- throw new NullArgumentException( "clazz" );
- }
- if( null == args )
- {
- throw new NullArgumentException( "args" );
- }
- for( int i=0; i < args.length; i++ )
- {
- Object p = args[i];
- if( null == p )
- {
- final String error =
- "User supplied instantiation argument at position ["
- + i
- + "] for the class ["
- + clazz.getName()
- + "] is a null value.";
- throw new NullArgumentException( error );
- }
- }
-
- if( clazz.getConstructors().length == 1 )
- {
- Constructor constructor = getSingleConstructor( clazz );
- return instantiate( constructor, args );
- }
- else
- {
- try
- {
- Expression expression = new Expression( clazz, "new", args );
- return expression.getValue();
- }
- catch( InvocationTargetException e )
- {
- throw e;
- }
- catch( RepositoryException e )
- {
- throw e;
- }
- catch( Throwable e )
- {
- final String error =
- "Class instantiation error [" + clazz.getName() + "]";
- throw new RepositoryException( error, e );
- }
- }
- }
-
- /**
- * Instantiate an instance of a class using the supplied constructor and
arguments.
- * @param constructor the target constructor
- * @param args the commandline arguments
- * @return the instantiated instance
- * @exception RepositoryException if an unexpected error occurs
- * @exception InvocationTargetException if the plugin instance raises an
exception
- * during instantiation
- */
- public Object instantiate( Constructor constructor, Object[] args )
- throws RepositoryException, InvocationTargetException
- {
- Object[] arguments = populate( constructor, args );
- return newInstance( constructor, arguments );
- }
-
- /**
- * Create a factory using a supplied class and command line arguments.
- *
- * @param clazz the the factory class
- * @param args the command line args
- * @return the plugin instance
- * @exception IOException if a plugin creation error occurs
- * @exception InvocationTargetException if a plugin constructor
invocation error occurs
- * @exception NullArgumentException if the class or args argument is null
- */
- private Object createPlugin( Class clazz, Object[] args )
- throws IOException, NullArgumentException, InvocationTargetException
- {
- if( null == clazz )
- {
- throw new NullArgumentException( "clazz" );
- }
- if( null == args )
- {
- throw new NullArgumentException( "args" );
- }
- return instantiate( clazz, args );
- }
-
- private Object[] populate( Constructor constructor, Object[] args )
throws RepositoryException
- {
- if( null == constructor )
- {
- throw new NullArgumentException( "constructor" );
- }
- if( null == args )
- {
- throw new NullArgumentException( "args" );
- }
-
- Class[] classes = constructor.getParameterTypes();
- Object[] arguments = new Object[ classes.length ];
- ArrayList list = new ArrayList();
- for( int i=0; i < args.length; i++ )
- {
- list.add( args[i] );
- }
-
- //
- // sweep though the construct arguments one by one and
- // see if we can assign a value based on the supplied args
- //
-
- for( int i=0; i < classes.length; i++ )
- {
- Class clazz = classes[i];
- Iterator iterator = list.iterator();
- while( iterator.hasNext() )
- {
- Object object = iterator.next();
- Class c = object.getClass();
- if( isAssignableFrom( clazz, c ) )
- {
- arguments[i] = object;
- list.remove( object );
- break;
- }
- }
- }
-
- //
- // if any arguments are unresolved then check if the argument type
- // is something we can implicity establish
- //
-
- for( int i=0; i < arguments.length; i++ )
- {
- if( null == arguments[i] )
- {
- Class c = classes[i];
- if( c.isArray() )
- {
- arguments[i] = getEmptyArrayInstance( c );
- }
- else
- {
- final String error =
- "Unable to resolve a value for a constructor
parameter."
- + "\nConstructor class: " +
constructor.getDeclaringClass().getName()
- + "\nParameter class: " + c.getName()
- + "\nParameter position: " + ( i + 1 );
- throw new RepositoryException( error );
- }
- }
- }
- return arguments;
- }
-
- private boolean isAssignableFrom( Class clazz, Class c )
- {
- if( clazz.isPrimitive() )
- {
- if( Integer.TYPE == clazz )
- {
- return Integer.class.isAssignableFrom( c );
- }
- else if( Boolean.TYPE == clazz )
- {
- return Boolean.class.isAssignableFrom( c );
- }
- else if( Byte.TYPE == clazz )
- {
- return Byte.class.isAssignableFrom( c );
- }
- else if( Short.TYPE == clazz )
- {
- return Short.class.isAssignableFrom( c );
- }
- else if( Long.TYPE == clazz )
- {
- return Long.class.isAssignableFrom( c );
- }
- else if( Float.TYPE == clazz )
- {
- return Float.class.isAssignableFrom( c );
- }
- else if( Double.TYPE == clazz )
- {
- return Double.class.isAssignableFrom( c );
- }
- else
- {
- final String error =
- "Primitive type ["
- + c.getName()
- + "] not supported.";
- throw new RuntimeException( error );
- }
- }
- else
- {
- return clazz.isAssignableFrom( c );
- }
- }
-
- private Object newInstance( Constructor constructor, Object[] arguments )
- throws RepositoryException, InvocationTargetException
- {
- try
- {
- Object instance = constructor.newInstance( arguments );
- //getMonitor().pluginInstantiated( instance );
- return instance;
- }
- catch( InvocationTargetException e )
- {
- throw e;
- }
- catch( Throwable e )
- {
- final String error =
- "Cannot create an instance of ["
- + constructor.getDeclaringClass().getName()
- + "] due to an instantiation failure.";
- throw new RepositoryException( error, e );
- }
- }
-
- private Constructor getSingleConstructor( Class clazz ) throws
RepositoryException
- {
- if( null == clazz )
- {
- throw new NullArgumentException( "clazz" );
- }
- Constructor[] constructors = clazz.getConstructors();
- if( constructors.length < 1 )
- {
- final String error =
- "Target class ["
- + clazz.getName()
- + "] does not declare a public constructor.";
- throw new RepositoryException( error );
- }
- else if( constructors.length > 1 )
- {
- final String error =
- "Target class ["
- + clazz.getName()
- + "] declares multiple public constructors.";
- throw new RepositoryException( error );
- }
- else
- {
- return constructors[0];
- }
- }
-
- /**
- * Constructs an empty array instance.
- * @param clazz the array class
- * @return the empty array instance
- * @exception RepositoryException if an error occurs
- */
- private Object[] getEmptyArrayInstance( Class clazz ) throws
RepositoryException
- {
- try
- {
- return (Object[]) Array.newInstance( clazz.getComponentType(), 0
);
- }
- catch( Throwable e )
- {
- final String error =
- "Internal error while attempting to construct an empty array
for the class: "
- + clazz.getName();
- throw new RepositoryException( error, e );
- }
- }
-
- /**
- * Load a factory class using a supplied classloader and factory
classname.
- * @param classloader the classloader to load the class from
- * @param classname the plugin classname
- * @return the factory class
- * @exception RepositoryException if a factory class loading error occurs
- * @exception NullArgumentException if the supplied classloader or
classname is null
- */
- protected Class loadPluginClass( ClassLoader classloader, String
classname )
- throws RepositoryException, NullArgumentException
- {
- if( null == classloader )
- {
- throw new NullArgumentException( "classloader" );
- }
- if( null == classname )
- {
- throw new NullArgumentException( "classname" );
- }
-
- try
- {
- return classloader.loadClass( classname );
- }
- catch( ClassNotFoundException e )
- {
- StringBuffer buffer = new StringBuffer();
- packClassLoader( buffer, classloader );
- final String error =
- "Plugin class not found."
- + "Class: " + classname
- + "\n"
- + buffer.toString();
- throw new RepositoryException( error, e );
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error while attempting to load class: ["
- + classname
- + "].";
- throw new RepositoryException( error, e );
- }
- }
-
- private void packClassLoader( StringBuffer buffer, ClassLoader
classloader )
- {
- if( classloader instanceof StandardClassLoader )
- {
- StandardClassLoader loader = (StandardClassLoader) classloader;
- buffer.append( loader.toString( true ) );
- }
- else
- {
- buffer.append( "Classloader: " + classloader.toString() );
- }
- }
-}

Modified:
trunk/main/transit/core/src/main/net/dpml/transit/StandardLoader.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/StandardLoader.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/transit/StandardLoader.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -36,12 +36,17 @@
import net.dpml.transit.artifact.ArtifactNotFoundException;
import net.dpml.transit.monitor.RepositoryMonitorRouter;

-import net.dpml.lang.Plugin;
import net.dpml.lang.Classpath;
import net.dpml.lang.Category;
-import net.dpml.lang.Strategy;
-import net.dpml.lang.Handler;

+import net.dpml.part.Part;
+import net.dpml.part.PartDirective;
+import net.dpml.part.PartHandler;
+import net.dpml.part.PartHandlerFactory;
+import net.dpml.part.PartBuilder;
+import net.dpml.part.Strategy;
+import net.dpml.part.Plugin;
+
/**
* Utility class supporting downloading of resources based on
* artifact references.
@@ -52,21 +57,47 @@
class StandardLoader implements Repository
{
private final Logger m_logger;
+ private final PartBuilder m_builder;

+ private static final PartHandlerFactory FACTORY =
PartHandlerFactory.getInstance();
+
/**
* Creation of a new repository handler.
* @param logger the assigned logging channel
*/
- StandardLoader( Logger logger )
+ StandardLoader( Logger logger, PartBuilder builder )
{
m_logger = logger;
+ m_builder = builder;
}

//
------------------------------------------------------------------------
// Repository
//
------------------------------------------------------------------------
-
+
/**
+ * Creates a plugin descriptor from an artifact.
+ *
+ * @param uri the artifact reference to the plugin descriptor
+ * @return the plugin descriptor
+ * @exception IOException if a factory creation error occurs
+ */
+ public Part getPart( URI uri ) throws IOException
+ {
+ try
+ {
+ return m_builder.loadPart( uri );
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected error during part resolve."
+ + "\nURI: " + uri;
+ throw new RepositoryException( error, e );
+ }
+ }
+
+ /**
* Get a plugin classloader relative to a supplied uri.
*
* @param parent the parent classloader
@@ -79,26 +110,38 @@
public ClassLoader getPluginClassLoader( ClassLoader parent, URI uri )
throws IOException, NullArgumentException
{
- if( null == uri )
- {
- throw new NullArgumentException( "uri" );
- }
- if( null == parent )
- {
- throw new NullArgumentException( "parent" );
- }
+ Part part = getPart( uri );
+ return getPluginClassLoader( parent, part );
+ }
+
+ /**
+ * Get a plugin classloader relative to a supplied uri.
+ *
+ * @param parent the parent classloader
+ * @param uri the plugin uri
+ * @return the plugin classloader.
+ * @exception IOException if plugin loading exception occurs.
+ * @exception NullArgumentException if the supplied uri or parent
classloader
+ * is null.
+ */
+ public ClassLoader getPluginClassLoader( ClassLoader parent, Part part )
+ throws IOException, NullArgumentException
+ {
try
{
- Plugin descriptor = getPluginDescriptor( uri );
- return createClassLoader( parent, descriptor );
+ Classpath classpath = part.getClasspath();
+ Strategy strategy = part.getStrategy();
+ PartDirective directive = strategy.getPartDirective();
+ PartHandler handler =
+ PartHandlerFactory.getInstance().getPartHandler( directive );
+ return handler.getClassLoader( parent, classpath );
}
- catch( Exception ce )
+ catch( Exception e )
{
- String error =
- "Unable to create a plugin classloader using ["
- + uri
- + "].";
- throw new RepositoryException( error, ce );
+ final String error =
+ "Unexpected error during part classloader resolve."
+ + "\nPart: " + part;
+ throw new RepositoryException( error, e );
}
}

@@ -117,29 +160,70 @@
public Class getPluginClass( ClassLoader parent, URI uri )
throws IOException, NullArgumentException
{
- if( null == uri )
+ try
{
- throw new NullArgumentException( "uri" );
+ Part part = m_builder.loadPart( parent, uri );
+ return getPluginClass( parent, part );
}
- if( null == parent )
+ catch( Exception e )
{
- throw new NullArgumentException( "parent" );
+ final String error =
+ "Unexpected error during part class resolve."
+ + "\nURI: " + uri;
+ throw new RepositoryException( error, e );
}
-
- Plugin descriptor = getPluginDescriptor( uri );
+ }
+
+ /**
+ * Get a plugin class relative to a supplied artifact. The artifact uri
+ * must refer to a plugin descriptor (i.e. the artifact type is "plugin").
+ * The class returned will be the class named in the plugin descriptor.
+ *
+ * @param parent the parent classloader
+ * @param uri the plugin artifact
+ * @return the plugin class
+ * @exception IOException if a class resolution error occurs
+ * @exception NullArgumentException if the supplied parent classloader or
uri is null
+ */
+ public Class getPluginClass( ClassLoader parent, Part part )
+ throws IOException, NullArgumentException
+ {
try
{
- return getPluginClass( parent, descriptor );
+ Classpath classpath = part.getClasspath();
+ Strategy strategy = part.getStrategy();
+ PartDirective directive = strategy.getPartDirective();
+ PartHandler handler =
+ PartHandlerFactory.getInstance().getPartHandler( directive );
+ ClassLoader classloader = handler.getClassLoader( parent,
classpath );
+ Object data = strategy.getDeploymentData();
+ if( data instanceof Plugin )
+ {
+ Plugin plugin = (Plugin) data;
+ String classname = plugin.getClassname();
+ return classloader.loadClass( classname );
+ }
+ else
+ {
+ throw new UnsupportedOperationException( "getPartClass/" +
data.getClass().getName() );
+ }
}
catch( ClassNotFoundException e )
{
final String error =
"Class: " + e.getMessage()
- + "\nURI: " + uri;
+ + "\nPart: " + part;
throw new PluginClassNotFoundException( error );
}
+ catch( Exception e )
+ {
+ final String error =
+ "Unexpected error during part class resolve."
+ + "\nPart: " + part;
+ throw new RepositoryException( error, e );
+ }
}
-
+
/**
* Instantiate an object using a plugin uri, parent classloader and
* a supplied argument array. The plugin uri is used to resolve a plugin
@@ -161,23 +245,15 @@
public Object getPlugin( ClassLoader parent, URI uri, Object[] args )
throws IOException, InvocationTargetException, NullArgumentException
{
- if( null == uri )
- {
- throw new NullArgumentException( "uri" );
- }
- if( null == parent )
- {
- throw new NullArgumentException( "parent" );
- }
-
try
{
- getLogger().debug( "loading plugin: " + uri );
- Plugin descriptor = getPluginDescriptor( uri );
- ClassLoader classloader = createClassLoader( parent, descriptor
);
- Strategy strategy = descriptor.getStrategy();
- Handler handler = getHandler( classloader, strategy );
- return handler.getPlugin( classloader, strategy, args );
+ net.dpml.part.Part part = m_builder.loadPart( parent, uri );
+ Classpath classpath = part.getClasspath();
+ net.dpml.part.Strategy strategy = part.getStrategy();
+ net.dpml.part.PartDirective directive =
strategy.getPartDirective();
+ net.dpml.part.PartHandler handler =
PartHandlerFactory.getInstance().getPartHandler( directive );
+ Object data = strategy.getDeploymentData();
+ return handler.getInstance( parent, classpath, data, args );
}
catch( RepositoryException re )
{
@@ -191,123 +267,17 @@
{
String error = "Unable to create a plugin using [" + uri + "].";
getLogger().error( error, ce );
- throw new InvocationTargetException( ce );
+ throw new RepositoryException( error, ce );
}
}

- private Handler getHandler( ClassLoader classloader, Strategy strategy )
throws Exception
- {
- String classname = strategy.getHandlerClassname();
- Class clazz = classloader.loadClass( classname );
- Object handler = clazz.newInstance();
- if( handler instanceof Handler )
- {
- return (Handler) handler;
- }
- else
- {
- final String error =
- "Plugin handler classname ["
- + classname
- + "] does not implement the "
- + Handler.class.getName()
- + " interface.";
- throw new IllegalStateException( error );
- }
- }
-
//---------------------------------------------------------------------
// implementation
//---------------------------------------------------------------------

- /**
- * Get a plugin class relative to a supplied descriptor.
- *
- * @param parent the parent classloader
- * @param descriptor the plugin descriptor
- * @return the plugin class
- * @exception IOException if a cload establishement error occurs
- * @exception NullArgumentException if the parent classloader or
descriptor is null
- * @exception IllegalArgumentException if the classname could not be
resolved
- */
- private Class getPluginClass( ClassLoader parent, Plugin descriptor )
- throws IOException, NullArgumentException, IllegalArgumentException,
ClassNotFoundException
- {
- if( null == descriptor )
- {
- throw new NullArgumentException( "descriptor" );
- }
- if( null == parent )
- {
- throw new NullArgumentException( "parent" );
- }
-
- try
- {
- ClassLoader classloader = createClassLoader( parent, descriptor
);
- Strategy strategy = descriptor.getStrategy();
- Handler handler = getHandler( classloader, strategy );
- return handler.getPluginClass( classloader, strategy );
- }
- catch( ClassNotFoundException e )
- {
- throw e;
- }
- catch( IllegalArgumentException iae )
- {
- throw iae;
- }
- catch( Throwable e )
- {
- final String error =
- "Failed to load plugin.\nURI:"
- + descriptor.getURI();
- throw new RepositoryException( error, e );
- }
- }
-
- /**
- * Creates a plugin descriptor from an artifact.
- *
- * @param uri the reference to the application
- * @return the plugin descriptor
- * @exception IOException if a plugin creation error occurs
- * @exception NullArgumentException if the supplied uri is null
- */
- public Plugin getPluginDescriptor( URI uri )
- throws IOException, NullArgumentException
- {
- if( null == uri )
- {
- throw new NullArgumentException( "uri" );
- }
-
- try
- {
- PluginBuilder builder = new PluginBuilder( m_logger );
- URL url = getURL( uri );
- return builder.load( url );
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to resolve a plugin descriptor for ["
- + uri
- + "].";
- throw new RepositoryException( error, e );
- }
- }
-
private URL getURL( URI uri ) throws IOException
{
- if( Artifact.isRecognized( uri ) )
- {
- return Artifact.createArtifact( uri ).toURL();
- }
- else
- {
- return uri.toURL();
- }
+ return Artifact.toURL( uri );
}

/**
@@ -388,7 +358,8 @@
}
}

- public Object instantiate( Constructor constructor, Object[] args )
throws RepositoryException, InvocationTargetException
+ public Object instantiate( Constructor constructor, Object[] args )
+ throws RepositoryException, InvocationTargetException
{
Object[] arguments = populate( constructor, args );
return newInstance( constructor, arguments );
@@ -584,32 +555,6 @@
}

/**
- * Returns a classloader based on supplied plugin descriptor.
- * @param base the parent classloader
- * @param descriptor the plugin descriptor
- * @return the classloader
- * @exception IOException if a classloader construction error occurs
- * @exception NullArgumentException if either the base or the descriptor
- * argument is null.
- */
- private ClassLoader createClassLoader( ClassLoader base, Plugin
descriptor )
- throws IOException, NullArgumentException
- {
- if( null == descriptor )
- {
- throw new NullArgumentException( "descriptor" );
- }
- if( null == base )
- {
- throw new NullArgumentException( "base" );
- }
-
- URI plugin = descriptor.getURI();
- Classpath classpath = descriptor.getClasspath();
- return createClassLoader( base, plugin, classpath );
- }
-
- /**
* Returns a classloader.
* @param base the parent classloader
* @param plugin the plugin uri
@@ -810,50 +755,6 @@
}
}

- /**
- * Return the plugin attributes associated with an artifact.
- * @param artifact the relative artifact from which a .plugin resource
will
- * be resolved to establish the artifact attributes
- * @return the properties associated with the artifact
- * @exception RepositoryException if an error occurs while retrieving
- * or building the attributes
- * @exception NullArgumentException if the supplied artifact is null
- */
- private Properties getAttributes( Artifact artifact )
- throws RepositoryException, NullArgumentException
- {
- if( null == artifact )
- {
- throw new NullArgumentException( "artifact" );
- }
-
- try
- {
- URL url = artifact.toURL();
- Properties props = new Properties();
- URLConnection connection = url.openConnection();
- InputStream input = connection.getInputStream();
- props.load( input );
- return props;
- }
- catch( ArtifactNotFoundException e )
- {
- throw new RepositoryException( e.getMessage(), e.getCause() );
- }
- catch( RepositoryException e )
- {
- throw e;
- }
- catch( Throwable e )
- {
- final String error =
- "Internal error while attempting to resolve plugin for ["
- + artifact
- + "].";
- throw new RepositoryException( error, e );
- }
- }
-
/**
* Convert a uri to an artifact.
* @param uri the uri to convert

Modified: trunk/main/transit/core/src/main/net/dpml/transit/Value.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Value.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/main/net/dpml/transit/Value.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -47,7 +47,7 @@
Object resolve( Map map ) throws Exception;

/**
- * Resolve an instance from the value using a supplied isolvation policy.
+ * Resolve an instance from the value using a supplied isolation policy.
*
* @param isolate the isolation policy
* @return the resolved instance
@@ -67,4 +67,17 @@
*/
Object resolve( Map map, boolean isolate ) throws Exception;

+ /**
+ * Resolve an instance from the value using a supplied context map. If
any
+ * target expressions in immediate or nested values contain a symbolic
+ * expression the value will be resolved using the supplied map.
+ *
+ * @param classname the default classname
+ * @param map the context map
+ * @param isolate the isolation policy
+ * @return the resolved instance
+ * @exception Exception if error occurs during instance resolution
+ */
+ Object resolve( String classname, Map map, boolean isolate ) throws
Exception;
+
}

Modified:
trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactURLConnection.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactURLConnection.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactURLConnection.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -34,12 +34,14 @@
import net.dpml.transit.Artifact;
import net.dpml.transit.Transit;
import net.dpml.transit.Repository;
-import net.dpml.lang.Plugin;
import net.dpml.transit.SecuredTransitContext;
import net.dpml.transit.ContentRegistry;
import net.dpml.transit.CacheHandler;
import net.dpml.transit.util.MimeTypeHandler;

+//import net.dpml.lang.Plugin;
+import net.dpml.part.Part;
+
/**
* The connection handler for URLs based on the "artifact" protocol family.
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
@@ -199,7 +201,8 @@
// if the type is a plugin then handle this directly
//

- if( "plugin".equals( type ) )
+ //if( "plugin".equals( type ) )
+ if( "part".equals( type ) )
{
Repository loader = Transit.getInstance().getRepository();
ClassLoader classloader =
Thread.currentThread().getContextClassLoader();
@@ -233,9 +236,13 @@
{
return loader.getPluginClass( classloader, uri );
}
- else if( Plugin.class.equals( c ) )
+ //else if( Plugin.class.equals( c ) )
+ //{
+ // return loader.getPluginDescriptor( uri );
+ //}
+ else if( Part.class.equals( c ) )
{
- return loader.getPluginDescriptor( uri );
+ return loader.getPart( uri );
}
}
}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/info/ValueDirectiveBeanInfo.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/info/ValueDirectiveBeanInfo.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/main/net/dpml/transit/info/ValueDirectiveBeanInfo.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -1,80 +0,0 @@
-/*
- * Copyright 2005 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.dpml.transit.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.Expression;
-import java.beans.Encoder;
-
-/**
- * BeanInfo for the ValueDirective class.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ValueDirectiveBeanInfo extends SimpleBeanInfo
-{
- private static final BeanDescriptor BEAN_DESCRIPTOR =
setupBeanDescriptor();
-
- /**
- * Creation of a bean descriptor.
- * @return the bean descriptor
- */
- public BeanDescriptor getBeanDescriptor()
- {
- return BEAN_DESCRIPTOR;
- }
-
- private static BeanDescriptor setupBeanDescriptor()
- {
- BeanDescriptor descriptor = new BeanDescriptor( ValueDirective.class
);
- descriptor.setValue(
- "persistenceDelegate",
- new ValueDirectivePersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Persistence delegate.
- */
- private static class ValueDirectivePersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Instantiate an expression.
- * @param old the old value
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- ValueDirective construct = (ValueDirective) old;
- Object[] args = new Object[3];
- args[0] = construct.getTargetExpression();
- args[1] = construct.getMethodName();
- if( construct.isCompound() )
- {
- args[2] = construct.getValueDirectives();
- }
- else
- {
- args[2] = construct.getBaseValue();
- }
- return new Expression( old, old.getClass(), "new", args );
- }
- }
-}

Added: trunk/main/transit/core/src/test/net/dpml/part/PartTestCase.java
===================================================================
--- trunk/main/transit/core/src/test/net/dpml/part/PartTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/test/net/dpml/part/PartTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2004-2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.part;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URI;
+import java.net.URL;
+
+import net.dpml.part.Part;
+import net.dpml.part.Strategy;
+import net.dpml.part.PartDirective;
+import net.dpml.part.PartBuilder;
+import net.dpml.part.UnresolvableHandlerException;
+import net.dpml.part.PartHandlerFactory;
+import net.dpml.part.PartHandler;
+
+import junit.framework.TestCase;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.DocumentType;
+
+
+/**
+ * Plugin test case.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class PartTestCase extends TestCase
+{
+ static
+ {
+ System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
+ }
+
+ PartBuilder m_builder;
+
+ /**
+ * Test the demo class.
+ */
+ public void setUp() throws Exception
+ {
+ m_builder = new PartBuilder( null );
+ }
+
+ /**
+ * Test the demo class.
+ */
+ public void testPlugin() throws Exception
+ {
+ evaluateDocument( "plugin.xml" );
+ }
+
+ /**
+ * Test the demo class.
+ */
+ public void testResource() throws Exception
+ {
+ evaluateDocument( "resource.xml" );
+ }
+
+ private void evaluateDocument( String path ) throws Exception
+ {
+ String base = System.getProperty( "project.test.dir" );
+ File test = new File( base );
+ File file = new File( test, path );
+ System.out.println( "source: " + file + " (" + file.exists() + ")" );
+
+ Part part = m_builder.loadPart( file.toURI() );
+ File out = new File( test, "export-" + path );
+ FileOutputStream output = new FileOutputStream( out );
+ m_builder.writePart( part, output, "" );
+ Part newPart = m_builder.loadPart( out.toURI() );
+ assertEquals( "part", part, newPart );
+ }
+}

Deleted: trunk/main/transit/core/src/test/net/dpml/transit/PluginTestCase.java
===================================================================
--- trunk/main/transit/core/src/test/net/dpml/transit/PluginTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/core/src/test/net/dpml/transit/PluginTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -1,134 +0,0 @@
-/*
- * Copyright 2004-2006 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.transit;
-
-import java.net.URI;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import net.dpml.lang.Plugin;
-import net.dpml.lang.Strategy;
-import net.dpml.lang.Category;
-import net.dpml.lang.Classpath;
-
-import net.dpml.transit.monitor.LoggingAdapter;
-
-/**
- * Plugin test case.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class PluginTestCase extends TestCase
-{
- private URI[] m_system;
- private URI[] m_public;
- private URI[] m_protected;
- private URI[] m_private;
- private Classpath m_classpath;
- private String m_title = "Sample Plugin";
- private String m_description = "Plugin generated via a testcase used for
validation of the externalization of a plugin definition to XML and the
subsequent reading in of the XML form and cronstruction of an equivalent
plugin definition.";
-
- /**
- * Testcase setup.
- * @exception Exception if an error occurs
- */
- public void setUp() throws Exception
- {
- m_system =
- new URI[]
- {
- new URI( "thing:a" ),
- new URI( "thing:b" )
- };
- m_public =
- new URI[]
- {
- new URI( "thing:c" ),
- new URI( "thing:d" ),
- new URI( "thing:e" )
- };
- m_protected =
- new URI[]
- {
- new URI( "thing:f" )
- };
- m_private =
- new URI[]
- {
- new URI( "thing:g" ),
- new URI( "thing:h" ),
- new URI( "thing:i" ),
- new URI( "thing:j" )
- };
- m_classpath = new Classpath( m_system, m_public, m_protected,
m_private );
- }
-
- /**
- * Test invalid null path argument.
- * @exception Exception if an unexpected error occurs
- */
- public void testPluginCreation() throws Exception
- {
- URI uri = new URI( "plugin:test" );
- Properties properties = new Properties();
- properties.setProperty( "foo", "bar" );
- properties.setProperty( "pi", "3.142" );
- Strategy strategy = new DefaultStrategy( "Test", properties );
- Plugin plugin =
- new DefaultPlugin(
- m_title, m_description, uri, strategy, m_classpath );
- assertEquals( "title", m_title, plugin.getTitle() );
- assertEquals( "description", m_description, plugin.getDescription()
);
- assertEquals( "uri", uri, plugin.getURI() );
- assertEquals( "strategy", strategy, plugin.getStrategy() );
- Classpath classpath = plugin.getClasspath();
- assertEquals( "classpath", m_classpath, classpath );
- assertEquals( "system", m_system.length, classpath.getDependencies(
Category.SYSTEM ).length );
- assertEquals( "public", m_public.length, classpath.getDependencies(
Category.PUBLIC ).length );
- assertEquals( "protected", m_protected.length,
classpath.getDependencies( Category.PROTECTED ).length );
- assertEquals( "private", m_private.length,
classpath.getDependencies( Category.PRIVATE ).length );
- }
-
- /**
- * Test the generation of a plugin xml file using the simple strategy.
- * @exception Exception if an unexpected error occurs
- */
- public void testSimpleStrategyExternalization() throws Exception
- {
- File file = new File( "target/test/plugin.xml" );
- Properties properties = new Properties();
- properties.setProperty( "foo", "bar" );
- properties.setProperty( "pi", "3.142" );
- URI uri = file.toURI();
- Strategy strategy = new DefaultStrategy( "Test", properties );
- Plugin plugin =
- new DefaultPlugin(
- m_title, m_description, uri, strategy, m_classpath );
- FileOutputStream output = new FileOutputStream( file );
- plugin.write( output );
- PluginBuilder loader = new PluginBuilder( new LoggingAdapter() );
- Plugin p = loader.load( file.toURI().toURL() );
- assertEquals( "plugin", plugin, p );
- }
-
-}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/AbstractTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/AbstractTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/AbstractTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -65,43 +65,4 @@
assertEquals( "equals", object, serialized );
assertEquals( "hash", object.hashCode(), serialized.hashCode() );
}
-
- /**
- * Test encoding of the supplied object.
- * @param object the object to encode
- * @return the result of decoding the encoded form of the supplied object
- * @exception Exception is an error occurs
- */
- /*
- public Object doEncodingTest( Object object, String filename ) throws
Exception
- {
- String base = System.getProperty( "project.test.dir" );
- File test = new File( base );
- File encoding = new File( test, "encoding" );
- File destination = new File( encoding, filename );
- encoding.mkdirs();
- FileOutputStream output = new FileOutputStream( destination );
- BufferedOutputStream buffer = new BufferedOutputStream( output );
- XMLEncoder encoder = new XMLEncoder( buffer );
- encoder.setExceptionListener(
- new ExceptionListener()
- {
- public void exceptionThrown( Exception e )
- {
- e.printStackTrace();
- fail( "encoding exception: " + e.toString() );
- }
- }
- );
- encoder.writeObject( object );
- encoder.close();
- FileInputStream input = new FileInputStream( destination );
- XMLDecoder decoder = new XMLDecoder( new BufferedInputStream( input
) );
- Object result = decoder.readObject();
- assertTrue( "!=", object != result ); // Ensure this is not the same
instance
- assertEquals( "encoding", object, result );
- assertEquals( "hash", object.hashCode(), result.hashCode() );
- return result;
- }
- */
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/CacheDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/CacheDirectiveTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/CacheDirectiveTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -124,14 +124,4 @@
{
doSerializationTest( m_directive );
}
-
- /**
- * Test directive encoding.
- * @exception Exception if an error occurs during setup.
- */
- //public void testEncoding() throws Exception
- //{
- // CacheDirective result = (CacheDirective) doEncodingTest(
m_directive, "cache.xml" );
- // assertEquals( "encoded", m_directive, result );
- //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/CodeBaseDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/CodeBaseDirectiveTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/CodeBaseDirectiveTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -135,15 +135,4 @@
CodeBaseDirective directive = new CodeBaseDirective( m_codebase,
m_values );
doSerializationTest( directive );
}
-
- /**
- * Test encoding.
- * @exception Exception if an error occurs during setup.
- */
- //public void testEncoding() throws Exception
- //{
- // CodeBaseDirective directive = new CodeBaseDirective( m_codebase,
m_values );
- // CodeBaseDirective result = (CodeBaseDirective) doEncodingTest(
directive, "value-directive.xml" );
- // assertEquals( "encoded", directive, result );
- //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/ContentDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/ContentDirectiveTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/ContentDirectiveTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -102,19 +102,4 @@
new ContentDirective( m_id, m_title, codebase, values );
doSerializationTest( directive );
}
-
- /**
- * Test encoding.
- * @exception Exception if an error occurs during setup.
- */
- //public void testEncoding() throws Exception
- //{
- // String codebase = getCodebaseValue();
- // ValueDirective[] values = getValueDirectives();
- // ContentDirective directive =
- // new ContentDirective( m_id, m_title, codebase, values );
- // ContentDirective result =
- // (ContentDirective) doEncodingTest( directive,
"content-handler-directive.xml" );
- // assertEquals( "encoded", directive, result );
- //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/HostDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/HostDirectiveTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/HostDirectiveTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -263,18 +263,4 @@
m_layout, m_scheme, m_prompt );
doSerializationTest( directive );
}
-
- /**
- * Test encoding.
- * @exception Exception if an error occurs
- */
- //public void testEncoding() throws Exception
- //{
- // HostDirective directive =
- // new HostDirective(
- // m_id, m_priority, m_host, m_index, m_username, m_password,
m_enabled, m_trusted,
- // m_layout, m_scheme, m_prompt );
- // HostDirective result = (HostDirective) doEncodingTest( directive,
"host-directive.xml" );
- // assertEquals( "encoded", directive, result );
- //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/LayoutDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/LayoutDirectiveTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/LayoutDirectiveTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -102,19 +102,4 @@
new LayoutDirective( m_id, m_title, codebase, values );
doSerializationTest( directive );
}
-
- /**
- * Test encoding.
- * @exception Exception if an error occurs
- */
- //public void testEncoding() throws Exception
- //{
- // String codebase = getCodebaseValue();
- // ValueDirective[] values = getValueDirectives();
- // LayoutDirective directive =
- // new LayoutDirective( m_id, m_title, codebase, values );
- // LayoutDirective result =
- // (LayoutDirective) doEncodingTest( directive,
"content-handler-directive.xml" );
- // assertEquals( "encoded", directive, result );
- //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/ProxyDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/ProxyDirectiveTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/ProxyDirectiveTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -134,21 +134,6 @@
ProxyDirective directive = new ProxyDirective( host, excludes,
username, password );
doSerializationTest( directive );
}
-
- /**
- * Test classic encoding.
- * @exception Exception if an error occurs
- */
- //public void testClassicEncoding() throws Exception
- //{
- // String host = "http://localhost:1234";;
- // String[] excludes = new String[]{"http://www.osm.net"};
- // String username = "me";
- // char[] password = new char[0];
- // ProxyDirective directive = new ProxyDirective( host, excludes,
username, password );
- // ProxyDirective result = (ProxyDirective) doEncodingTest(
directive, "proxy-directive.xml" );
- // assertEquals( "encoded", directive, result );
- //}

/**
* Test serailization with null fields.
@@ -164,18 +149,4 @@
doSerializationTest( directive );
}

- /**
- * Test encoding with null fields.
- * @exception Exception if an error occurs
- */
- //public void testNullEncoding() throws Exception
- //{
- // String host = "http://localhost:1234";;
- // String[] excludes = null;
- // String username = null;
- // char[] password = null;
- // ProxyDirective directive = new ProxyDirective( host, excludes,
username, password );
- // ProxyDirective result = (ProxyDirective) doEncodingTest(
directive, "proxy-directive.xml" );
- // assertEquals( "encoded", directive, result );
- //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/TransitDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/TransitDirectiveTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/TransitDirectiveTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -75,14 +75,4 @@
{
doSerializationTest( m_directive );
}
-
- /**
- * Test directive encoding.
- * @exception Exception if an error occurs
- */
- //public void testEncoding() throws Exception
- //{
- // TransitDirective result = (TransitDirective) doEncodingTest(
m_directive, "transit.xml" );
- // assertEquals( "encoded", m_directive, result );
- //}
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/ValueDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/ValueDirectiveTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/ValueDirectiveTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -201,21 +201,6 @@
ValueDirective directive = new ValueDirective( target, args );
doSerializationTest( directive );
}
-
- /**
- * Test encoding.
- * @exception Exception if an error occurs
- */
- //public void testEncoding() throws Exception
- //{
- // String target = "java.io.File";
- // ValueDirective base = new ValueDirective( "java.io.File", "." );
- // ValueDirective spec = new ValueDirective( "test" );
- // ValueDirective[] args = new ValueDirective[]{base, spec};
- // ValueDirective directive = new ValueDirective( target, args );
- // ValueDirective result = (ValueDirective) doEncodingTest(
directive, "value-directive.xml" );
- // assertEquals( "encoded", directive, result );
- //}
}



Modified:
trunk/main/transit/core/src/test/net/dpml/transit/test/AbstractEncodingTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/test/AbstractEncodingTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/test/net/dpml/transit/test/AbstractEncodingTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -18,18 +18,10 @@

package net.dpml.transit.test;

-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedInputStream;
-import java.beans.Encoder;
-import java.beans.XMLDecoder;
-import java.beans.XMLEncoder;
-import java.beans.ExceptionListener;
-import java.beans.Expression;
-import java.beans.DefaultPersistenceDelegate;
-import java.net.URI;
+import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;

import junit.framework.TestCase;

@@ -48,52 +40,23 @@
* @return the result of decoding the encoded structure
* @exception Exception if an error occurs
*/
- public Object executeEncodingTest( Object object, String filename )
throws Exception
+ public Object executeEncodingTest( Object object ) throws Exception
{
- File test = new File( "target/test" );
- File destination = new File( test, filename );
- FileOutputStream output = new FileOutputStream( destination );
- BufferedOutputStream buffer = new BufferedOutputStream( output );
- XMLEncoder encoder = new XMLEncoder( buffer );
- encoder.setPersistenceDelegate( URI.class, new
URIPersistenceDelegate() );
- encoder.setExceptionListener(
- new ExceptionListener()
- {
- public void exceptionThrown( Exception e )
- {
- e.printStackTrace();
- fail( "encoding exception: " + e.toString() );
- }
- }
- );
- encoder.writeObject( object );
- encoder.close();
+ ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
+ ObjectOutputStream output = new ObjectOutputStream( byteOutputStream
);
+ output.writeObject( object );
+ output.close();
+
+ ByteArrayInputStream byteInputStream = new ByteArrayInputStream(
byteOutputStream.toByteArray() );
+ ObjectInputStream input = new ObjectInputStream( byteInputStream );
+ Object serialized = input.readObject();
+ input.close();
+
+ assertTrue( "!=", object != serialized ); // Ensure this is not the
same instance
+ assertEquals( "equals", object, serialized );
+ assertEquals( "hash", object.hashCode(), serialized.hashCode() );

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

- /**
- * Internal persitance delage for the URI class.
- */
- public static class URIPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Create an expression using an existing uri.
- * @param old the old uri
- * @param encoder the encoder
- * @return the expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- URI uri = (URI) old;
- String spec = uri.toString();
- Object[] args = new Object[]{spec};
- return new Expression( old, old.getClass(), "new", args );
- }
- }
-
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/test/ConstructTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/test/ConstructTestCase.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/core/src/test/net/dpml/transit/test/ConstructTestCase.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -266,7 +266,7 @@
Value number = new Construct( "int", "${number}" );
Value logical = new Construct( "boolean", "${logical}" );
Value construct = new Construct( Context2.class.getName(), new
Value[]{number, logical} );
- Value result = (Value) executeEncodingTest( construct,
"construct.xml" );
+ Value result = (Value) executeEncodingTest( construct );
assertEquals( "encoding", construct, result );
}


Deleted: trunk/main/transit/core/src/test/plugin.properties
===================================================================
--- trunk/main/transit/core/src/test/plugin.properties 2006-03-14 15:58:38
UTC (rev 1169)
+++ trunk/main/transit/core/src/test/plugin.properties 2006-03-14 15:59:54
UTC (rev 1170)
@@ -1,46 +0,0 @@
-
-#
-# Specification classifier.
-#
-dpml.plugin.meta.namespace = net.dpml
-dpml.plugin.meta.version = 1.0
-
-#
-# Artifact descriptor.
-#
-dpml.artifact.group = dpml/metro
-dpml.artifact.name = dpml-metro-cli
-dpml.artifact.version = 123
-dpml.artifact.signature = 20041031.131418
-
-#
-# Type.
-#
-dpml.plugin.class = net.dpml.metro.Metro
-
-#
-# API dependencies.
-#
-dpml.artifact.dependency.api.0 =
artifact:jar:dpml/logging/dpml-logging-api#123
-dpml.artifact.dependency.api.1 =
artifact:jar:dpml/activity/dpml-activity-api#123
-dpml.artifact.dependency.api.2 =
artifact:jar:dpml/context/dpml-context-api#123
-dpml.artifact.dependency.api.3 =
artifact:jar:dpml/transit/dpml-transit-main#123
-
-#
-# SPI dependencies.
-#
-dpml.artifact.dependency.spi.0 =
artifact:jar:dpml/transit/dpml-transit-spi#123
-dpml.artifact.dependency.spi.1 =
artifact:jar:dpml/logging/dpml-logging-spi#123
-
-#
-# Implementation dependencies.
-#
-dpml.artifact.dependency.0 = artifact:jar:dpml/util/dpml-util-i18n#123
-dpml.artifact.dependency.1 = artifact:jar:dpml/util/dpml-util-exception#123
-dpml.artifact.dependency.2 = artifact:jar:dpml/util/dpml-util-cli#123
-dpml.artifact.dependency.3 = artifact:jar:commons-cli/commons-cli#1.0
-dpml.artifact.dependency.4 = artifact:jar:dpml/metro/dpml-metro-cli#123
-
-#
-# EOF.
-#

Modified: trunk/main/transit/module.xml
===================================================================
--- trunk/main/transit/module.xml 2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/module.xml 2006-03-14 15:59:54 UTC (rev 1170)
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE module PUBLIC "-//DPML//DTD Library 1.0//EN"
"http://download.dpml.net/dtds/library_1_0.dtd"; >
-
-<module name="transit">
+<module name="transit"
+ xmlns="artifact:xsd:dpml/lang/dpml-module#1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+ xmlns:part="artifact:xsd:dpml/lang/dpml-part#1.0">

<properties>
<property name="project.test.fork" value="true"/>
@@ -10,10 +11,7 @@
<project name="dpml-transit-console" basedir="console">
<types>
<type id="jar"/>
- <type id="plugin">
- <property name="project.plugin.class"
- value="net.dpml.transit.console.TransitConsoleHandler"/>
- </type>
+ <part:plugin class="net.dpml.transit.console.TransitConsoleHandler"/>
</types>
<dependencies>
<include ref="dpml/transit/dpml-transit-main"/>
@@ -24,17 +22,17 @@
</dependencies>
</project>

- <resource name="dpml-transit-main" basedir="core">
+ <resource name="dpml-transit-main">
<types>
<type id="jar"/>
</types>
</resource>

- <resource name="dpml-transit-tools" basedir="tools">
+ <resource name="dpml-transit-tools">
<types>
<type id="jar"/>
</types>
- <dependencies scope="RUNTIME">
+ <dependencies scope="runtime">
<include key="dpml-transit-main"/>
<include ref="ant/ant"/>
</dependencies>

Modified: trunk/main/transit/tools/build.properties
===================================================================
--- trunk/main/transit/tools/build.properties 2006-03-14 15:58:38 UTC (rev
1169)
+++ trunk/main/transit/tools/build.properties 2006-03-14 15:59:54 UTC (rev
1170)
@@ -1,4 +1,4 @@

-home = ..
+home = ../..
project.specification.version = 1.0


Modified:
trunk/main/transit/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
===================================================================
---
trunk/main/transit/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/tools/src/main/net/dpml/transit/tools/ImportArtifactTask.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -95,8 +95,7 @@
{
try
{
- Artifact artifact = Artifact.createArtifact( uri );
- URL url = artifact.toURL();
+ URL url = Artifact.toURL( uri );
File local = (File) url.getContent( new Class[]{File.class} );
super.setFile( local.getAbsolutePath() );
}

Modified:
trunk/main/transit/tools/src/main/net/dpml/transit/tools/PluginTask.java
===================================================================
--- trunk/main/transit/tools/src/main/net/dpml/transit/tools/PluginTask.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/tools/src/main/net/dpml/transit/tools/PluginTask.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -27,9 +27,13 @@

import net.dpml.transit.Transit;
import net.dpml.transit.Repository;
-import net.dpml.lang.Plugin;
import net.dpml.transit.util.ElementHelper;

+//import net.dpml.lang.Plugin;
+import net.dpml.part.Part;
+import net.dpml.part.Plugin;
+import net.dpml.part.Resource;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Project;
@@ -280,12 +284,19 @@
private void loadAntlib(
URI uri, ClassLoader classloader, ComponentHelper helper, Antlib
antlib ) throws Exception
{
- Plugin plugin = getRepository().getPluginDescriptor( uri );
-
+ //Plugin plugin = getRepository().getPluginDescriptor( uri );
+ Part part = getRepository().getPart( uri );
+ Object data = part.getStrategy().getDeploymentData();
+
String resource = antlib.getPath();
if( null == resource )
{
- resource = plugin.getStrategy().getProperties().getProperty(
"project.plugin.resource" );
+ if( data instanceof Resource )
+ {
+ Resource res = (Resource) data;
+ resource = res.getPath();
+ }
+ //resource = plugin.getStrategy().getProperties().getProperty(
"project.plugin.resource" );
}
if( null == resource )
{
@@ -296,8 +307,8 @@
+ "]";
throw new BuildException( error, getLocation() );
}
-
- String urn = getAntLibURN( antlib, plugin );
+
+ String urn = getAntLibURN( antlib, data );
if( null == urn )
{
final String error =
@@ -329,7 +340,8 @@
}
}

- private String getAntLibURN( Antlib antlib, Plugin plugin )
+ //private String getAntLibURN( Antlib antlib, Plugin plugin )
+ private String getAntLibURN( Antlib antlib, Object data )
{
if( null != m_urn )
{
@@ -342,7 +354,16 @@
}
else
{
- return plugin.getStrategy().getProperties().getProperty(
"project.plugin.urn" );
+ if( data instanceof Resource )
+ {
+ Resource res = (Resource) data;
+ return res.getURN();
+ }
+ else
+ {
+ return null;
+ }
+ //return plugin.getStrategy().getProperties().getProperty(
"project.plugin.urn" );
}
}


Modified:
trunk/main/transit/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
===================================================================
---
trunk/main/transit/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
2006-03-14 15:58:38 UTC (rev 1169)
+++
trunk/main/transit/tools/src/main/net/dpml/transit/tools/TransitComponentHelper.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -23,7 +23,11 @@
import java.util.Hashtable;
import java.net.URI;

-import net.dpml.lang.Plugin;
+import net.dpml.part.Part;
+import net.dpml.part.Plugin;
+import net.dpml.part.Resource;
+
+//import net.dpml.lang.Plugin;
import net.dpml.transit.Repository;
import net.dpml.transit.Transit;
import net.dpml.transit.util.ElementHelper;
@@ -84,7 +88,8 @@
/**
* The constant artifact plugin header.
*/
- public static final String PLUGIN_ARTIFACT_HEADER = "artifact:plugin:";
+ //public static final String PLUGIN_ARTIFACT_HEADER = "artifact:plugin:";
+ public static final String PLUGIN_ARTIFACT_HEADER = "artifact:part:";

/**
* Creation of a component helper for the supplied project.
@@ -340,20 +345,23 @@
m_project.log( "installing: " + uri + " as " + urn );

Repository loader = Transit.getInstance().getRepository();
- Plugin descriptor = loader.getPluginDescriptor( uri );
+ Part part = loader.getPart( uri );
+ Object data = part.getStrategy().getDeploymentData();
+
ClassLoader current =
Thread.currentThread().getContextClassLoader();
- ClassLoader classloader = loader.getPluginClassLoader( current,
uri );
- String pluginClassname =
descriptor.getStrategy().getProperties().getProperty( "project.plugin.class"
);
- if( null != pluginClassname )
+
+ if( data instanceof Plugin )
{
- Class clazz = classloader.loadClass( pluginClassname );
+ Class clazz = loader.getPluginClass( current, part );
final String key = uri + ":" + name;
getProject().log( "installing single task plugin [" + key +
"]", Project.MSG_VERBOSE );
super.addTaskDefinition( key, clazz );
}
- else
+ else if( data instanceof Resource )
{
- String resource =
descriptor.getStrategy().getProperties().getProperty(
"project.plugin.resource" );
+ ClassLoader classloader = loader.getPluginClassLoader(
current, part );
+ Resource res = (Resource) data;
+ String resource = res.getPath();
getProject().log( "installing antlib plugin [" + resource +
"]", Project.MSG_VERBOSE );
InputStream input = classloader.getResourceAsStream(
resource );
if( null == input )

Modified:
trunk/main/transit/tools/src/main/net/dpml/transit/tools/TransitTask.java
===================================================================
--- trunk/main/transit/tools/src/main/net/dpml/transit/tools/TransitTask.java
2006-03-14 15:58:38 UTC (rev 1169)
+++ trunk/main/transit/tools/src/main/net/dpml/transit/tools/TransitTask.java
2006-03-14 15:59:54 UTC (rev 1170)
@@ -79,6 +79,10 @@
if( !m_INIT )
{
m_INIT = true;
+ if( null == System.getProperty( "java.protocol.handler.pkgs"
) )
+ {
+ System.setProperty( "java.protocol.handler.pkgs",
"net.dpml.transit" );
+ }
try
{
Adapter logger = new AntAdapter( task );




  • r1170 - in trunk/main/transit: . console/etc/bin core core/etc/test core/src/main/net/dpml/lang core/src/main/net/dpml/part core/src/main/net/dpml/transit core/src/main/net/dpml/transit/artifact core/src/main/net/dpml/transit/info core/src/test core/src/test/net/dpml core/src/test/net/dpml/part core/src/test/net/dpml/transit core/src/test/net/dpml/transit/info core/src/test/net/dpml/transit/test tools tools/src/main/net/dpml/transit/tools, mcconnell at BerliOS, 03/14/2006

Archive powered by MHonArc 2.6.24.

Top of Page