tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r591858 [13/13] - in /openejb/trunk/openejb3: ./ assembly/openejb-tomcat/ assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/ container/openejb-core/ container/openejb-core/src/main/java/org/apache/openejb/ container/openejb-co...
Date Sun, 04 Nov 2007 22:42:06 GMT
Added: openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SaajUniverse.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SaajUniverse.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SaajUniverse.java
(added)
+++ openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SaajUniverse.java
Sun Nov  4 14:41:49 2007
@@ -0,0 +1,81 @@
+/**
+ * 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.openejb.server.webservices.saaj;
+
+import java.util.LinkedList;
+
+import org.apache.openejb.util.Logger;
+import org.apache.openejb.util.LogCategory;
+
+public class SaajUniverse {
+    private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_WS, SaajUniverse.class);
+    
+    static {
+        setProperty("javax.xml.soap.MessageFactory", "org.apache.openejb.server.webservices.saaj.MessageFactoryImpl");
+        setProperty("javax.xml.soap.SOAPFactory", "org.apache.openejb.server.webservices.saaj.SoapFactoryImpl");
+        setProperty("javax.xml.soap.SOAPConnectionFactory", "org.apache.openejb.server.webservices.saaj.SoapConnectionFactoryImpl");
+        setProperty("javax.xml.soap.MetaFactory", "org.apache.openejb.server.webservices.saaj.MetaFactoryImpl");
+    }
+
+    private static void setProperty(String name, String value) {
+        if (System.getProperty(name) == null) {
+            System.setProperty(name, value);
+        }
+    }
+
+    enum Type { DEFAULT, AXIS1, AXIS2, SUN }
+    
+    public static final Type DEFAULT = Type.DEFAULT;
+    public static final Type SUN = Type.SUN;
+    public static final Type AXIS1 = Type.AXIS1;
+    public static final Type AXIS2 = Type.AXIS2;
+    
+    private static final ThreadLocal<LinkedList<Type>> currentUniverse = 
+        new InheritableThreadLocal<LinkedList<Type>>();
+        
+    public void set(Type newUniverse) {
+        LinkedList<Type> universeList = currentUniverse.get();
+        if (universeList == null) {
+            universeList = new LinkedList<Type>();
+            currentUniverse.set(universeList);
+        }
+        universeList.add(newUniverse);
+        if (logger.isDebugEnabled()) {
+            logger.debug("Set universe: " + Thread.currentThread() + " " + newUniverse);
+        }
+    }
+    
+    public void unset() {
+        LinkedList<Type> universeList = currentUniverse.get();
+        if (universeList != null && !universeList.isEmpty()) {
+            universeList.removeLast();
+            if (logger.isDebugEnabled()) {
+                logger.debug("Restored universe: " + Thread.currentThread());
+            }
+        }
+    }
+    
+    static Type getCurrentUniverse() {
+        LinkedList<Type> universeList = currentUniverse.get();
+        if (universeList != null && !universeList.isEmpty()) {
+            return universeList.getLast();
+        } else {
+            return null;
+        }                
+    }
+       
+}

Added: openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SoapConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SoapConnectionFactoryImpl.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SoapConnectionFactoryImpl.java
(added)
+++ openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SoapConnectionFactoryImpl.java
Sun Nov  4 14:41:49 2007
@@ -0,0 +1,36 @@
+/**
+ * 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.openejb.server.webservices.saaj;
+
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPException;
+
+public class SoapConnectionFactoryImpl extends SOAPConnectionFactory {
+    
+    private SOAPConnectionFactory getSOAPConnectionFactory() throws SOAPException {
+        SOAPConnectionFactory factory = 
+            (SOAPConnectionFactory) SaajFactoryFinder.find("javax.xml.soap.SOAPConnectionFactory");
+        return factory;
+        
+    }
+
+    public SOAPConnection createConnection() throws SOAPException {
+        return getSOAPConnectionFactory().createConnection();
+    }
+      
+}

Added: openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SoapFactoryImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SoapFactoryImpl.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SoapFactoryImpl.java
(added)
+++ openejb/trunk/openejb3/server/openejb-webservices/src/main/java/org/apache/openejb/server/webservices/saaj/SoapFactoryImpl.java
Sun Nov  4 14:41:49 2007
@@ -0,0 +1,67 @@
+/**
+ * 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.openejb.server.webservices.saaj;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.Detail;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPFault;
+
+public class SoapFactoryImpl extends SOAPFactory {
+    
+    private SOAPFactory getSOAPFactory() throws SOAPException {
+        SOAPFactory factory = 
+            (SOAPFactory) SaajFactoryFinder.find("javax.xml.soap.SOAPFactory");
+        return factory;
+        
+    }
+    public Detail createDetail() throws SOAPException {
+        return getSOAPFactory().createDetail();
+    }
+
+    public SOAPElement createElement(Name arg0) throws SOAPException {
+        return getSOAPFactory().createElement(arg0);
+    }
+
+    public SOAPElement createElement(String arg0) throws SOAPException {
+        return getSOAPFactory().createElement(arg0);
+    }
+
+    public SOAPElement createElement(String arg0, String arg1, String arg2) throws SOAPException
{
+        return getSOAPFactory().createElement(arg0, arg1, arg2);
+    }
+
+    public SOAPFault createFault() throws SOAPException {
+        return getSOAPFactory().createFault();
+    }
+
+    public SOAPFault createFault(String arg0, QName arg1) throws SOAPException {
+        return getSOAPFactory().createFault(arg0, arg1);
+    }
+
+    public Name createName(String arg0) throws SOAPException {
+        return getSOAPFactory().createName(arg0);
+    }
+
+    public Name createName(String arg0, String arg1, String arg2) throws SOAPException {
+        return getSOAPFactory().createName(arg0, arg1, arg2);
+    }
+      
+}

Added: openejb/trunk/openejb3/server/openejb-webservices/src/test/java/org/apache/openejb/server/webservices/saaj/SaajUniverseTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-webservices/src/test/java/org/apache/openejb/server/webservices/saaj/SaajUniverseTest.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/server/openejb-webservices/src/test/java/org/apache/openejb/server/webservices/saaj/SaajUniverseTest.java
(added)
+++ openejb/trunk/openejb3/server/openejb-webservices/src/test/java/org/apache/openejb/server/webservices/saaj/SaajUniverseTest.java
Sun Nov  4 14:41:49 2007
@@ -0,0 +1,75 @@
+/**
+ *  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.openejb.server.webservices.saaj;
+
+import junit.framework.TestCase;
+
+import javax.xml.soap.MessageFactory;
+
+public class SaajUniverseTest extends TestCase {
+    private static final String SUN_MESSAGE_CLASS = "com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl";
+
+    private static final String AXIS1_MESSAGE_CLASS = "org.apache.axis.Message";
+
+    private static final String DEFAULT_MESSAGE_CLASS = SUN_MESSAGE_CLASS;
+
+    public void testBasic() throws Exception {
+        // case 1, universe not set
+        assertEquals(DEFAULT_MESSAGE_CLASS, MessageFactory.newInstance().createMessage().getClass().getName());
+
+        // case 2, default universe set                       
+        SaajUniverse u = new SaajUniverse();
+        u.set(SaajUniverse.DEFAULT);
+        assertEquals(DEFAULT_MESSAGE_CLASS, MessageFactory.newInstance().createMessage().getClass().getName());
+        u.unset();
+
+        // case 3, Sun universe set
+        u.set(SaajUniverse.SUN);
+        assertEquals(SUN_MESSAGE_CLASS, MessageFactory.newInstance().createMessage().getClass().getName());
+        u.unset();
+
+        // case 4, Axis1 universe set        
+        u.set(SaajUniverse.AXIS1);
+        assertEquals(AXIS1_MESSAGE_CLASS, MessageFactory.newInstance().createMessage().getClass().getName());
+        u.unset();
+    }
+
+    public void testNested() throws Exception {
+        assertEquals(DEFAULT_MESSAGE_CLASS, MessageFactory.newInstance().createMessage().getClass().getName());
+
+        SaajUniverse u = new SaajUniverse();
+
+        // set axis1
+        u.set(SaajUniverse.AXIS1);
+        assertEquals(AXIS1_MESSAGE_CLASS, MessageFactory.newInstance().createMessage().getClass().getName());
+
+        // set sun, nested
+        u.set(SaajUniverse.SUN);
+        assertEquals(SUN_MESSAGE_CLASS, MessageFactory.newInstance().createMessage().getClass().getName());
+
+        // unset sun
+        u.unset();
+
+        // should be axis
+        assertEquals(AXIS1_MESSAGE_CLASS, MessageFactory.newInstance().createMessage().getClass().getName());
+
+        u.unset();
+
+        assertEquals(DEFAULT_MESSAGE_CLASS, MessageFactory.newInstance().createMessage().getClass().getName());
+    }
+
+}

Modified: openejb/trunk/openejb3/server/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/pom.xml?rev=591858&r1=591857&r2=591858&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/pom.xml (original)
+++ openejb/trunk/openejb3/server/pom.xml Sun Nov  4 14:41:49 2007
@@ -35,12 +35,14 @@
     <module>openejb-client</module>
     <module>openejb-http</module>
     <module>openejb-telnet</module>
-    <module>openejb-xfire</module>
-    <module>openejb-axis</module>
     <module>openejb-activemq</module>
     <module>openejb-corba</module>
     <module>openejb-derbynet</module>
     <module>openejb-hsql</module>
+    <module>openejb-webservices</module>
+    <module>openejb-axis</module>
+    <module>openejb-axis2</module>
+    <module>openejb-cxf</module>
   </modules>
   <dependencies>
     <!--



Mime
View raw message