jboynes 2004/02/08 23:17:31
Modified: modules/deployment project.xml
Added: modules/deployment maven.xml
modules/deployment/src/schema geronimo-common.xsd
geronimo-config.xsd xmlconfig.xml
modules/deployment/src/test-resources/services plan1.xml
modules/deployment/src/test/org/apache/geronimo/deployment/service
ConfigPlanTest.java
Log:
Add schema and xmlbeans for configuration plan
Revision Changes Path
1.9 +28 -6 incubator-geronimo/modules/deployment/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/deployment/project.xml,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- project.xml 6 Feb 2004 08:55:04 -0000 1.8
+++ project.xml 9 Feb 2004 07:17:31 -0000 1.9
@@ -52,6 +52,14 @@
</dependency>
<dependency>
+ <groupId>geronimo-spec</groupId>
+ <artifactId>geronimo-spec-j2ee-deployment</artifactId>
+ <version>DEV</version>
+ <properties>
+ </properties>
+ </dependency>
+
+ <dependency>
<id>cglib+full</id>
<version>2.0-RC2</version>
<url>http://cglib.sf.net/</url>
@@ -75,11 +83,9 @@
</dependency>
<dependency>
- <groupId>geronimo-spec</groupId>
- <artifactId>geronimo-spec-j2ee-deployment</artifactId>
- <version>DEV</version>
- <properties>
- </properties>
+ <id>commons-cli</id>
+ <version>1.0</version>
+ <url>http://jakarta.apache.org/commons/cli/</url>
</dependency>
<dependency>
@@ -91,6 +97,22 @@
</properties>
</dependency>
+<!-- uncomment to verify XML loading with DOM
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.6.0</version>
+ <properties>
+ </properties>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xmlParserAPIs</artifactId>
+ <version>2.2.1</version>
+ <properties>
+ </properties>
+ </dependency>
+-->
</dependencies>
1.1 incubator-geronimo/modules/deployment/maven.xml
Index: maven.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- $Revision: 1.1 $ $Date: 2004/02/09 07:17:31 $ -->
<project default="default"
xmlns:xmlbeans="geronimo:xmlbeans">
<preGoal name="java:compile">
<xmlbeans:schema2java
sourceschema="${basedir}/src/schema/geronimo-config.xsd"
xmlconfigs="${basedir}/src/schema/xmlconfig.xml"
targetdir="${basedir}/target/xmlbeans"/>
</preGoal>
</project>
1.1
incubator-geronimo/modules/deployment/src/schema/geronimo-common.xsd
Index: geronimo-common.xsd
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
>
<xs:annotation>
<xs:documentation>
<![CDATA[
Partial schema containing common elements which can be included
in other schemas.
This schema does not define a targetNamespace and so all
definitions from this
schema instance will end up in the targetNamespace of the
including document.
]]>
</xs:documentation>
</xs:annotation>
<xs:complexType name="dependencyType">
<xs:sequence>
<xs:element name="groupId" type="xs:string"/>
<xs:element name="artifactId" type="xs:string"/>
<xs:element name="version" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="gbeanType">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="attribute" type="attributeType"/>
<xs:element name="reference" type="referenceType"/>
<xs:element name="references" type="referencesType"/>
</xs:choice>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="class" type="xs:string"/>
</xs:complexType>
<xs:complexType name="attributeType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="referenceType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="referencesType">
<xs:sequence>
<xs:element name="pattern" type="xs:string" minOccurs="1"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
1.1
incubator-geronimo/modules/deployment/src/schema/geronimo-config.xsd
Index: geronimo-config.xsd
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns="http://geronimo.apache.org/xml/ns/deployment"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://geronimo.apache.org/xml/ns/deployment"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
>
<xs:annotation>
<xs:documentation>
Schema for Geronimo Services deployment plans.
Instance documents should begin with the element:
>gbeans
xmlns="http://geronimo.apache.org/xml/ns/deployment"<
</xs:documentation>
</xs:annotation>
<xs:include schemaLocation="geronimo-common.xsd"/>
<xs:element name="configuration" type="configurationType"/>
<xs:complexType name="configurationType">
<xs:sequence>
<xs:element name="dependency" type="dependencyType" minOccurs="0"
maxOccurs="unbounded"/>
<xs:element name="gbean" type="gbeanType" minOccurs="1"
maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="configId" type="xs:string" use="required"/>
<xs:attribute name="parentId" type="xs:string" use="optional"/>
</xs:complexType>
</xs:schema>
1.1
incubator-geronimo/modules/deployment/src/schema/xmlconfig.xml
Index: xmlconfig.xml
===================================================================
<xb:config xmlns:xb="http://www.bea.com/2002/09/xbean/config">
<xb:namespace uri="http://geronimo.apache.org/xml/ns/deployment">
<xb:package>org.apache.geronimo.deployment.xbeans</xb:package>
</xb:namespace>
</xb:config>
1.1
incubator-geronimo/modules/deployment/src/test-resources/services/plan1.xml
Index: plan1.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<configuration
xmlns="http://geronimo.apache.org/xml/ns/deployment"
configId="test/plan1"
>
<dependency>
<groupId>geronimo</groupId>
<artifactId>geronimo-kernel</artifactId>
<version>DEV</version>
</dependency>
<gbean name="geronimo.test:name=MyMockGMBean"
class="org.apache.geronimo.deployment.MockGBean">
<attribute name="Value">1234</attribute>
<attribute name="IntValue">1234</attribute>
<reference
name="MockEndpoint">geronimo.test:name=MyMockGMBean</reference>
</gbean>
</configuration>
1.1
incubator-geronimo/modules/deployment/src/test/org/apache/geronimo/deployment/service/ConfigPlanTest.java
Index: ConfigPlanTest.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.deployment.service;
import java.net.URL;
import org.apache.geronimo.deployment.xbeans.AttributeType;
import org.apache.geronimo.deployment.xbeans.ConfigurationDocument;
import org.apache.geronimo.deployment.xbeans.ConfigurationType;
import org.apache.geronimo.deployment.xbeans.GbeanType;
import org.apache.geronimo.deployment.xbeans.ReferenceType;
import org.apache.geronimo.deployment.xbeans.DependencyType;
import junit.framework.TestCase;
/**
*
*
* @version $Revision: 1.1 $ $Date: 2004/02/09 07:17:31 $
*/
public class ConfigPlanTest extends TestCase {
private URL plan1;
public void testParser() throws Exception {
ConfigurationDocument doc =
ConfigurationDocument.Factory.parse(plan1);
ConfigurationType configuration = doc.getConfiguration();
assertEquals("test/plan1", configuration.getConfigId());
DependencyType[] dependencies = configuration.getDependencyArray();
assertEquals(1, dependencies.length);
assertEquals("geronimo", dependencies[0].getGroupId());
assertEquals("geronimo-kernel", dependencies[0].getArtifactId());
assertEquals("DEV", dependencies[0].getVersion());
GbeanType[] gbeans = configuration.getGbeanArray();
assertEquals(1, gbeans.length);
assertEquals("geronimo.test:name=MyMockGMBean", gbeans[0].getName());
AttributeType[] attrs = gbeans[0].getAttributeArray();
assertEquals(2, attrs.length);
assertEquals("Value", attrs[0].getName());
assertEquals("1234", attrs[0].getStringValue());
assertEquals("IntValue", attrs[1].getName());
assertEquals("1234", attrs[1].getStringValue());
ReferenceType[] refs = gbeans[0].getReferenceArray();
assertEquals(1, refs.length);
assertEquals("MockEndpoint", refs[0].getName());
assertEquals("geronimo.test:name=MyMockGMBean",
refs[0].getStringValue());
}
protected void setUp() throws Exception {
super.setUp();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
plan1 = cl.getResource("services/plan1.xml");
}
}