You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2008/09/24 23:11:11 UTC

svn commit: r698737 - in /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core: singleton/ stateless/ webservices/

Author: dblevins
Date: Wed Sep 24 14:11:10 2008
New Revision: 698737

URL: http://svn.apache.org/viewvc?rev=698737&view=rev
Log:
OPENEJB-917: JAX-WS 2.1: Support for WebServiceContext.getEndpointReference()
Patch from Jarek Gawor.  Thanks, Jarek!

Added:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/AddressingSupport.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/NoAddressingSupport.java
Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/EjbWsContext.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/EjbWsContext.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/EjbWsContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/EjbWsContext.java?rev=698737&r1=698736&r2=698737&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/EjbWsContext.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/EjbWsContext.java Wed Sep 24 14:11:10 2008
@@ -24,6 +24,7 @@
 import javax.xml.ws.handler.MessageContext;
 
 import org.apache.openejb.core.ThreadContext;
+import org.apache.openejb.core.webservices.AddressingSupport;
 import org.w3c.dom.Element;
 
 public class EjbWsContext implements WebServiceContext {
@@ -50,13 +51,20 @@
         return this.context.isCallerInRole(roleName);
     }
 
-    @SuppressWarnings({"UnusedDeclaration"})
+    private AddressingSupport getAddressingSupport() {
+        ThreadContext threadContext = ThreadContext.getThreadContext();
+        AddressingSupport wsaSupport = threadContext.get(AddressingSupport.class);
+        if (wsaSupport == null) {
+            throw new IllegalStateException("Only calls on the service-endpoint can get the EndpointReference.");
+        }
+        return wsaSupport;
+    }
+    
     public EndpointReference getEndpointReference(org.w3c.dom.Element... referenceParameters) {
-        throw new UnsupportedOperationException("JaxWS 2.1 APIs are not supported");        
+        return getAddressingSupport().getEndpointReference(referenceParameters);      
     }
 
-    @SuppressWarnings({"UnusedDeclaration"})
     public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element... referenceParameters) {
-        throw new UnsupportedOperationException("JaxWS 2.1 APIs are not supported");
+        return getAddressingSupport().getEndpointReference(clazz, referenceParameters);
     }
 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java?rev=698737&r1=698736&r2=698737&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/singleton/SingletonContainer.java Wed Sep 24 14:11:10 2008
@@ -47,6 +47,9 @@
 import org.apache.openejb.core.interceptor.InterceptorStack;
 import org.apache.openejb.core.timer.EjbTimerService;
 import org.apache.openejb.core.transaction.TransactionPolicy;
+import org.apache.openejb.core.webservices.AddressingSupport;
+import org.apache.openejb.core.webservices.NoAddressingSupport;
+
 import static org.apache.openejb.core.transaction.EjbTransactionUtil.handleApplicationException;
 import static org.apache.openejb.core.transaction.EjbTransactionUtil.handleSystemException;
 import static org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke;
@@ -286,8 +289,8 @@
     }
 
     private Object invokeWebService(Object[] args, CoreDeploymentInfo deploymentInfo, Method runMethod, Instance instance) throws Exception {
-        if (args.length != 2){
-            throw new IllegalArgumentException("WebService calls must follow format {messageContext, interceptor}.");
+        if (args.length < 2) {
+            throw new IllegalArgumentException("WebService calls must follow format {messageContext, interceptor, [arg...]}.");
         }
 
         Object messageContext = args[0];
@@ -325,6 +328,13 @@
             ThreadContext.getThreadContext().set(javax.xml.rpc.handler.MessageContext.class, (javax.xml.rpc.handler.MessageContext) messageContext);
             return interceptorStack.invoke((javax.xml.rpc.handler.MessageContext) messageContext, params);
         } else if (messageContext instanceof javax.xml.ws.handler.MessageContext) {
+            AddressingSupport wsaSupport = NoAddressingSupport.INSTANCE;
+            for (int i = 2; i < args.length; i++) {
+                if (args[i] instanceof AddressingSupport) {
+                    wsaSupport = (AddressingSupport)args[i];
+                }
+            }
+            ThreadContext.getThreadContext().set(AddressingSupport.class, wsaSupport);
             ThreadContext.getThreadContext().set(javax.xml.ws.handler.MessageContext.class, (javax.xml.ws.handler.MessageContext) messageContext);
             return interceptorStack.invoke((javax.xml.ws.handler.MessageContext) messageContext, params);
         }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/EjbWsContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/EjbWsContext.java?rev=698737&r1=698736&r2=698737&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/EjbWsContext.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/EjbWsContext.java Wed Sep 24 14:11:10 2008
@@ -24,6 +24,7 @@
 import javax.xml.ws.handler.MessageContext;
 
 import org.apache.openejb.core.ThreadContext;
+import org.apache.openejb.core.webservices.AddressingSupport;
 import org.w3c.dom.Element;
 
 public class EjbWsContext implements WebServiceContext {
@@ -50,13 +51,20 @@
         return this.context.isCallerInRole(roleName);
     }
 
-    @SuppressWarnings({"UnusedDeclaration"})
+    private AddressingSupport getAddressingSupport() {
+        ThreadContext threadContext = ThreadContext.getThreadContext();
+        AddressingSupport wsaSupport = threadContext.get(AddressingSupport.class);
+        if (wsaSupport == null) {
+            throw new IllegalStateException("Only calls on the service-endpoint can get the EndpointReference.");
+        }
+        return wsaSupport;
+    }
+    
     public EndpointReference getEndpointReference(org.w3c.dom.Element... referenceParameters) {
-        throw new UnsupportedOperationException("JaxWS 2.1 APIs are not supported");        
+        return getAddressingSupport().getEndpointReference(referenceParameters);      
     }
 
-    @SuppressWarnings({"UnusedDeclaration"})
     public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element... referenceParameters) {
-        throw new UnsupportedOperationException("JaxWS 2.1 APIs are not supported");
+        return getAddressingSupport().getEndpointReference(clazz, referenceParameters);
     }
 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java?rev=698737&r1=698736&r2=698737&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateless/StatelessContainer.java Wed Sep 24 14:11:10 2008
