Author: sergeyb
Date: 2010-06-30 12:15:47 -0400 (Wed, 30 Jun 2010)
New Revision: 12552
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/ServletHelper.java
stack/cxf/trunk/modules/testsuite/test-excludes-jboss501.txt
stack/cxf/trunk/modules/testsuite/test-excludes-jboss600.txt
stack/cxf/trunk/modules/testsuite/test-excludes-jboss601.txt
Log:
[JBWS-2596] Initial support for EJB/Resources injection, enabling JBWS-2634 framework
test
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java 2010-06-30
09:44:32 UTC (rev 12551)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java 2010-06-30
16:15:47 UTC (rev 12552)
@@ -87,4 +87,6 @@
{
ServletHelper.callRequestHandler(req, res, getServletContext(), getBus(),
endpoint);
}
+
+
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2010-06-30
09:44:32 UTC (rev 12551)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2010-06-30
16:15:47 UTC (rev 12552)
@@ -21,6 +21,8 @@
*/
package org.jboss.wsf.stack.cxf.configuration;
+import java.util.List;
+
import org.apache.cxf.Bus;
import org.apache.cxf.binding.soap.SoapTransportFactory;
import org.apache.cxf.configuration.Configurer;
@@ -30,6 +32,7 @@
import org.apache.cxf.transport.DestinationFactoryManager;
import org.jboss.ws.Constants;
import org.jboss.wsf.spi.binding.BindingCustomization;
+import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
import org.jboss.wsf.stack.cxf.interceptor.EndpointAssociationInterceptor;
@@ -89,9 +92,11 @@
*
* @param customization The binding customization to set in the configurer, if any
* @param wsdlPublisher The wsdl file publisher to set in the configurer, if any
+ * @param depEndpoints The list of deployment endpoints
* @return The new jbossws cxf configurer
*/
- public abstract Configurer createServerConfigurer(BindingCustomization customization,
WSDLFilePublisher wsdlPublisher);
+ public abstract Configurer createServerConfigurer(BindingCustomization customization,
WSDLFilePublisher wsdlPublisher,
+ List<Endpoint> depEndpoints);
protected static void setInterceptors(Bus bus)
{
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2010-06-30
09:44:32 UTC (rev 12551)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2010-06-30
16:15:47 UTC (rev 12552)
@@ -21,7 +21,7 @@
*/
package org.jboss.wsf.stack.cxf.configuration;
-import java.io.IOException;
+import java.util.List;
import javax.xml.ws.soap.SOAPBinding;
@@ -34,8 +34,9 @@
import org.apache.cxf.transport.DestinationFactory;
import org.apache.cxf.transport.servlet.ServletTransportFactory;
import org.jboss.wsf.spi.binding.BindingCustomization;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.stack.cxf.client.configuration.JBossWSNonSpringBusFactory;
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSNonSpringConfigurer;
-import org.jboss.wsf.stack.cxf.client.configuration.JBossWSNonSpringBusFactory;
import org.jboss.wsf.stack.cxf.deployment.EndpointImpl;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
import org.jboss.wsf.stack.cxf.metadata.services.DDBeans;
@@ -118,11 +119,13 @@
}
@Override
- public Configurer createServerConfigurer(BindingCustomization customization,
WSDLFilePublisher wsdlPublisher)
+ public Configurer createServerConfigurer(BindingCustomization customization,
WSDLFilePublisher wsdlPublisher,
+ List<Endpoint> depEndpoints)
{
ServerBeanCustomizer customizer = new ServerBeanCustomizer();
customizer.setBindingCustomization(customization);
customizer.setWsdlPublisher(wsdlPublisher);
+ customizer.setDeploymentEndpoints(depEndpoints);
return new JBossWSNonSpringConfigurer(customizer);
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java 2010-06-30
09:44:32 UTC (rev 12551)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java 2010-06-30
16:15:47 UTC (rev 12552)
@@ -21,6 +21,11 @@
*/
package org.jboss.wsf.stack.cxf.configuration;
+import java.util.List;
+
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.stack.cxf.AbstractInvoker;
import org.jboss.wsf.stack.cxf.client.configuration.BeanCustomizer;
import org.jboss.wsf.stack.cxf.deployment.EndpointImpl;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
@@ -33,13 +38,33 @@
public class ServerBeanCustomizer extends BeanCustomizer
{
private WSDLFilePublisher wsdlPublisher;
-
+ private List<Endpoint> depEndpoints;
+
@Override
public void customize(Object beanInstance)
{
if (beanInstance instanceof EndpointImpl)
{
configureEndpoint((EndpointImpl)beanInstance);
+ }
+ if (beanInstance instanceof ServerFactoryBean)
+ {
+ ServerFactoryBean factory = (ServerFactoryBean)beanInstance;
+
+ if (factory.getInvoker() instanceof AbstractInvoker)
+ {
+ ((AbstractInvoker)factory.getInvoker()).setTargetBean(factory.getServiceBean());
+ }
+ if (depEndpoints != null)
+ {
+ for (Endpoint depEndpoint : depEndpoints)
+ {
+ if (depEndpoint.getTargetBeanClass() == factory.getServiceBean().getClass())
+ {
+ depEndpoint.addAttachment(ServerFactoryBean.class, factory);
+ }
+ }
+ }
}
super.customize(beanInstance);
}
@@ -58,4 +83,9 @@
this.wsdlPublisher = wsdlPublisher;
}
+ public void setDeploymentEndpoints(List<Endpoint> endpoints)
+ {
+ this.depEndpoints = endpoints;
+ }
+
}
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2010-06-30
09:44:32 UTC (rev 12551)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2010-06-30
16:15:47 UTC (rev 12552)
@@ -36,6 +36,7 @@
import org.apache.cxf.transport.servlet.ServletTransportFactory;
import org.jboss.logging.Logger;
import org.jboss.wsf.spi.binding.BindingCustomization;
+import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
import org.jboss.wsf.stack.cxf.spring.handler.NamespaceHandlerResolver;
@@ -131,12 +132,14 @@
}
@Override
- public Configurer createServerConfigurer(BindingCustomization customization,
WSDLFilePublisher wsdlPublisher)
+ public Configurer createServerConfigurer(BindingCustomization customization,
WSDLFilePublisher wsdlPublisher,
+ List<Endpoint> depEndpoints)
{
ApplicationContext ctx = bus.getExtension(BusApplicationContext.class);
ServerBeanCustomizer customizer = new ServerBeanCustomizer();
customizer.setBindingCustomization(customization);
customizer.setWsdlPublisher(wsdlPublisher);
+ customizer.setDeploymentEndpoints(depEndpoints);
JBossWSServerSpringConfigurer serverConfigurer = new
JBossWSServerSpringConfigurer(ctx);
serverConfigurer.setCustomizer(customizer);
return serverConfigurer;
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2010-06-30
09:44:32 UTC (rev 12551)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2010-06-30
16:15:47 UTC (rev 12552)
@@ -80,7 +80,8 @@
try
{
holder = new SpringBusHolder(cxfServletURL,
deploymentResolver.resolve(jbosswsCxfXml));
- Configurer configurer =
holder.createServerConfigurer(dep.getAttachment(BindingCustomization.class), new
WSDLFilePublisher(aDep));
+ Configurer configurer =
holder.createServerConfigurer(dep.getAttachment(BindingCustomization.class), new
WSDLFilePublisher(aDep),
+
dep.getService().getEndpoints());
holder.configure(new SoapTransportFactoryExt(), resolver, configurer);
}
catch (Exception e)
@@ -92,7 +93,8 @@
{
DDBeans metadata = dep.getAttachment(DDBeans.class);
holder = new NonSpringBusHolder(metadata);
- Configurer configurer =
holder.createServerConfigurer(dep.getAttachment(BindingCustomization.class), new
WSDLFilePublisher(aDep));
+ Configurer configurer =
holder.createServerConfigurer(dep.getAttachment(BindingCustomization.class), new
WSDLFilePublisher(aDep),
+
dep.getService().getEndpoints());
holder.configure(new SoapTransportFactoryExt(), resolver, configurer);
}
dep.addAttachment(BusHolder.class, holder);
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/ServletHelper.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/ServletHelper.java 2010-06-30
09:44:32 UTC (rev 12551)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/ServletHelper.java 2010-06-30
16:15:47 UTC (rev 12552)
@@ -23,20 +23,26 @@
import java.io.IOException;
import java.lang.reflect.Method;
+import java.util.List;
import javax.management.ObjectName;
+import javax.naming.Context;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.Handler;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
import org.apache.cxf.management.InstrumentationManager;
import org.apache.cxf.management.counters.CounterRepository;
import org.jboss.wsf.common.ObjectNameFactory;
+import org.jboss.wsf.common.injection.InjectionHelper;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.deployment.Endpoint;
@@ -44,6 +50,7 @@
import org.jboss.wsf.spi.invocation.RequestHandler;
import org.jboss.wsf.spi.management.EndpointRegistry;
import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+import org.jboss.wsf.spi.metadata.injection.InjectionsMetaData;
import org.jboss.wsf.stack.cxf.management.InstrumentationManagerExtImpl;
/**
@@ -92,9 +99,37 @@
throw new WebServiceException("Cannot obtain endpoint for: " +
oname);
}
+ //Inject the EJB and JNDI resources if possible
+ injectServiceAndHandlerResources(endpoint);
+
+
return endpoint;
}
+ private static void injectServiceAndHandlerResources(Endpoint endpoint)
+ {
+ ServerFactoryBean factory = endpoint.getAttachment(ServerFactoryBean.class);
+ if (factory != null)
+ {
+ InjectionsMetaData metadata = endpoint.getAttachment(InjectionsMetaData.class);
+ Context jndiContext = endpoint.getJNDIContext();
+ if (factory.getServiceBean() != null)
+ {
+ InjectionHelper.injectResources(factory.getServiceBean(), metadata,
jndiContext);
+ InjectionHelper.callPostConstructMethod(factory.getServiceBean());
+ }
+ List<Handler> chain =
((JaxWsEndpointImpl)factory.getServer().getEndpoint()).getJaxwsBinding().getHandlerChain();
+ if (chain != null)
+ {
+ for (Handler handler : chain)
+ {
+ InjectionHelper.injectResources(handler, metadata, jndiContext);
+ InjectionHelper.callPostConstructMethod(handler);
+ }
+ }
+ }
+ }
+
public static void callRequestHandler(HttpServletRequest req, HttpServletResponse res,
ServletContext ctx, Bus bus, Endpoint endpoint) throws ServletException
{
try
Modified: stack/cxf/trunk/modules/testsuite/test-excludes-jboss501.txt
===================================================================
--- stack/cxf/trunk/modules/testsuite/test-excludes-jboss501.txt 2010-06-30 09:44:32 UTC
(rev 12551)
+++ stack/cxf/trunk/modules/testsuite/test-excludes-jboss501.txt 2010-06-30 16:15:47 UTC
(rev 12552)
@@ -22,7 +22,6 @@
# [JBWS-2596] Resource injection in jaxws endpoints and handlers
org/jboss/test/ws/jaxws/jbws2074/**
-org/jboss/test/ws/jaxws/jbws2634/**
# [JBWS-2561] XOP request not properly inlined
org/jboss/test/ws/jaxws/samples/xop/doclit/XOPHandlerTestCase.*
Modified: stack/cxf/trunk/modules/testsuite/test-excludes-jboss600.txt
===================================================================
--- stack/cxf/trunk/modules/testsuite/test-excludes-jboss600.txt 2010-06-30 09:44:32 UTC
(rev 12551)
+++ stack/cxf/trunk/modules/testsuite/test-excludes-jboss600.txt 2010-06-30 16:15:47 UTC
(rev 12552)
@@ -22,7 +22,6 @@
# [JBWS-2596] Resource injection in jaxws endpoints and handlers
org/jboss/test/ws/jaxws/jbws2074/**
-org/jboss/test/ws/jaxws/jbws2634/**
# [JBWS-2561] XOP request not properly inlined
org/jboss/test/ws/jaxws/samples/xop/doclit/XOPHandlerTestCase.*
Modified: stack/cxf/trunk/modules/testsuite/test-excludes-jboss601.txt
===================================================================
--- stack/cxf/trunk/modules/testsuite/test-excludes-jboss601.txt 2010-06-30 09:44:32 UTC
(rev 12551)
+++ stack/cxf/trunk/modules/testsuite/test-excludes-jboss601.txt 2010-06-30 16:15:47 UTC
(rev 12552)
@@ -22,7 +22,6 @@
# [JBWS-2596] Resource injection in jaxws endpoints and handlers
org/jboss/test/ws/jaxws/jbws2074/**
-org/jboss/test/ws/jaxws/jbws2634/**
# [JBWS-2561] XOP request not properly inlined
org/jboss/test/ws/jaxws/samples/xop/doclit/XOPHandlerTestCase.*