You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ch...@apache.org on 2005/03/16 05:23:48 UTC

svn commit: r157661 - in webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis: ./ wsdl/ wsdl/builder/ wsdl/builder/WOMBuilder.java wsdl/builder/WOMBuilderFactory.java wsdl/builder/WSDL2ToWOMBuilder.java

Author: chathura
Date: Tue Mar 15 20:23:48 2005
New Revision: 157661

URL: http://svn.apache.org/viewcvs?view=rev&rev=157661
Log:
Adding the WOM Builder Architecture which will be a external builders to WOM. WOMBuilderFactory will return one of the Builder implementations.

Added:
    webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/
    webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/
    webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/
    webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WOMBuilder.java
    webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WOMBuilderFactory.java
    webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WSDL2ToWOMBuilder.java

Added: webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WOMBuilder.java?view=auto&rev=157661
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WOMBuilder.java (added)
+++ webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WOMBuilder.java Tue Mar 15 20:23:48 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis.wsdl.builder;
+
+import org.apache.wsdl.WSDLDescription;
+
+import javax.wsdl.WSDLException;
+import java.io.InputStream;
+
+/**
+ * @author chathura@opensource.lk
+ */
+public interface WOMBuilder {
+
+    public WSDLDescription build(InputStream in) throws WSDLException;
+}

Added: webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WOMBuilderFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WOMBuilderFactory.java?view=auto&rev=157661
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WOMBuilderFactory.java (added)
+++ webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WOMBuilderFactory.java Tue Mar 15 20:23:48 2005
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis.wsdl.builder;
+
+import org.apache.axis.wsdl.builder.wsdl4j.WSDL1ToWOMBuilder;
+import org.apache.wsdl.WSDLConstants;
+import org.apache.wsdl.util.Utils;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import javax.wsdl.WSDLException;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author chathura@opensource.lk
+ */
+public class WOMBuilderFactory {
+
+    public static final int WSDL11 = 1;
+    public static final int wsdl20 = 2;
+
+
+    public static WOMBuilder getBuilder(int wsdlDocumentType) throws WSDLException {
+
+        if (wsdlDocumentType == WSDL11) {
+            return new WSDL1ToWOMBuilder();
+        }
+        if (wsdlDocumentType == wsdl20) {
+            return new WSDL2ToWOMBuilder();
+        }
+        throw new WSDLException(WSDLException.INVALID_WSDL, "The document type specified is not valid");
+    }
+
+
+    public static WOMBuilder getBuilder(InputStream in) throws WSDLException {
+        // Load the wsdl as a DOM
+        Document doc;
+        try {
+            doc = Utils.newDocument(in);
+        } catch (ParserConfigurationException e) {
+            throw new WSDLException(WSDLException.PARSER_ERROR, "Parser Configuration Exception", e);
+        } catch (IOException e1) {
+            throw new WSDLException(WSDLException.PARSER_ERROR, "WSDL Document read error", e1);
+        } catch (SAXException e2) {
+            throw new WSDLException(WSDLException.PARSER_ERROR, "Parser Exception", e2);
+        }
+        
+        
+        //Check the target namespace of the WSDL and determine the WSDL version.
+        int version = getWSDLVersion(doc);
+
+        if (version == WSDL11) {
+            return (WOMBuilder) new WSDL1ToWOMBuilder();
+        } else if (version == wsdl20) {
+            return (WOMBuilder) new WSDL2ToWOMBuilder();
+        }
+
+        throw new WSDLException(WSDLException.OTHER_ERROR, "Unable to Figure out the WSDL vesion of the Document");
+    }
+
+    /**
+     * Will return an int that will represent the wsdl version and the int will correspond to the static
+     * variables defined in this class.
+     *
+     * @param doc
+     * @return
+     * @throws WSDLException If the version cannot be determined
+     */
+    private static int getWSDLVersion(Document doc) throws WSDLException {
+        //TODO check weather the namespaces are correct and the / problem too
+        if (WSDLConstants.WSDL2_0_NAMESPACE.equals(doc.getDocumentElement().getNamespaceURI())) {
+            return wsdl20;
+        } else if (WSDLConstants.WSDL1_1_NAMESPACE.equals(doc.getDocumentElement().getNamespaceURI())) {
+            return WSDL11;
+        }
+
+        throw new WSDLException(WSDLException.OTHER_ERROR, "Unable to Figure out the WSDL vesion of the Document");
+    }
+}

Added: webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WSDL2ToWOMBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WSDL2ToWOMBuilder.java?view=auto&rev=157661
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WSDL2ToWOMBuilder.java (added)
+++ webservices/axis/trunk/java/modules/wsdl/src/java/org/apache/axis/wsdl/builder/WSDL2ToWOMBuilder.java Tue Mar 15 20:23:48 2005
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2001-2004 The apace Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      tap://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.axis.wsdl.builder;
+
+import org.apache.wsdl.WSDLDescription;
+
+import javax.wsdl.WSDLException;
+import java.io.InputStream;
+
+/**
+ * @author chathura@opensource.lk
+ */
+public class WSDL2ToWOMBuilder implements WOMBuilder {
+
+    public WSDLDescription build(InputStream in) throws WSDLException {
+
+        throw new UnsupportedOperationException("Fill the imps");
+
+
+    }
+}