notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r1141 - in trunk/lab: . component component/etc component/etc/deliverables component/etc/deliverables/xsds part part/etc part/etc/deliverables part/etc/deliverables/xsds schema schema/etc schema/etc/test schema/src/main/dpmlx/schema schema/src/test/dpmlx/schema/test
- From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
- To: notify-dpml AT lists.ibiblio.org
- Subject: r1141 - in trunk/lab: . component component/etc component/etc/deliverables component/etc/deliverables/xsds part part/etc part/etc/deliverables part/etc/deliverables/xsds schema schema/etc schema/etc/test schema/src/main/dpmlx/schema schema/src/test/dpmlx/schema/test
- Date: Tue, 28 Feb 2006 10:37:49 +0100
Author: mcconnell
Date: 2006-02-28 10:37:45 +0100 (Tue, 28 Feb 2006)
New Revision: 1141
Added:
trunk/lab/component/
trunk/lab/component/build.xml
trunk/lab/component/etc/
trunk/lab/component/etc/deliverables/
trunk/lab/component/etc/deliverables/xsds/
trunk/lab/component/etc/deliverables/xsds/project.xsd
trunk/lab/part/
trunk/lab/part/build.xml
trunk/lab/part/etc/
trunk/lab/part/etc/deliverables/
trunk/lab/part/etc/deliverables/xsds/
trunk/lab/part/etc/deliverables/xsds/project.xsd
trunk/lab/schema/build.xml
trunk/lab/schema/etc/
trunk/lab/schema/etc/test/
trunk/lab/schema/etc/test/component.xml
trunk/lab/schema/etc/test/plugin.xml
Removed:
trunk/lab/schema/examples/
Modified:
trunk/lab/library.xml
trunk/lab/schema/
trunk/lab/schema/src/main/dpmlx/schema/StandardBuilder.java
trunk/lab/schema/src/test/dpmlx/schema/test/SchemaTestCase.java
Log:
building the namespace to to handler resolution strategy
Property changes on: trunk/lab/component
___________________________________________________________________
Name: svn:ignore
+ target
Added: trunk/lab/component/build.xml
===================================================================
--- trunk/lab/component/build.xml 2006-02-28 03:19:46 UTC (rev 1140)
+++ trunk/lab/component/build.xml 2006-02-28 09:37:45 UTC (rev 1141)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="dpml:depot" >
+
+ <transit:import uri="local:template:dpml/tools/standard"/>
+
+ <target name="init" depends="standard.init">
+ <x:filter feature="uri" type="xsd" token="PROJECT-XSD-URI"/>
+ </target>
+
+ <target name="package" depends="standard.package">
+ <move file="target/deliverables/xsds/project.xsd"
+
toFile="target/deliverables/xsds/${project.name}-${project.version}.xsd"/>
+ </target>
+
+</project>
Added: trunk/lab/component/etc/deliverables/xsds/project.xsd
===================================================================
--- trunk/lab/component/etc/deliverables/xsds/project.xsd 2006-02-28
03:19:46 UTC (rev 1140)
+++ trunk/lab/component/etc/deliverables/xsds/project.xsd 2006-02-28
09:37:45 UTC (rev 1141)
@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="@PROJECT-XSD-URI@"
+ xmlns="@PROJECT-XSD-URI@"
+ elementFormDefault="qualified">
+
+ <xsd:element name="component" type="ComponentType"/>
+
+ <xsd:complexType name="ComponentType">
+ <xsd:sequence>
+ <xsd:element name="context" type="ContextType" minOccurs="0"
maxOccurs="1"/>
+ </xsd:sequence>
+ <xsd:attribute name="type" type="xsd:string"/>
+ <xsd:attribute name="lifestyle" type="xsd:string"/>
+ <xsd:attribute name="collection" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="ContextType">
+ <xsd:sequence>
+ <xsd:element name="entry" type="EntryType" minOccurs="0"
maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="EntryType">
+ <xsd:sequence>
+ <xsd:element name="value" type="ValueType" minOccurs="0"
maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="key" type="xsd:string"/>
+ <xsd:attribute name="value" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="ValueType">
+ <xsd:sequence>
+ <xsd:element name="value" type="ValueType" minOccurs="0"
maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="class" type="xsd:string"/>
+ <xsd:attribute name="value" type="xsd:string"/>
+ </xsd:complexType>
+
+</xsd:schema>
Modified: trunk/lab/library.xml
===================================================================
--- trunk/lab/library.xml 2006-02-28 03:19:46 UTC (rev 1140)
+++ trunk/lab/library.xml 2006-02-28 09:37:45 UTC (rev 1141)
@@ -8,10 +8,26 @@
<import uri="link:module:dpml"/>
</imports>
+ <properties>
+ <property name="project.test.fork" value="true"/>
+ </properties>
+
<modules>
<module name="dpmlx">
+ <project name="dpmlx-part" basedir="part">
+ <types>
+ <type id="xsd"/>
+ </types>
+ </project>
+
+ <project name="dpmlx-component" basedir="component">
+ <types>
+ <type id="xsd"/>
+ </types>
+ </project>
+
<project name="dpmlx-schema-test" basedir="schema">
<types>
<type id="jar"/>
@@ -20,6 +36,10 @@
value="dpmlx.schema.StandardBuilder"/>
</type>
</types>
+ <dependencies scope="build">
+ <include key="dpmlx-part"/>
+ <include key="dpmlx-component"/>
+ </dependencies>
<dependencies scope="test">
<include ref="dpml/transit/dpml-transit-main"/>
<include ref="ant/ant-junit"/>
Property changes on: trunk/lab/part
___________________________________________________________________
Name: svn:ignore
+ target
Added: trunk/lab/part/build.xml
===================================================================
--- trunk/lab/part/build.xml 2006-02-28 03:19:46 UTC (rev 1140)
+++ trunk/lab/part/build.xml 2006-02-28 09:37:45 UTC (rev 1141)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="dpml:depot" >
+
+ <transit:import uri="local:template:dpml/tools/standard"/>
+
+ <target name="init" depends="standard.init">
+ <x:filter feature="uri" type="xsd" token="PROJECT-XSD-URI"/>
+ </target>
+
+ <target name="package" depends="standard.package">
+ <move file="target/deliverables/xsds/project.xsd"
+
toFile="target/deliverables/xsds/${project.name}-${project.version}.xsd"/>
+ </target>
+
+</project>
Added: trunk/lab/part/etc/deliverables/xsds/project.xsd
===================================================================
--- trunk/lab/part/etc/deliverables/xsds/project.xsd 2006-02-28 03:19:46
UTC (rev 1140)
+++ trunk/lab/part/etc/deliverables/xsds/project.xsd 2006-02-28 09:37:45
UTC (rev 1141)
@@ -0,0 +1,83 @@
+<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="@PROJECT-XSD-URI@"
+ xmlns="@PROJECT-XSD-URI@"
+ elementFormDefault="qualified">
+
+ <xsd:element name="part" type="PartType"/>
+
+ <xsd:complexType name="PartType">
+ <xsd:sequence>
+ <xsd:element name="info" type="InfoType"/>
+ <xsd:choice>
+ <xsd:element name="strategy" type="StrategyType"/>
+ <xsd:element name="plugin" type="PluginType"/>
+ </xsd:choice>
+ <xsd:element name="classpath" type="ClassPathType"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="StrategyType">
+ <xsd:sequence>
+ <xsd:any minOccurs="0"/>
+ </xsd:sequence>
+ <xsd:attribute name="uri" type="xsd:anyURI"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="ClassPathType">
+ <xsd:sequence>
+ <xsd:element name="system" type="ClassLoaderType" minOccurs="0"
maxOccurs="1"/>
+ <xsd:element name="public" type="ClassLoaderType" minOccurs="0"
maxOccurs="1"/>
+ <xsd:element name="protected" type="ClassLoaderType" minOccurs="0"
maxOccurs="1"/>
+ <xsd:element name="private" type="ClassLoaderType" minOccurs="0"
maxOccurs="1"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="ClassLoaderType">
+ <xsd:sequence>
+ <xsd:element name="uri" type="URIType" minOccurs="0"
maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="InfoType">
+ <xsd:sequence>
+ <xsd:element name="description" type="xsd:string" minOccurs="0"
maxOccurs="1"/>
+ </xsd:sequence>
+ <xsd:attribute name="title" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="URIType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:anyURI"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="PluginType">
+ <xsd:choice>
+ <xsd:element name="class" type="ClassType"/>
+ <xsd:element name="resource" type="ResourceType"/>
+ </xsd:choice>
+ </xsd:complexType>
+
+ <xsd:complexType name="ClassType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:string"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+ <xsd:complexType name="ResourceType">
+ <xsd:sequence>
+ <xsd:element name="urn" type="URNType"/>
+ <xsd:element name="path" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="URNType">
+ <xsd:simpleContent>
+ <xsd:extension base="xsd:anyURI"/>
+ </xsd:simpleContent>
+ </xsd:complexType>
+
+
+</xsd:schema>
+
Property changes on: trunk/lab/schema
___________________________________________________________________
Name: svn:ignore
+ target
Added: trunk/lab/schema/build.xml
===================================================================
--- trunk/lab/schema/build.xml 2006-02-28 03:19:46 UTC (rev 1140)
+++ trunk/lab/schema/build.xml 2006-02-28 09:37:45 UTC (rev 1141)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="dpml:depot" >
+
+ <transit:import uri="local:template:dpml/tools/standard"/>
+
+ <target name="init" depends="standard.init">
+ <x:filter feature="uri" type="xsd" token="COMPONENT-XSD-URI"
ref="dpmlx/dpmlx-component"/>
+ <x:filter feature="uri" type="xsd" token="PART-XSD-URI"
ref="dpmlx/dpmlx-part"/>
+ <x:filter feature="version" token="VERSION"/>
+ </target>
+
+</project>
Added: trunk/lab/schema/etc/test/component.xml
===================================================================
--- trunk/lab/schema/etc/test/component.xml 2006-02-28 03:19:46 UTC (rev
1140)
+++ trunk/lab/schema/etc/test/component.xml 2006-02-28 09:37:45 UTC (rev
1141)
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<part xmlns="@PART-XSD-URI@"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:metro="@COMPONENT-XSD-URI@"
+ xsi:schemaLocation="
+ @PART-XSD-URI@ @PART-XSD-URI@
+ @COMPONENT-XSD-URI@ @COMPONENT-XSD-URI@
+ " >
+
+ <info title="Demo Part">
+ <description>
+ Plugin descriptor using XMLSchema.
+ </description>
+ </info>
+
+ <strategy uri="link:plugin:dpml/metro/dpml-metro-builder">
+ <metro:component type="org.acme.Widget">
+ <metro:context>
+ <metro:entry key="foo" value="abc"/>
+ <metro:entry key="bar">
+ <metro:value class="int" value="2"/>
+ </metro:entry>
+ </metro:context>
+ </metro:component>
+ </strategy>
+
+ <classpath>
+ <public>
+ <uri>link:jar:fred/blogs"</uri>
+ <uri>link:jar:peter/rabbit"</uri>
+ </public>
+ </classpath>
+
+</part>
Added: trunk/lab/schema/etc/test/plugin.xml
===================================================================
--- trunk/lab/schema/etc/test/plugin.xml 2006-02-28 03:19:46 UTC (rev
1140)
+++ trunk/lab/schema/etc/test/plugin.xml 2006-02-28 09:37:45 UTC (rev
1141)
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<part xmlns="@PART-XSD-URI@"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ @PART-XSD-URI@ @PART-XSD-URI@
+ ">
+
+ <info title="Demo Plugin">
+ <description>
+ Plugin descriptor using XMLSchema.
+ </description>
+ </info>
+
+ <plugin>
+ <class>Widget</class>
+ <!--
+ <resource>
+ <urn>dpml:metro</urn>
+ <path>net/dpml/metro/tools/antlib.xml</path>
+ </resource>
+ -->
+ </plugin>
+
+ <classpath>
+ <public>
+ <uri>link:jar:fred/blogs"</uri>
+ <uri>link:jar:peter/rabbit"</uri>
+ </public>
+ </classpath>
+
+</part>
Modified: trunk/lab/schema/src/main/dpmlx/schema/StandardBuilder.java
===================================================================
--- trunk/lab/schema/src/main/dpmlx/schema/StandardBuilder.java 2006-02-28
03:19:46 UTC (rev 1140)
+++ trunk/lab/schema/src/main/dpmlx/schema/StandardBuilder.java 2006-02-28
09:37:45 UTC (rev 1141)
@@ -108,17 +108,22 @@
}
else
{
- //dbf.setFeature( FEATURE_SECURE_PROCESSING, false );
+ System.out.println( "VALIDATING" );
Class schemaFactoryClass =
getClass().getClassLoader().loadClass( "javax.xml.validation.SchemaFactory" );
+ Class schemaClass = getClass().getClassLoader().loadClass(
"javax.xml.validation.Schema" );
+
Method newInstanceMethod = schemaFactoryClass.getMethod(
"newInstance", new Class[]{ String.class } );
Object schemaFactory = newInstanceMethod.invoke( null, new
Object[]{ W3C_XML_SCHEMA_NS_URI } );
- Method newSchemaMethod = schemaFactory.getClass().getMethod(
"newSchema", new Class[0] );
+ Method newSchemaMethod = schemaFactoryClass.getMethod(
"newSchema", new Class[0] );
Object schemaObject = newSchemaMethod.invoke( schemaFactory, new
Object[0] );
- Class schemaClass = getClass().getClassLoader().loadClass(
"javax.xml.validation.Schema" );
Method setSchemaMethod = DocumentBuilderFactory.class.getMethod(
"setSchema", new Class[]{ schemaClass } );
setSchemaMethod.invoke( dbf, new Object[]{ schemaObject } );
+
+ //Class validatorClass = getClass().getClassLoader().loadClass(
"javax.xml.validation.Validator" );
+ //Method newValidatorMethod = schemaClass.getMethod(
"newValidator", new Class[0] );
+
//SchemaFactory factory = SchemaFactory.newInstance(
XMLConstants.W3C_XML_SCHEMA_NS_URI );
//Schema schema = factory.newSchema();
//dbf.setXIncludeAware( false );
Modified: trunk/lab/schema/src/test/dpmlx/schema/test/SchemaTestCase.java
===================================================================
--- trunk/lab/schema/src/test/dpmlx/schema/test/SchemaTestCase.java
2006-02-28 03:19:46 UTC (rev 1140)
+++ trunk/lab/schema/src/test/dpmlx/schema/test/SchemaTestCase.java
2006-02-28 09:37:45 UTC (rev 1141)
@@ -28,7 +28,7 @@
public void setUp() throws Exception
{
ClassLoader classloader = Transit.class.getClassLoader();
- File file = new File(
"target/deliverables/plugins/dpmlx-schema-test-SNAPSHOT.plugin" );
+ File file = new File(
"target/deliverables/plugins/dpmlx-schema-test-@VERSION@.plugin" );
URI uri = file.toURI();
Object[] args = new Object[0];
m_builder =
@@ -41,39 +41,49 @@
*/
public void testPlugin() throws Exception
{
- Document doc = m_builder.parse( "examples/plugin.xml" );
- final Element root = doc.getDocumentElement();
- final String uri = root.getNamespaceURI();
- //System.out.println( "NS: [" + uri + "]" );
- //System.out.println( "ROOT: [" + root + "]" );
- Element strategy = ElementHelper.getChild( root, "strategy" );
- String handlerUri = ElementHelper.getAttribute( strategy, "uri" );
- if( null == handlerUri )
- {
- System.out.println( "DEFAULT STRATEGY" );
- }
- else
- {
- System.out.println( "CUSTOM STRATEGY: " + handlerUri );
- }
+ Document doc = m_builder.parse( "target/test/plugin.xml" );
+ evaluateDocument( doc );
}
public void testComponent() throws Exception
{
- Document doc = m_builder.parse( "examples/component.xml" );
+ Document doc = m_builder.parse( "target/test/component.xml" );
+ evaluateDocument( doc );
+ }
+
+ private void evaluateDocument( Document doc ) throws Exception
+ {
final Element root = doc.getDocumentElement();
- final String uri = root.getNamespaceURI();
- //System.out.println( "NS: [" + uri + "]" );
- //System.out.println( "ROOT: [" + root + "]" );
- Element strategy = ElementHelper.getChild( root, "strategy" );
- String handlerUri = ElementHelper.getAttribute( strategy, "uri" );
- if( null == handlerUri )
+ final String namespace = root.getNamespaceURI();
+ //assertEquals( "namespace", "dpml:transit/part", namespace );
+
+ Element plugin = ElementHelper.getChild( root, "plugin" );
+ if( null != plugin )
{
- System.out.println( "DEFAULT STRATEGY" );
+ // this is a standard transit plugin containing either
+ // a <class> element or a <resource> element as such is
+ // a concern private to the transit implementation to
+ // resolve the plugin strategy
+
+ System.out.println( "PLUGIN STRATEGY " + namespace );
}
else
{
- System.out.println( "CUSTOM STRATEGY: " + handlerUri );
+ // this is a custom deployment strategy defined under
+ // a <strategy> element
+
+ Element strategy = ElementHelper.getChild( root, "strategy" );
+ Element[] children = ElementHelper.getChildren( strategy );
+ if( children.length == 1 )
+ {
+ Element thing = children[0];
+ System.out.println( "CUSTOM STRATEGY " +
thing.getNamespaceURI() );
+ }
+ else
+ {
+ fail( "Strategy must contain a single element." );
+ }
}
}
+
}
- r1141 - in trunk/lab: . component component/etc component/etc/deliverables component/etc/deliverables/xsds part part/etc part/etc/deliverables part/etc/deliverables/xsds schema schema/etc schema/etc/test schema/src/main/dpmlx/schema schema/src/test/dpmlx/schema/test, mcconnell at BerliOS, 02/28/2006
Archive powered by MHonArc 2.6.24.