You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/01 10:30:26 UTC
svn commit: r524557 - in /incubator/tuscany/java/sca/scdl4j: idl-java-xml/
idl-java-xml/src/ idl-java-xml/src/main/ idl-java-xml/src/main/java/
idl-java-xml/src/main/java/org/ idl-java-xml/src/main/java/org/apache/
idl-java-xml/src/main/java/org/apache...
Author: jsdelfino
Date: Sun Apr 1 01:30:23 2007
New Revision: 524557
URL: http://svn.apache.org/viewvc?view=rev&rev=524557
Log:
Implemented StAX loaders for WSDL and Java interfaces
Added:
incubator/tuscany/java/sca/scdl4j/idl-java-xml/ (with props)
incubator/tuscany/java/sca/scdl4j/idl-java-xml/pom.xml (with props)
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaConstants.java (with props)
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaHandler.java (with props)
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaReader.java (with props)
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/ReadTestCase.java (with props)
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/SAXReadTestCase.java (with props)
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/Calculator.composite (with props)
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/CalculatorComponent.constrainingType
incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/CalculatorImpl.componentType (with props)
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/ (with props)
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/pom.xml (with props)
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLConstants.java (with props)
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLHandler.java (with props)
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLReader.java (with props)
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/ReadTestCase.java (with props)
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/SAXReadTestCase.java (with props)
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/Calculator.composite (with props)
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/CalculatorComponent.constrainingType
incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/CalculatorImpl.componentType (with props)
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Apr 1 01:30:23 2007
@@ -0,0 +1,14 @@
+target
+*.iws
+*.ipr
+*.iml
+.project
+.classpath
+maven.log
+velocity.log*
+junit*.properties
+surefire*.properties
+.settings
+.deployables
+.wtpmodules
+
Added: incubator/tuscany/java/sca/scdl4j/idl-java-xml/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-java-xml/pom.xml?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-java-xml/pom.xml (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-java-xml/pom.xml Sun Apr 1 01:30:23 2007
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-scdl4j</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-idl-java-xml</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany support for Java Interfaces in SCA XML assembly files.</name>
+ <description>Apache Tuscany support for Java Interfaces in SCA XML assembly files.</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-idl-java</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaConstants.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaConstants.java?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaConstants.java (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaConstants.java Sun Apr 1 01:30:23 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.tuscany.idl.java.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.scdl.Constants;
+
+public interface JavaConstants {
+
+ public final String INTERFACE_JAVA = "interface.java";
+ public final QName INTERFACE_JAVA_QNAME = new QName(Constants.SCA10_NS, "interface.java");
+ public final String INTERFACE = "interface";
+ public final String CLASS = "class";
+
+}
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaConstants.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaHandler.java?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaHandler.java (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaHandler.java Sun Apr 1 01:30:23 2007
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.tuscany.idl.java.xml;
+
+import org.apache.tuscany.idl.java.JavaFactory;
+import org.apache.tuscany.idl.java.JavaInterface;
+import org.apache.tuscany.sca.idl.Interface;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.InterfaceHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * A content handler for Java interfaces and implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaHandler extends DefaultHandler implements InterfaceHandler {
+
+ private JavaFactory javaFactory;
+ private JavaInterface javaInterface;
+
+ public JavaHandler(JavaFactory javaFactory) {
+ this.javaFactory = javaFactory;
+ }
+
+ public void startDocument() throws SAXException {
+ javaInterface = null;
+ }
+
+ public void startElement(String uri, String name, String qname, Attributes attr) throws SAXException {
+
+ if (Constants.SCA10_NS.equals(uri)) {
+
+ if (JavaConstants.INTERFACE_JAVA.equals(name)) {
+
+ // Parse a Java interface
+ javaInterface = javaFactory.createJavaInterface();
+ javaInterface.setUnresolved(true);
+ javaInterface.setName(attr.getValue(JavaConstants.INTERFACE));
+ }
+ }
+ }
+
+ public Interface getInterface() {
+ return javaInterface;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaReader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaReader.java?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaReader.java (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaReader.java Sun Apr 1 01:30:23 2007
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.tuscany.idl.java.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.idl.java.JavaFactory;
+import org.apache.tuscany.idl.java.JavaInterface;
+import org.apache.tuscany.scdl.stax.Loader;
+
+public class JavaReader implements Loader<JavaInterface>, JavaConstants {
+
+ private JavaFactory javaFactory;
+
+ public JavaReader(JavaFactory javaFactory) {
+ this.javaFactory = javaFactory;
+ }
+
+ public JavaInterface load(XMLStreamReader reader) throws XMLStreamException {
+
+ // Read an <interface.java>
+ JavaInterface javaInterface = javaFactory.createJavaInterface();
+ javaInterface.setUnresolved(true);
+ javaInterface.setName(reader.getAttributeValue(null, INTERFACE));
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && INTERFACE_JAVA_QNAME.equals(reader.getName()))
+ break;
+ }
+ return javaInterface;
+ }
+}
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/main/java/org/apache/tuscany/idl/java/xml/JavaReader.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/ReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/ReadTestCase.java?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/ReadTestCase.java (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/ReadTestCase.java Sun Apr 1 01:30:23 2007
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.tuscany.idl.java.xml;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.ComponentType;
+import org.apache.tuscany.assembly.model.Composite;
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.assembly.model.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.assembly.util.CompositeUtil;
+import org.apache.tuscany.assembly.util.PrintUtil;
+import org.apache.tuscany.idl.java.impl.DefaultJavaFactory;
+import org.apache.tuscany.policy.model.PolicyFactory;
+import org.apache.tuscany.policy.model.impl.DefaultPolicyFactory;
+import org.apache.tuscany.scdl.stax.LoaderRegistry;
+import org.apache.tuscany.scdl.stax.impl.ComponentTypeLoader;
+import org.apache.tuscany.scdl.stax.impl.CompositeLoader;
+import org.apache.tuscany.scdl.stax.impl.ConstrainingTypeLoader;
+import org.apache.tuscany.scdl.stax.impl.LoaderRegistryImpl;
+
+/**
+ * Test the usability of the assembly model API when loading SCDL
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadTestCase extends TestCase {
+
+ XMLInputFactory inputFactory;
+ AssemblyFactory assemblyFactory;
+ PolicyFactory policyFactory;
+ LoaderRegistry loaderRegistry;
+
+ public void setUp() throws Exception {
+ inputFactory = XMLInputFactory.newInstance();
+ assemblyFactory = new DefaultAssemblyFactory();
+ policyFactory = new DefaultPolicyFactory();
+ loaderRegistry = new LoaderRegistryImpl();
+
+ JavaReader javaReader = new JavaReader(new DefaultJavaFactory());
+ loaderRegistry.addLoader(JavaConstants.INTERFACE_JAVA_QNAME, javaReader);
+ }
+
+ public void tearDown() throws Exception {
+ inputFactory = null;
+ assemblyFactory = null;
+ policyFactory = null;
+ loaderRegistry = null;
+ }
+
+ public void testReadComponentType() throws Exception {
+ ComponentTypeLoader componentTypeReader = new ComponentTypeLoader(assemblyFactory, policyFactory, loaderRegistry);
+ InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorImpl.componentType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ComponentType componentType = componentTypeReader.load(reader);
+ assertNotNull(componentType);
+
+ new PrintUtil(System.out).print(componentType);
+ }
+
+ public void testReadConstrainingType() throws Exception {
+ ConstrainingTypeLoader constrainingTypeReader = new ConstrainingTypeLoader(assemblyFactory, policyFactory, loaderRegistry);
+ InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorComponent.constrainingType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ConstrainingType constrainingType = constrainingTypeReader.load(reader);
+ assertNotNull(constrainingType);
+
+ new PrintUtil(System.out).print(constrainingType);
+ }
+
+ public void testReadComposite() throws Exception {
+ CompositeLoader compositeReader = new CompositeLoader(assemblyFactory, policyFactory, loaderRegistry);
+ InputStream is = getClass().getClassLoader().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeReader.load(reader);
+ assertNotNull(composite);
+
+ new CompositeUtil(assemblyFactory, composite).configure(null);
+
+ new PrintUtil(System.out).print(composite);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/ReadTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/ReadTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/SAXReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/SAXReadTestCase.java?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/SAXReadTestCase.java (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/SAXReadTestCase.java Sun Apr 1 01:30:23 2007
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.tuscany.idl.java.xml;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.assembly.util.CompositeUtil;
+import org.apache.tuscany.assembly.util.PrintUtil;
+import org.apache.tuscany.idl.java.impl.DefaultJavaFactory;
+import org.apache.tuscany.policy.model.PolicyFactory;
+import org.apache.tuscany.policy.model.impl.DefaultPolicyFactory;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.impl.ComponentTypeHandler;
+import org.apache.tuscany.scdl.impl.CompositeHandler;
+import org.apache.tuscany.scdl.impl.ConstrainingTypeHandler;
+import org.apache.tuscany.scdl.impl.ImplementationHandlerRegistry;
+import org.apache.tuscany.scdl.impl.InterfaceHandlerRegistry;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * Test the usability of the assembly model API when loading SCDL
+ *
+ * @version $Rev$ $Date$
+ */
+public class SAXReadTestCase extends TestCase {
+
+ AssemblyFactory assemblyFactory;
+ PolicyFactory policyFactory;
+ XMLReader reader;
+ InterfaceHandlerRegistry interfaceHandlers;
+ ImplementationHandlerRegistry implementationHandlers;
+
+ public void setUp() throws Exception {
+
+ reader = XMLReaderFactory.createXMLReader();
+
+ assemblyFactory = new DefaultAssemblyFactory();
+ policyFactory = new DefaultPolicyFactory();
+
+ JavaHandler javaHandler = new JavaHandler(new DefaultJavaFactory());
+ interfaceHandlers = new InterfaceHandlerRegistry();
+ interfaceHandlers.addHandler(Constants.SCA10_NS, JavaConstants.INTERFACE_JAVA, javaHandler);
+ }
+
+ public void tearDown() throws Exception {
+ assemblyFactory = null;
+ reader = null;
+ }
+
+ public void testReadComponentType() throws Exception {
+ InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorImpl.componentType");
+ ComponentTypeHandler handler = new ComponentTypeHandler(assemblyFactory, policyFactory, interfaceHandlers);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(is));
+ assertNotNull(handler.getComponentType());
+
+ new PrintUtil(System.out).print(handler.getComponentType());
+ }
+
+ public void testReadConstrainingType() throws Exception {
+ InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorComponent.constrainingType");
+ ConstrainingTypeHandler handler = new ConstrainingTypeHandler(assemblyFactory, policyFactory, interfaceHandlers);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(is));
+ assertNotNull(handler.getConstrainingType());
+
+ new PrintUtil(System.out).print(handler.getConstrainingType());
+ }
+
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getClassLoader().getResourceAsStream("Calculator.composite");
+ CompositeHandler handler = new CompositeHandler(assemblyFactory, policyFactory, interfaceHandlers, implementationHandlers, null);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(is));
+ assertNotNull(handler.getComposite());
+
+ new CompositeUtil(assemblyFactory, handler.getComposite()).configure(null);
+
+ new PrintUtil(System.out).print(handler.getComposite());
+ }
+
+}
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/SAXReadTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/java/org/apache/tuscany/idl/java/xml/SAXReadTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/Calculator.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/Calculator.composite?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/Calculator.composite (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/Calculator.composite Sun Apr 1 01:30:23 2007
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://sample.calculator"
+ name="calc:Calculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.java interface="calculator.CalculatorService"/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/Calculator.composite
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/Calculator.composite
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/CalculatorComponent.constrainingType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/CalculatorComponent.constrainingType?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/CalculatorComponent.constrainingType (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/CalculatorComponent.constrainingType Sun Apr 1 01:30:23 2007
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<constrainingType xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://sample.calculator"
+ name="calc:CalculatorComponent">
+
+ <service name="CalculatorService">
+ <interface.java class="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService">
+ <interface.java class="calculator.DivideService" />
+ </reference>
+
+</constrainingType>
+
\ No newline at end of file
Added: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/CalculatorImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/CalculatorImpl.componentType?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/CalculatorImpl.componentType (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/CalculatorImpl.componentType Sun Apr 1 01:30:23 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
+
+ <service name="CalculatorService">
+ <interface.java class="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService">
+ <interface.java class="calculator.DivideService" />
+ </reference>
+
+</componentType>
+
\ No newline at end of file
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/CalculatorImpl.componentType
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-java-xml/src/test/resources/CalculatorImpl.componentType
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Apr 1 01:30:23 2007
@@ -0,0 +1,14 @@
+target
+*.iws
+*.ipr
+*.iml
+.project
+.classpath
+maven.log
+velocity.log*
+junit*.properties
+surefire*.properties
+.settings
+.deployables
+.wtpmodules
+
Added: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/pom.xml?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/pom.xml (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/pom.xml Sun Apr 1 01:30:23 2007
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-scdl4j</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-idl-wsdl-xml</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany support for WSDL Interfaces in SCA XML assembly files.</name>
+ <description>Apache Tuscany support for WSDL Interfaces in SCA XML assembly files.</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-idl-wsdl</artifactId>
+ <version>0.1-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLConstants.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLConstants.java?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLConstants.java (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLConstants.java Sun Apr 1 01:30:23 2007
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.tuscany.idl.wsdl.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.scdl.Constants;
+
+public interface WSDLConstants {
+
+ public final String INTERFACE_WSDL = "interface.wsdl";
+ public final QName INTERFACE_WSDL_QNAME = new QName(Constants.SCA10_NS, "interface.wsdl");
+ public final String INTERFACE = "interface";
+
+}
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLConstants.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLHandler.java?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLHandler.java (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLHandler.java Sun Apr 1 01:30:23 2007
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.tuscany.idl.wsdl.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.idl.WSDLFactory;
+import org.apache.tuscany.idl.WSDLInterface;
+import org.apache.tuscany.sca.idl.Interface;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.InterfaceHandler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * A content handler for Java interfaces and implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSDLHandler extends DefaultHandler implements InterfaceHandler {
+
+ private WSDLFactory wsdlFactory;
+ private WSDLInterface wsdlInterface;
+
+ public WSDLHandler(WSDLFactory wsdlFactory) {
+ this.wsdlFactory = wsdlFactory;
+ }
+
+ public void startDocument() throws SAXException {
+ wsdlInterface = null;
+ }
+
+ public void startElement(String uri, String name, String qname, Attributes attr) throws SAXException {
+
+ if (Constants.SCA10_NS.equals(uri)) {
+
+ if (WSDLConstants.INTERFACE_WSDL.equals(name)) {
+
+ // Parse a WSDL interface
+ wsdlInterface = wsdlFactory.createWSDLInterface();
+ wsdlInterface.setUnresolved(true);
+ //TODO handle qname
+ wsdlInterface.setName(new QName("", attr.getValue(WSDLConstants.INTERFACE)));
+ }
+ }
+ }
+
+ public Interface getInterface() {
+ return wsdlInterface;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLReader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLReader.java?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLReader.java (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLReader.java Sun Apr 1 01:30:23 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.tuscany.idl.wsdl.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.idl.WSDLFactory;
+import org.apache.tuscany.idl.WSDLInterface;
+import org.apache.tuscany.scdl.stax.Loader;
+
+public class WSDLReader implements Loader<WSDLInterface>, WSDLConstants {
+
+ private WSDLFactory wsdlFactory;
+
+ public WSDLReader(WSDLFactory javaFactory) {
+ this.wsdlFactory = javaFactory;
+ }
+
+ public WSDLInterface load(XMLStreamReader reader) throws XMLStreamException {
+
+ // Read an <interface.java>
+ WSDLInterface wsdlInterface = wsdlFactory.createWSDLInterface();
+ wsdlInterface.setUnresolved(true);
+ //TODO handle qname
+ wsdlInterface.setName(new QName("", reader.getAttributeValue(null, INTERFACE)));
+
+ // Skip to end element
+ while (reader.hasNext()) {
+ if (reader.next() == END_ELEMENT && INTERFACE_WSDL_QNAME.equals(reader.getName()))
+ break;
+ }
+ return wsdlInterface;
+ }
+}
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLReader.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/main/java/org/apache/tuscany/idl/wsdl/xml/WSDLReader.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/ReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/ReadTestCase.java?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/ReadTestCase.java (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/ReadTestCase.java Sun Apr 1 01:30:23 2007
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.tuscany.idl.wsdl.xml;
+
+import java.io.InputStream;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.ComponentType;
+import org.apache.tuscany.assembly.model.Composite;
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.assembly.model.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.assembly.util.CompositeUtil;
+import org.apache.tuscany.assembly.util.PrintUtil;
+import org.apache.tuscany.idl.wsdl.impl.DefaultWSDLFactory;
+import org.apache.tuscany.policy.model.PolicyFactory;
+import org.apache.tuscany.policy.model.impl.DefaultPolicyFactory;
+import org.apache.tuscany.scdl.stax.LoaderRegistry;
+import org.apache.tuscany.scdl.stax.impl.ComponentTypeLoader;
+import org.apache.tuscany.scdl.stax.impl.CompositeLoader;
+import org.apache.tuscany.scdl.stax.impl.ConstrainingTypeLoader;
+import org.apache.tuscany.scdl.stax.impl.LoaderRegistryImpl;
+
+/**
+ * Test the usability of the assembly model API when loading SCDL
+ *
+ * @version $Rev$ $Date$
+ */
+public class ReadTestCase extends TestCase {
+
+ XMLInputFactory inputFactory;
+ AssemblyFactory assemblyFactory;
+ PolicyFactory policyFactory;
+ LoaderRegistry loaderRegistry;
+
+ public void setUp() throws Exception {
+ inputFactory = XMLInputFactory.newInstance();
+ assemblyFactory = new DefaultAssemblyFactory();
+ policyFactory = new DefaultPolicyFactory();
+ loaderRegistry = new LoaderRegistryImpl();
+
+ WSDLReader wsdlReader = new WSDLReader(new DefaultWSDLFactory());
+ loaderRegistry.addLoader(WSDLConstants.INTERFACE_WSDL_QNAME, wsdlReader);
+ }
+
+ public void tearDown() throws Exception {
+ inputFactory = null;
+ assemblyFactory = null;
+ policyFactory = null;
+ loaderRegistry = null;
+ }
+
+ public void testReadComponentType() throws Exception {
+ ComponentTypeLoader componentTypeReader = new ComponentTypeLoader(assemblyFactory, policyFactory, loaderRegistry);
+ InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorImpl.componentType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ComponentType componentType = componentTypeReader.load(reader);
+ assertNotNull(componentType);
+
+ new PrintUtil(System.out).print(componentType);
+ }
+
+ public void testReadConstrainingType() throws Exception {
+ ConstrainingTypeLoader constrainingTypeReader = new ConstrainingTypeLoader(assemblyFactory, policyFactory, loaderRegistry);
+ InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorComponent.constrainingType");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ ConstrainingType constrainingType = constrainingTypeReader.load(reader);
+ assertNotNull(constrainingType);
+
+ new PrintUtil(System.out).print(constrainingType);
+ }
+
+ public void testReadComposite() throws Exception {
+ CompositeLoader compositeReader = new CompositeLoader(assemblyFactory, policyFactory, loaderRegistry);
+ InputStream is = getClass().getClassLoader().getResourceAsStream("Calculator.composite");
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
+ Composite composite = compositeReader.load(reader);
+ assertNotNull(composite);
+
+ new CompositeUtil(assemblyFactory, composite).configure(null);
+
+ new PrintUtil(System.out).print(composite);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/ReadTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/ReadTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/SAXReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/SAXReadTestCase.java?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/SAXReadTestCase.java (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/SAXReadTestCase.java Sun Apr 1 01:30:23 2007
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.tuscany.idl.wsdl.xml;
+
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.assembly.util.CompositeUtil;
+import org.apache.tuscany.assembly.util.PrintUtil;
+import org.apache.tuscany.idl.wsdl.impl.DefaultWSDLFactory;
+import org.apache.tuscany.policy.model.PolicyFactory;
+import org.apache.tuscany.policy.model.impl.DefaultPolicyFactory;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.impl.ComponentTypeHandler;
+import org.apache.tuscany.scdl.impl.CompositeHandler;
+import org.apache.tuscany.scdl.impl.ConstrainingTypeHandler;
+import org.apache.tuscany.scdl.impl.ImplementationHandlerRegistry;
+import org.apache.tuscany.scdl.impl.InterfaceHandlerRegistry;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * Test the usability of the assembly model API when loading SCDL
+ *
+ * @version $Rev$ $Date$
+ */
+public class SAXReadTestCase extends TestCase {
+
+ AssemblyFactory assemblyFactory;
+ PolicyFactory policyFactory;
+ XMLReader reader;
+ InterfaceHandlerRegistry interfaceHandlers;
+ ImplementationHandlerRegistry implementationHandlers;
+
+ public void setUp() throws Exception {
+
+ reader = XMLReaderFactory.createXMLReader();
+
+ assemblyFactory = new DefaultAssemblyFactory();
+ policyFactory = new DefaultPolicyFactory();
+
+ WSDLHandler wsdlHandler = new WSDLHandler(new DefaultWSDLFactory());
+ interfaceHandlers = new InterfaceHandlerRegistry();
+ interfaceHandlers.addHandler(Constants.SCA10_NS, WSDLConstants.INTERFACE_WSDL, wsdlHandler);
+ }
+
+ public void tearDown() throws Exception {
+ assemblyFactory = null;
+ reader = null;
+ }
+
+ public void testReadComponentType() throws Exception {
+ InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorImpl.componentType");
+ ComponentTypeHandler handler = new ComponentTypeHandler(assemblyFactory, policyFactory, interfaceHandlers);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(is));
+ assertNotNull(handler.getComponentType());
+
+ new PrintUtil(System.out).print(handler.getComponentType());
+ }
+
+ public void testReadConstrainingType() throws Exception {
+ InputStream is = getClass().getClassLoader().getResourceAsStream("CalculatorComponent.constrainingType");
+ ConstrainingTypeHandler handler = new ConstrainingTypeHandler(assemblyFactory, policyFactory, interfaceHandlers);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(is));
+ assertNotNull(handler.getConstrainingType());
+
+ new PrintUtil(System.out).print(handler.getConstrainingType());
+ }
+
+ public void testReadComposite() throws Exception {
+ InputStream is = getClass().getClassLoader().getResourceAsStream("Calculator.composite");
+ CompositeHandler handler = new CompositeHandler(assemblyFactory, policyFactory, interfaceHandlers, implementationHandlers, null);
+ reader.setContentHandler(handler);
+ reader.parse(new InputSource(is));
+ assertNotNull(handler.getComposite());
+
+ new CompositeUtil(assemblyFactory, handler.getComposite()).configure(null);
+
+ new PrintUtil(System.out).print(handler.getComposite());
+ }
+
+}
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/SAXReadTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/java/org/apache/tuscany/idl/wsdl/xml/SAXReadTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/Calculator.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/Calculator.composite?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/Calculator.composite (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/Calculator.composite Sun Apr 1 01:30:23 2007
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://sample.calculator"
+ name="calc:Calculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/>
+ </service>
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/Calculator.composite
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/Calculator.composite
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/CalculatorComponent.constrainingType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/CalculatorComponent.constrainingType?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/CalculatorComponent.constrainingType (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/CalculatorComponent.constrainingType Sun Apr 1 01:30:23 2007
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<constrainingType xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:calc="http://sample.calculator"
+ name="calc:CalculatorComponent">
+
+ <service name="CalculatorService">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/>
+ </service>
+
+ <reference name="divideService">
+ <interface.java class="calculator.DivideService" />
+ </reference>
+
+</constrainingType>
+
\ No newline at end of file
Added: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/CalculatorImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/CalculatorImpl.componentType?view=auto&rev=524557
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/CalculatorImpl.componentType (added)
+++ incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/CalculatorImpl.componentType Sun Apr 1 01:30:23 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+-->
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
+
+ <service name="CalculatorService">
+ <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/>
+ </service>
+
+ <reference name="divideService">
+ <interface.java class="calculator.DivideService" />
+ </reference>
+
+</componentType>
+
\ No newline at end of file
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/CalculatorImpl.componentType
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/idl-wsdl-xml/src/test/resources/CalculatorImpl.componentType
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org