@@ -43,6 +43,9 @@
 import org.apache.openejb.core.interceptor.InterceptorStack;
 import org.apache.openejb.core.timer.EjbTimerService;
 import org.apache.openejb.core.transaction.TransactionPolicy;
+import org.apache.openejb.core.webservices.AddressingSupport;
+import org.apache.openejb.core.webservices.NoAddressingSupport;
+
 import static org.apache.openejb.core.transaction.EjbTransactionUtil.handleApplicationException;
 import static org.apache.openejb.core.transaction.EjbTransactionUtil.handleSystemException;
 import static org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke;
@@ -232,8 +235,8 @@
     }
 
     private Object invokeWebService(Object[] args, CoreDeploymentInfo deploymentInfo, Method runMethod, Instance instance, Object returnValue) throws Exception {
-        if (args.length != 2){
-            throw new IllegalArgumentException("WebService calls must follow format {messageContext, interceptor}.");
+        if (args.length < 2) {
+            throw new IllegalArgumentException("WebService calls must follow format {messageContext, interceptor, [arg...]}.");
         }
 
         Object messageContext = args[0];
@@ -268,6 +271,13 @@
             ThreadContext.getThreadContext().set(javax.xml.rpc.handler.MessageContext.class, (javax.xml.rpc.handler.MessageContext) messageContext);
             returnValue = interceptorStack.invoke((javax.xml.rpc.handler.MessageContext) messageContext, params);
         } else if (messageContext instanceof javax.xml.ws.handler.MessageContext) {
+            AddressingSupport wsaSupport = NoAddressingSupport.INSTANCE;
+            for (int i = 2; i < args.length; i++) {
+                if (args[i] instanceof AddressingSupport) {
+                    wsaSupport = (AddressingSupport)args[i];
+                }
+            }
+            ThreadContext.getThreadContext().set(AddressingSupport.class, wsaSupport);
             ThreadContext.getThreadContext().set(javax.xml.ws.handler.MessageContext.class, (javax.xml.ws.handler.MessageContext) messageContext);
             returnValue = interceptorStack.invoke((javax.xml.ws.handler.MessageContext) messageContext, params);
         }

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/AddressingSupport.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/AddressingSupport.java?rev=698737&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/AddressingSupport.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/AddressingSupport.java Wed Sep 24 14:11:10 2008
@@ -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.core.webservices;
+
+import javax.xml.ws.EndpointReference;
+
+import org.w3c.dom.Element;
+
+/**
+ * This interface defines the WS-Addressing functions of {@link javax.xml.ws.WebServiceContext WebServiceContext} 
+ * that must be implemented by each JAX-WS provider. This interface is used within 
+ * {@link org.apache.openejb.core.stateless.EjbWsContext EjbWsContext} and its implementation can be passed to 
+ * the stateless or singleton container on Web Service invocations. 
+ */
+public interface AddressingSupport {
+    
+    public EndpointReference getEndpointReference(org.w3c.dom.Element... referenceParameters);
+
+    public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element... referenceParameters);
+    
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/NoAddressingSupport.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/NoAddressingSupport.java?rev=698737&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/NoAddressingSupport.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/NoAddressingSupport.java Wed Sep 24 14:11:10 2008
@@ -0,0 +1,40 @@
+/**
+ *
+ * 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.core.webservices;
+
+import javax.xml.ws.EndpointReference;
+
+import org.w3c.dom.Element;
+
+/**
+ * An implementation of the {@link AddressingSupport} interface that throws
+ * {@link UnsupportedOperationException} for all its methods.
+ */
+public class NoAddressingSupport implements AddressingSupport {
+    
+    public static final NoAddressingSupport INSTANCE = new NoAddressingSupport();
+    
+    public EndpointReference getEndpointReference(org.w3c.dom.Element... referenceParameters) {
+        throw new UnsupportedOperationException("JaxWS 2.1 APIs are not supported.");
+    }
+
+    public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element... referenceParameters) {
+        throw new UnsupportedOperationException("JaxWS 2.1 APIs are not supported.");
+    }
+    
+}