Skip to Content.
Sympa Menu

notify-dpml - r1151 - in trunk/lab: . component/etc/deliverables/xsds component/src/main/dpmlx/component lang lang/src lang/src/main lang/src/main/dpmlx lang/src/main/dpmlx/lang lang/src/main/dpmlx/schema schema schema/src schema/src/test/dpmlx/schema/test

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: r1151 - in trunk/lab: . component/etc/deliverables/xsds component/src/main/dpmlx/component lang lang/src lang/src/main lang/src/main/dpmlx lang/src/main/dpmlx/lang lang/src/main/dpmlx/schema schema schema/src schema/src/test/dpmlx/schema/test
  • Date: Wed, 1 Mar 2006 00:21:21 +0100

Author: mcconnell
Date: 2006-03-01 00:21:19 +0100 (Wed, 01 Mar 2006)
New Revision: 1151

Added:
trunk/lab/component/src/main/dpmlx/component/ComponentPartHandler.java
trunk/lab/lang/
trunk/lab/lang/build.xml
trunk/lab/lang/src/
trunk/lab/lang/src/main/
trunk/lab/lang/src/main/dpmlx/
trunk/lab/lang/src/main/dpmlx/lang/
trunk/lab/lang/src/main/dpmlx/lang/PartHandler.java
trunk/lab/lang/src/main/dpmlx/schema/
trunk/lab/lang/src/main/dpmlx/schema/ParserAPIUsage.java
trunk/lab/lang/src/main/dpmlx/schema/StandardBuilder.java
trunk/lab/lang/src/main/dpmlx/schema/UnresolvableHandlerException.java
Removed:
trunk/lab/schema/src/main/
Modified:
trunk/lab/component/etc/deliverables/xsds/project.xsd
trunk/lab/library.xml
trunk/lab/schema/build.xml
trunk/lab/schema/src/test/dpmlx/schema/test/SchemaTestCase.java
Log:
separate test from core

Modified: trunk/lab/component/etc/deliverables/xsds/project.xsd
===================================================================
--- trunk/lab/component/etc/deliverables/xsds/project.xsd 2006-02-28
22:37:46 UTC (rev 1150)
+++ trunk/lab/component/etc/deliverables/xsds/project.xsd 2006-02-28
23:21:19 UTC (rev 1151)
@@ -6,7 +6,7 @@
elementFormDefault="qualified">

<xsd:element name="component" type="ComponentType"/>
-
+
<xsd:complexType name="ComponentType">
<xsd:sequence>
<xsd:element name="context" type="ContextType" minOccurs="0"
maxOccurs="1"/>
@@ -21,7 +21,7 @@
<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"/>
@@ -29,7 +29,7 @@
<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"/>

Added: trunk/lab/component/src/main/dpmlx/component/ComponentPartHandler.java
===================================================================
--- trunk/lab/component/src/main/dpmlx/component/ComponentPartHandler.java
2006-02-28 22:37:46 UTC (rev 1150)
+++ trunk/lab/component/src/main/dpmlx/component/ComponentPartHandler.java
2006-02-28 23:21:19 UTC (rev 1151)
@@ -0,0 +1,53 @@
+/*
+ * 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 dpmlx.component;
+
+import java.net.URI;
+
+import dpmlx.lang.PartHandler;
+
+import org.w3c.dom.Element;
+
+/**
+ * Component part handler.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ComponentPartHandler implements PartHandler
+{
+ private Element m_element;
+
+ public ComponentPartHandler( Element element )
+ {
+ m_element = element;
+ }
+
+ /**
+ * Handle the deployment of a part.
+ *
+ * @param classloader the classloader
+ * @param args supplimentary deployment arguments
+ * @exception Exception if an error occurs
+ */
+ public Object getInstance( ClassLoader classloader, Object[] args )
throws Exception
+ {
+ return null;
+ }
+}


Property changes on: trunk/lab/lang
___________________________________________________________________
Name: svn:ignore
+ target


Added: trunk/lab/lang/build.xml
===================================================================
--- trunk/lab/lang/build.xml 2006-02-28 22:37:46 UTC (rev 1150)
+++ trunk/lab/lang/build.xml 2006-02-28 23:21:19 UTC (rev 1151)
@@ -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/lang/src/main/dpmlx/lang/PartHandler.java
===================================================================
--- trunk/lab/lang/src/main/dpmlx/lang/PartHandler.java 2006-02-28 22:37:46
UTC (rev 1150)
+++ trunk/lab/lang/src/main/dpmlx/lang/PartHandler.java 2006-02-28 23:21:19
UTC (rev 1151)
@@ -0,0 +1,39 @@
+/*
+ * 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 dpmlx.lang;
+
+import java.net.URI;
+
+/**
+ * Interface implemented by part handlers.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface PartHandler
+{
+ /**
+ * Handle the deployment of a part.
+ *
+ * @param classloader the classloader
+ * @param args supplimentary deployment arguments
+ * @exception Exception if an error occurs
+ */
+ Object getInstance( ClassLoader classloader, Object[] args ) throws
Exception;
+}

