notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r1188 - in trunk/main: lang/application lang/application/etc lang/common/etc lang/part/etc metro metro/station metro/station/api metro/station/api/etc metro/station/api/etc/test metro/station/api/src/main/net/dpml/station/info metro/station/api/src/test/net/dpml/station/info metro/station/builder metro/station/builder/src metro/station/builder/src/main metro/station/builder/src/main/net metro/station/builder/src/main/net/dpml metro/station/builder/src/main/net/dpml/station metro/station/builder/src/main/net/dpml/station/builder
- From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
- To: notify-dpml AT lists.ibiblio.org
- Subject: r1188 - in trunk/main: lang/application lang/application/etc lang/common/etc lang/part/etc metro metro/station metro/station/api metro/station/api/etc metro/station/api/etc/test metro/station/api/src/main/net/dpml/station/info metro/station/api/src/test/net/dpml/station/info metro/station/builder metro/station/builder/src metro/station/builder/src/main metro/station/builder/src/main/net metro/station/builder/src/main/net/dpml metro/station/builder/src/main/net/dpml/station metro/station/builder/src/main/net/dpml/station/builder
- Date: Wed, 15 Mar 2006 17:07:31 +0100
Author: mcconnell
Date: 2006-03-15 17:07:28 +0100 (Wed, 15 Mar 2006)
New Revision: 1188
Added:
trunk/main/metro/station/api/etc/
trunk/main/metro/station/api/etc/test/
trunk/main/metro/station/api/etc/test/application.xml
trunk/main/metro/station/api/etc/test/registry.xml
trunk/main/metro/station/api/src/test/net/dpml/station/info/ApplicationXMLTestCase.java
trunk/main/metro/station/api/src/test/net/dpml/station/info/RegistryXMLTestCase.java
trunk/main/metro/station/builder/
trunk/main/metro/station/builder/src/
trunk/main/metro/station/builder/src/main/
trunk/main/metro/station/builder/src/main/net/
trunk/main/metro/station/builder/src/main/net/dpml/
trunk/main/metro/station/builder/src/main/net/dpml/station/
trunk/main/metro/station/builder/src/main/net/dpml/station/builder/
trunk/main/metro/station/builder/src/main/net/dpml/station/builder/RegistryBuilder.java
Removed:
trunk/main/metro/station/api/src/main/net/dpml/station/info/ApplicationDescriptorBeanInfo.java
trunk/main/metro/station/api/src/main/net/dpml/station/info/RegistryDescriptorBeanInfo.java
trunk/main/metro/station/api/src/main/net/dpml/station/info/StartupPolicyBeanInfo.java
Modified:
trunk/main/lang/application/
trunk/main/lang/application/etc/application.xsd
trunk/main/lang/common/etc/common.xsd
trunk/main/lang/part/etc/part.xsd
trunk/main/metro/module.xml
trunk/main/metro/station/api/build.xml
trunk/main/metro/station/api/src/test/net/dpml/station/info/AbstractTestCase.java
trunk/main/metro/station/api/src/test/net/dpml/station/info/ApplicationDescriptorTestCase.java
trunk/main/metro/station/api/src/test/net/dpml/station/info/RegistryDescriptorTestCase.java
trunk/main/metro/station/api/src/test/net/dpml/station/info/StartupPolicyTestCase.java
Log:
remove encoding support from application descriptors and initiate the
establishment of a formal schema based application and registry XML definition
Property changes on: trunk/main/lang/application
___________________________________________________________________
Name: svn:ignore
+ target
Modified: trunk/main/lang/application/etc/application.xsd
===================================================================
--- trunk/main/lang/application/etc/application.xsd 2006-03-15 07:53:05
UTC (rev 1187)
+++ trunk/main/lang/application/etc/application.xsd 2006-03-15 16:07:28
UTC (rev 1188)
@@ -35,9 +35,19 @@
<import namespace="@PART-XSD-URI@" schemaLocation="@PART-XSD-URI@"/>
<element name="application" type="this:ApplicationType"/>
- <element name="param" type="this:ValueType"/>
- <element name="codebase" type="part:codebase"/>
+ <element name="param" type="part:ValueType"
substitutionGroup="part:param"/>
+ <element name="codebase" type="part:codebase"
substitutionGroup="common:codebase"/>
+ <element name="registry" type="this:RegistryType"/>
+ <element name="app" type="this:TaggedApplicationType"/>
+ <complexType name="RegistryType">
+ <sequence>
+ <element ref="this:app" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="title" type="string"/>
+ <attribute name="policy" type="this:StartupPolicy"/>
+ </complexType>
+
<complexType name="ApplicationType">
<sequence>
<element name="jvm" type="this:JVMType" minOccurs="0" maxOccurs="1"/>
@@ -47,18 +57,25 @@
<attribute name="policy" type="this:StartupPolicy"/>
</complexType>
+ <complexType name="TaggedApplicationType">
+ <complexContent>
+ <extension base="this:ApplicationType">
+ <attribute name="key" type="string" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
<complexType name="JVMType">
<sequence>
<element name="startup" type="this:TimeoutType" minOccurs="0"
maxOccurs="1"/>
<element name="shutdown" type="this:TimeoutType" minOccurs="0"
maxOccurs="1"/>
<element name="properties" type="this:PropertiesType" minOccurs="0"
maxOccurs="1"/>
</sequence>
- <attribute name="title" type="string"/>
- <attribute name="policy" type="this:StartupPolicy"/>
+ <attribute name="basedir" type="string"/>
</complexType>
<simpleType name="TimeoutType">
- <restriction base="xsd:integer"/>
+ <restriction base="integer"/>
</simpleType>
<simpleType name="StartupPolicy">
Modified: trunk/main/lang/common/etc/common.xsd
===================================================================
--- trunk/main/lang/common/etc/common.xsd 2006-03-15 07:53:05 UTC (rev
1187)
+++ trunk/main/lang/common/etc/common.xsd 2006-03-15 16:07:28 UTC (rev
1188)
@@ -17,7 +17,7 @@
</complexType>
<complexType name="CodeBaseType" abstract="true">
- <attribute name="uri" type="anyUri"/>
+ <attribute name="uri" type="anyURI"/>
</complexType>
</schema>
Modified: trunk/main/lang/part/etc/part.xsd
===================================================================
--- trunk/main/lang/part/etc/part.xsd 2006-03-15 07:53:05 UTC (rev 1187)
+++ trunk/main/lang/part/etc/part.xsd 2006-03-15 16:07:28 UTC (rev 1188)
@@ -96,7 +96,7 @@
<complexContent>
<extension base="common:CodeBaseType">
<sequence>
- <element name="param" type="this:ValueType" minOccurs="0"
maxOccurs="unbounded"/>
+ <element ref="this:param" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</extension>
</complexContent>
Modified: trunk/main/metro/module.xml
===================================================================
--- trunk/main/metro/module.xml 2006-03-15 07:53:05 UTC (rev 1187)
+++ trunk/main/metro/module.xml 2006-03-15 16:07:28 UTC (rev 1188)
@@ -182,6 +182,18 @@
<include ref="junit/junit"/>
</dependencies>
</project>
+
+ <project name="dpml-station-builder" basedir="station/builder">
+ <types>
+ <type id="jar"/>
+ </types>
+ <dependencies>
+ <include key="dpml-station-api" tag="public"/>
+ </dependencies>
+ <dependencies scope="test">
+ <include ref="junit/junit"/>
+ </dependencies>
+ </project>
<project name="dpml-station-server" basedir="station/server">
<types>
@@ -192,6 +204,7 @@
<include ref="dpml/metro/dpml-part-api" tag="public"/>
<include key="dpml-station-api" tag="public"/>
<include ref="dpml/transit/dpml-transit-main" tag="public"/>
+ <include ref="dpml/metro/dpml-station-builder" tag="protected"/>
<include ref="dpml/util/dpml-util-cli"/>
</dependencies>
<dependencies scope="test">
Modified: trunk/main/metro/station/api/build.xml
===================================================================
--- trunk/main/metro/station/api/build.xml 2006-03-15 07:53:05 UTC (rev
1187)
+++ trunk/main/metro/station/api/build.xml 2006-03-15 16:07:28 UTC (rev
1188)
@@ -6,4 +6,11 @@
<transit:import uri="local:template:dpml/tools/standard"/>
+ <target name="init" depends="standard.init">
+ <x:filter token="COMMON-XSD-URI" ref="dpml/lang/dpml-common" type="xsd"
feature="uri" />
+ <x:filter token="PART-XSD-URI" ref="dpml/lang/dpml-part" type="xsd"
feature="uri" />
+ <x:filter token="COMPONENT-XSD-URI" ref="dpml/lang/dpml-component"
type="xsd" feature="uri" />
+ <x:filter token="APPLICATION-XSD-URI" ref="dpml/lang/dpml-application"
type="xsd" feature="uri" />
+ </target>
+
</project>
Added: trunk/main/metro/station/api/etc/test/application.xml
===================================================================
--- trunk/main/metro/station/api/etc/test/application.xml 2006-03-15
07:53:05 UTC (rev 1187)
+++ trunk/main/metro/station/api/etc/test/application.xml 2006-03-15
16:07:28 UTC (rev 1188)
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+
+<application xmlns="@APPLICATION-XSD-URI@"
+ title="Test Application"
+ policy="manual">
+
+ <jvm basedir=".">
+ <startup>120</startup>
+ <shutdown>60</shutdown>
+ <properties>
+ <property name="foo" value="bar"/>
+ </properties>
+ </jvm>
+
+ <codebase uri="link:part:acme/widget">
+ <param class="java.awt.Color" method="RED"/>
+ </codebase>
+
+</application>
\ No newline at end of file
Added: trunk/main/metro/station/api/etc/test/registry.xml
===================================================================
--- trunk/main/metro/station/api/etc/test/registry.xml 2006-03-15 07:53:05
UTC (rev 1187)
+++ trunk/main/metro/station/api/etc/test/registry.xml 2006-03-15 16:07:28
UTC (rev 1188)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+
+<registry xmlns="@APPLICATION-XSD-URI@">
+
+ <app key="demo" title="Test Application" policy="manual">
+
+ <jvm>
+ <startup>120</startup>
+ <shutdown>60</shutdown>
+ <properties>
+ <property name="foo" value="bar"/>
+ </properties>
+ </jvm>
+
+ <codebase uri="link:part:acme/widget">
+ <param class="java.awt.Color" method="RED"/>
+ </codebase>
+
+ </app>
+
+</registry>
Deleted:
trunk/main/metro/station/api/src/main/net/dpml/station/info/ApplicationDescriptorBeanInfo.java
===================================================================
---
trunk/main/metro/station/api/src/main/net/dpml/station/info/ApplicationDescriptorBeanInfo.java
2006-03-15 07:53:05 UTC (rev 1187)
+++
trunk/main/metro/station/api/src/main/net/dpml/station/info/ApplicationDescriptorBeanInfo.java
2006-03-15 16:07:28 UTC (rev 1188)
@@ -1,58 +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.station.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the CodeBaseDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class ApplicationDescriptorBeanInfo 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(
ApplicationDescriptor.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate(
- new String[]
- {
- "codeBaseURISpec", "title", "valueDirectives", "basePath",
"startupPolicy",
- "startupTimeout", "shutdownTimeout", "systemProperties",
- "configurationURISpec"
- }
- )
- );
- return descriptor;
- }
-}
Deleted:
trunk/main/metro/station/api/src/main/net/dpml/station/info/RegistryDescriptorBeanInfo.java
===================================================================
---
trunk/main/metro/station/api/src/main/net/dpml/station/info/RegistryDescriptorBeanInfo.java
2006-03-15 07:53:05 UTC (rev 1187)
+++
trunk/main/metro/station/api/src/main/net/dpml/station/info/RegistryDescriptorBeanInfo.java
2006-03-15 16:07:28 UTC (rev 1188)
@@ -1,51 +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.station.info;
-
-import java.beans.SimpleBeanInfo;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-
-/**
- * BeanInfo for the RegistryDescriptor class that declares a persistence
- * delegate.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class RegistryDescriptorBeanInfo 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(
RegistryDescriptor.class );
- descriptor.setValue(
- "persistenceDelegate",
- new DefaultPersistenceDelegate(
- new String[]{"entries"} ) );
- return descriptor;
- }
-}
Deleted:
trunk/main/metro/station/api/src/main/net/dpml/station/info/StartupPolicyBeanInfo.java
===================================================================
---
trunk/main/metro/station/api/src/main/net/dpml/station/info/StartupPolicyBeanInfo.java
2006-03-15 07:53:05 UTC (rev 1187)
+++
trunk/main/metro/station/api/src/main/net/dpml/station/info/StartupPolicyBeanInfo.java
2006-03-15 16:07:28 UTC (rev 1188)
@@ -1,83 +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.station.info;
-
-import java.beans.Expression;
-import java.beans.BeanDescriptor;
-import java.beans.DefaultPersistenceDelegate;
-import java.beans.PropertyDescriptor;
-import java.beans.SimpleBeanInfo;
-import java.beans.Encoder;
-
-/**
- * Bean info for state encoding of the startup policy enumeration.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class StartupPolicyBeanInfo 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( StartupPolicy.class
);
- descriptor.setValue(
- "persistenceDelegate",
- new PolicyPersistenceDelegate() );
- return descriptor;
- }
-
- /**
- * Return an emptry property descriptor array.
- * @return an empty array
- */
- public PropertyDescriptor[] getPropertyDescriptors()
- {
- return new PropertyDescriptor[0];
- }
-
- /**
- * StartupPolicy persitence delegate.
- */
- private static class PolicyPersistenceDelegate extends
DefaultPersistenceDelegate
- {
- /**
- * Return an expression.
- * @param old the old value
- * @param encoder the encoder
- * @return an expression
- */
- public Expression instantiate( Object old, Encoder encoder )
- {
- StartupPolicy policy = (StartupPolicy) old;
- String name = policy.getName();
- final Class clazz = StartupPolicy.class;
- return new Expression( old, clazz, "parse", new Object[]{name} );
- }
- }
-}
Modified:
trunk/main/metro/station/api/src/test/net/dpml/station/info/AbstractTestCase.java
===================================================================
---
trunk/main/metro/station/api/src/test/net/dpml/station/info/AbstractTestCase.java
2006-03-15 07:53:05 UTC (rev 1187)
+++
trunk/main/metro/station/api/src/test/net/dpml/station/info/AbstractTestCase.java
2006-03-15 16:07:28 UTC (rev 1188)
@@ -60,44 +60,4 @@
assertEquals( object, serialized );
assertEquals( object.hashCode(), serialized.hashCode() );
}
-
- public Object doEncodingTest( Object object, String filename ) throws
Exception
- {
- return doEncodingTest( object, filename, true );
- }
-
- public Object doEncodingTest( Object object, String filename, boolean
testSame ) 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();
- if( testSame )
- {
- assertTrue( "!=", object != result ); // Ensure this is not the
same instance
- }
- assertEquals( "encoding", object, result );
- assertEquals( "hashcode", object.hashCode(), result.hashCode() );
- return result;
- }
-
}
Modified:
trunk/main/metro/station/api/src/test/net/dpml/station/info/ApplicationDescriptorTestCase.java
===================================================================
---
trunk/main/metro/station/api/src/test/net/dpml/station/info/ApplicationDescriptorTestCase.java
2006-03-15 07:53:05 UTC (rev 1187)
+++
trunk/main/metro/station/api/src/test/net/dpml/station/info/ApplicationDescriptorTestCase.java
2006-03-15 16:07:28 UTC (rev 1188)
@@ -160,12 +160,4 @@
doSerializationTest( m_descriptor );
}
- /**
- * Test descriptor encoding and decoding.
- * @exception Exception if a error occurs
- */
- public void testXMLEncoding() throws Exception
- {
- doEncodingTest( m_descriptor, "application.xml" );
- }
}
Added:
trunk/main/metro/station/api/src/test/net/dpml/station/info/ApplicationXMLTestCase.java
===================================================================
---
trunk/main/metro/station/api/src/test/net/dpml/station/info/ApplicationXMLTestCase.java
2006-03-15 07:53:05 UTC (rev 1187)
+++
trunk/main/metro/station/api/src/test/net/dpml/station/info/ApplicationXMLTestCase.java
2006-03-15 16:07:28 UTC (rev 1188)
@@ -0,0 +1,100 @@
+/*
+ * 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.station.info;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import net.dpml.part.DOM3DocumentBuilder;
+import net.dpml.transit.util.ElementHelper;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Test example application sources.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class ApplicationXMLTestCase extends TestCase
+{
+ public void testExample1() throws Exception
+ {
+ Element element = getRootElement( "application.xml" );
+ String tag = element.getTagName();
+ assertEquals( "tag", "application", tag );
+ String title = ElementHelper.getAttribute( element, "title" );
+ assertEquals( "title", "Test Application", title );
+ String policy = ElementHelper.getAttribute( element, "policy" );
+ assertEquals( "policy", "manual", policy );
+
+ Element jvm = ElementHelper.getChild( element, "jvm" );
+ assertNotNull( "jvm", jvm );
+ Element startup = ElementHelper.getChild( jvm, "startup" );
+ assertNotNull( "startup", startup );
+ Element shutdown = ElementHelper.getChild( jvm, "shutdown" );
+ assertNotNull( "shutdown", shutdown );
+ String startupValue = ElementHelper.getValue( startup );
+ assertEquals( "startup value", "120", startupValue );
+ String shutdownValue = ElementHelper.getValue( shutdown );
+ assertEquals( "shutdown value", "60", shutdownValue );
+ Element properties = ElementHelper.getChild( jvm, "properties" );
+ assertNotNull( "properties", properties );
+ Element[] children = ElementHelper.getChildren( properties,
"property" );
+ assertNotNull( "properties array", children );
+ assertEquals( "properties count", 1, children.length );
+ Element property = children[0];
+ String name = ElementHelper.getAttribute( property, "name" );
+ assertEquals( "name", "foo", name );
+ String value = ElementHelper.getAttribute( property, "value" );
+ assertEquals( "value", "bar", value );
+
+ Element codebase = ElementHelper.getChild( element, "codebase" );
+ assertNotNull( "codebase", codebase );
+ String uri = ElementHelper.getAttribute( codebase, "uri" );
+ assertEquals( "uri", "link:part:acme/widget", uri );
+ Element[] params = ElementHelper.getChildren( codebase, "param" );
+ assertNotNull( "params array", params );
+ assertEquals( "params count", 1, params.length );
+ Element param = params[0];
+ String classname = ElementHelper.getAttribute( param, "class" );
+ assertEquals( "classname", "java.awt.Color", classname );
+ String method = ElementHelper.getAttribute( param, "method" );
+ assertEquals( "method", "RED", method );
+
+ }
+
+ private Element getRootElement( String filename ) throws Exception
+ {
+ Document doc = getDocument( filename );
+ return doc.getDocumentElement();
+ }
+
+ private Document getDocument( String filename ) throws Exception
+ {
+ DOM3DocumentBuilder builder = new DOM3DocumentBuilder();
+ String base = System.getProperty( "project.test.dir" );
+ File test = new File( base );
+ File file = new File( test, filename );
+ return builder.parse( file.toURI() );
+ }
+
+}
Modified:
trunk/main/metro/station/api/src/test/net/dpml/station/info/RegistryDescriptorTestCase.java
===================================================================
---
trunk/main/metro/station/api/src/test/net/dpml/station/info/RegistryDescriptorTestCase.java
2006-03-15 07:53:05 UTC (rev 1187)
+++
trunk/main/metro/station/api/src/test/net/dpml/station/info/RegistryDescriptorTestCase.java
2006-03-15 16:07:28 UTC (rev 1188)
@@ -118,13 +118,4 @@
{
doSerializationTest( m_descriptor );
}
-
- /**
- * Test registry encoding/decoding cycle.
- * @exception Exception if a error occurs
- */
- public void testXMLEncoding() throws Exception
- {
- doEncodingTest( m_descriptor, "registry.xml" );
- }
}
Added:
trunk/main/metro/station/api/src/test/net/dpml/station/info/RegistryXMLTestCase.java
===================================================================
---
trunk/main/metro/station/api/src/test/net/dpml/station/info/RegistryXMLTestCase.java
2006-03-15 07:53:05 UTC (rev 1187)
+++
trunk/main/metro/station/api/src/test/net/dpml/station/info/RegistryXMLTestCase.java
2006-03-15 16:07:28 UTC (rev 1188)
@@ -0,0 +1,60 @@
+/*
+ * 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.station.info;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import net.dpml.part.DOM3DocumentBuilder;
+import net.dpml.transit.util.ElementHelper;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Test example application sources.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class RegistryXMLTestCase extends TestCase
+{
+ public void testRegistryXML() throws Exception
+ {
+ Element element = getRootElement( "registry.xml" );
+
+ }
+
+ private Element getRootElement( String filename ) throws Exception
+ {
+ Document doc = getDocument( filename );
+ return doc.getDocumentElement();
+ }
+
+ private Document getDocument( String filename ) throws Exception
+ {
+ DOM3DocumentBuilder builder = new DOM3DocumentBuilder();
+ String base = System.getProperty( "project.test.dir" );
+ File test = new File( base );
+ File file = new File( test, filename );
+ return builder.parse( file.toURI() );
+ }
+
+}
Modified:
trunk/main/metro/station/api/src/test/net/dpml/station/info/StartupPolicyTestCase.java
===================================================================
---
trunk/main/metro/station/api/src/test/net/dpml/station/info/StartupPolicyTestCase.java
2006-03-15 07:53:05 UTC (rev 1187)
+++
trunk/main/metro/station/api/src/test/net/dpml/station/info/StartupPolicyTestCase.java
2006-03-15 16:07:28 UTC (rev 1188)
@@ -65,14 +65,4 @@
StartupPolicy policy = StartupPolicy.AUTOMATIC;
doSerializationTest( policy );
}
-
- /**
- * Test policy encoding/decoding cycle.
- * @exception Exception if an error occurs
- */
- public void testXMLEncoding() throws Exception
- {
- StartupPolicy policy = StartupPolicy.AUTOMATIC;
- doEncodingTest( policy, "policy.xml", false );
- }
}
Added:
trunk/main/metro/station/builder/src/main/net/dpml/station/builder/RegistryBuilder.java
===================================================================
---
trunk/main/metro/station/builder/src/main/net/dpml/station/builder/RegistryBuilder.java
2006-03-15 07:53:05 UTC (rev 1187)
+++
trunk/main/metro/station/builder/src/main/net/dpml/station/builder/RegistryBuilder.java
2006-03-15 16:07:28 UTC (rev 1188)
@@ -0,0 +1,222 @@
+/*
+ * 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.station.builder;
+
+import java.net.URI;
+import java.util.Properties;
+
+import net.dpml.station.info.RegistryDescriptor;
+import net.dpml.station.info.RegistryDescriptor.Entry;
+import net.dpml.station.info.ApplicationDescriptor;
+import net.dpml.station.info.StartupPolicy;
+
+import net.dpml.part.DOM3DocumentBuilder;
+
+import net.dpml.lang.BuilderException;
+import net.dpml.lang.Builder;
+
+import net.dpml.transit.info.ValueDirective;
+import net.dpml.transit.util.ElementHelper;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Test example application sources.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class RegistryBuilder implements Builder
+{
+ private static final DOM3DocumentBuilder DOCUMENT_BUILDER =
+ new DOM3DocumentBuilder();
+
+ public Object build( URI uri ) throws Exception
+ {
+ Document document = DOCUMENT_BUILDER.parse( uri );
+ Element root = document.getDocumentElement();
+ return build( null, root );
+ }
+
+ public Object build( ClassLoader classloader, Element element ) throws
Exception
+ {
+ String tag = element.getTagName();
+ if( "application".equals( tag ) )
+ {
+ return buildApplicationDescriptor( element );
+ }
+ else if( "registry".equals( tag ) )
+ {
+ return buildRegistryDescriptor( element );
+ }
+ else
+ {
+ final String error =
+ "Document element name [" + tag + "] not recognized.";
+ throw new BuilderException( element, error );
+ }
+ }
+
+ private RegistryDescriptor buildRegistryDescriptor( Element element )
throws Exception
+ {
+ Element[] elements = ElementHelper.getChildren( element );
+ Entry[] entries = new Entry[ elements.length ];
+ for( int i=0; i<elements.length; i++ )
+ {
+ Element elem = elements[i];
+ String key = ElementHelper.getAttribute( elem, "key" );
+ if( null == key )
+ {
+ final String error =
+ "Missing 'key' attribute in application element.";
+ throw new BuilderException( elem, error );
+ }
+ ApplicationDescriptor descriptor = buildApplicationDescriptor(
elem );
+ entries[i] = new Entry( key, descriptor );
+ }
+ return new RegistryDescriptor( entries );
+ }
+
+ private ApplicationDescriptor buildApplicationDescriptor( Element
element ) throws Exception
+ {
+ String title = ElementHelper.getAttribute( element, "title" );
+ StartupPolicy policy = buildStartupPolicy( element );
+ Element jvm = ElementHelper.getChild( element, "jvm" );
+ String base = ElementHelper.getAttribute( jvm, "base" );
+ Element startupElement = ElementHelper.getChild( jvm, "startup" );
+ Element shutdownElement = ElementHelper.getChild( jvm, "shutdown" );
+ int startup = buildTimeout( startupElement,
ApplicationDescriptor.DEFAULT_STARTUP_TIMEOUT );
+ int shutdown = buildTimeout( startupElement,
ApplicationDescriptor.DEFAULT_SHUTDOWN_TIMEOUT );
+ Element propertiesElement = ElementHelper.getChild( jvm,
"properties" );
+ Properties properties = buildProperties( propertiesElement );
+ Element codebase = ElementHelper.getChild( element, "codebase" );
+ if( null == codebase )
+ {
+ final String error =
+ "Missing codebase element.";
+ throw new BuilderException( element, error );
+ }
+ String spec = ElementHelper.getAttribute( codebase, "uri" );
+ if( null == spec )
+ {
+ final String error =
+ "Missing codebase uri attribute.";
+ throw new BuilderException( codebase, error );
+ }
+ Element[] params = ElementHelper.getChildren( codebase, "param" );
+ ValueDirective[] values = buildValueDirectives( params );
+
+ // need to rework ApplicationDescriptor such that the codebase is
presented
+ // as an abstract type - e.g. net.dpml.part.CodeBaseDirective verus
+ // net.dpml.metro.CodeBaseDirective
+
+ return new ApplicationDescriptor( spec, title, values, base, policy,
startup, shutdown, properties, null );
+ }
+
+ private StartupPolicy buildStartupPolicy( Element element ) throws
Exception
+ {
+ String policy = ElementHelper.getAttribute( element, "policy" );
+ if( null == policy )
+ {
+ return StartupPolicy.MANUAL;
+ }
+ else
+ {
+ return StartupPolicy.parse( policy );
+ }
+ }
+
+ private int buildTimeout( Element element, int fallback ) throws
Exception
+ {
+ if( null == element )
+ {
+ return fallback;
+ }
+ else
+ {
+ String value = ElementHelper.getValue( element );
+ if( null == value )
+ {
+ return fallback;
+ }
+ else
+ {
+ return Integer.parseInt( value );
+ }
+ }
+ }
+
+ private Properties buildProperties( Element element )
+ {
+ Properties properties = new Properties();
+ if( null == element )
+ {
+ return properties;
+ }
+ else
+ {
+ Element[] children = ElementHelper.getChildren( element );
+ for( int i=0; i<children.length; i++ )
+ {
+ Element child = children[i];
+ String name = ElementHelper.getAttribute( child, "name" );
+ if( null == name )
+ {
+ final String error =
+ "Property declaration does not contain a 'name'
attribute.";
+ throw new BuilderException( child, error );
+ }
+ else
+ {
+ String value = ElementHelper.getAttribute( child,
"value" );
+ properties.setProperty( name, value );
+ }
+ }
+ return properties;
+ }
+ }
+
+ protected ValueDirective[] buildValueDirectives( Element[] elements )
+ {
+ ValueDirective[] values = new ValueDirective[ elements.length ];
+ for( int i=0; i<elements.length; i++ )
+ {
+ values[i] = buildValueDirective( elements[i] );
+ }
+ return values;
+ }
+
+ protected ValueDirective buildValueDirective( Element element )
+ {
+ String classname = ElementHelper.getAttribute( element, "class" );
+ String method = ElementHelper.getAttribute( element, "method" );
+ Element[] elements = ElementHelper.getChildren( element, "param" );
+ if( elements.length > 0 )
+ {
+ ValueDirective[] values = buildValueDirectives( elements );
+ return new ValueDirective( classname, method, values );
+ }
+ else
+ {
+ String value = ElementHelper.getAttribute( element, "value" );
+ return new ValueDirective( classname, method, value );
+ }
+ }
+}
- r1188 - in trunk/main: lang/application lang/application/etc lang/common/etc lang/part/etc metro metro/station metro/station/api metro/station/api/etc metro/station/api/etc/test metro/station/api/src/main/net/dpml/station/info metro/station/api/src/test/net/dpml/station/info metro/station/builder metro/station/builder/src metro/station/builder/src/main metro/station/builder/src/main/net metro/station/builder/src/main/net/dpml metro/station/builder/src/main/net/dpml/station metro/station/builder/src/main/net/dpml/station/builder, mcconnell at BerliOS, 03/15/2006
Archive powered by MHonArc 2.6.24.