[jboss-cvs] JBossAS SVN: r82045 - in projects/jaxr/trunk: modules/juddi-jaxr/src/main/java/org/jboss/jaxr and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Dec 4 09:32:57 EST 2008


Author: richard.opalka at jboss.com
Date: 2008-12-04 09:32:57 -0500 (Thu, 04 Dec 2008)
New Revision: 82045

Added:
   projects/jaxr/trunk/modules/juddi-jaxr/src/main/java/org/jboss/jaxr/scout/
   projects/jaxr/trunk/modules/juddi-jaxr/src/main/java/org/jboss/jaxr/scout/transport/
   projects/jaxr/trunk/modules/juddi-jaxr/src/main/java/org/jboss/jaxr/scout/transport/SaajTransport.java
Removed:
   projects/jaxr/trunk/modules/juddi-jaxr/src/main/java/org/jboss/jaxr/juddi/transport/
Modified:
   projects/jaxr/trunk/modules/juddi-saaj/pom.xml
   projects/jaxr/trunk/modules/juddi-service/pom.xml
   projects/jaxr/trunk/pom.xml
Log:
[JAXR-12] implementing scout transport, removing obsolete juddi transport, upgrading to the latest maven artifacts, do not package juddi.jar and scout.jar to juddi-service.sar

Added: projects/jaxr/trunk/modules/juddi-jaxr/src/main/java/org/jboss/jaxr/scout/transport/SaajTransport.java
===================================================================
--- projects/jaxr/trunk/modules/juddi-jaxr/src/main/java/org/jboss/jaxr/scout/transport/SaajTransport.java	                        (rev 0)
+++ projects/jaxr/trunk/modules/juddi-jaxr/src/main/java/org/jboss/jaxr/scout/transport/SaajTransport.java	2008-12-04 14:32:57 UTC (rev 82045)
@@ -0,0 +1,245 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jaxr.scout.transport;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URI;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPBodyElement;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPFault;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+
+import org.apache.ws.scout.transport.Transport;
+import org.apache.ws.scout.registry.RegistryException;
+import org.apache.juddi.IRegistry;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.common.DOMWriter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+/**
+ * Transport based on SAAJ
+ *
+ * @author Anil Saldhana (anil at apache.org)
+ * @author Richard Opalka (richard.opalka at redhat.com)
+ */
+public class SaajTransport implements Transport
+{
+    // private reference to the jUDDI logger
+    private static Logger log = Logger.getLogger(SaajTransport.class); 
+    
+    /**
+     * @see Transport#send(org.w3c.dom.Element, java.net.URL)
+     */
+    public Element send(Element request, URI endpointURL)
+            throws RegistryException
+    {
+       String requestMessage = DOMWriter.printNode(request, true);
+        log.debug("Request message:" + requestMessage); 
+
+        Element response = null;
+        try
+        {
+           SOAPMessage message = this.createSOAPMessage(request);
+           //Make the SAAJ Call now
+           SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
+           SOAPConnection connection = soapConnectionFactory.createConnection();
+           SOAPMessage soapResponse = connection.call(message, endpointURL.toURL()); 
+           
+           SOAPBody soapBody = soapResponse.getSOAPBody();
+           boolean hasFault = soapBody.hasFault();
+           if(hasFault)
+           {
+              SOAPFault soapFault = soapBody.getFault();
+              String faultStr = soapFault.getFaultCode() + "::" + soapFault.getFaultString();
+              throw new RegistryException(faultStr);
+           }
+           response = getFirstChildElement(soapBody);
+        } catch (Exception ex)
+        { 
+            log.error("Exception::",ex);
+            throw new RegistryException(ex);
+        }
+
+        log.debug("Response message:" + DOMWriter.printNode(response, true)); 
+        return response;
+    }
+
+    /**
+     * @see Transport#send(java.lang.String, java.net.URL)
+     */
+    public String send(String request, URI endpointURL)
+            throws RegistryException
+    {
+        Element reqEl = getElement(request);
+        Element respEl = this.send(reqEl, endpointURL);
+        StringWriter sw = new StringWriter();
+
+        DOMWriter dw = new DOMWriter(sw);
+        dw.print(respEl);
+        return sw.toString();
+    }
+    
+    // PRIVATE METHODS
+    
+    private SOAPMessage createSOAPMessage(Element elem) throws Exception
+    {
+       String prefix = "";
+       MessageFactory msgFactory = MessageFactory.newInstance();
+       SOAPFactory factory = SOAPFactory.newInstance();
+       
+       SOAPMessage message = msgFactory.createMessage();
+       message.getSOAPHeader().detachNode();
+       SOAPPart soapPart = message.getSOAPPart();
+       SOAPBody soapBody = soapPart.getEnvelope().getBody(); 
+       //Create the outer body element
+       String uddins = IRegistry.UDDI_V2_NAMESPACE;
+       Name bodyName = factory.createName(elem.getNodeName(),prefix,uddins);
+       SOAPBodyElement bodyElement = soapBody.addBodyElement(bodyName);
+       bodyElement.addNamespaceDeclaration(prefix,uddins);      
+       appendAttributes(bodyElement, elem.getAttributes(), factory);
+       appendElements(bodyElement,elem.getChildNodes(), factory); 
+       return message;
+    }
+    
+    private void appendAttributes(SOAPElement bodyElement, NamedNodeMap nnm,
+          SOAPFactory factory) throws SOAPException
+    {
+       int len = nnm != null ? nnm.getLength() : 0;
+       for (int i = 0; i < len; i++)
+       {
+           Node n = nnm.item(i);
+           String nodename = n.getNodeName();
+           String nodevalue = n.getNodeValue(); 
+           if("xmlns".equals(nodename))
+              continue; 
+           if(nodename.startsWith("xmlns:")) // TODO: remove???
+        	  continue;                      // TODO: remove???
+           //Special case:  xml:lang
+           if("xml:lang".equals(nodename))
+           {
+              Name xmlLang = factory.createName("lang","xml","");
+              bodyElement.addAttribute(xmlLang, nodevalue);
+           }
+           else
+               bodyElement.addAttribute(factory.createName(nodename), nodevalue);
+       } 
+    }
+    
+    private void appendElements(SOAPElement bodyElement, NodeList nlist,
+          SOAPFactory factory) 
+    throws SOAPException
+    {  
+       String prefix = "";
+       String uddins = IRegistry.UDDI_V2_NAMESPACE;
+       int len = nlist != null ? nlist.getLength() : 0;
+
+       for (int i = 0; i < len; i++)
+       {
+           Node node = nlist.item(i);
+           short nodeType = node != null ? node.getNodeType() : -100;
+           if (Node.ELEMENT_NODE == nodeType)
+           {
+              Element el = (Element)node;
+              Name name = factory.createName(el.getNodeName(), prefix,uddins);
+              SOAPElement attachedEl = bodyElement.addChildElement(name); 
+              appendAttributes(attachedEl, el.getAttributes(), factory);
+              appendElements(attachedEl, el.getChildNodes(), factory);
+           } else if (nodeType == Node.TEXT_NODE)
+           {
+               bodyElement.addTextNode(node.getNodeValue());
+           } 
+       } 
+    } 
+    
+
+    /**
+     * Get an Element given a string
+     * 
+     * @param xmlFrag
+     * @return
+     */
+    private static Element getElement(String xmlFrag)
+    {
+        Document doc = null;
+        Element reqElement = null;
+        try
+        {
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            doc = factory.newDocumentBuilder().parse(new InputSource(new StringReader(xmlFrag)));
+            reqElement = doc.getDocumentElement();
+        } catch (Exception e)
+        {
+            log.error("Exception:",e);
+        }  
+
+        return reqElement; 
+    }
+
+    /**
+     * Return the first child element
+     * 
+     * @param el
+     * @return
+     */
+    private Element getFirstChildElement(Element el)
+    {
+        return getFirstChildElement(el, null);
+    }
+
+    /**
+     * Return the first child element for a givenname
+     */
+    private Element getFirstChildElement(Element el, String tagName)
+    {
+        Element childEl = null;
+        NodeList nlist = el != null ? el.getChildNodes() : null;
+        int len = nlist != null ? nlist.getLength() : 0;
+        for (int i = 0; childEl == null && i < len; i++)
+        {
+            Node node = nlist.item(i);
+            if (node.getNodeType() == Node.ELEMENT_NODE)
+            {
+                if (tagName == null || tagName.equals(node.getLocalName()))
+                    childEl = (Element) node;
+            }
+        }
+        String responseObtained =  DOMWriter.printNode(childEl, true);
+        log.debug("Response obtained="+responseObtained);
+        return childEl;
+    }
+}