Added: trunk/lab/lang/src/main/dpmlx/schema/ParserAPIUsage.java
===================================================================
--- trunk/lab/lang/src/main/dpmlx/schema/ParserAPIUsage.java 2006-02-28
22:37:46 UTC (rev 1150)
+++ trunk/lab/lang/src/main/dpmlx/schema/ParserAPIUsage.java 2006-02-28
23:21:19 UTC (rev 1151)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2005 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 dpmlx.schema;
+
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * <p>A sample which demonstrates usage of the JAXP 1.3 Parser API.</p>
+ *
+ * @author Michael Glavassevich, IBM
+ * @author Ankit Pasricha, IBM
+ *
+ * @version $Id: ParserAPIUsage.java,v 1.2 2005/06/10 03:43:46 mrglavas Exp $
+ */
+public class ParserAPIUsage extends DefaultHandler {
+
+ /** Default constructor. */
+ public ParserAPIUsage() {
+ } // <init>()
+
+ //
+ // ErrorHandler methods
+ //
+
+ /** Warning. */
+ public void warning(SAXParseException ex) throws SAXException {
+ printError("Warning", ex);
+ } // warning(SAXParseException)
+
+ /** Error. */
+ public void error(SAXParseException ex) throws SAXException {
+ printError("Error", ex);
+ } // error(SAXParseException)
+
+ /** Fatal error. */
+ public void fatalError(SAXParseException ex) throws SAXException {
+ printError("Fatal Error", ex);
+ throw ex;
+ } // fatalError(SAXParseException)
+
+ //
+ // Protected methods
+ //
+
+ /** Prints the error message. */
+ protected void printError(String type, SAXParseException ex) {
+
+ System.err.print("[");
+ System.err.print(type);
+ System.err.print("] ");
+ String systemId = ex.getSystemId();
+ if (systemId != null) {
+ int index = systemId.lastIndexOf('/');
+ if (index != -1)
+ systemId = systemId.substring(index + 1);
+ System.err.print(systemId);
+ }
+ System.err.print(':');
+ System.err.print(ex.getLineNumber());
+ System.err.print(':');
+ System.err.print(ex.getColumnNumber());
+ System.err.print(": ");
+ System.err.print(ex.getMessage());
+ System.err.println();
+ System.err.flush();
+
+ } // printError(String,SAXParseException)
+
+} // ParserAPIUsage

