Author: thomas.diesler(a)jboss.com
Date: 2007-05-16 18:47:19 -0400 (Wed, 16 May 2007)
New Revision: 3115
Added:
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/AbstractInvocationHandler.java
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/core/utils/JavaUtils.java
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/AbstractWebServiceContext.java
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/BasicInvocation.java
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/Invocation.java
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/WebServiceContextEJB.java
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/WebServiceContextJSE.java
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/ServiceEndpointInvokerDeployer.java
Removed:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/AbstractWebServiceContext.java
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextEJB.java
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextJSE.java
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/utils/JavaUtils.java
Modified:
branches/tdiesler/trunk/integration/jboss50/.classpath
branches/tdiesler/trunk/integration/jboss50/ant-import/build-thirdparty.xml
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/InvocationHandlerEJB21.java
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/InvocationHandlerEJB3.java
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/InvocationHandlerJSE.java
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInterceptor.java
branches/tdiesler/trunk/integration/jbws-jboss50/src/main/resources/jbossws.sar/META-INF/jbossws-beans.xml
branches/tdiesler/trunk/integration/spi/ant-import/build-thirdparty.xml
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/BasicLifecycleHandler.java
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/InvocationHandler.java
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/EndpointInvocation.java
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/RequestHandlerImpl.java
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvokerEJB21.java
branches/tdiesler/trunk/jbossws/src/test/java/org/jboss/test/ws/jaxws/samples/context/EndpointNoInjectEJB.java
Log:
restructure
Modified: branches/tdiesler/trunk/integration/jboss50/.classpath
===================================================================
--- branches/tdiesler/trunk/integration/jboss50/.classpath 2007-05-16 22:34:28 UTC (rev
3114)
+++ branches/tdiesler/trunk/integration/jboss50/.classpath 2007-05-16 22:47:19 UTC (rev
3115)
@@ -7,5 +7,6 @@
<classpathentry kind="lib"
path="/spi/thirdparty/jsr181-api.jar"/>
<classpathentry kind="con"
path="org.eclipse.jdt.USER_LIBRARY/jboss-5.0.x"/>
<classpathentry kind="lib"
path="/spi/thirdparty/jaxrpc-api.jar"/>
+ <classpathentry kind="lib"
path="/spi/thirdparty/saaj-api.jar"/>
<classpathentry kind="output" path="output-eclipse"/>
</classpath>
Modified: branches/tdiesler/trunk/integration/jboss50/ant-import/build-thirdparty.xml
===================================================================
--- branches/tdiesler/trunk/integration/jboss50/ant-import/build-thirdparty.xml 2007-05-16
22:34:28 UTC (rev 3114)
+++ branches/tdiesler/trunk/integration/jboss50/ant-import/build-thirdparty.xml 2007-05-16
22:47:19 UTC (rev 3115)
@@ -36,6 +36,7 @@
<pathelement location="${spi.dir}/thirdparty/jaxws-api.jar"/>
<pathelement location="${spi.dir}/thirdparty/jaxrpc-api.jar"/>
<pathelement location="${spi.dir}/thirdparty/jsr181-api.jar"/>
+ <pathelement location="${spi.dir}/thirdparty/saaj-api.jar"/>
<pathelement location="${jboss50.lib}/jboss-aop-jdk50.jar"/>
<pathelement location="${jboss50.lib}/jboss-common-core.jar"/>
<pathelement location="${jboss50.lib}/jboss-deployers.jar"/>
Added:
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/AbstractInvocationHandler.java
===================================================================
---
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/AbstractInvocationHandler.java
(rev 0)
+++
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/AbstractInvocationHandler.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -0,0 +1,119 @@
+/*
+ * 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.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.UndeclaredThrowableException;
+
+import javax.management.MBeanException;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.utils.JavaUtils;
+import org.jboss.ws.integration.Endpoint;
+import org.jboss.ws.integration.invocation.InvocationHandler;
+
+/**
+ * Handles invocations on endpoints.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Apr-2007
+ */
+public abstract class AbstractInvocationHandler implements InvocationHandler
+{
+ // provide logging
+ private static final Logger log = Logger.getLogger(AbstractInvocationHandler.class);
+
+ protected Method getImplMethod(Class implClass, Method seiMethod) throws
ClassNotFoundException, NoSuchMethodException
+ {
+ String methodName = seiMethod.getName();
+ Class[] paramTypes = seiMethod.getParameterTypes();
+ for (int i = 0; i < paramTypes.length; i++)
+ {
+ Class paramType = paramTypes[i];
+ if (JavaUtils.isPrimitive(paramType) == false)
+ {
+ String paramTypeName = paramType.getName();
+ paramType = JavaUtils.loadJavaType(paramTypeName);
+ paramTypes[i] = paramType;
+ }
+ }
+
+ Method implMethod = implClass.getMethod(methodName, paramTypes);
+ return implMethod;
+ }
+
+ protected void handleInvocationException(Throwable th) throws Exception
+ {
+ if (th instanceof InvocationTargetException)
+ {
+ // unwrap the throwable raised by the service endpoint implementation
+ Throwable targetEx = ((InvocationTargetException)th).getTargetException();
+ handleInvocationThrowable(targetEx);
+ }
+
+ if (th instanceof MBeanException)
+ {
+ throw ((MBeanException)th).getTargetException();
+ }
+
+ handleInvocationThrowable(th);
+ }
+
+ private void handleInvocationThrowable(Throwable th) throws Exception
+ {
+ if (th instanceof Exception)
+ {
+ throw (Exception)th;
+ }
+ else if (th instanceof Error)
+ {
+ throw (Error)th;
+ }
+ else
+ {
+ throw new UndeclaredThrowableException(th);
+ }
+ }
+
+ public void create(Endpoint ep)
+ {
+ log.debug("Create: " + ep.getName());
+ }
+
+ public void start(Endpoint ep)
+ {
+ log.debug("Start: " + ep.getName());
+ }
+
+ public void stop(Endpoint ep)
+ {
+ log.debug("Stop: " + ep.getName());
+ }
+
+ public void destroy(Endpoint ep)
+ {
+ log.debug("Destroy: " + ep.getName());
+ }
+}
Property changes on:
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/AbstractInvocationHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/InvocationHandlerEJB21.java
===================================================================
---
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/InvocationHandlerEJB21.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/InvocationHandlerEJB21.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -28,13 +28,15 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import javax.xml.rpc.handler.MessageContext;
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.ws.WebServiceException;
import org.jboss.ejb.EjbModule;
import org.jboss.ejb.Interceptor;
import org.jboss.ejb.StatelessSessionContainer;
import org.jboss.ejb.plugins.AbstractInterceptor;
-import org.jboss.invocation.Invocation;
+import org.jboss.invocation.InvocationKey;
import org.jboss.invocation.InvocationType;
import org.jboss.invocation.PayloadKey;
import org.jboss.logging.Logger;
@@ -43,8 +45,7 @@
import org.jboss.ws.integration.Endpoint;
import org.jboss.ws.integration.deployment.UnifiedDeploymentInfo;
import org.jboss.ws.integration.invocation.HandlerCallback;
-import org.jboss.ws.integration.invocation.InvocationContext;
-import org.jboss.ws.integration.invocation.InvocationHandler;
+import org.jboss.ws.integration.invocation.Invocation;
import org.jboss.ws.metadata.j2ee.UnifiedApplicationMetaData;
import org.jboss.ws.metadata.j2ee.UnifiedBeanMetaData;
import org.jboss.ws.utils.ObjectNameFactory;
@@ -55,7 +56,7 @@
* @author Thomas.Diesler(a)jboss.org
* @since 25-Apr-2007
*/
-public class InvocationHandlerEJB21 implements InvocationHandler
+public class InvocationHandlerEJB21 extends AbstractInvocationHandler
{
// provide logging
private static final Logger log = Logger.getLogger(InvocationHandlerEJB21.class);
@@ -64,15 +65,16 @@
private MBeanServer server;
private ObjectName objectName;
- public void create(Endpoint endpoint)
+ public void create(Endpoint ep)
{
- server = MBeanServerLocator.locateJBoss();
+ super.create(ep);
- String ejbName =
endpoint.getName().getKeyProperty(Endpoint.SEPID_PROPERTY_ENDPOINT);
+ ObjectName epName = ep.getName();
+ String ejbName = epName.getKeyProperty(Endpoint.SEPID_PROPERTY_ENDPOINT);
if (ejbName == null)
throw new WebServiceException("Cannot obtain ejb-link from port
component");
- UnifiedDeploymentInfo udi =
endpoint.getService().getDeployment().getContext().getAttachment(UnifiedDeploymentInfo.class);
+ UnifiedDeploymentInfo udi =
ep.getService().getDeployment().getContext().getAttachment(UnifiedDeploymentInfo.class);
UnifiedApplicationMetaData applMetaData =
(UnifiedApplicationMetaData)udi.metaData;
UnifiedBeanMetaData beanMetaData =
(UnifiedBeanMetaData)applMetaData.getBeanByEjbName(ejbName);
if (beanMetaData == null)
@@ -83,7 +85,10 @@
if (jndiName == null)
throw new WebServiceException("Cannot obtain JNDI name for: " +
ejbName);
+ server = MBeanServerLocator.locateJBoss();
objectName = ObjectNameFactory.create("jboss.j2ee:jndiName=" + jndiName +
",service=EJB");
+ if (server.isRegistered(objectName) == false)
+ throw new WebServiceException("Cannot find service endpoint target: "
+ objectName);
// Dynamically add the service endpoint interceptor
//
http://jira.jboss.org/jira/browse/JBWS-758
@@ -100,7 +105,7 @@
if (next.getNext() == null)
{
log.debug("Inject service endpoint interceptor after: " +
prev.getClass().getName());
- AbstractInterceptor sepInterceptor =
endpoint.getAttachment(AbstractInterceptor.class);
+ AbstractInterceptor sepInterceptor =
ep.getAttachment(AbstractInterceptor.class);
if (sepInterceptor == null)
throw new IllegalStateException("Cannot obtain endpoint
interceptor");
@@ -118,52 +123,46 @@
log.warn("Cannot add service endpoint interceptor", ex);
}
- if (server.isRegistered(objectName) == false)
- throw new WebServiceException("Cannot find service endpoint target: "
+ objectName);
-
}
- public void start(Endpoint ep)
+ public void invoke(Endpoint ep, Invocation epInv) throws Exception
{
- }
+ log.debug("Invoke: " + epInv.getJavaMethod().getName());
- public Object getTargetBean(Endpoint ep) throws InstantiationException,
IllegalAccessException
- {
- return null;
- }
-
- public Object invoke(Endpoint ep, Object targetBean, Method method, Object[] args,
InvocationContext context) throws Exception
- {
// these are provided by the ServerLoginHandler
Principal principal = SecurityAssociation.getPrincipal();
Object credential = SecurityAssociation.getCredential();
- Invocation inv = new Invocation(null, method, args, null, principal, credential);
+ // invoke on the container
+ try
+ {
+ // setup the invocation
+ Method method = epInv.getJavaMethod();
+ Object[] args = epInv.getArgs();
+ org.jboss.invocation.Invocation inv = new org.jboss.invocation.Invocation(null,
method, args, null, principal, credential);
- //inv.setValue(InvocationKey.SOAP_MESSAGE_CONTEXT, msgContext);
- //inv.setValue(InvocationKey.SOAP_MESSAGE, msgContext.getSOAPMessage());
- inv.setType(InvocationType.SERVICE_ENDPOINT);
+ // EJB2.1 endpoints will only get an JAXRPC context
+ MessageContext msgContext =
epInv.getInvocationContext().getAttachment(MessageContext.class);
+ if (msgContext == null)
+ throw new IllegalStateException("Cannot obtain MessageContext");
+
+ HandlerCallback callback =
epInv.getInvocationContext().getAttachment(HandlerCallback.class);
+ if (callback == null)
+ throw new IllegalStateException("Cannot obtain HandlerCallback");
+
+ inv.setValue(InvocationKey.SOAP_MESSAGE_CONTEXT, msgContext);
+ inv.setValue(InvocationKey.SOAP_MESSAGE,
((SOAPMessageContext)msgContext).getMessage());
+ inv.setType(InvocationType.SERVICE_ENDPOINT);
+ inv.setValue(HandlerCallback.class.getName(), callback, PayloadKey.TRANSIENT);
+ inv.setValue(Invocation.class.getName(), epInv, PayloadKey.TRANSIENT);
- HandlerCallback callback = ep.getAttachment(HandlerCallback.class);
- if (callback == null)
- throw new IllegalStateException("Cannot obtain handler callback");
-
- inv.setValue(HandlerCallback.class.getName(), callback, PayloadKey.TRANSIENT);
- inv.setValue(InvocationContext.class.getName(), context, PayloadKey.TRANSIENT);
-
- String[] sig = { Invocation.class.getName() };
- Object retObj = server.invoke(objectName, "invoke", new Object[] { inv },
sig);
-
- return retObj;
+ String[] sig = { Invocation.class.getName() };
+ Object retObj = server.invoke(objectName, "invoke", new Object[] { inv
}, sig);
+ epInv.setReturn(retObj);
+ }
+ catch (Exception e)
+ {
+ handleInvocationException(e);
+ }
}
-
- public void stop(Endpoint ep)
- {
- // Nothing to do
- }
-
- public void destroy(Endpoint ep)
- {
- // Nothing to do
- }
}
Modified:
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/InvocationHandlerEJB3.java
===================================================================
---
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/InvocationHandlerEJB3.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/InvocationHandlerEJB3.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -27,7 +27,6 @@
import javax.ejb.EJBContext;
import javax.management.ObjectName;
-import javax.xml.ws.WebServiceContext;
import javax.xml.ws.WebServiceException;
import org.jboss.aop.Dispatcher;
@@ -38,11 +37,10 @@
import org.jboss.ejb3.stateless.StatelessBeanContext;
import org.jboss.ejb3.stateless.StatelessContainer;
import org.jboss.injection.lang.reflect.BeanProperty;
-import org.jboss.logging.Logger;
import org.jboss.ws.integration.Endpoint;
import org.jboss.ws.integration.deployment.UnifiedDeploymentInfo;
-import org.jboss.ws.integration.invocation.InvocationContext;
-import org.jboss.ws.integration.invocation.InvocationHandler;
+import org.jboss.ws.integration.invocation.Invocation;
+import org.jboss.ws.integration.invocation.WebServiceContextEJB;
import org.jboss.ws.utils.ObjectNameFactory;
/**
@@ -51,20 +49,19 @@
* @author Thomas.Diesler(a)jboss.org
* @since 25-Apr-2007
*/
-public class InvocationHandlerEJB3 implements InvocationHandler
+public class InvocationHandlerEJB3 extends AbstractInvocationHandler
{
- // provide logging
- private static final Logger log = Logger.getLogger(InvocationHandlerEJB3.class);
-
private ObjectName objectName;
- public void create(Endpoint endpoint)
+ public void create(Endpoint ep)
{
- String ejbName =
endpoint.getName().getKeyProperty(Endpoint.SEPID_PROPERTY_ENDPOINT);
+ super.create(ep);
+
+ String ejbName = ep.getName().getKeyProperty(Endpoint.SEPID_PROPERTY_ENDPOINT);
if (ejbName == null)
throw new WebServiceException("Cannot obtain ejb-link");
- UnifiedDeploymentInfo udi =
endpoint.getService().getDeployment().getContext().getAttachment(UnifiedDeploymentInfo.class);
+ UnifiedDeploymentInfo udi =
ep.getService().getDeployment().getContext().getAttachment(UnifiedDeploymentInfo.class);
String nameStr = "jboss.j2ee:name=" + ejbName +
",service=EJB3,jar=" + udi.simpleName;
if (udi.parent != null)
{
@@ -76,83 +73,72 @@
public void start(Endpoint ep)
{
+ super.start(ep);
+
Dispatcher dispatcher = Dispatcher.singleton;
if (dispatcher.getRegistered(objectName.getCanonicalName()) == null)
throw new WebServiceException("Cannot find service endpoint target: "
+ objectName);
}
- public Object getTargetBean(Endpoint ep) throws InstantiationException,
IllegalAccessException
+ public void invoke(Endpoint ep, Invocation epInv) throws Exception
{
- return null;
- }
+ try
+ {
+ Dispatcher dispatcher = Dispatcher.singleton;
+ StatelessContainer container =
(StatelessContainer)dispatcher.getRegistered(objectName.getCanonicalName());
+ Class beanClass = container.getBeanClass();
- public Object invoke(Endpoint ep, Object targetBean, Method method, Object[] args,
InvocationContext context) throws Exception
- {
- Dispatcher dispatcher = Dispatcher.singleton;
- StatelessContainer container =
(StatelessContainer)dispatcher.getRegistered(objectName.getCanonicalName());
+ Method method = getImplMethod(beanClass, epInv.getJavaMethod());
+ Object[] args = epInv.getArgs();
- MethodInfo info = container.getMethodInfo(method);
+ MethodInfo info = container.getMethodInfo(method);
+ EJBContainerInvocation<StatelessContainer, StatelessBeanContext> ejb3Inv =
new EJBContainerInvocation<StatelessContainer, StatelessBeanContext>(info);
+ ejb3Inv.setAdvisor(container);
+ ejb3Inv.setArguments(args);
+ ejb3Inv.setContextCallback(new CallbackImpl(epInv));
- EJBContainerInvocation<StatelessContainer, StatelessBeanContext> ejb3Inv =
new EJBContainerInvocation<StatelessContainer, StatelessBeanContext>(info);
- ejb3Inv.setAdvisor(container);
- ejb3Inv.setArguments(args);
- ejb3Inv.setContextCallback(new ContextCallback(context));
+ Object retObj = ejb3Inv.invokeNext();
- Object retObj;
- try
- {
- retObj = ejb3Inv.invokeNext();
+ epInv.setReturn(retObj);
}
- catch (Exception ex)
+ catch (Throwable th)
{
- throw ex;
+ handleInvocationException(th);
}
- catch (Throwable ex)
- {
- throw new RuntimeException(ex);
- }
- return retObj;
}
- public void stop(Endpoint ep)
+ static class CallbackImpl implements BeanContextLifecycleCallback
{
- // Nothing to do
- }
+ private javax.xml.ws.handler.MessageContext jaxwsMessageContext;
+ private javax.xml.rpc.handler.MessageContext jaxrpcMessageContext;
- public void destroy(Endpoint ep)
- {
- // Nothing to do
- }
-
- class ContextCallback implements BeanContextLifecycleCallback
- {
- private WebServiceContext wsContext;
-
- public ContextCallback(InvocationContext context)
+ public CallbackImpl(Invocation epInv)
{
- if (context instanceof WebServiceContext)
- this.wsContext = (WebServiceContext)context;
+ jaxrpcMessageContext =
epInv.getInvocationContext().getAttachment(javax.xml.rpc.handler.MessageContext.class);
+ jaxwsMessageContext =
epInv.getInvocationContext().getAttachment(javax.xml.ws.handler.MessageContext.class);
}
public void attached(BeanContext beanCtx)
{
StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
+ sbc.setMessageContextJAXRPC(jaxrpcMessageContext);
BeanProperty beanProp = sbc.getWebServiceContextProperty();
- if (beanProp != null && wsContext instanceof WebServiceContext)
+ if (beanProp != null)
{
EJBContext ejbCtx = beanCtx.getEJBContext();
- beanProp.set(beanCtx.getInstance(), wsContext);
+ beanProp.set(beanCtx.getInstance(), new
WebServiceContextEJB(jaxwsMessageContext, ejbCtx));
}
}
public void released(BeanContext beanCtx)
{
StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
+ sbc.setMessageContextJAXRPC(null);
BeanProperty beanProp = sbc.getWebServiceContextProperty();
if (beanProp != null)
beanProp.set(beanCtx.getInstance(), null);
}
}
-}
+}
\ No newline at end of file
Modified:
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/InvocationHandlerJSE.java
===================================================================
---
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/InvocationHandlerJSE.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/InvocationHandlerJSE.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -25,11 +25,14 @@
import java.lang.reflect.Method;
+import javax.xml.rpc.server.ServiceLifecycle;
+import javax.xml.rpc.server.ServletEndpointContext;
import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.WebServiceException;
import org.jboss.ws.integration.Endpoint;
+import org.jboss.ws.integration.invocation.Invocation;
import org.jboss.ws.integration.invocation.InvocationContext;
-import org.jboss.ws.integration.invocation.InvocationHandler;
import org.jboss.ws.integration.invocation.WebServiceContextInjector;
/**
@@ -38,41 +41,60 @@
* @author Thomas.Diesler(a)jboss.org
* @since 25-Apr-2007
*/
-public class InvocationHandlerJSE implements InvocationHandler
+public class InvocationHandlerJSE extends AbstractInvocationHandler
{
+ private Object targetBean;
+
public void create(Endpoint ep)
{
- // Nothing to do
+ try
+ {
+ Class epImpl = ep.getTargetBean();
+ targetBean = epImpl.newInstance();
+ }
+ catch (Exception ex)
+ {
+ throw new WebServiceException("Cannot load target bean");
+ }
}
- public void start(Endpoint endpoint)
+ public void invoke(Endpoint ep, Invocation epInv) throws Exception
{
- // Nothing to do
- }
+ try
+ {
+ InvocationContext invContext = epInv.getInvocationContext();
+ WebServiceContext wsContext =
invContext.getAttachment(WebServiceContext.class);
+ if (wsContext != null)
+ {
+ new WebServiceContextInjector().injectContext(targetBean,
(WebServiceContext)wsContext);
+ }
- public void stop(Endpoint endpoint)
- {
- // Nothing to do
- }
+ if (targetBean instanceof ServiceLifecycle)
+ {
+ ServletEndpointContext sepContext =
invContext.getAttachment(ServletEndpointContext.class);
+ if (sepContext == null)
+ throw new IllegalStateException("Cannot obtain
ServletEndpointContext");
+
+ ((ServiceLifecycle)targetBean).init(sepContext);
+ }
- public void destroy(Endpoint ep)
- {
- // Nothing to do
+ try
+ {
+ Method method = getImplMethod(ep.getTargetBean(), epInv.getJavaMethod());
+ Object retObj = method.invoke(targetBean, epInv.getArgs());
+ epInv.setReturn(retObj);
+ }
+ finally
+ {
+ if (targetBean instanceof ServiceLifecycle)
+ {
+ ((ServiceLifecycle)targetBean).destroy();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ handleInvocationException(e);
+ }
}
-
- public Object getTargetBean(Endpoint endpoint) throws InstantiationException,
IllegalAccessException
- {
- Class epImpl = endpoint.getTargetBean();
- Object targetBean = epImpl.newInstance();
- return targetBean;
- }
-
- public Object invoke(Endpoint endpoint, Object targetBean, Method method, Object[]
args, InvocationContext context) throws Exception
- {
- if (context instanceof WebServiceContext)
- new WebServiceContextInjector().injectContext(targetBean,
(WebServiceContext)context);
-
- Object retObj = method.invoke(targetBean, args);
- return retObj;
- }
}
Modified:
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInterceptor.java
===================================================================
---
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInterceptor.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/integration/jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInterceptor.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -23,7 +23,7 @@
// $Id$
-import javax.xml.rpc.handler.MessageContext;
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
import org.jboss.ejb.plugins.AbstractInterceptor;
import org.jboss.invocation.Invocation;
@@ -53,30 +53,50 @@
public Object invoke(final Invocation mi) throws Exception
{
// If no msgContext, it's not for us
- MessageContext msgContext =
(MessageContext)mi.getPayloadValue(InvocationKey.SOAP_MESSAGE_CONTEXT);
+ SOAPMessageContext msgContext =
(SOAPMessageContext)mi.getPayloadValue(InvocationKey.SOAP_MESSAGE_CONTEXT);
if (msgContext == null)
{
return getNext().invoke(mi);
}
+ // Get the endpoint invocation
+ org.jboss.ws.integration.invocation.Invocation epInv =
(org.jboss.ws.integration.invocation.Invocation)mi
+ .getValue(org.jboss.ws.integration.invocation.Invocation.class.getName());
+
// Get the handler callback
HandlerCallback callback =
(HandlerCallback)mi.getValue(HandlerCallback.class.getName());
// Handlers need to be Tx. Therefore we must invoke the handler chain after the
TransactionInterceptor.
- if (callback != null)
+ if (callback != null && epInv != null)
{
try
{
// call the request handlers
boolean handlersPass =
callback.callRequestHandlerChain(HandlerType.ENDPOINT);
handlersPass = handlersPass &&
callback.callRequestHandlerChain(HandlerType.POST);
-
- Object resObj = getNext().invoke(mi);
+ // Call the next interceptor in the chain
+ if (handlersPass)
+ {
+ // The SOAPContentElements stored in the EndpointInvocation might have
changed after
+ // handler processing. Get the updated request payload. This should be a
noop if request
+ // handlers did not modify the incomming SOAP message.
+ Object[] reqParams = epInv.getArgs();
+ mi.setArguments(reqParams);
+ Object resObj = getNext().invoke(mi);
+
+ // Setting the message to null should trigger binding of the response
message
+ msgContext.setMessage(null);
+ epInv.setReturn(resObj);
+ }
+
// call the response handlers
handlersPass = callback.callResponseHandlerChain(HandlerType.POST);
handlersPass = handlersPass &&
callback.callResponseHandlerChain(HandlerType.ENDPOINT);
+ // update the return value after response handler processing
+ Object resObj = epInv.getReturn();
+
return resObj;
}
catch (Exception ex)
@@ -93,6 +113,10 @@
}
throw ex;
}
+ finally
+ {
+ // do nothing
+ }
}
else
{
Modified:
branches/tdiesler/trunk/integration/jbws-jboss50/src/main/resources/jbossws.sar/META-INF/jbossws-beans.xml
===================================================================
---
branches/tdiesler/trunk/integration/jbws-jboss50/src/main/resources/jbossws.sar/META-INF/jbossws-beans.xml 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/integration/jbws-jboss50/src/main/resources/jbossws.sar/META-INF/jbossws-beans.xml 2007-05-16
22:47:19 UTC (rev 3115)
@@ -116,6 +116,7 @@
<inject bean="WSEndpointHandlerDeployer"/>
<inject bean="WSPublishContractDeployer"/>
<inject bean="WSClassLoaderInjectionDeployer"/>
+ <inject bean="WSServiceEndpointInvokerDeployer"/>
<inject bean="WSEagerInitializeDeployer"/>
<inject bean="WSEventingDeployer"/>
<inject bean="WSEndpointRegistryDeployer"/>
@@ -150,6 +151,7 @@
<property
name="servletClass">org.jboss.ws.core.server.ServiceEndpointServlet</property>
</bean>
<bean name="WSPublishContractDeployer"
class="org.jboss.ws.core.deployment.PublishContractDeployer"/>
+ <bean name="WSServiceEndpointInvokerDeployer"
class="org.jboss.ws.core.deployment.ServiceEndpointInvokerDeployer"/>
<bean name="WSUnifiedDeploymentInfoDeployer"
class="org.jboss.ws.integration.jboss50.UnifiedDeploymentInfoDeployer"/>
<bean name="WSUnifiedMetaDataAssociationDeployer"
class="org.jboss.ws.core.deployment.UnifiedMetaDataAssociationDeployer"/>
<bean name="WSUnifiedMetaDataDeployer"
class="org.jboss.ws.core.deployment.UnifiedMetaDataDeployer"/>
Modified: branches/tdiesler/trunk/integration/spi/ant-import/build-thirdparty.xml
===================================================================
--- branches/tdiesler/trunk/integration/spi/ant-import/build-thirdparty.xml 2007-05-16
22:34:28 UTC (rev 3114)
+++ branches/tdiesler/trunk/integration/spi/ant-import/build-thirdparty.xml 2007-05-16
22:47:19 UTC (rev 3115)
@@ -55,6 +55,7 @@
<get src="${jboss.repository}/sun-jaf/${sun-jaf}/lib/activation.jar"
dest="${thirdparty.dir}/activation.jar" usetimestamp="true"
verbose="true"/>
<get src="${jboss.repository}/sun-jaxws/${sun-jaxws}/lib/jaxws-api.jar"
dest="${thirdparty.dir}/jaxws-api.jar" usetimestamp="true"
verbose="true"/>
<get src="${jboss.repository}/sun-jaxws/${sun-jaxws}/lib/jsr181-api.jar"
dest="${thirdparty.dir}/jsr181-api.jar" usetimestamp="true"
verbose="true"/>
+ <get src="${jboss.repository}/sun-jaxws/${sun-jaxws}/lib/saaj-api.jar"
dest="${thirdparty.dir}/saaj-api.jar" usetimestamp="true"
verbose="true"/>
<get
src="${jboss.repository}/sun-jaxrpc/${sun-jaxrpc}/lib/jaxrpc-api.jar"
dest="${thirdparty.dir}/jaxrpc-api.jar" usetimestamp="true"
verbose="true"/>
<get
src="${jboss.repository}/sun-servlet/${sun-servlet}/lib/servlet-api.jar"
dest="${thirdparty.dir}/servlet-api.jar" usetimestamp="true"
verbose="true"/>
Added:
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/core/utils/JavaUtils.java
===================================================================
---
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/core/utils/JavaUtils.java
(rev 0)
+++
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/core/utils/JavaUtils.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -0,0 +1,648 @@
+/*
+ * 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.utils;
+
+// $Id$
+
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.HashMap;
+import java.util.HashSet;
+
+import org.jboss.logging.Logger;
+
+/** Java utilities
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 22-Dec-2004
+ */
+public class JavaUtils
+{
+ // provide logging
+ private static final Logger log = Logger.getLogger(JavaUtils.class);
+
+ private static HashMap<String, Class> primitiveNames = new HashMap<String,
Class>(8);
+ private static HashMap<String, String> primitiveNameDescriptors = new
HashMap<String, String>(8);
+ private static HashSet<String> reservedKeywords = new
HashSet<String>(50);
+
+ static
+ {
+ primitiveNames.put("int", int.class);
+ primitiveNames.put("short", short.class);
+ primitiveNames.put("boolean", boolean.class);
+ primitiveNames.put("byte", byte.class);
+ primitiveNames.put("long", long.class);
+ primitiveNames.put("double", double.class);
+ primitiveNames.put("float", float.class);
+ primitiveNames.put("char", char.class);
+
+ primitiveNameDescriptors.put("int", "I");
+ primitiveNameDescriptors.put("short", "S");
+ primitiveNameDescriptors.put("boolean", "Z");
+ primitiveNameDescriptors.put("byte", "B");
+ primitiveNameDescriptors.put("long", "J");
+ primitiveNameDescriptors.put("double", "D");
+ primitiveNameDescriptors.put("float", "F");
+ primitiveNameDescriptors.put("char", "C");
+
+ reservedKeywords.add("abstract");
+ reservedKeywords.add("continue");
+ reservedKeywords.add("for");
+ reservedKeywords.add("new");
+ reservedKeywords.add("switch");
+ reservedKeywords.add("assert");
+ reservedKeywords.add("default");
+ reservedKeywords.add("if");
+ reservedKeywords.add("package");
+ reservedKeywords.add("synchronized");
+ reservedKeywords.add("boolean");
+ reservedKeywords.add("do");
+ reservedKeywords.add("goto");
+ reservedKeywords.add("private");
+ reservedKeywords.add("this");
+ reservedKeywords.add("break");
+ reservedKeywords.add("double");
+ reservedKeywords.add("implements");
+ reservedKeywords.add("protected");
+ reservedKeywords.add("throw");
+ reservedKeywords.add("byte");
+ reservedKeywords.add("else");
+ reservedKeywords.add("import");
+ reservedKeywords.add("public");
+ reservedKeywords.add("throws");
+ reservedKeywords.add("case");
+ reservedKeywords.add("enum");
+ reservedKeywords.add("instanceof");
+ reservedKeywords.add("return");
+ reservedKeywords.add("transient");
+ reservedKeywords.add("catch");
+ reservedKeywords.add("extends");
+ reservedKeywords.add("int");
+ reservedKeywords.add("short");
+ reservedKeywords.add("try");
+ reservedKeywords.add("char");
+ reservedKeywords.add("final");
+ reservedKeywords.add("interface");
+ reservedKeywords.add("static");
+ reservedKeywords.add("void");
+ reservedKeywords.add("class");
+ reservedKeywords.add("finally");
+ reservedKeywords.add("long");
+ reservedKeywords.add("strictfp");
+ reservedKeywords.add("volatile");
+ reservedKeywords.add("const");
+ reservedKeywords.add("float");
+ reservedKeywords.add("native");
+ reservedKeywords.add("super");
+ reservedKeywords.add("while");
+ }
+
+ /**
+ * Load a Java type from a given class loader.
+ *
+ * @param typeName maybe the source notation of a primitve, class name, array of both
+ */
+ public static Class loadJavaType(String typeName) throws ClassNotFoundException
+ {
+ return loadJavaType(typeName, null);
+ }
+
+ /**
+ * Load a Java type from a given class loader.
+ *
+ * @param typeName maybe the source notation of a primitve, class name, array of both
+ */
+ public static Class loadJavaType(String typeName, ClassLoader classLoader) throws
ClassNotFoundException
+ {
+ if (classLoader == null)
+ classLoader = Thread.currentThread().getContextClassLoader();
+
+ Class javaType = primitiveNames.get(typeName);
+ if (javaType == null)
+ javaType = getArray(typeName, classLoader);
+
+ if (javaType == null)
+ javaType = classLoader.loadClass(typeName);
+
+ return javaType;
+ }
+
+ /**
+ * True if the given type name is the source notation of a primitive or array of
which.
+ */
+ public static boolean isPrimitive(String javaType)
+ {
+ return getPrimitiveType(javaType) != null;
+ }
+
+ /**
+ * True if the given class is a primitive or array of which.
+ */
+ public static boolean isPrimitive(Class javaType)
+ {
+ return javaType.isPrimitive() || (javaType.isArray() &&
isPrimitive(javaType.getComponentType()));
+ }
+
+ public static Class getPrimitiveType(String javaType)
+ {
+ Class type = primitiveNames.get(javaType);
+ if (type != null)
+ return type;
+
+ try
+ {
+ // null loader = primitive only
+ type = getArray(javaType, null);
+ }
+ catch (ClassNotFoundException e)
+ {
+ // This will actually never be thrown since is null
+ }
+
+ return type;
+ }
+
+ private static Class getArray(String javaType, ClassLoader loader) throws
ClassNotFoundException
+ {
+ if (javaType.charAt(0) == '[')
+ return getArrayFromJVMName(javaType, loader);
+
+ if (javaType.endsWith("[]"))
+ return getArrayFromSourceName(javaType, loader);
+
+ return null;
+ }
+
+ private static Class getArrayFromJVMName(String javaType, ClassLoader loader) throws
ClassNotFoundException
+ {
+ Class componentType;
+ int componentStart = javaType.lastIndexOf('[') + 1;
+ switch (javaType.charAt(componentStart))
+ {
+ case 'I': componentType = int.class; break;
+ case 'S': componentType = short.class; break;
+ case 'Z': componentType = boolean.class; break;
+ case 'B': componentType = byte.class; break;
+ case 'J': componentType = long.class; break;
+ case 'D': componentType = double.class; break;
+ case 'F': componentType = float.class; break;
+ case 'C': componentType = char.class; break;
+ case 'L':
+ if (loader == null)
+ return null;
+ String name = javaType.substring(componentStart + 1, javaType.length() - 1);
+ componentType = loader.loadClass(name);
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid binary component for array:
" + javaType.charAt(componentStart));
+ }
+
+ // componentStart doubles as the number of '['s which is the number of
dimensions
+ return Array.newInstance(componentType, new int[componentStart]).getClass();
+ }
+
+ private static Class getArrayFromSourceName(String javaType, ClassLoader loader)
throws ClassNotFoundException
+ {
+ int arrayStart = javaType.indexOf('[');
+ String componentName = javaType.substring(0, arrayStart);
+
+ Class componentType = primitiveNames.get(componentName);
+ if (componentType == null)
+ {
+ if (loader == null)
+ return null;
+
+ componentType = loader.loadClass(componentName);
+ }
+
+ // [][][][] divided by 2
+ int dimensions = (javaType.length() - arrayStart) >> 1;
+
+ return Array.newInstance(componentType, new int[dimensions]).getClass();
+ }
+
+ /**
+ * Get the corresponding primitive for a give wrapper type.
+ * Also handles arrays of which.
+ */
+ public static Class getPrimitiveType(Class javaType)
+ {
+ if (javaType == Integer.class)
+ return int.class;
+ if (javaType == Short.class)
+ return short.class;
+ if (javaType == Boolean.class)
+ return boolean.class;
+ if (javaType == Byte.class)
+ return byte.class;
+ if (javaType == Long.class)
+ return long.class;
+ if (javaType == Double.class)
+ return double.class;
+ if (javaType == Float.class)
+ return float.class;
+ if (javaType == Character.class)
+ return char.class;
+
+ if (javaType == Integer[].class)
+ return int[].class;
+ if (javaType == Short[].class)
+ return short[].class;
+ if (javaType == Boolean[].class)
+ return boolean[].class;
+ if (javaType == Byte[].class)
+ return byte[].class;
+ if (javaType == Long[].class)
+ return long[].class;
+ if (javaType == Double[].class)
+ return double[].class;
+ if (javaType == Float[].class)
+ return float[].class;
+ if (javaType == Character[].class)
+ return char[].class;
+
+ if (javaType.isArray() && javaType.getComponentType().isArray())
+ {
+ Class compType = getPrimitiveType(javaType.getComponentType());
+ return Array.newInstance(compType, 0).getClass();
+ }
+
+ return javaType;
+ }
+
+ /**
+ * Converts an n-dimensional array of wrapper types to primitive types
+ */
+ public static Object getPrimitiveValueArray(Object value)
+ {
+ if (value == null)
+ return null;
+
+ Class javaType = value.getClass();
+ if (javaType.isArray())
+ {
+ int length = Array.getLength(value);
+ Object destArr =
Array.newInstance(getPrimitiveType(javaType.getComponentType()), length);
+ for (int i = 0; i < length; i++)
+ {
+ Object srcObj = Array.get(value, i);
+ Array.set(destArr, i, getPrimitiveValueArray(srcObj));
+ }
+ return destArr;
+ }
+
+ return value;
+ }
+
+ /**
+ * Get the corresponding wrapper type for a give primitive.
+ * Also handles arrays of which.
+ */
+ public static Class getWrapperType(Class javaType)
+ {
+ if (javaType == int.class)
+ return Integer.class;
+ if (javaType == short.class)
+ return Short.class;
+ if (javaType == boolean.class)
+ return Boolean.class;
+ if (javaType == byte.class)
+ return Byte.class;
+ if (javaType == long.class)
+ return Long.class;
+ if (javaType == double.class)
+ return Double.class;
+ if (javaType == float.class)
+ return Float.class;
+ if (javaType == char.class)
+ return Character.class;
+
+ if (javaType == int[].class)
+ return Integer[].class;
+ if (javaType == short[].class)
+ return Short[].class;
+ if (javaType == boolean[].class)
+ return Boolean[].class;
+ if (javaType == byte[].class)
+ return Byte[].class;
+ if (javaType == long[].class)
+ return Long[].class;
+ if (javaType == double[].class)
+ return Double[].class;
+ if (javaType == float[].class)
+ return Float[].class;
+ if (javaType == char[].class)
+ return Character[].class;
+
+ if (javaType.isArray() && javaType.getComponentType().isArray())
+ {
+ Class compType = getWrapperType(javaType.getComponentType());
+ return Array.newInstance(compType, 0).getClass();
+ }
+
+ return javaType;
+ }
+
+ /**
+ * Converts an n-dimensional array of primitive types to wrapper types
+ */
+ public static Object getWrapperValueArray(Object value)
+ {
+ if (value == null)
+ return null;
+
+ Class javaType = value.getClass();
+ if (javaType.isArray())
+ {
+ int length = Array.getLength(value);
+ Object destArr = Array.newInstance(getWrapperType(javaType.getComponentType()),
length);
+ for (int i = 0; i < length; i++)
+ {
+ Object srcObj = Array.get(value, i);
+ Array.set(destArr, i, getWrapperValueArray(srcObj));
+ }
+ return destArr;
+ }
+
+ return value;
+ }
+
+ public static Object syncArray(Object array, Class target)
+ {
+ return (JavaUtils.isPrimitive(target)) ? JavaUtils.getPrimitiveValueArray(array) :
JavaUtils.getWrapperValueArray(array);
+ }
+
+ /**
+ * Return true if the dest class is assignable from the src.
+ * Also handles arrays and primitives.
+ */
+ public static boolean isAssignableFrom(Class dest, Class src)
+ {
+ if (dest == null)
+ throw new IllegalArgumentException("Destination class cannot be
null");
+ if (src == null)
+ throw new IllegalArgumentException("Source class cannot be null");
+
+ boolean isAssignable = dest.isAssignableFrom(src);
+ if (isAssignable == false && dest.getName().equals(src.getName()))
+ {
+ ClassLoader destLoader = dest.getClassLoader();
+ ClassLoader srcLoader = src.getClassLoader();
+ if(log.isDebugEnabled()) log.debug("Not assignable because of conflicting
class loaders:\ndstLoader=" + destLoader + "\nsrcLoader=" + srcLoader);
+ }
+
+ if (isAssignable == false && isPrimitive(dest))
+ {
+ dest = getWrapperType(dest);
+ isAssignable = dest.isAssignableFrom(src);
+ }
+ if (isAssignable == false && isPrimitive(src))
+ {
+ src = getWrapperType(src);
+ isAssignable = dest.isAssignableFrom(src);
+ }
+ return isAssignable;
+ }
+
+ public static String convertJVMNameToSourceName(String typeName, ClassLoader loader)
+ {
+ // TODO Don't use a ClassLoader for this, we need to just convert it
+ try
+ {
+ Class javaType = loadJavaType(typeName, loader);
+ typeName = getSourceName(javaType);
+ }
+ catch (Exception e)
+ {
+ }
+
+ return typeName;
+ }
+
+ /**
+ * Converts a JVM external name to a JVM signature name. An external name is
+ * that which is returned from {@link Class#getName()} A signature name is
+ * the name in class file format.
+ * <p>
+ * For example:
+ * <p>
+ * [java.lang.Object
+ * <p>
+ * becomes:
+ * <p>
+ * [Ljava/lang/Object;
+ *
+ * @param externalName
+ * @return
+ */
+ public static String toSignature(String externalName)
+ {
+ if (externalName == null)
+ return null;
+
+ String ret = primitiveNameDescriptors.get(externalName);
+ if (ret != null)
+ return ret;
+
+ ret = externalName.replace('.', '/');
+ return (ret.charAt(0) == '[') ? ret : "L" + ret + ";";
+ }
+
+ public static String printArray(Object[] val)
+ {
+ if (val == null)
+ return "null";
+
+ StringBuilder out = new StringBuilder("[");
+ for (int i = 0; i < val.length; i++)
+ {
+ if (i > 0)
+ {
+ out.append(",");
+ }
+ out.append(val[i].getClass().isArray() ? printArray((Object[])val[i]) :
val[i]);
+ }
+ return out.append("]").toString();
+ }
+
+ public static String getSourceName(Class type)
+ {
+ if (! type.isArray())
+ return type.getName();
+
+ String arrayNotation = "";
+ Class component = type;
+ while(component.isArray())
+ {
+ component = component.getComponentType();
+ arrayNotation += "[]";
+ }
+
+ return component.getName() + arrayNotation;
+ }
+
+ public static String capitalize(String source)
+ {
+ if (source == null)
+ return null;
+
+ if (source.length() == 0)
+ return source;
+
+ if (Character.isUpperCase(source.charAt(0)))
+ return source;
+
+ char c = Character.toUpperCase(source.charAt(0));
+
+ return c + source.substring(1);
+ }
+
+ public static boolean isLoaded(String className, ClassLoader loader)
+ {
+ try
+ {
+ loadJavaType(className, loader);
+ }
+ catch (ClassNotFoundException e)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public static String getPackageName(Class<?> clazz)
+ {
+ String fullName = clazz.getName();
+ return fullName.substring(0, fullName.lastIndexOf("."));
+ }
+
+ public static boolean isReservedKeyword(String keyword)
+ {
+ return reservedKeywords.contains(keyword);
+ }
+
+ /**
+ * Erases a type according to the JLS type erasure rules
+ *
+ * @param t type to erase
+ * @return erased type
+ */
+ public static Class erasure(Type type)
+ {
+ if (type instanceof ParameterizedType)
+ {
+ return erasure(((ParameterizedType)type).getRawType());
+ }
+ if (type instanceof TypeVariable)
+ {
+ return erasure(((TypeVariable)type).getBounds()[0]);
+ }
+ if (type instanceof WildcardType)
+ {
+ return erasure(((WildcardType)type).getUpperBounds()[0]);
+ }
+ if (type instanceof GenericArrayType)
+ {
+ return
Array.newInstance(erasure(((GenericArrayType)type).getGenericComponentType()),
0).getClass();
+ }
+
+ // Only type left is class
+ return (Class)type;
+ }
+
+ public static String[] getRawParameterTypeArguments(ParameterizedType type)
+ {
+ Type[] arguments = type.getActualTypeArguments();
+ String[] ret = new String[arguments.length];
+ for (int i = 0; i < arguments.length; i++)
+ {
+ Class raw = erasure(arguments[i]);
+ ret[i] = raw.getName();
+ }
+
+ return ret;
+ }
+
+ /**
+ * This method tests for retro translation by searching for a known problem where
Class
+ * does not implement Type. If this is true, then code must never cast a Class to a
Type.
+ *
+ * @return true if we are in retro
+ */
+ public static boolean isRetro14()
+ {
+ return !(String.class instanceof java.lang.reflect.Type);
+ }
+
+ /**
+ * Tests if this class loader is a JBoss RepositoryClassLoader
+ *
+ * @param loader
+ * @return
+ */
+ public static boolean isJBossRepositoryClassLoader(ClassLoader loader)
+ {
+ Class clazz = loader.getClass();
+ while (!clazz.getName().startsWith("java"))
+ {
+ if
("org.jboss.mx.loading.RepositoryClassLoader".equals(clazz.getName()))
+ return true;
+ clazz = clazz.getSuperclass();
+ }
+
+ return false;
+ }
+
+ /**
+ * Clears black lists on a JBoss RepositoryClassLoader. This is somewhat of a hack,
and
+ * could be replaced with an integration module. This is needed when the following
order of
+ * events occur.
+ *
+ * <ol>
+ * <li>loadClass() returns not found</li>
+ * <li>Some call to defineClass()</li>
+ * <ol>
+ *
+ * The CNFE triggers a black list addition, which cause the class never again to be
found.
+ *
+ * @param loader the loader to clear black lists for
+ */
+ public static void clearBlacklists(ClassLoader loader)
+ {
+ if (isJBossRepositoryClassLoader(loader))
+ {
+ try
+ {
+ loader.getClass().getMethod("clearBlacklists").invoke(loader);
+ }
+ catch (Exception e)
+ {
+ if(log.isDebugEnabled()) log.debug("Could not clear blacklists on "
+ loader);
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on:
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/core/utils/JavaUtils.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/BasicLifecycleHandler.java
===================================================================
---
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/BasicLifecycleHandler.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/BasicLifecycleHandler.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -25,7 +25,6 @@
import org.jboss.logging.Logger;
import org.jboss.ws.integration.Endpoint.EndpointState;
-import org.jboss.ws.integration.invocation.InvocationHandler;
/**
* A basic lifecycle handler
@@ -38,42 +37,47 @@
// provide logging
protected final Logger log = Logger.getLogger(getClass());
- public void create(Endpoint endpoint)
+ public void create(Endpoint ep)
{
- log.debug("Create: " + endpoint.getName());
+ log.debug("Create: " + ep.getName());
- // Initialize the invoker
- InvocationHandler invoker = endpoint.getInvocationHandler();
- invoker.create(endpoint);
+ ep.getInvocationHandler().create(ep);
- endpoint.setState(EndpointState.CREATED);
+ ep.setState(EndpointState.CREATED);
}
- public void start(Endpoint endpoint)
+ public void start(Endpoint ep)
{
- log.debug("Start: " + endpoint.getName());
+ log.debug("Start: " + ep.getName());
- EndpointState state = endpoint.getState();
+ EndpointState state = ep.getState();
if (state == EndpointState.UNDEFINED || state == EndpointState.DESTROYED)
throw new IllegalStateException("Cannot start endpoint in state: " +
state);
- endpoint.setState(EndpointState.STARTED);
+ ep.getInvocationHandler().start(ep);
+
+ ep.setState(EndpointState.STARTED);
}
- public void stop(Endpoint endpoint)
+ public void stop(Endpoint ep)
{
- log.debug("Stop: " + endpoint.getName());
+ log.debug("Stop: " + ep.getName());
- EndpointState state = endpoint.getState();
+ EndpointState state = ep.getState();
if (state != EndpointState.STARTED)
throw new IllegalStateException("Cannot stop endpoint in state: " +
state);
- endpoint.setState(EndpointState.STOPED);
+ ep.getInvocationHandler().stop(ep);
+
+ ep.setState(EndpointState.STOPED);
}
- public void destroy(Endpoint endpoint)
+ public void destroy(Endpoint ep)
{
- log.debug("Destroy: " + endpoint.getName());
- endpoint.setState(EndpointState.DESTROYED);
+ log.debug("Destroy: " + ep.getName());
+
+ ep.getInvocationHandler().destroy(ep);
+
+ ep.setState(EndpointState.DESTROYED);
}
}
Copied:
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/AbstractWebServiceContext.java
(from rev 3110,
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/AbstractWebServiceContext.java)
===================================================================
---
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/AbstractWebServiceContext.java
(rev 0)
+++
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/AbstractWebServiceContext.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -0,0 +1,69 @@
+/*
+ * 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.invocation;
+
+import java.security.Principal;
+
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+import org.jboss.util.NotImplementedException;
+import org.w3c.dom.Element;
+
+/**
+ * A WebServiceContext makes it possible for a web service endpoint implementation
+ * class to access message context and security information relative to a request
+ * being served. Typically a WebServiceContext is injected into an endpoint
implementation
+ * class using the Resource annotation.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 03-May-2006
+ */
+public abstract class AbstractWebServiceContext implements WebServiceContext
+{
+ private MessageContext messageContext;
+
+ public AbstractWebServiceContext(MessageContext messageContext)
+ {
+ this.messageContext = messageContext;
+ }
+
+ public MessageContext getMessageContext()
+ {
+ return messageContext;
+ }
+
+ public abstract Principal getUserPrincipal();
+
+ public abstract boolean isUserInRole(String role);
+
+ public EndpointReference getEndpointReference(Element... referenceParameters)
+ {
+ throw new NotImplementedException();
+ }
+
+ public <T extends EndpointReference> T getEndpointReference(Class<T>
clazz, Element... referenceParameters)
+ {
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
Added:
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/BasicInvocation.java
===================================================================
---
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/BasicInvocation.java
(rev 0)
+++
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/BasicInvocation.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -0,0 +1,114 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (
http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache
Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <
http://www.apache.org/>.
+ */
+package org.jboss.ws.integration.invocation;
+
+import java.lang.reflect.Method;
+
+//$Id$
+
+/**
+ * A general endpoint invocation.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public class BasicInvocation implements Invocation
+{
+ private InvocationContext invocationContext;
+ private Method javaMethod;
+ private Object[] args;
+ private Object returnValue;
+
+ public InvocationContext getInvocationContext()
+ {
+ return invocationContext;
+ }
+
+ public void setInvocationContext(InvocationContext invocationContext)
+ {
+ this.invocationContext = invocationContext;
+ }
+
+ public Method getJavaMethod()
+ {
+ return javaMethod;
+ }
+
+ public void setJavaMethod(Method javaMethod)
+ {
+ this.javaMethod = javaMethod;
+ }
+
+ public Object[] getArgs()
+ {
+ return args;
+ }
+
+ public void setArgs(Object[] args)
+ {
+ this.args = args;
+ }
+
+ public Object getReturn()
+ {
+ return returnValue;
+ }
+
+ public void setReturn(Object returnValue)
+ {
+ this.returnValue = returnValue;
+ }
+}
Property changes on:
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/BasicInvocation.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/Invocation.java
===================================================================
---
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/Invocation.java
(rev 0)
+++
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/Invocation.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -0,0 +1,85 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (
http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache
Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <
http://www.apache.org/>.
+ */
+package org.jboss.ws.integration.invocation;
+
+import java.lang.reflect.Method;
+
+//$Id$
+
+/**
+ * A general endpoint invocation.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 20-Apr-2007
+ */
+public interface Invocation
+{
+ InvocationContext getInvocationContext();
+
+ void setInvocationContext(InvocationContext context);
+
+ Method getJavaMethod();
+
+ void setJavaMethod(Method method);
+
+ Object[] getArgs();
+
+ void setArgs(Object[] args);
+
+ Object getReturn();
+
+ void setReturn(Object ret);
+}
Property changes on:
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/Invocation.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/InvocationHandler.java
===================================================================
---
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/InvocationHandler.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/InvocationHandler.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -57,10 +57,6 @@
//$Id$
-import java.lang.reflect.Method;
-
-import javax.xml.ws.WebServiceContext;
-
import org.jboss.ws.integration.Endpoint;
/**
@@ -73,19 +69,16 @@
{
/** Create the invocation handler */
void create(Endpoint ep);
-
+
/** Start the invocation handler */
void start(Endpoint ep);
-
- /** Get an instance of the target bean */
- Object getTargetBean(Endpoint ep) throws InstantiationException,
IllegalAccessException;
-
- /** Invoke the the service ep */
- Object invoke(Endpoint ep, Object targetBean, Method method, Object[] args,
InvocationContext context) throws Exception;
-
+
+ /** Invoke the the service endpoint */
+ void invoke(Endpoint ep, Invocation inv) throws Exception;
+
/** Stop the invocation handler */
void stop(Endpoint ep);
-
+
/** Destroy the invocation handler */
void destroy(Endpoint ep);
}
Copied:
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/WebServiceContextEJB.java
(from rev 3110,
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextEJB.java)
===================================================================
---
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/WebServiceContextEJB.java
(rev 0)
+++
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/WebServiceContextEJB.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -0,0 +1,58 @@
+/*
+ * 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.invocation;
+
+// $Id$
+
+import java.security.Principal;
+
+import javax.ejb.EJBContext;
+import javax.xml.ws.handler.MessageContext;
+
+/**
+ * A WebServiceContext implementation that delegates to the EJBContext.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 23-Jan-2007
+ */
+public class WebServiceContextEJB extends AbstractWebServiceContext
+{
+ private EJBContext ejbContext;
+
+ public WebServiceContextEJB(MessageContext msgContext, EJBContext ejbContext)
+ {
+ super(msgContext);
+ this.ejbContext = ejbContext;
+ }
+
+ public Principal getUserPrincipal()
+ {
+ Principal principal = ejbContext.getCallerPrincipal();
+ return principal;
+ }
+
+ public boolean isUserInRole(String role)
+ {
+ boolean isUserInRole = ejbContext.isCallerInRole(role);
+ return isUserInRole;
+ }
+}
Copied:
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/WebServiceContextJSE.java
(from rev 3110,
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextJSE.java)
===================================================================
---
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/WebServiceContextJSE.java
(rev 0)
+++
branches/tdiesler/trunk/integration/spi/src/main/java/org/jboss/ws/integration/invocation/WebServiceContextJSE.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -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.invocation;
+
+// $Id$
+
+import java.security.Principal;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.ws.handler.MessageContext;
+
+/**
+ * A WebServiceContext implementation that delegates to the HttpServletRequest.
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 23-Jan-2007
+ */
+public class WebServiceContextJSE extends AbstractWebServiceContext
+{
+ private HttpServletRequest httpRequest;
+
+ public WebServiceContextJSE(MessageContext messageContext)
+ {
+ super(messageContext);
+ httpRequest =
(HttpServletRequest)messageContext.get(MessageContext.SERVLET_REQUEST);
+ if (httpRequest == null)
+ throw new IllegalStateException("Cannot obtain HTTPServletRequest from
message context");
+ }
+
+ @Override
+ public Principal getUserPrincipal()
+ {
+ Principal principal = httpRequest.getUserPrincipal();
+ return principal;
+ }
+
+ @Override
+ public boolean isUserInRole(String role)
+ {
+ boolean isUserInRole = httpRequest.isUserInRole(role);
+ return isUserInRole;
+ }
+}
Modified:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/EndpointInvocation.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/EndpointInvocation.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/EndpointInvocation.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -1,24 +1,24 @@
/*
-* 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.
-*/
+ * 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;
// $Id$
@@ -99,22 +99,31 @@
public void setRequestParamValue(QName xmlName, Object value)
{
- if(log.isDebugEnabled()) log.debug("setRequestParamValue: [name=" +
xmlName + ",value=" + getTypeName(value) + "]");
+ if (log.isDebugEnabled())
+ log.debug("setRequestParamValue: [name=" + xmlName +
",value=" + getTypeName(value) + "]");
reqPayload.put(xmlName, value);
}
- public Object getRequestParamValue(QName xmlName) throws SOAPException
+ public Object getRequestParamValue(QName xmlName)
{
- if(log.isDebugEnabled()) log.debug("getRequestParamValue: " + xmlName);
+ if (log.isDebugEnabled())
+ log.debug("getRequestParamValue: " + xmlName);
Object paramValue = reqPayload.get(xmlName);
ParameterMetaData paramMetaData = opMetaData.getParameter(xmlName);
- paramValue = transformPayloadValue(paramMetaData, paramValue);
+ try
+ {
+ paramValue = transformPayloadValue(paramMetaData, paramValue);
+ }
+ catch (SOAPException ex)
+ {
+ throw new WSException(ex);
+ }
return paramValue;
}
/** Returns the payload that can be passed on to the endpoint implementation
*/
- public Object[] getRequestPayload() throws SOAPException
+ public Object[] getRequestPayload()
{
log.debug("getRequestPayload");
List<QName> xmlNames = getRequestParamNames();
@@ -141,13 +150,15 @@
public void setResponseParamValue(QName xmlName, Object value)
{
- if(log.isDebugEnabled()) log.debug("setResponseParamValue: [name=" +
xmlName + ",value=" + getTypeName(value) + "]");
+ if (log.isDebugEnabled())
+ log.debug("setResponseParamValue: [name=" + xmlName +
",value=" + getTypeName(value) + "]");
resPayload.put(xmlName, value);
}
public Object getResponseParamValue(QName xmlName) throws SOAPException
{
- if(log.isDebugEnabled()) log.debug("getResponseParamValue: " + xmlName);
+ if (log.isDebugEnabled())
+ log.debug("getResponseParamValue: " + xmlName);
Object paramValue = resPayload.get(xmlName);
ParameterMetaData paramMetaData = opMetaData.getParameter(xmlName);
paramValue = transformPayloadValue(paramMetaData, paramValue);
@@ -168,18 +179,27 @@
if (value != null && retMetaData == null)
throw new WSException("Operation does not have a return value: " +
opMetaData.getQName());
- if(log.isDebugEnabled()) log.debug("setReturnValue: " +
getTypeName(value));
+ if (log.isDebugEnabled())
+ log.debug("setReturnValue: " + getTypeName(value));
this.returnValue = value;
}
- public Object getReturnValue() throws SOAPException
+ public Object getReturnValue()
{
- if(log.isDebugEnabled()) log.debug("getReturnValue");
+ if (log.isDebugEnabled())
+ log.debug("getReturnValue");
Object paramValue = returnValue;
ParameterMetaData paramMetaData = opMetaData.getReturnParameter();
if (paramMetaData != null)
{
- paramValue = transformPayloadValue(paramMetaData, paramValue);
+ try
+ {
+ paramValue = transformPayloadValue(paramMetaData, paramValue);
+ }
+ catch (SOAPException ex)
+ {
+ throw new WSException(ex);
+ }
}
return paramValue;
}
@@ -237,14 +257,15 @@
// the content element as is.
// Note, that it is possible for a Java type to be bound to an any
// type, so checking the xml type is not sufficient.
- if (! Element.class.isAssignableFrom(javaType))
+ if (!Element.class.isAssignableFrom(javaType))
{
SOAPContentElement soapElement = (SOAPContentElement)paramValue;
retValue = soapElement.getObjectValue();
}
}
- if(log.isDebugEnabled()) log.debug("transformPayloadValue: " +
getTypeName(paramValue) + " -> " + getTypeName(retValue));
+ if (log.isDebugEnabled())
+ log.debug("transformPayloadValue: " + getTypeName(paramValue) + "
-> " + getTypeName(retValue));
return retValue;
}
@@ -307,7 +328,7 @@
Method method = opMetaData.getJavaMethod();
Class[] targetParameterTypes = method.getParameterTypes();
- if (opMetaData.isDocumentWrapped() && !paramMetaData.isInHeader()&&
!paramMetaData.isSwA() && !paramMetaData.isMessageType())
+ if (opMetaData.isDocumentWrapped() && !paramMetaData.isInHeader()
&& !paramMetaData.isSwA() && !paramMetaData.isMessageType())
{
outParameters = ParameterWrapping.unwrapRequestParameters(paramMetaData,
paramValue, payload);
syncOutWrappedParameters(targetParameterTypes, payload);
@@ -336,7 +357,8 @@
retValue = JavaUtils.syncArray(retValue, targetParameterType);
}
- if(log.isDebugEnabled()) log.debug("syncEndpointInputParam: " +
getTypeName(paramValue) + " -> " + getTypeName(retValue) + "(" +
index + ")");
+ if (log.isDebugEnabled())
+ log.debug("syncEndpointInputParam: " + getTypeName(paramValue) +
" -> " + getTypeName(retValue) + "(" + index + ")");
payload[index] = retValue;
}
}
Added:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/ServiceEndpointInvokerDeployer.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/ServiceEndpointInvokerDeployer.java
(rev 0)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/ServiceEndpointInvokerDeployer.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -0,0 +1,63 @@
+/*
+ * 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.deployment;
+
+//$Id$
+
+import org.jboss.ws.core.server.ServiceEndpointInvoker;
+import org.jboss.ws.core.server.ServiceEndpointInvokerEJB21;
+import org.jboss.ws.integration.Endpoint;
+import org.jboss.ws.integration.deployment.AbstractDeployer;
+import org.jboss.ws.integration.deployment.Deployment;
+import org.jboss.ws.integration.deployment.Deployment.DeploymentType;
+
+/**
+ * A deployer that associates the ServiceEndpointInvoker with the endpoint
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 25-Apr-2007
+ */
+public class ServiceEndpointInvokerDeployer extends AbstractDeployer
+{
+ @Override
+ public void create(Deployment dep)
+ {
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ ServiceEndpointInvoker epInvoker =
ep.getAttachment(ServiceEndpointInvoker.class);
+ if (epInvoker == null)
+ {
+ DeploymentType depType = ep.getService().getDeployment().getType();
+ if (depType == DeploymentType.JAXRPC_EJB21)
+ {
+ epInvoker = new ServiceEndpointInvokerEJB21();
+ }
+ else
+ {
+ epInvoker = new ServiceEndpointInvoker();
+ }
+ ep.addAttachment(ServiceEndpointInvoker.class, epInvoker);
+ epInvoker.init(ep);
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/deployment/ServiceEndpointInvokerDeployer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/AbstractWebServiceContext.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/AbstractWebServiceContext.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/AbstractWebServiceContext.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -1,69 +0,0 @@
-/*
- * 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;
-
-import java.security.Principal;
-
-import javax.xml.ws.EndpointReference;
-import javax.xml.ws.WebServiceContext;
-import javax.xml.ws.handler.MessageContext;
-
-import org.jboss.util.NotImplementedException;
-import org.w3c.dom.Element;
-
-/**
- * A WebServiceContext makes it possible for a web service endpoint implementation
- * class to access message context and security information relative to a request
- * being served. Typically a WebServiceContext is injected into an endpoint
implementation
- * class using the Resource annotation.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 03-May-2006
- */
-public abstract class AbstractWebServiceContext implements WebServiceContext
-{
- private MessageContext messageContext;
-
- public AbstractWebServiceContext(MessageContext messageContext)
- {
- this.messageContext = messageContext;
- }
-
- public MessageContext getMessageContext()
- {
- return messageContext;
- }
-
- public abstract Principal getUserPrincipal();
-
- public abstract boolean isUserInRole(String role);
-
- public EndpointReference getEndpointReference(Element... referenceParameters)
- {
- throw new NotImplementedException();
- }
-
- public <T extends EndpointReference> T getEndpointReference(Class<T>
clazz, Element... referenceParameters)
- {
- throw new NotImplementedException();
- }
-}
\ No newline at end of file
Deleted:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextEJB.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextEJB.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextEJB.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -1,65 +0,0 @@
-/*
- * 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.security.Principal;
-
-import javax.ejb.EJBContext;
-import javax.xml.ws.handler.MessageContext;
-
-import org.jboss.logging.Logger;
-
-/**
- * A WebServiceContext implementation that delegates to the EJBContext.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 23-Jan-2007
- */
-public class WebServiceContextEJB extends AbstractWebServiceContext
-{
- // provide logging
- private Logger log = Logger.getLogger(WebServiceContextEJB.class);
-
- private EJBContext ejbContext;
-
- public WebServiceContextEJB(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;
- }
-}
Deleted:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextJSE.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextJSE.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/jaxws/WebServiceContextJSE.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -1,64 +0,0 @@
-/*
- * 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.security.Principal;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.xml.ws.handler.MessageContext;
-
-import org.jboss.ws.core.jaxws.handler.MessageContextJAXWS;
-
-/**
- * A WebServiceContext implementation that delegates to the HttpServletRequest.
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 23-Jan-2007
- */
-public class WebServiceContextJSE extends AbstractWebServiceContext
-{
- private HttpServletRequest httpRequest;
-
- public WebServiceContextJSE(MessageContext messageContext)
- {
- super(messageContext);
- httpRequest =
(HttpServletRequest)messageContext.get(MessageContextJAXWS.SERVLET_REQUEST);
- if (httpRequest == null)
- throw new IllegalStateException("Cannot obtain HTTPServletRequest from
message context");
- }
-
- @Override
- public Principal getUserPrincipal()
- {
- Principal principal = httpRequest.getUserPrincipal();
- return principal;
- }
-
- @Override
- public boolean isUserInRole(String role)
- {
- boolean isUserInRole = httpRequest.isUserInRole(role);
- return isUserInRole;
- }
-}
Modified:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/RequestHandlerImpl.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/RequestHandlerImpl.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/RequestHandlerImpl.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -77,9 +77,7 @@
import org.jboss.ws.integration.Endpoint;
import org.jboss.ws.integration.RequestHandler;
import org.jboss.ws.integration.Endpoint.EndpointState;
-import org.jboss.ws.integration.deployment.Deployment.DeploymentType;
import org.jboss.ws.integration.invocation.InvocationContext;
-import org.jboss.ws.integration.invocation.InvocationHandler;
import org.jboss.ws.integration.management.ServerConfig;
import org.jboss.ws.integration.management.ServerConfigFactory;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
@@ -305,12 +303,12 @@
/**
* Handle a request to this web service endpoint
*/
- private MessageAbstraction processRequest(Endpoint endpoint, MimeHeaderSource
headerSource, ServletRequestContext reqContext, InputStream inputStream)
+ private MessageAbstraction processRequest(Endpoint ep, MimeHeaderSource headerSource,
ServletRequestContext reqContext, InputStream inputStream)
throws BindingException
{
CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
- ServerEndpointMetaData sepMetaData =
endpoint.getAttachment(ServerEndpointMetaData.class);
+ ServerEndpointMetaData sepMetaData =
ep.getAttachment(ServerEndpointMetaData.class);
if (sepMetaData == null)
throw new IllegalStateException("Cannot obtain endpoint meta data");
@@ -318,7 +316,7 @@
ClassLoader ctxClassLoader = Thread.currentThread().getContextClassLoader();
try
{
- EndpointState state = endpoint.getState();
+ EndpointState state = ep.getState();
if (state != EndpointState.STARTED)
{
QName faultCode = Constants.SOAP11_FAULT_CODE_SERVER;
@@ -326,8 +324,8 @@
throw new SOAPFaultException(faultCode, faultString, null, null);
}
- log.debug("BEGIN handleRequest: " + endpoint.getName());
- beginProcessing = initRequestMetrics(endpoint);
+ log.debug("BEGIN handleRequest: " + ep.getName());
+ beginProcessing = initRequestMetrics(ep);
MimeHeaders headers = (headerSource != null ? headerSource.getMimeHeaders() :
null);
@@ -358,26 +356,9 @@
Thread.currentThread().setContextClassLoader(classLoader);
// Get the Invoker
- ServiceEndpointInvoker epInvoker =
endpoint.getAttachment(ServiceEndpointInvoker.class);
+ ServiceEndpointInvoker epInvoker =
ep.getAttachment(ServiceEndpointInvoker.class);
if (epInvoker == null)
- {
- DeploymentType depType = endpoint.getService().getDeployment().getType();
- if (depType == DeploymentType.JAXRPC_EJB21)
- {
- epInvoker = new ServiceEndpointInvokerEJB21();
- }
- else
- {
- epInvoker = new ServiceEndpointInvoker();
- }
- epInvoker.init(endpoint);
-
- // TODO: proper invoker lifecycle handling, possibly
- // called from endpoint lifecycle method
- InvocationHandler invHandler = endpoint.getInvocationHandler();
- invHandler.create(endpoint);
- invHandler.start(endpoint);
- }
+ throw new IllegalStateException("Cannot obtain
ServiceEndpointInvoker");
// Invoke the service endpoint
epInvoker.invoke(reqContext);
@@ -419,11 +400,11 @@
{
if (resMessage.isFaultMessage())
{
- processFaultMetrics(endpoint, beginProcessing);
+ processFaultMetrics(ep, beginProcessing);
}
else
{
- processResponseMetrics(endpoint, beginProcessing);
+ processResponseMetrics(ep, beginProcessing);
}
}
}
@@ -434,7 +415,7 @@
// Reset the thread context class loader
Thread.currentThread().setContextClassLoader(ctxClassLoader);
- log.debug("END handleRequest: " + endpoint.getName());
+ log.debug("END handleRequest: " + ep.getName());
}
}
Modified:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -23,15 +23,12 @@
// $Id$
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.lang.reflect.UndeclaredThrowableException;
import java.util.HashMap;
import javax.activation.DataHandler;
-import javax.management.MBeanException;
import javax.xml.namespace.QName;
-import javax.xml.rpc.ServiceException;
+import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.rpc.server.ServiceLifecycle;
import javax.xml.rpc.server.ServletEndpointContext;
import javax.xml.rpc.soap.SOAPFaultException;
@@ -40,6 +37,7 @@
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPMessage;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.http.HTTPBinding;
@@ -55,10 +53,10 @@
import org.jboss.ws.core.MessageAbstraction;
import org.jboss.ws.core.DirectionHolder.Direction;
import org.jboss.ws.core.jaxrpc.ServletEndpointContextImpl;
+import org.jboss.ws.core.jaxrpc.binding.BindingException;
import org.jboss.ws.core.jaxrpc.handler.HandlerDelegateJAXRPC;
import org.jboss.ws.core.jaxrpc.handler.MessageContextJAXRPC;
import org.jboss.ws.core.jaxrpc.handler.SOAPMessageContextJAXRPC;
-import org.jboss.ws.core.jaxws.WebServiceContextJSE;
import org.jboss.ws.core.jaxws.binding.BindingProviderImpl;
import org.jboss.ws.core.jaxws.handler.HandlerDelegateJAXWS;
import org.jboss.ws.core.jaxws.handler.MessageContextJAXWS;
@@ -68,8 +66,11 @@
import org.jboss.ws.core.utils.JavaUtils;
import org.jboss.ws.extensions.xop.XOPContext;
import org.jboss.ws.integration.Endpoint;
+import org.jboss.ws.integration.invocation.BasicInvocation;
+import org.jboss.ws.integration.invocation.Invocation;
import org.jboss.ws.integration.invocation.InvocationContext;
import org.jboss.ws.integration.invocation.InvocationHandler;
+import org.jboss.ws.integration.invocation.WebServiceContextJSE;
import org.jboss.ws.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.ws.metadata.umdm.OperationMetaData;
@@ -200,9 +201,10 @@
epInv = binding.unbindRequestMessage(opMetaData, reqMessage);
}
- /** Invoke an instance of the SEI implementation bean */
- Object targetBean = getTargetBean(endpoint, invContext);
- invokeTargetBean(endpoint, targetBean, epInv, invContext);
+ // Invoke an instance of the SEI implementation bean
+ Invocation inv = setupInvocation(endpoint, epInv, invContext);
+ InvocationHandler invHandler = endpoint.getInvocationHandler();
+ invHandler.invoke(endpoint, inv);
}
finally
{
@@ -275,59 +277,61 @@
}
}
- protected void invokeTargetBean(Endpoint endpoint, Object targetBean,
EndpointInvocation epInv, InvocationContext invContext) throws Exception
+ protected Invocation setupInvocation(Endpoint ep, EndpointInvocation epInv,
InvocationContext invContext) throws Exception
{
- // Set the the ServletEndpointContext on a JSE endpoint
- if (targetBean instanceof ServiceLifecycle && invContext instanceof
ServletRequestContext)
+ CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
+ if (msgContext instanceof SOAPMessageContextJAXWS)
{
- try
- {
- ServiceLifecycle serviceLifecycle = ((ServiceLifecycle)targetBean);
- ServletEndpointContext servletEndpointContext = new
ServletEndpointContextImpl((ServletRequestContext)invContext);
- serviceLifecycle.init(servletEndpointContext);
- }
- catch (ServiceException ex)
- {
- throw new WSException(ex);
- }
+ invContext.addAttachment(WebServiceContext.class, new
WebServiceContextJSE((SOAPMessageContextJAXWS)msgContext));
+ invContext.addAttachment(javax.xml.ws.handler.MessageContext.class,
msgContext);
}
-
- try
+ if (msgContext instanceof SOAPMessageContextJAXRPC)
{
- Method implMethod = getImplMethod(endpoint, epInv);
+ invContext.addAttachment(javax.xml.rpc.handler.MessageContext.class,
msgContext);
+ }
+ if (ServiceLifecycle.class.isAssignableFrom(ep.getTargetBean()) &&
invContext instanceof ServletRequestContext)
+ {
+ ServletEndpointContext servletEndpointContext = new
ServletEndpointContextImpl((ServletRequestContext)invContext);
+ invContext.addAttachment(ServletEndpointContext.class, servletEndpointContext);
+ }
- Object[] args = epInv.getRequestPayload();
+ Invocation inv = new DelegatingInvocation(epInv);
+ inv.setInvocationContext(invContext);
+ inv.setJavaMethod(getImplMethod(endpoint, epInv));
- CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
- if (msgContext instanceof SOAPMessageContextJAXWS)
- {
- WebServiceContext wsContext = new
WebServiceContextJSE((SOAPMessageContextJAXWS)msgContext);
- invContext.addAttachment(WebServiceContext.class, wsContext);
- }
- if (msgContext instanceof SOAPMessageContextJAXRPC)
- {
- invContext.addAttachment(javax.xml.rpc.handler.MessageContext.class,
msgContext);
- }
+ return inv;
+ }
- InvocationHandler invHandler = endpoint.getInvocationHandler();
- Object retObj = invHandler.invoke(endpoint, targetBean, implMethod, args,
invContext);
+ protected Method getImplMethod(Endpoint endpoint, EndpointInvocation epInv) throws
ClassNotFoundException, NoSuchMethodException
+ {
+ Class implClass = endpoint.getTargetBean();
+ Method seiMethod = epInv.getJavaMethod();
- epInv.setReturnValue(retObj);
- }
- finally
+ String methodName = seiMethod.getName();
+ Class[] paramTypes = seiMethod.getParameterTypes();
+ for (int i = 0; i < paramTypes.length; i++)
{
- if (targetBean instanceof ServiceLifecycle)
+ Class paramType = paramTypes[i];
+ if (JavaUtils.isPrimitive(paramType) == false)
{
- ((ServiceLifecycle)targetBean).destroy();
+ String paramTypeName = paramType.getName();
+ paramType = JavaUtils.loadJavaType(paramTypeName);
+ paramTypes[i] = paramType;
}
}
- }
- protected Object getTargetBean(Endpoint endpoint, InvocationContext invContext) throws
InstantiationException, IllegalAccessException
- {
- InvocationHandler invHandler = endpoint.getInvocationHandler();
- Object targetBean = invHandler.getTargetBean(endpoint);
- return targetBean;
+ Method implMethod = null;
+ try
+ {
+ implMethod = implClass.getMethod(methodName, paramTypes);
+ }
+ catch (NoSuchMethodException ex)
+ {
+ log.error("CodeSource: " +
implClass.getProtectionDomain().getCodeSource());
+ log.error("ClassLoader: " + implClass.getClassLoader());
+ throw ex;
+ }
+ return implMethod;
}
protected void setInboundContextProperties()
@@ -420,69 +424,55 @@
return opMetaData;
}
- protected Method getImplMethod(Endpoint endpoint, EndpointInvocation epInv) throws
ClassNotFoundException, NoSuchMethodException
+ class DelegatingInvocation extends BasicInvocation
{
- Class implClass = endpoint.getTargetBean();
- Method seiMethod = epInv.getJavaMethod();
+ private EndpointInvocation epInv;
- String methodName = seiMethod.getName();
- Class[] paramTypes = seiMethod.getParameterTypes();
- for (int i = 0; i < paramTypes.length; i++)
+ public DelegatingInvocation(EndpointInvocation epInv)
{
- Class paramType = paramTypes[i];
- if (JavaUtils.isPrimitive(paramType) == false)
- {
- String paramTypeName = paramType.getName();
- paramType = JavaUtils.loadJavaType(paramTypeName);
- paramTypes[i] = paramType;
- }
+ this.epInv = epInv;
}
- Method implMethod = null;
- try
+ @Override
+ public void setReturn(Object value)
{
- implMethod = implClass.getMethod(methodName, paramTypes);
+ epInv.setReturnValue(value);
+
+ SOAPMessageContext msgContext =
(SOAPMessageContext)getInvocationContext().getAttachment(javax.xml.rpc.handler.MessageContext.class);
+ if (msgContext != null && msgContext.getMessage() == null)
+ {
+ try
+ {
+ // Bind the response message
+ OperationMetaData opMetaData = epInv.getOperationMetaData();
+ CommonBindingProvider bindingProvider = new
CommonBindingProvider(opMetaData.getEndpointMetaData());
+ CommonBinding binding =
(CommonBinding)bindingProvider.getCommonBinding();
+ SOAPMessage resMessage =
(SOAPMessage)binding.bindResponseMessage(opMetaData, epInv);
+ msgContext.setMessage(resMessage);
+ }
+ catch (BindingException ex)
+ {
+ WSException.rethrow(ex);
+ }
+ }
}
- catch (NoSuchMethodException ex)
- {
- log.error("CodeSource: " +
implClass.getProtectionDomain().getCodeSource());
- log.error("ClassLoader: " + implClass.getClassLoader());
- throw ex;
- }
- return implMethod;
- }
- /** handle invocation exceptions */
- public void handleInvocationException(Throwable th) throws Exception
- {
- if (th instanceof InvocationTargetException)
+ @Override
+ public Object[] getArgs()
{
- // unwrap the throwable raised by the service endpoint implementation
- Throwable targetEx = ((InvocationTargetException)th).getTargetException();
- handleInvocationThrowable(targetEx);
+ return epInv.getRequestPayload();
}
- if (th instanceof MBeanException)
+ @Override
+ public Object getReturn()
{
- throw ((MBeanException)th).getTargetException();
+ return epInv.getReturnValue();
}
- handleInvocationThrowable(th);
- }
-
- private void handleInvocationThrowable(Throwable th) throws Exception
- {
- if (th instanceof Exception)
+ @Override
+ public void setArgs(Object[] args)
{
- throw (Exception)th;
+ throw new IllegalArgumentException("Cannot set args on this
invocation");
}
- else if (th instanceof Error)
- {
- throw (Error)th;
- }
- else
- {
- throw new UndeclaredThrowableException(th);
- }
}
}
Modified:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvokerEJB21.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvokerEJB21.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvokerEJB21.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -23,14 +23,11 @@
// $Id$
-import java.lang.reflect.Method;
-
-import org.jboss.logging.Logger;
import org.jboss.ws.core.EndpointInvocation;
import org.jboss.ws.integration.Endpoint;
import org.jboss.ws.integration.invocation.HandlerCallback;
+import org.jboss.ws.integration.invocation.Invocation;
import org.jboss.ws.integration.invocation.InvocationContext;
-import org.jboss.ws.integration.invocation.InvocationHandler;
import org.jboss.ws.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
@@ -42,33 +39,16 @@
*/
public class ServiceEndpointInvokerEJB21 extends ServiceEndpointInvoker
{
- // provide logging
- private static final Logger log =
Logger.getLogger(ServiceEndpointInvokerEJB21.class);
-
@Override
- protected void invokeTargetBean(Endpoint endpoint, Object targetBean,
EndpointInvocation epInv, InvocationContext invContext) throws Exception
+ protected Invocation setupInvocation(Endpoint ep, EndpointInvocation epInv,
InvocationContext invContext) throws Exception
{
- log.debug("invokeServiceEndpoint: " + epInv.getJavaMethod().getName());
+ Invocation inv = super.setupInvocation(ep, epInv, invContext);
+
+ // Attach the handler callback
+ ServerEndpointMetaData sepMetaData =
endpoint.getAttachment(ServerEndpointMetaData.class);
+ invContext.addAttachment(HandlerCallback.class, new
HandlerCallbackImpl(sepMetaData));
- try
- {
- // setup the invocation
- Method method = getImplMethod(endpoint, epInv);
- Object[] args = epInv.getRequestPayload();
-
- // Set the handler callback and endpoint invocation
- ServerEndpointMetaData sepMetaData =
endpoint.getAttachment(ServerEndpointMetaData.class);
- endpoint.addAttachment(HandlerCallback.class, new
HandlerCallbackImpl(sepMetaData));
-
- InvocationHandler invHandler = endpoint.getInvocationHandler();
- Object retObj = invHandler.invoke(endpoint, targetBean, method, args,
invContext);
-
- epInv.setReturnValue(retObj);
- }
- catch (Exception e)
- {
- handleInvocationException(e);
- }
+ return inv;
}
/** Handlers are beeing called through the HandlerCallback from the EJB interceptor
*/
Deleted:
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/utils/JavaUtils.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/utils/JavaUtils.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/jbossws/src/main/java/org/jboss/ws/core/utils/JavaUtils.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -1,648 +0,0 @@
-/*
- * 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.utils;
-
-// $Id$
-
-import java.lang.reflect.Array;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
-import java.util.HashMap;
-import java.util.HashSet;
-
-import org.jboss.logging.Logger;
-
-/** Java utilities
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 22-Dec-2004
- */
-public class JavaUtils
-{
- // provide logging
- private static final Logger log = Logger.getLogger(JavaUtils.class);
-
- private static HashMap<String, Class> primitiveNames = new HashMap<String,
Class>(8);
- private static HashMap<String, String> primitiveNameDescriptors = new
HashMap<String, String>(8);
- private static HashSet<String> reservedKeywords = new
HashSet<String>(50);
-
- static
- {
- primitiveNames.put("int", int.class);
- primitiveNames.put("short", short.class);
- primitiveNames.put("boolean", boolean.class);
- primitiveNames.put("byte", byte.class);
- primitiveNames.put("long", long.class);
- primitiveNames.put("double", double.class);
- primitiveNames.put("float", float.class);
- primitiveNames.put("char", char.class);
-
- primitiveNameDescriptors.put("int", "I");
- primitiveNameDescriptors.put("short", "S");
- primitiveNameDescriptors.put("boolean", "Z");
- primitiveNameDescriptors.put("byte", "B");
- primitiveNameDescriptors.put("long", "J");
- primitiveNameDescriptors.put("double", "D");
- primitiveNameDescriptors.put("float", "F");
- primitiveNameDescriptors.put("char", "C");
-
- reservedKeywords.add("abstract");
- reservedKeywords.add("continue");
- reservedKeywords.add("for");
- reservedKeywords.add("new");
- reservedKeywords.add("switch");
- reservedKeywords.add("assert");
- reservedKeywords.add("default");
- reservedKeywords.add("if");
- reservedKeywords.add("package");
- reservedKeywords.add("synchronized");
- reservedKeywords.add("boolean");
- reservedKeywords.add("do");
- reservedKeywords.add("goto");
- reservedKeywords.add("private");
- reservedKeywords.add("this");
- reservedKeywords.add("break");
- reservedKeywords.add("double");
- reservedKeywords.add("implements");
- reservedKeywords.add("protected");
- reservedKeywords.add("throw");
- reservedKeywords.add("byte");
- reservedKeywords.add("else");
- reservedKeywords.add("import");
- reservedKeywords.add("public");
- reservedKeywords.add("throws");
- reservedKeywords.add("case");
- reservedKeywords.add("enum");
- reservedKeywords.add("instanceof");
- reservedKeywords.add("return");
- reservedKeywords.add("transient");
- reservedKeywords.add("catch");
- reservedKeywords.add("extends");
- reservedKeywords.add("int");
- reservedKeywords.add("short");
- reservedKeywords.add("try");
- reservedKeywords.add("char");
- reservedKeywords.add("final");
- reservedKeywords.add("interface");
- reservedKeywords.add("static");
- reservedKeywords.add("void");
- reservedKeywords.add("class");
- reservedKeywords.add("finally");
- reservedKeywords.add("long");
- reservedKeywords.add("strictfp");
- reservedKeywords.add("volatile");
- reservedKeywords.add("const");
- reservedKeywords.add("float");
- reservedKeywords.add("native");
- reservedKeywords.add("super");
- reservedKeywords.add("while");
- }
-
- /**
- * Load a Java type from a given class loader.
- *
- * @param typeName maybe the source notation of a primitve, class name, array of both
- */
- public static Class loadJavaType(String typeName) throws ClassNotFoundException
- {
- return loadJavaType(typeName, null);
- }
-
- /**
- * Load a Java type from a given class loader.
- *
- * @param typeName maybe the source notation of a primitve, class name, array of both
- */
- public static Class loadJavaType(String typeName, ClassLoader classLoader) throws
ClassNotFoundException
- {
- if (classLoader == null)
- classLoader = Thread.currentThread().getContextClassLoader();
-
- Class javaType = primitiveNames.get(typeName);
- if (javaType == null)
- javaType = getArray(typeName, classLoader);
-
- if (javaType == null)
- javaType = classLoader.loadClass(typeName);
-
- return javaType;
- }
-
- /**
- * True if the given type name is the source notation of a primitive or array of
which.
- */
- public static boolean isPrimitive(String javaType)
- {
- return getPrimitiveType(javaType) != null;
- }
-
- /**
- * True if the given class is a primitive or array of which.
- */
- public static boolean isPrimitive(Class javaType)
- {
- return javaType.isPrimitive() || (javaType.isArray() &&
isPrimitive(javaType.getComponentType()));
- }
-
- public static Class getPrimitiveType(String javaType)
- {
- Class type = primitiveNames.get(javaType);
- if (type != null)
- return type;
-
- try
- {
- // null loader = primitive only
- type = getArray(javaType, null);
- }
- catch (ClassNotFoundException e)
- {
- // This will actually never be thrown since is null
- }
-
- return type;
- }
-
- private static Class getArray(String javaType, ClassLoader loader) throws
ClassNotFoundException
- {
- if (javaType.charAt(0) == '[')
- return getArrayFromJVMName(javaType, loader);
-
- if (javaType.endsWith("[]"))
- return getArrayFromSourceName(javaType, loader);
-
- return null;
- }
-
- private static Class getArrayFromJVMName(String javaType, ClassLoader loader) throws
ClassNotFoundException
- {
- Class componentType;
- int componentStart = javaType.lastIndexOf('[') + 1;
- switch (javaType.charAt(componentStart))
- {
- case 'I': componentType = int.class; break;
- case 'S': componentType = short.class; break;
- case 'Z': componentType = boolean.class; break;
- case 'B': componentType = byte.class; break;
- case 'J': componentType = long.class; break;
- case 'D': componentType = double.class; break;
- case 'F': componentType = float.class; break;
- case 'C': componentType = char.class; break;
- case 'L':
- if (loader == null)
- return null;
- String name = javaType.substring(componentStart + 1, javaType.length() - 1);
- componentType = loader.loadClass(name);
- break;
- default:
- throw new IllegalArgumentException("Invalid binary component for array:
" + javaType.charAt(componentStart));
- }
-
- // componentStart doubles as the number of '['s which is the number of
dimensions
- return Array.newInstance(componentType, new int[componentStart]).getClass();
- }
-
- private static Class getArrayFromSourceName(String javaType, ClassLoader loader)
throws ClassNotFoundException
- {
- int arrayStart = javaType.indexOf('[');
- String componentName = javaType.substring(0, arrayStart);
-
- Class componentType = primitiveNames.get(componentName);
- if (componentType == null)
- {
- if (loader == null)
- return null;
-
- componentType = loader.loadClass(componentName);
- }
-
- // [][][][] divided by 2
- int dimensions = (javaType.length() - arrayStart) >> 1;
-
- return Array.newInstance(componentType, new int[dimensions]).getClass();
- }
-
- /**
- * Get the corresponding primitive for a give wrapper type.
- * Also handles arrays of which.
- */
- public static Class getPrimitiveType(Class javaType)
- {
- if (javaType == Integer.class)
- return int.class;
- if (javaType == Short.class)
- return short.class;
- if (javaType == Boolean.class)
- return boolean.class;
- if (javaType == Byte.class)
- return byte.class;
- if (javaType == Long.class)
- return long.class;
- if (javaType == Double.class)
- return double.class;
- if (javaType == Float.class)
- return float.class;
- if (javaType == Character.class)
- return char.class;
-
- if (javaType == Integer[].class)
- return int[].class;
- if (javaType == Short[].class)
- return short[].class;
- if (javaType == Boolean[].class)
- return boolean[].class;
- if (javaType == Byte[].class)
- return byte[].class;
- if (javaType == Long[].class)
- return long[].class;
- if (javaType == Double[].class)
- return double[].class;
- if (javaType == Float[].class)
- return float[].class;
- if (javaType == Character[].class)
- return char[].class;
-
- if (javaType.isArray() && javaType.getComponentType().isArray())
- {
- Class compType = getPrimitiveType(javaType.getComponentType());
- return Array.newInstance(compType, 0).getClass();
- }
-
- return javaType;
- }
-
- /**
- * Converts an n-dimensional array of wrapper types to primitive types
- */
- public static Object getPrimitiveValueArray(Object value)
- {
- if (value == null)
- return null;
-
- Class javaType = value.getClass();
- if (javaType.isArray())
- {
- int length = Array.getLength(value);
- Object destArr =
Array.newInstance(getPrimitiveType(javaType.getComponentType()), length);
- for (int i = 0; i < length; i++)
- {
- Object srcObj = Array.get(value, i);
- Array.set(destArr, i, getPrimitiveValueArray(srcObj));
- }
- return destArr;
- }
-
- return value;
- }
-
- /**
- * Get the corresponding wrapper type for a give primitive.
- * Also handles arrays of which.
- */
- public static Class getWrapperType(Class javaType)
- {
- if (javaType == int.class)
- return Integer.class;
- if (javaType == short.class)
- return Short.class;
- if (javaType == boolean.class)
- return Boolean.class;
- if (javaType == byte.class)
- return Byte.class;
- if (javaType == long.class)
- return Long.class;
- if (javaType == double.class)
- return Double.class;
- if (javaType == float.class)
- return Float.class;
- if (javaType == char.class)
- return Character.class;
-
- if (javaType == int[].class)
- return Integer[].class;
- if (javaType == short[].class)
- return Short[].class;
- if (javaType == boolean[].class)
- return Boolean[].class;
- if (javaType == byte[].class)
- return Byte[].class;
- if (javaType == long[].class)
- return Long[].class;
- if (javaType == double[].class)
- return Double[].class;
- if (javaType == float[].class)
- return Float[].class;
- if (javaType == char[].class)
- return Character[].class;
-
- if (javaType.isArray() && javaType.getComponentType().isArray())
- {
- Class compType = getWrapperType(javaType.getComponentType());
- return Array.newInstance(compType, 0).getClass();
- }
-
- return javaType;
- }
-
- /**
- * Converts an n-dimensional array of primitive types to wrapper types
- */
- public static Object getWrapperValueArray(Object value)
- {
- if (value == null)
- return null;
-
- Class javaType = value.getClass();
- if (javaType.isArray())
- {
- int length = Array.getLength(value);
- Object destArr = Array.newInstance(getWrapperType(javaType.getComponentType()),
length);
- for (int i = 0; i < length; i++)
- {
- Object srcObj = Array.get(value, i);
- Array.set(destArr, i, getWrapperValueArray(srcObj));
- }
- return destArr;
- }
-
- return value;
- }
-
- public static Object syncArray(Object array, Class target)
- {
- return (JavaUtils.isPrimitive(target)) ? JavaUtils.getPrimitiveValueArray(array) :
JavaUtils.getWrapperValueArray(array);
- }
-
- /**
- * Return true if the dest class is assignable from the src.
- * Also handles arrays and primitives.
- */
- public static boolean isAssignableFrom(Class dest, Class src)
- {
- if (dest == null)
- throw new IllegalArgumentException("Destination class cannot be
null");
- if (src == null)
- throw new IllegalArgumentException("Source class cannot be null");
-
- boolean isAssignable = dest.isAssignableFrom(src);
- if (isAssignable == false && dest.getName().equals(src.getName()))
- {
- ClassLoader destLoader = dest.getClassLoader();
- ClassLoader srcLoader = src.getClassLoader();
- if(log.isDebugEnabled()) log.debug("Not assignable because of conflicting
class loaders:\ndstLoader=" + destLoader + "\nsrcLoader=" + srcLoader);
- }
-
- if (isAssignable == false && isPrimitive(dest))
- {
- dest = getWrapperType(dest);
- isAssignable = dest.isAssignableFrom(src);
- }
- if (isAssignable == false && isPrimitive(src))
- {
- src = getWrapperType(src);
- isAssignable = dest.isAssignableFrom(src);
- }
- return isAssignable;
- }
-
- public static String convertJVMNameToSourceName(String typeName, ClassLoader loader)
- {
- // TODO Don't use a ClassLoader for this, we need to just convert it
- try
- {
- Class javaType = loadJavaType(typeName, loader);
- typeName = getSourceName(javaType);
- }
- catch (Exception e)
- {
- }
-
- return typeName;
- }
-
- /**
- * Converts a JVM external name to a JVM signature name. An external name is
- * that which is returned from {@link Class#getName()} A signature name is
- * the name in class file format.
- * <p>
- * For example:
- * <p>
- * [java.lang.Object
- * <p>
- * becomes:
- * <p>
- * [Ljava/lang/Object;
- *
- * @param externalName
- * @return
- */
- public static String toSignature(String externalName)
- {
- if (externalName == null)
- return null;
-
- String ret = primitiveNameDescriptors.get(externalName);
- if (ret != null)
- return ret;
-
- ret = externalName.replace('.', '/');
- return (ret.charAt(0) == '[') ? ret : "L" + ret + ";";
- }
-
- public static String printArray(Object[] val)
- {
- if (val == null)
- return "null";
-
- StringBuilder out = new StringBuilder("[");
- for (int i = 0; i < val.length; i++)
- {
- if (i > 0)
- {
- out.append(",");
- }
- out.append(val[i].getClass().isArray() ? printArray((Object[])val[i]) :
val[i]);
- }
- return out.append("]").toString();
- }
-
- public static String getSourceName(Class type)
- {
- if (! type.isArray())
- return type.getName();
-
- String arrayNotation = "";
- Class component = type;
- while(component.isArray())
- {
- component = component.getComponentType();
- arrayNotation += "[]";
- }
-
- return component.getName() + arrayNotation;
- }
-
- public static String capitalize(String source)
- {
- if (source == null)
- return null;
-
- if (source.length() == 0)
- return source;
-
- if (Character.isUpperCase(source.charAt(0)))
- return source;
-
- char c = Character.toUpperCase(source.charAt(0));
-
- return c + source.substring(1);
- }
-
- public static boolean isLoaded(String className, ClassLoader loader)
- {
- try
- {
- loadJavaType(className, loader);
- }
- catch (ClassNotFoundException e)
- {
- return false;
- }
-
- return true;
- }
-
- public static String getPackageName(Class<?> clazz)
- {
- String fullName = clazz.getName();
- return fullName.substring(0, fullName.lastIndexOf("."));
- }
-
- public static boolean isReservedKeyword(String keyword)
- {
- return reservedKeywords.contains(keyword);
- }
-
- /**
- * Erases a type according to the JLS type erasure rules
- *
- * @param t type to erase
- * @return erased type
- */
- public static Class erasure(Type type)
- {
- if (type instanceof ParameterizedType)
- {
- return erasure(((ParameterizedType)type).getRawType());
- }
- if (type instanceof TypeVariable)
- {
- return erasure(((TypeVariable)type).getBounds()[0]);
- }
- if (type instanceof WildcardType)
- {
- return erasure(((WildcardType)type).getUpperBounds()[0]);
- }
- if (type instanceof GenericArrayType)
- {
- return
Array.newInstance(erasure(((GenericArrayType)type).getGenericComponentType()),
0).getClass();
- }
-
- // Only type left is class
- return (Class)type;
- }
-
- public static String[] getRawParameterTypeArguments(ParameterizedType type)
- {
- Type[] arguments = type.getActualTypeArguments();
- String[] ret = new String[arguments.length];
- for (int i = 0; i < arguments.length; i++)
- {
- Class raw = erasure(arguments[i]);
- ret[i] = raw.getName();
- }
-
- return ret;
- }
-
- /**
- * This method tests for retro translation by searching for a known problem where
Class
- * does not implement Type. If this is true, then code must never cast a Class to a
Type.
- *
- * @return true if we are in retro
- */
- public static boolean isRetro14()
- {
- return !(String.class instanceof java.lang.reflect.Type);
- }
-
- /**
- * Tests if this class loader is a JBoss RepositoryClassLoader
- *
- * @param loader
- * @return
- */
- public static boolean isJBossRepositoryClassLoader(ClassLoader loader)
- {
- Class clazz = loader.getClass();
- while (!clazz.getName().startsWith("java"))
- {
- if
("org.jboss.mx.loading.RepositoryClassLoader".equals(clazz.getName()))
- return true;
- clazz = clazz.getSuperclass();
- }
-
- return false;
- }
-
- /**
- * Clears black lists on a JBoss RepositoryClassLoader. This is somewhat of a hack,
and
- * could be replaced with an integration module. This is needed when the following
order of
- * events occur.
- *
- * <ol>
- * <li>loadClass() returns not found</li>
- * <li>Some call to defineClass()</li>
- * <ol>
- *
- * The CNFE triggers a black list addition, which cause the class never again to be
found.
- *
- * @param loader the loader to clear black lists for
- */
- public static void clearBlacklists(ClassLoader loader)
- {
- if (isJBossRepositoryClassLoader(loader))
- {
- try
- {
- loader.getClass().getMethod("clearBlacklists").invoke(loader);
- }
- catch (Exception e)
- {
- if(log.isDebugEnabled()) log.debug("Could not clear blacklists on "
+ loader);
- }
- }
- }
-}
\ No newline at end of file
Modified:
branches/tdiesler/trunk/jbossws/src/test/java/org/jboss/test/ws/jaxws/samples/context/EndpointNoInjectEJB.java
===================================================================
---
branches/tdiesler/trunk/jbossws/src/test/java/org/jboss/test/ws/jaxws/samples/context/EndpointNoInjectEJB.java 2007-05-16
22:34:28 UTC (rev 3114)
+++
branches/tdiesler/trunk/jbossws/src/test/java/org/jboss/test/ws/jaxws/samples/context/EndpointNoInjectEJB.java 2007-05-16
22:47:19 UTC (rev 3115)
@@ -37,9 +37,9 @@
import org.jboss.annotation.security.SecurityDomain;
import org.jboss.ws.annotation.WebContext;
import org.jboss.ws.core.CommonMessageContext;
-import org.jboss.ws.core.jaxws.WebServiceContextEJB;
import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
import org.jboss.ws.core.soap.MessageContextAssociation;
+import org.jboss.ws.integration.invocation.WebServiceContextEJB;
@WebService(name = "TestEndpoint", targetNamespace =
"http://org.jboss.ws/jaxws/context")
@SOAPBinding(style = Style.RPC)