Author: thomas.diesler(a)jboss.com
Date: 2007-01-23 04:22:12 -0500 (Tue, 23 Jan 2007)
New Revision: 2030
Added:
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/WebServiceContextEJB3.java
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextImpl.java
Modified:
trunk/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/ServiceEndpointInvokerEJB3.java
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB3.java
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextInjector.java
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvokerJSE.java
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointEJB.java
trunk/jbossws-tests/src/main/resources/tests-jboss40-excludes.txt
trunk/jbossws-tests/src/main/resources/tests-jboss42-excludes.txt
trunk/jbossws-tests/src/main/resources/tests-jboss42-noejb3-excludes.txt
trunk/jbossws-tests/src/main/resources/tests-tomcat-excludes.txt
Log:
[JBWS-1468] @Resource WebServiceContext for jbossas-4.x
Modified:
trunk/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/ServiceEndpointInvokerEJB3.java
===================================================================
---
trunk/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/ServiceEndpointInvokerEJB3.java 2007-01-23
04:37:44 UTC (rev 2029)
+++
trunk/integration-jboss42/src/main/java/org/jboss/ws/integration/jboss42/ServiceEndpointInvokerEJB3.java 2007-01-23
09:22:12 UTC (rev 2030)
@@ -33,15 +33,11 @@
import org.jboss.logging.Logger;
import org.jboss.mx.util.MBeanServerLocator;
import org.jboss.ws.WSException;
-import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.EndpointInvocation;
-import org.jboss.ws.core.jaxrpc.handler.SOAPMessageContextJAXRPC;
-import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
import org.jboss.ws.core.server.AbstractServiceEndpointInvoker;
import org.jboss.ws.core.server.ServiceEndpointInfo;
import org.jboss.ws.core.server.ServiceEndpointInvoker;
import org.jboss.ws.core.server.UnifiedDeploymentInfo;
-import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.core.utils.ObjectNameFactory;
/**
@@ -100,8 +96,6 @@
public void invokeServiceEndpoint(ServiceEndpointInfo seInfo, Object seiImpl,
EndpointInvocation epInv) throws Exception
{
log.debug("invokeServiceEndpoint: " + epInv.getJavaMethod().getName());
-
- // invoke on the container
try
{
// setup the invocation
@@ -115,23 +109,8 @@
throw new WSException("Cannot obtain container from Dispatcher: " +
canonicalName);
Class beanClass = container.getBeanClass();
-
- SOAPMessageContextJAXWS jaxwsMessageContext = null;
- SOAPMessageContextJAXRPC jaxrpcMessageContext = null;
- CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
- if (msgContext instanceof SOAPMessageContextJAXRPC)
- {
- jaxrpcMessageContext = (SOAPMessageContextJAXRPC)msgContext;
- jaxwsMessageContext = new SOAPMessageContextJAXWS(msgContext);
- }
- else if (msgContext instanceof SOAPMessageContextJAXWS)
- {
- jaxwsMessageContext = (SOAPMessageContextJAXWS)msgContext;
- jaxrpcMessageContext = new SOAPMessageContextJAXRPC(msgContext);
- }
Method implMethod = getImplMethod(beanClass, seiMethod);
- //BeanContextLifecycleCallback callback = new CallbackImpl(jaxrpcMessageContext,
jaxwsMessageContext);
Object retObj = container.localInvoke(implMethod, args);
epInv.setReturnValue(retObj);
Modified:
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB3.java
===================================================================
---
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB3.java 2007-01-23
04:37:44 UTC (rev 2029)
+++
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB3.java 2007-01-23
09:22:12 UTC (rev 2030)
@@ -24,12 +24,10 @@
// $Id$
import java.lang.reflect.Method;
-import java.security.Principal;
import javax.ejb.EJBContext;
import javax.management.ObjectName;
import javax.xml.rpc.soap.SOAPFaultException;
-import javax.xml.ws.handler.MessageContext;
import org.jboss.aop.Dispatcher;
import org.jboss.aop.MethodInfo;
@@ -44,7 +42,6 @@
import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.EndpointInvocation;
import org.jboss.ws.core.jaxrpc.handler.SOAPMessageContextJAXRPC;
-import org.jboss.ws.core.jaxws.AbstractWebServiceContext;
import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
import org.jboss.ws.core.server.AbstractServiceEndpointInvoker;
import org.jboss.ws.core.server.ServiceEndpointInfo;
@@ -173,7 +170,7 @@
if (beanProp != null)
{
EJBContext ejbCtx = beanCtx.getEJBContext();
- beanProp.set(beanCtx.getInstance(), new
WebServiceContextEJB(jaxwsMessageContext, ejbCtx));
+ beanProp.set(beanCtx.getInstance(), new
WebServiceContextEJB3(jaxwsMessageContext, ejbCtx));
}
}
@@ -187,29 +184,4 @@
beanProp.set(beanCtx.getInstance(), null);
}
}
-
- /** Delegate to EJBContext
- */
- class WebServiceContextEJB extends AbstractWebServiceContext
- {
- private EJBContext ejbContext;
-
- public WebServiceContextEJB(MessageContext messageContext, EJBContext ejbContext)
- {
- super(messageContext);
- this.ejbContext = ejbContext;
- }
-
- @Override
- public Principal getUserPrincipal()
- {
- return ejbContext.getCallerPrincipal();
- }
-
- @Override
- public boolean isUserInRole(String role)
- {
- return ejbContext.isCallerInRole(role);
- }
- }
}
Added:
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/WebServiceContextEJB3.java
===================================================================
---
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/WebServiceContextEJB3.java
(rev 0)
+++
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/WebServiceContextEJB3.java 2007-01-23
09:22:12 UTC (rev 2030)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ws.integration.jboss50;
+
+// $Id$
+
+import java.security.Principal;
+
+import javax.ejb.EJBContext;
+import javax.xml.ws.handler.MessageContext;
+
+import org.jboss.ws.core.jaxws.AbstractWebServiceContext;
+
+/**
+ * A WebServiceContext implementation that delegates to the EJBContext.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 23-Jan-2007
+ */
+public class WebServiceContextEJB3 extends AbstractWebServiceContext
+{
+ private EJBContext ejbContext;
+
+ public WebServiceContextEJB3(MessageContext messageContext, EJBContext ejbContext)
+ {
+ super(messageContext);
+ this.ejbContext = ejbContext;
+ }
+
+ @Override
+ public Principal getUserPrincipal()
+ {
+ Principal principal = ejbContext.getCallerPrincipal();
+ return principal;
+ }
+
+ @Override
+ public boolean isUserInRole(String role)
+ {
+ boolean isUserInRole = ejbContext.isCallerInRole(role);
+ return isUserInRole;
+ }
+}
Property changes on:
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/WebServiceContextEJB3.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextImpl.java
===================================================================
--- trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextImpl.java
(rev 0)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextImpl.java 2007-01-23
09:22:12 UTC (rev 2030)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ws.core.jaxws;
+
+// $Id$
+
+import java.io.Serializable;
+import java.security.Principal;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.xml.ws.handler.MessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.security.RealmMapping;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SimplePrincipal;
+
+/**
+ * A WebServiceContext implementation that delegates to the EJBContext if available.
+ * Otherwise it uses jbosssx.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 23-Jan-2007
+ */
+public class WebServiceContextImpl extends AbstractWebServiceContext implements
Serializable
+{
+ // provide logging
+ private Logger log = Logger.getLogger(WebServiceContextImpl.class);
+
+ private transient RealmMapping realmMapping;
+
+ public WebServiceContextImpl(MessageContext messageContext)
+ {
+ super(messageContext);
+ }
+
+ @Override
+ public Principal getUserPrincipal()
+ {
+ Principal principal = SecurityAssociation.getCallerPrincipal();
+ return principal;
+ }
+
+ @Override
+ public boolean isUserInRole(String role)
+ {
+ boolean isUserInRole = false;
+ Principal principal = SecurityAssociation.getCallerPrincipal();
+ RealmMapping realmMapping = getRealmMapping();
+ if (realmMapping != null && principal != null)
+ {
+ Set<Principal> roles = new HashSet<Principal>();
+ roles.add(new SimplePrincipal(role));
+ isUserInRole = realmMapping.doesUserHaveRole(principal, roles);
+ }
+ return isUserInRole;
+ }
+
+ private RealmMapping getRealmMapping()
+ {
+ if (realmMapping == null)
+ {
+ String lookupName = "java:comp/env/security/realmMapping";
+ try
+ {
+ InitialContext iniCtx = new InitialContext();
+ realmMapping = (RealmMapping)iniCtx.lookup(lookupName);
+ }
+ catch (NamingException e)
+ {
+ log.debug("Cannot obtain realm mapping from: " + lookupName);
+ }
+ }
+ return realmMapping;
+ }
+}
Property changes on:
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextInjector.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextInjector.java 2007-01-23
04:37:44 UTC (rev 2029)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextInjector.java 2007-01-23
09:22:12 UTC (rev 2030)
@@ -25,58 +25,48 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.security.Principal;
-import java.util.HashSet;
-import java.util.Set;
import javax.annotation.Resource;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
import javax.xml.ws.WebServiceContext;
-import javax.xml.ws.handler.MessageContext;
import org.jboss.logging.Logger;
-import org.jboss.security.RealmMapping;
-import org.jboss.security.SecurityAssociation;
-import org.jboss.security.SimplePrincipal;
/**
* Inject the JAXWS WebServiceContext
*
* @author Thomas.Diesler(a)jboss.org
- * @since 04-Jan-2006
+ * @since 04-Jan-2007
*/
public class WebServiceContextInjector
{
// provide logging
private static Logger log = Logger.getLogger(WebServiceContextInjector.class);
- public void injectContext(Object epImpl, MessageContext msgContext)
+ public void injectContext(Object epInstance, WebServiceContext wsContext)
{
- AbstractWebServiceContext webServiceContext = new
WebServiceContextJSE(msgContext);
try
{
// scan fields that are marked with @Resource
- Field[] fields = epImpl.getClass().getDeclaredFields();
+ Field[] fields = epInstance.getClass().getDeclaredFields();
for (Field field : fields)
{
Class type = field.getType();
if (type == WebServiceContext.class &&
field.isAnnotationPresent(Resource.class))
{
field.setAccessible(true);
- field.set(epImpl, webServiceContext);
+ field.set(epInstance, wsContext);
}
}
// scan methods that are marked with @Resource
- Method[] methods = epImpl.getClass().getDeclaredMethods();
+ Method[] methods = epInstance.getClass().getDeclaredMethods();
for (Method method : methods)
{
Class[] paramTypes = method.getParameterTypes();
if (paramTypes.length == 1 && paramTypes[0] ==
WebServiceContext.class && method.isAnnotationPresent(Resource.class))
{
method.setAccessible(true);
- method.invoke(epImpl, new Object[] { webServiceContext });
+ method.invoke(epInstance, new Object[] { wsContext });
}
}
}
@@ -89,54 +79,4 @@
log.warn("Cannot inject WebServiceContext", ex);
}
}
-
- class WebServiceContextJSE extends AbstractWebServiceContext
- {
- private RealmMapping realmMapping;
-
- public WebServiceContextJSE(MessageContext messageContext)
- {
- super(messageContext);
- }
-
- @Override
- public Principal getUserPrincipal()
- {
- Principal principal = SecurityAssociation.getCallerPrincipal();
- return principal;
- }
-
- @Override
- public boolean isUserInRole(String role)
- {
- boolean isUserInRole = false;
- Principal principal = SecurityAssociation.getCallerPrincipal();
- RealmMapping realmMapping = getRealmMapping();
- if (realmMapping != null && principal != null)
- {
- Set<Principal> roles = new HashSet<Principal>();
- roles.add(new SimplePrincipal(role));
- isUserInRole = realmMapping.doesUserHaveRole(principal, roles);
- }
- return isUserInRole;
- }
-
- private RealmMapping getRealmMapping()
- {
- if (realmMapping == null)
- {
- String lookupName = "java:comp/env/security/realmMapping";
- try
- {
- InitialContext iniCtx = new InitialContext();
- realmMapping = (RealmMapping) iniCtx.lookup(lookupName);
- }
- catch (NamingException e)
- {
- log.debug("Cannot obtain realm mapping from: " + lookupName);
- }
- }
- return realmMapping;
- }
- }
}
Modified:
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvokerJSE.java
===================================================================
---
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvokerJSE.java 2007-01-23
04:37:44 UTC (rev 2029)
+++
trunk/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvokerJSE.java 2007-01-23
09:22:12 UTC (rev 2030)
@@ -29,12 +29,14 @@
import javax.xml.rpc.server.ServiceLifecycle;
import javax.xml.rpc.server.ServletEndpointContext;
import javax.xml.rpc.soap.SOAPFaultException;
+import javax.xml.ws.WebServiceContext;
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.EndpointInvocation;
import org.jboss.ws.core.jaxrpc.ServletEndpointContextImpl;
+import org.jboss.ws.core.jaxws.WebServiceContextImpl;
import org.jboss.ws.core.jaxws.WebServiceContextInjector;
import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
import org.jboss.ws.core.soap.MessageContextAssociation;
@@ -89,7 +91,10 @@
{
CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
if (msgContext instanceof SOAPMessageContextJAXWS)
- new WebServiceContextInjector().injectContext(seiImpl,
(SOAPMessageContextJAXWS)msgContext);
+ {
+ WebServiceContext wsContext = new
WebServiceContextImpl((SOAPMessageContextJAXWS)msgContext);
+ new WebServiceContextInjector().injectContext(seiImpl, wsContext);
+ }
Class implClass = seiImpl.getClass();
Method seiMethod = epInv.getJavaMethod();
Modified:
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointEJB.java
===================================================================
---
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointEJB.java 2007-01-23
04:37:44 UTC (rev 2029)
+++
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointEJB.java 2007-01-23
09:22:12 UTC (rev 2030)
@@ -47,7 +47,8 @@
@RolesAllowed("friend")
public class EndpointEJB
{
- @Resource
+ // mappedName needed for jboss40
+ @Resource(mappedName = "wsCtx")
WebServiceContext wsCtx;
@WebMethod
Modified: trunk/jbossws-tests/src/main/resources/tests-jboss40-excludes.txt
===================================================================
--- trunk/jbossws-tests/src/main/resources/tests-jboss40-excludes.txt 2007-01-23 04:37:44
UTC (rev 2029)
+++ trunk/jbossws-tests/src/main/resources/tests-jboss40-excludes.txt 2007-01-23 09:22:12
UTC (rev 2030)
@@ -4,7 +4,8 @@
org/jboss/test/ws/jaxrpc/samples/wseventing/**
org/jboss/test/ws/jaxrpc/wseventing/**
org/jboss/test/ws/jaxws/benchmark/**
+org/jboss/test/ws/jaxws/context/WebServiceContextEJBTestCase*
org/jboss/test/ws/jaxws/endpoint/**
-org/jboss/test/ws/jaxws/jsr181/handlerchain/HandlerChainClientTestCase.*
+org/jboss/test/ws/jaxws/jsr181/handlerchain/HandlerChainClientTestCase*
org/jboss/test/ws/jaxws/webserviceref/**
Modified: trunk/jbossws-tests/src/main/resources/tests-jboss42-excludes.txt
===================================================================
--- trunk/jbossws-tests/src/main/resources/tests-jboss42-excludes.txt 2007-01-23 04:37:44
UTC (rev 2029)
+++ trunk/jbossws-tests/src/main/resources/tests-jboss42-excludes.txt 2007-01-23 09:22:12
UTC (rev 2030)
@@ -4,6 +4,7 @@
org/jboss/test/ws/jaxrpc/samples/wseventing/**
org/jboss/test/ws/jaxrpc/wseventing/**
org/jboss/test/ws/jaxws/benchmark/**
+org/jboss/test/ws/jaxws/context/WebServiceContextEJBTestCase*
org/jboss/test/ws/jaxws/endpoint/**
-org/jboss/test/ws/jaxws/jsr181/handlerchain/HandlerChainClientTestCase.*
+org/jboss/test/ws/jaxws/jsr181/handlerchain/HandlerChainClientTestCase*
org/jboss/test/ws/jaxws/webserviceref/**
Modified: trunk/jbossws-tests/src/main/resources/tests-jboss42-noejb3-excludes.txt
===================================================================
--- trunk/jbossws-tests/src/main/resources/tests-jboss42-noejb3-excludes.txt 2007-01-23
04:37:44 UTC (rev 2029)
+++ trunk/jbossws-tests/src/main/resources/tests-jboss42-noejb3-excludes.txt 2007-01-23
09:22:12 UTC (rev 2030)
@@ -4,6 +4,7 @@
org/jboss/test/ws/jaxrpc/samples/wseventing/**
org/jboss/test/ws/jaxrpc/wseventing/**
org/jboss/test/ws/jaxws/benchmark/**
+org/jboss/test/ws/jaxws/context/WebServiceContextEJBTestCase*
org/jboss/test/ws/jaxws/endpoint/**
org/jboss/test/ws/jaxws/jsr181/handlerchain/HandlerChainClientTestCase.*
org/jboss/test/ws/jaxws/webserviceref/**
Modified: trunk/jbossws-tests/src/main/resources/tests-tomcat-excludes.txt
===================================================================
--- trunk/jbossws-tests/src/main/resources/tests-tomcat-excludes.txt 2007-01-23 04:37:44
UTC (rev 2029)
+++ trunk/jbossws-tests/src/main/resources/tests-tomcat-excludes.txt 2007-01-23 09:22:12
UTC (rev 2030)
@@ -10,6 +10,7 @@
org/jboss/test/ws/jaxrpc/samples/wsbpel/**
org/jboss/test/ws/jaxrpc/samples/wssecurity/StorePassEncryptTestCase.*
org/jboss/test/ws/jaxrpc/wseventing/**
+org/jboss/test/ws/jaxws/context/WebServiceContextEJBTestCase*
org/jboss/test/ws/jaxws/jsr181/handlerchain/HandlerChainClientTestCase.*
org/jboss/test/ws/jaxws/samples/jsr181ejb/**
org/jboss/test/ws/jaxws/samples/retail/**