Modified: projects/jaxr/trunk/modules/juddi-saaj/pom.xml
===================================================================
--- projects/jaxr/trunk/modules/juddi-saaj/pom.xml	2008-12-04 14:30:53 UTC (rev 82044)
+++ projects/jaxr/trunk/modules/juddi-saaj/pom.xml	2008-12-04 14:32:57 UTC (rev 82045)
@@ -2,7 +2,7 @@
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   
-  <name>JBoss Registry - Saaj Transport</name>
+  <name>JBoss Registry - SAAJ Transport</name>
   <artifactId>juddi-saaj</artifactId>
   <packaging>jar</packaging>
   

Modified: projects/jaxr/trunk/modules/juddi-service/pom.xml
===================================================================
--- projects/jaxr/trunk/modules/juddi-service/pom.xml	2008-12-04 14:30:53 UTC (rev 82044)
+++ projects/jaxr/trunk/modules/juddi-service/pom.xml	2008-12-04 14:32:57 UTC (rev 82045)
@@ -1,18 +1,18 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
-  
+
   <name>JBoss Registry - JUDDI Service</name>
   <artifactId>juddi-service</artifactId>
   <packaging>jboss-sar</packaging>
-  
+
   <parent>
     <groupId>org.jboss.jaxr</groupId>
     <artifactId>juddi-parent</artifactId>
     <version>2.0.RC6-SNAPSHOT</version>
     <relativePath>../../pom.xml</relativePath>
   </parent>