Added: trunk/lab/lang/src/main/dpmlx/schema/StandardBuilder.java
===================================================================
--- trunk/lab/lang/src/main/dpmlx/schema/StandardBuilder.java 2006-02-28
22:37:46 UTC (rev 1150)
+++ trunk/lab/lang/src/main/dpmlx/schema/StandardBuilder.java 2006-02-28
23:21:19 UTC (rev 1151)
@@ -0,0 +1,119 @@
+/*
+ * 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 dpmlx.schema;
+
+import java.lang.reflect.Method;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.stream.StreamSource;
+
+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.helpers.XMLReaderFactory;
+import org.xml.sax.helpers.DefaultHandler;
+
+import org.w3c.dom.Document;
+
+public class StandardBuilder extends DefaultHandler
+{
+ static final String PARSER_NAME = "org.apache.xerces.parsers.SAXParser";
+
+ protected static final String DEFAULT_API_TO_USE = "sax";
+
+ protected static final boolean DEFAULT_XINCLUDE = false;
+
+ protected static final boolean DEFAULT_SECURE_PROCESSING = false;
+
+ 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";;
+
+ private static boolean VALIDATING = isSchemaCapable();
+
+ //
+ // Constructors
+ //
+
+ public StandardBuilder( String[] args ) throws Exception
+ {
+ if (args.length == 1)
+ {
+ try
+ {
+ String source = args[0];
+ parse( source );
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public Document parse( String source ) throws Exception
+ {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware( true );
+ if( VALIDATING )
+ {
+ setupBuilderForSchemaValidation( dbf );
+ }
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ db.setErrorHandler( new ParserAPIUsage() );
+ return db.parse( source );
+ }
+
+ private void setupBuilderForSchemaValidation( DocumentBuilderFactory dbf
) throws Exception
+ {
+ 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 = schemaFactoryClass.getMethod( "newSchema",
new Class[0] );
+ Object schemaObject = newSchemaMethod.invoke( schemaFactory, new
Object[0] );
+ Method setSchemaMethod = DocumentBuilderFactory.class.getMethod(
"setSchema", new Class[]{ schemaClass } );
+ setSchemaMethod.invoke( dbf, new Object[]{ schemaObject } );
+ }
+
+ private static boolean isSchemaCapable()
+ {
+ try
+ {
+ ClassLoader classloader = StandardBuilder.class.getClassLoader();
+ classloader.loadClass( "javax.xml.XMLConstants" );
+ System.out.println( "validating" );
+ return true;
+ }
+ catch( ClassNotFoundException e )
+ {
+ System.out.println( "validation disabled" );
+ return false;
+ }
+ }
+}

Added: trunk/lab/lang/src/main/dpmlx/schema/UnresolvableHandlerException.java
===================================================================
--- trunk/lab/lang/src/main/dpmlx/schema/UnresolvableHandlerException.java
2006-02-28 22:37:46 UTC (rev 1150)
+++ trunk/lab/lang/src/main/dpmlx/schema/UnresolvableHandlerException.java
2006-02-28 23:21:19 UTC (rev 1151)
@@ -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 dpmlx.schema;
+
+import java.net.URI;
+
+import net.dpml.transit.artifact.ArtifactNotFoundException;
+
+public class UnresolvableHandlerException extends ArtifactNotFoundException
+{
+ public UnresolvableHandlerException( String message, URI uri )
+ {
+ super( message, uri );
+ }
+}

Modified: trunk/lab/library.xml
===================================================================
--- trunk/lab/library.xml 2006-02-28 22:37:46 UTC (rev 1150)
+++ trunk/lab/library.xml 2006-02-28 23:21:19 UTC (rev 1151)
@@ -15,35 +15,50 @@
<modules>

<module name="dpmlx">
-
+
<project name="dpmlx-part" basedir="part">
<types>
<type id="xsd"/>
</types>
</project>

- <project name="dpmlx-component" basedir="component">
+ <project name="dpmlx-lang" basedir="lang">
<types>
- <type id="xsd"/>
+ <type id="jar"/>
+ <type id="plugin" alias="true">
+ <property name="project.plugin.class"
+ value="dpmlx.schema.StandardBuilder"/>
+ </type>
</types>
+ <dependencies scope="runtime">
+ <include ref="dpml/transit/dpml-transit-main"/>
+ </dependencies>
</project>
-
- <project name="dpmlx-schema-test" basedir="schema">
+
+ <project name="dpmlx-component" basedir="component">
<types>
+ <type id="xsd"/>
<type id="jar"/>
<type id="plugin" alias="true">
<property name="project.plugin.class"
- value="dpmlx.schema.StandardBuilder"/>
+ value="dpmlx.component.ComponentPartHandler"/>
</type>
</types>
+ <dependencies scope="runtime">
+ <include key="dpmlx-lang"/>
+ </dependencies>
+ </project>
+
+ <project name="dpmlx-schema-test" basedir="schema">
+ <types>
+ <type id="jar"/>
+ </types>
<dependencies scope="build">
<include key="dpmlx-part"/>
<include key="dpmlx-component"/>
</dependencies>
- <dependencies scope="runtime">
- <include ref="dpml/transit/dpml-transit-main"/>
- </dependencies>
<dependencies scope="test">
+ <include key="dpmlx-lang"/>
<include ref="ant/ant-junit"/>
</dependencies>
</project>

Modified: trunk/lab/schema/build.xml
===================================================================
--- trunk/lab/schema/build.xml 2006-02-28 22:37:46 UTC (rev 1150)
+++ trunk/lab/schema/build.xml 2006-02-28 23:21:19 UTC (rev 1151)
@@ -9,7 +9,7 @@
<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"/>
+ <x:filter feature="uri" type="plugin" token="LANG-PLUGIN-URI"
ref="dpmlx/dpmlx-lang"/>
</target>

</project>

Modified: trunk/lab/schema/src/test/dpmlx/schema/test/SchemaTestCase.java
===================================================================
--- trunk/lab/schema/src/test/dpmlx/schema/test/SchemaTestCase.java
2006-02-28 22:37:46 UTC (rev 1150)
+++ trunk/lab/schema/src/test/dpmlx/schema/test/SchemaTestCase.java
2006-02-28 23:21:19 UTC (rev 1151)
@@ -32,8 +32,7 @@
public void setUp() throws Exception
{
ClassLoader classloader = Transit.class.getClassLoader();
- File file = new File(
"target/deliverables/plugins/dpmlx-schema-test-@VERSION@.plugin" );
- URI uri = file.toURI();
+ URI uri = new URI( "@LANG-PLUGIN-URI@" );
Object[] args = new Object[0];
m_builder =
(StandardBuilder) Transit.getInstance().getRepository().getPlugin(




  • r1151 - in trunk/lab: . component/etc/deliverables/xsds component/src/main/dpmlx/component lang lang/src lang/src/main lang/src/main/dpmlx lang/src/main/dpmlx/lang lang/src/main/dpmlx/schema schema schema/src schema/src/test/dpmlx/schema/test, mcconnell at BerliOS, 02/28/2006

Archive powered by MHonArc 2.6.24.

Top of Page