-  
+
   <build>
     <finalName>${artifactId}</finalName>
     <plugins>
@@ -41,31 +41,21 @@
             <configuration>
               <tasks>
                 <mkdir dir="${basedir}/target"/>
-                
-                <!-- [TODO] show me how to use the dependency atrtifacts from the local repository -->
-                <property name="jboss.repository" value="http://repository.jboss.com"/>
-                <property name="thirdparty.dir" value="${basedir}/thirdparty"/>
-                <property name="apache-scout" value="1.0rc1"/>
-                <property name="juddi" value="2.0rc5"/>
-                
-                <mkdir dir="${thirdparty.dir}"/>
-                <get src="${jboss.repository}/apache-scout/${apache-scout}/lib/scout.jar" dest="${thirdparty.dir}/scout.jar" usetimestamp="true" verbose="true"/>
-                <get src="${jboss.repository}/juddi/${juddi}/lib/juddi.jar" dest="${thirdparty.dir}/juddi.jar" usetimestamp="true" verbose="true"/>
-                
+
                 <!--juddi-service.jar-->
                 <jar jarfile="${basedir}/target/juddi-service.jar">
                   <fileset dir="${basedir}/../juddi-jaxr/target/classes">
                     <include name="org/jboss/jaxr/juddi/**"/>
                   </fileset>
                 </jar>
-                
+
                 <!--juddi-saaj.jar-->
                 <jar jarfile="${basedir}/target/juddi-saaj.jar">
                   <fileset dir="${basedir}/../juddi-jaxr/target/classes">
                     <include name="org/jboss/jaxr/juddi/transport/**"/>
                   </fileset>
                 </jar>
-                
+
                 <!--juddi.war -->
                 <mkdir dir="${basedir}/target/juddi.war/WEB-INF/classes"/>
                 <copy todir="${basedir}/target/juddi.war">
@@ -80,25 +70,19 @@
                     <include name="org/jboss/jaxr/juddi/JUDDIServlet.*"/>
                   </fileset>
                 </copy>
-                
+
                 <!--juddi-service.sar-->
                 <jar jarfile="${basedir}/target/juddi-service.sar">
                   <metainf dir="${basedir}/src/main/resources/META-INF">
                     <include name="jboss-service.xml"/>
                     <include name="ddl/**"/>
                   </metainf>
-                  
                   <fileset dir="${basedir}/target">
                     <include name="juddi-service.jar"/>
                     <include name="juddi-saaj.jar"/>
                     <include name="juddi.war/**"/>
                   </fileset>
-                  <fileset dir="${thirdparty.dir}">
-                    <include name="juddi.jar"/>
-                    <include name="scout.jar"/>
-                  </fileset>
                 </jar>
-                
               </tasks>
             </configuration>
             <goals>

Modified: projects/jaxr/trunk/pom.xml
===================================================================
--- projects/jaxr/trunk/pom.xml	2008-12-04 14:30:53 UTC (rev 82044)
+++ projects/jaxr/trunk/pom.xml	2008-12-04 14:32:57 UTC (rev 82045)
@@ -128,45 +128,35 @@
       <version>1.0rc1</version>
     </dependency>
     <dependency>
-      <groupId>jboss</groupId>
-      <artifactId>jboss-common</artifactId>
-      <version>1.0.4.GA</version>
+      <groupId>juddi</groupId>
+      <artifactId>juddi</artifactId>
+      <!-- Keep this version in sync with the artifact that is packaged in the juddi-service.sar --> 
+      <version>2.0rc5</version>
     </dependency>
     <dependency>
-      <groupId>jboss</groupId>
-      <artifactId>jboss-system</artifactId>
-      <version>4.2.1.GA</version>
+      <groupId>org.jboss.javaee</groupId>
+      <artifactId>jboss-javaee</artifactId>
+      <version>5.0.0.GA</version>
     </dependency>
     <dependency>
-      <groupId>jboss</groupId>
-      <artifactId>jboss-j2ee</artifactId>
-      <version>4.0.2</version>
+      <groupId>org.jboss.ws</groupId>
+      <artifactId>jbossws-common</artifactId>
+      <version>1.0.7.GA</version>
     </dependency>
     <dependency>
-      <groupId>jboss.jbossws</groupId>
-      <artifactId>jboss-jaxrpc</artifactId>
-      <version>1.0.4.GA</version>
+      <groupId>org.jboss.ws.native</groupId>
+      <artifactId>jbossws-native-saaj</artifactId>
+      <version>3.0.4.GA</version>
     </dependency>
     <dependency>
-      <groupId>jboss.jbossws</groupId>
-      <artifactId>jboss-saaj</artifactId>
-      <version>1.0.4.GA</version>
+      <groupId>org.jboss.jbossas</groupId>
+      <artifactId>jboss-as-system-jmx</artifactId>
+      <version>5.0.0.CR2</version>
     </dependency>
     <dependency>
-      <groupId>jboss</groupId>
-      <artifactId>jboss-jmx</artifactId>
-      <version>4.0.4</version>
-    </dependency>
-    <dependency>
-      <groupId>juddi</groupId>
-      <artifactId>juddi</artifactId>
-      <!-- Keep this version in sync with the artifact that is packaged in the juddi-service.sar --> 
-      <version>2.0rc5</version>
-    </dependency>
-    <dependency>
-      <groupId>sun-servlet</groupId>
+      <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
-      <version>2.4</version>
+      <version>2.5</version>
     </dependency>
   </dependencies>
 




More information about the jboss-cvs-commits mailing list