Author: alessio.soldano(a)jboss.com
Date: 2010-03-26 13:59:21 -0400 (Fri, 26 Mar 2010)
New Revision: 11872
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/BusHolder.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/BusDeploymentAspect.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/SecurityActions.java
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/DescriptorDeploymentAspect.java
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as5.xml
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as6.xml
Log:
[JBWS-2974] Refactoring CXF Bus creation and configuration + adding a deployment aspect
for eargerly loading the bus during deploy when required
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/BusHolder.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/BusHolder.java
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/BusHolder.java 2010-03-26
17:59:21 UTC (rev 11872)
@@ -0,0 +1,229 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.wsf.stack.cxf.client.configuration;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.binding.soap.SoapTransportFactory;
+import org.apache.cxf.bus.spring.BusApplicationContext;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.resource.ResourceManager;
+import org.apache.cxf.resource.ResourceResolver;
+import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.transport.servlet.ServletTransportFactory;
+import org.jboss.logging.Logger;
+import org.jboss.ws.Constants;
+import org.jboss.wsf.spi.binding.BindingCustomization;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.InputStreamResource;
+
+/**
+ * An wrapper of the Bus for performing most of the configurations required on it by
JBossWS
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 25-Mar-2010
+ *
+ */
+public class BusHolder
+{
+ private static final Logger log = Logger.getLogger(BusHolder.class);
+ public static final String PARAM_CXF_BEANS_URL = "jbossws.cxf.beans.url";
+ private boolean configured = false;
+ protected BusApplicationContext ctx ;
+ protected List<GenericApplicationContext> additionalCtx = new
LinkedList<GenericApplicationContext>();
+ protected Bus bus;
+
+ /**
+ * Private constructor
+ */
+ private BusHolder()
+ {
+ //NOP
+ }
+
+ /**
+ * Creates a new BusHolder instance; a new Bus is created using the
+ * provided location for loading additional configurations
+ *
+ * @param location
+ * @return
+ */
+ public static BusHolder create(URL location)
+ {
+ BusHolder holder = new BusHolder();
+ holder.createBus(location);
+ return holder;
+ }
+
+ /**
+ * Creates a new BusHolder instance using the provided Bus
+ *
+ * @param bus
+ * @return
+ */
+ public static BusHolder create(Bus bus)
+ {
+ BusHolder holder = new BusHolder();
+ holder.setBus(bus);
+ holder.setContext(bus.getExtension(BusApplicationContext.class));
+ return holder;
+ }
+
+ /**
+ * Update the Bus held by the this instance using the provided parameters.
+ * This basically prepares the bus for being used with JBossWS.
+ *
+ * @param jbossCxfXml The location of the jboss-cxf.xml configuration file
+ * @param soapTransportFactory The SoapTransportFactory to configure, if any
+ * @param resolver The ResourceResolver to configure, if any
+ * @param customization The BindingCustomization to configure, if any
+ * @throws IOException Throws IOException if the jboss-cxf.xml file
can't be read
+ */
+ public void configure(URL jbossCxfXml, SoapTransportFactory soapTransportFactory,
ResourceResolver resolver, BindingCustomization customization) throws IOException
+ {
+ if (configured)
+ {
+ throw new IllegalStateException("Underlying bus is already configured for
JBossWS use!");
+ }
+ setSoapTransportFactory(bus, soapTransportFactory);
+ setResourceResolver(bus, resolver);
+ setBindingCustomization(bus, customization);
+ if (jbossCxfXml != null)
+ {
+ additionalCtx.add(loadAdditionalConfig(ctx, jbossCxfXml));
+ }
+ configured = true;
+ }
+
+ /**
+ * Performs close operations (currently implies destroying additional contexts)
+ *
+ */
+ public void close()
+ {
+ for (GenericApplicationContext gac : additionalCtx)
+ {
+ gac.destroy();
+ }
+ }
+
+ /**
+ * Creates the Bus using a SpringBusFactory with no specific Spring application
context.
+ * Then loads additional configurations from the provided location
+ *
+ * @param location
+ * @return
+ */
+ protected void createBus(URL location)
+ {
+ bus = new SpringBusFactory().createBus();
+ ctx = bus.getExtension(BusApplicationContext.class);
+ //Load additional configurations from cxf-servlet.xml
+ if (location != null)
+ {
+ try
+ {
+ additionalCtx.add(loadAdditionalConfig(ctx, location));
+ }
+ catch (IOException e)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Could not load additional config from location: " +
location, e);
+ }
+ }
+ //Force servlet transport to prevent CXF from using Jetty as a transport
+ DestinationFactory factory = new ServletTransportFactory(bus);
+ for (String s : factory.getTransportIds()) {
+ registerTransport(factory, s);
+ }
+ }
+
+ protected static void setResourceResolver(Bus bus, ResourceResolver resourceResolver)
+ {
+ if (resourceResolver != null)
+ {
+ bus.getExtension(ResourceManager.class).addResourceResolver(resourceResolver);
+ }
+ }
+
+ protected static void setSoapTransportFactory(Bus bus, SoapTransportFactory factory)
+ {
+ if (factory != null)
+ {
+ DestinationFactoryManager dfm =
bus.getExtension(DestinationFactoryManager.class);
+ factory.setBus(bus);
+ dfm.registerDestinationFactory(Constants.NS_SOAP11, factory);
+ dfm.registerDestinationFactory(Constants.NS_SOAP12, factory);
+ }
+ }
+
+ protected static void setBindingCustomization(Bus bus, BindingCustomization
customization)
+ {
+ if (customization != null) {
+ Configurer prev = bus.getExtension(Configurer.class);
+ JBossWSCXFConfigurer jbosswsConfigurer = (prev instanceof JBossWSCXFConfigurer)
? (JBossWSCXFConfigurer)prev : new JBossWSCXFConfigurer(prev);
+ jbosswsConfigurer.setBindingCustomization(customization);
+ bus.setExtension(jbosswsConfigurer, Configurer.class);
+ }
+ }
+
+ protected static GenericApplicationContext loadAdditionalConfig(ApplicationContext
ctx, URL locationUrl) throws IOException
+ {
+ if (locationUrl == null) throw new IllegalArgumentException("Cannot load
additional config from null location!");
+ InputStream is = locationUrl.openStream();
+ GenericApplicationContext childCtx = new GenericApplicationContext(ctx);
+ XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(childCtx);
+ reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
+ reader.loadBeanDefinitions(new InputStreamResource(is));
+ childCtx.refresh();
+ return childCtx;
+ }
+
+ private void registerTransport(DestinationFactory factory, String namespace)
+ {
+
bus.getExtension(DestinationFactoryManager.class).registerDestinationFactory(namespace,
factory);
+ }
+
+ public Bus getBus()
+ {
+ return bus;
+ }
+
+ private void setBus(Bus bus)
+ {
+ this.bus = bus;
+ }
+
+ private void setContext(BusApplicationContext ctx)
+ {
+ this.ctx = ctx;
+ }
+}
Property changes on:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/BusHolder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/BusDeploymentAspect.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/BusDeploymentAspect.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/BusDeploymentAspect.java 2010-03-26
17:59:21 UTC (rev 11872)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.wsf.stack.cxf;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+
+import org.apache.cxf.BusFactory;
+import org.jboss.ws.Constants;
+import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
+import org.jboss.wsf.common.integration.WSConstants;
+import org.jboss.wsf.spi.binding.BindingCustomization;
+import org.jboss.wsf.spi.deployment.ArchiveDeployment;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.ResourceResolver;
+import org.jboss.wsf.stack.cxf.client.configuration.BusHolder;
+
+/**
+ * A deployment aspect that creates the CXF Bus early and attaches it to the endpoints
(wrapped in a BusHolder)
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 25-Mar-2010
+ */
+public class BusDeploymentAspect extends AbstractDeploymentAspect
+{
+ @SuppressWarnings("unchecked")
+ @Override
+ public void start(Deployment dep)
+ {
+ if (Constants.LAZY_LOAD_CXF_BUS)
+ return;
+
+ log.debug("Lazy load of CXF bus disabled, loading bus during
deployment...");
+ BusHolder holder;
+ ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
+ try
+ {
+ //set the runtime classloader (pointing to the deployment unit) to allow CXF
accessing to the classes
+ SecurityActions.setContextClassLoader(dep.getRuntimeClassLoader());
+
+ ResourceResolver deploymentResolver =
((ArchiveDeployment)dep).getResourceResolver();
+
+ URL cxfServletURL = null;
+ try
+ {
+ cxfServletURL =
deploymentResolver.resolve("WEB-INF/cxf-servlet.xml");
+ }
+ catch (IOException e)
+ {
+ } //ignore, cxf-servlet.xml is optional
+
+ holder = BusHolder.create(cxfServletURL);
+
+ Map<String, String> contextParams = (Map<String,
String>)dep.getProperty(WSConstants.STACK_CONTEXT_PARAMS);
+ try
+ {
+ URL jbossCxfXml =
deploymentResolver.resolve(contextParams.get(BusHolder.PARAM_CXF_BEANS_URL));
+ org.apache.cxf.resource.ResourceResolver resolver = new
JBossWSResourceResolver(deploymentResolver);
+ BindingCustomization customizations =
dep.getAttachment(BindingCustomization.class);
+ holder.configure(jbossCxfXml, new SoapTransportFactoryExt(), resolver,
customizations);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e); //re-throw, jboss-cxf.xml is required
+ }
+ }
+ finally
+ {
+ //clean threadlocals in BusFactory and restore the original classloader
+ BusFactory.setDefaultBus(null);
+ BusFactory.setThreadDefaultBus(null);
+ SecurityActions.setContextClassLoader(origClassLoader);
+ }
+
+ for (Endpoint endpoint : dep.getService().getEndpoints())
+ {
+ endpoint.addAttachment(BusHolder.class, holder);
+ }
+ dep.addAttachment(BusHolder.class, holder);
+ }
+
+ @Override
+ public void stop(Deployment dep)
+ {
+ for (Endpoint endpoint : dep.getService().getEndpoints())
+ {
+ BusHolder holder = endpoint.removeAttachment(BusHolder.class);
+ if (holder != null)
+ {
+ holder.close();
+ }
+ }
+ BusHolder holder = dep.removeAttachment(BusHolder.class);
+ if (holder != null)
+ {
+ holder.close();
+ }
+ }
+}
Property changes on:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/BusDeploymentAspect.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
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-03-26
17:23:50 UTC (rev 11871)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java 2010-03-26
17:59:21 UTC (rev 11872)
@@ -22,8 +22,6 @@
package org.jboss.wsf.stack.cxf;
import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URL;
@@ -37,20 +35,12 @@
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
-import org.apache.cxf.binding.soap.SoapTransportFactory;
-import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.endpoint.ServerRegistry;
-import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
-import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
import org.apache.cxf.management.InstrumentationManager;
import org.apache.cxf.management.counters.CounterRepository;
import org.apache.cxf.resource.ResourceManager;
import org.apache.cxf.resource.ResourceResolver;
-import org.apache.cxf.transport.DestinationFactoryManager;
-import org.apache.cxf.transport.jms.AddressType;
-import org.apache.cxf.transport.jms.JMSDestination;
import org.apache.cxf.transport.servlet.CXFServlet;
+import org.apache.cxf.transport.servlet.ServletContextResourceResolver;
import org.apache.cxf.transport.servlet.ServletController;
import org.apache.cxf.transport.servlet.ServletTransportFactory;
import org.jboss.logging.Logger;
@@ -64,12 +54,9 @@
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.stack.cxf.client.configuration.JBossWSCXFConfigurer;
+import org.jboss.wsf.stack.cxf.client.configuration.BusHolder;
import org.jboss.wsf.stack.cxf.management.InstrumentationManagerExtImpl;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.GenericApplicationContext;
-import org.springframework.core.io.InputStreamResource;
/**
* An extension to the CXF servlet
@@ -79,15 +66,12 @@
*/
public class CXFServletExt extends CXFServlet
{
- public static final String PARAM_CXF_BEANS_URL = "jbossws.cxf.beans.url";
+ private static final Logger log = Logger.getLogger(CXFServletExt.class);
public static final String ENABLE_CXF_MANAGEMENT = "enable.cxf.management";
- public static final String JMS_NS = "http://cxf.apache.org/transports/jms";
- private static Logger log = Logger.getLogger(CXFServletExt.class);
-
protected Endpoint endpoint;
protected EndpointRegistry epRegistry;
- protected GenericApplicationContext childCtx;
+ protected BusHolder lazyLoadedBusHolder;
@Override
public void init(ServletConfig servletConfig) throws ServletException
@@ -105,31 +89,73 @@
@Override
public void loadBus(ServletConfig servletConfig) throws ServletException
{
- super.loadBus(servletConfig);
-
+ //Init the Endpoint
+ initEndpoint(servletConfig);
+
ServletContext svCtx = getServletContext();
- ApplicationContext appCtx =
(ApplicationContext)svCtx.getAttribute("org.springframework.web.context.WebApplicationContext.ROOT");
-
- Bus bus = getBus();
-
+ if (isBusLoadRequired(svCtx))
+ {
+ //reload bus using CXF servlet
+ lazyLoadBus(servletConfig);
+ }
+ else
+ {
+ //keep the bus created during deployment and update it with the information
coming from the servlet config
+ updateAvailableBusWithServletInfo(servletConfig);
+ }
+
//register the InstrumentManagementImpl
+ //TODO!! remove reflection use inside this by providing proper hook in CXF and move
this configuration to BusHolder
if (svCtx.getInitParameter(ENABLE_CXF_MANAGEMENT) != null &&
"true".equalsIgnoreCase((String)svCtx.getInitParameter(ENABLE_CXF_MANAGEMENT)))
{
registerInstrumentManger(bus);
}
-
- //Install our SoapTransportFactory to allow for proper soap address rewrite
- DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
- SoapTransportFactory factory = new SoapTransportFactoryExt();
- factory.setBus(bus);
- dfm.registerDestinationFactory(Constants.NS_SOAP11, factory);
- dfm.registerDestinationFactory(Constants.NS_SOAP12, factory);
-
- //Init the Endpoint
- initEndpoint(servletConfig);
-
- //Load additional configurations
- loadAdditionalConfigExt(appCtx, servletConfig);
}
+
+ private static boolean isBusLoadRequired(ServletContext svCtx)
+ {
+ boolean result = Constants.LAZY_LOAD_CXF_BUS;
+ result = result || (ApplicationContext)svCtx.getAttribute("interface
org.springframework.web.context.WebApplicationContext.ROOT") != null;
+ result = result ||
(ApplicationContext)svCtx.getAttribute("org.springframework.web.context.WebApplicationContext.ROOT")
!= null;
+ return result;
+ }
+
+ private void lazyLoadBus(ServletConfig servletConfig) throws ServletException
+ {
+ log.debug("Loading Bus through CXF servlet...");
+ super.loadBus(servletConfig);
+ //set the controller in the servlet context now that the bus has been configured in
the servlet
+ servletConfig.getServletContext().setAttribute(ServletController.class.getName(),
getController());
+ //recreate holder from the new bus
+ lazyLoadedBusHolder = BusHolder.create(getBus());
+ //configure bus for jbossws use
+ String jbossCxfXml =
servletConfig.getServletContext().getInitParameter(BusHolder.PARAM_CXF_BEANS_URL);
+ try
+ {
+ ResourceResolver resolver = endpoint.getAttachment(ResourceResolver.class);
+ BindingCustomization customizations =
endpoint.getAttachment(BindingCustomization.class);
+ lazyLoadedBusHolder.configure(new URL(jbossCxfXml), new
SoapTransportFactoryExt(), resolver, customizations);
+ }
+ catch (IOException e)
+ {
+ throw new ServletException("Error while configuring bus for JBossWS
use", e);
+ }
+ }
+
+ private void updateAvailableBusWithServletInfo(ServletConfig servletConfig)
+ {
+ BusHolder holder = endpoint.getAttachment(BusHolder.class);
+ //set the bus from deployment into the CXF servlet and assign it to the current
thread
+ bus = holder.getBus();
+ BusFactory.possiblySetDefaultBus(bus);
+ //update the resource manager adding the ServletContextResourceResolver that was to
be added by CXF servlet
+ ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
+ resourceManager.addResourceResolver(new
ServletContextResourceResolver(servletConfig.getServletContext()));
+ replaceDestinationFactory();
+ //set up the ServletController as the CXF servlet would have done
+ controller = createServletController(servletConfig);
+ //set the controller in the servlet context now that the bus has been configured in
the servlet
+ servletConfig.getServletContext().setAttribute(ServletController.class.getName(),
getController());
+ }
private void initEndpoint(ServletConfig servletConfig)
{
@@ -139,50 +165,8 @@
ServletContext context = servletConfig.getServletContext();
String contextPath = context.getContextPath();
endpoint = initServiceEndpoint(contextPath);
-
- //Install the JBossWS resource resolver
- ResourceResolver resourceResolver =
endpoint.getAttachment(ResourceResolver.class);
- if (resourceResolver != null)
- {
- bus.getExtension(ResourceManager.class).addResourceResolver(resourceResolver);
- }
-
- //Add customization check to use default CXF configurer
- BindingCustomization customization =
endpoint.getAttachment(BindingCustomization.class);
- if (customization != null) {
- //Add extension to configure server beans according to JBossWS customizations
- JBossWSCXFConfigurer jbosswsConfigurer = new
JBossWSCXFConfigurer(bus.getExtension(Configurer.class));
-
jbosswsConfigurer.setBindingCustomization(endpoint.getAttachment(BindingCustomization.class));
- bus.setExtension(jbosswsConfigurer, Configurer.class);
- }
- context.setAttribute(ServletController.class.getName(), getController());
}
- private void loadAdditionalConfigExt(ApplicationContext ctx, ServletConfig
servletConfig) throws ServletException
- {
- //Load configuration
- String location =
servletConfig.getServletContext().getInitParameter(PARAM_CXF_BEANS_URL);
- if (location != null)
- {
- InputStream is;
- try
- {
- is = new URL(location).openStream();
- }
- catch (IOException e)
- {
- throw new ServletException(e);
- }
-
- childCtx = new GenericApplicationContext(ctx);
- XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(childCtx);
- reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
- reader.loadBeanDefinitions(new InputStreamResource(is, location));
-
- childCtx.refresh();
- }
- }
-
@Override
protected void invoke(HttpServletRequest req, HttpServletResponse res) throws
ServletException
{
@@ -204,15 +188,6 @@
}
}
- @Override
- public void destroy()
- {
- if (childCtx != null)
- childCtx.destroy();
-
- super.destroy();
- }
-
/** Initialize the service endpoint
*/
private Endpoint initServiceEndpoint(String contextPath)
@@ -243,6 +218,16 @@
return endpoint;
}
+ @Override
+ public void destroy()
+ {
+ if (lazyLoadedBusHolder != null)
+ {
+ lazyLoadedBusHolder.close();
+ }
+ super.destroy();
+ }
+
private void registerInstrumentManger(Bus bus) throws ServletException
{
InstrumentationManagerExtImpl instrumentationManagerImpl = new
InstrumentationManagerExtImpl();
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/DescriptorDeploymentAspect.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/DescriptorDeploymentAspect.java 2010-03-26
17:23:50 UTC (rev 11871)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/DescriptorDeploymentAspect.java 2010-03-26
17:59:21 UTC (rev 11872)
@@ -37,6 +37,7 @@
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
+import org.jboss.wsf.stack.cxf.client.configuration.BusHolder;
import org.jboss.wsf.stack.cxf.metadata.services.DDBeans;
import org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint;
@@ -214,7 +215,7 @@
dep.setProperty(WSConstants.STACK_CONTEXT_PARAMS, contextParams);
}
// put cxf config URL to the property map
- contextParams.put(CXFServletExt.PARAM_CXF_BEANS_URL, cxfURL.toExternalForm());
+ contextParams.put(BusHolder.PARAM_CXF_BEANS_URL, cxfURL.toExternalForm());
}
private static boolean isMtomEnabled(Class<?> beanClass)
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/SecurityActions.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/SecurityActions.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/SecurityActions.java 2010-03-26
17:59:21 UTC (rev 11872)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.wsf.stack.cxf;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 26-Mar-2010
+ *
+ */
+class SecurityActions
+{
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ /**
+ * Set context classloader.
+ *
+ * @param classLoader the classloader
+ */
+ static void setContextClassLoader(final ClassLoader classLoader)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return null;
+ }
+ });
+ }
+ }
+
+}
Property changes on:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as5.xml
===================================================================
---
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as5.xml 2010-03-26
17:23:50 UTC (rev 11871)
+++
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as5.xml 2010-03-26
17:59:21 UTC (rev 11872)
@@ -75,5 +75,11 @@
<property name="provides">JAXBIntros</property>
<property name="relativeOrder">20</property> <!--
[JBDEPLOY-201] workaround -->
</bean>
+
+ <bean name="WSCXFBusDeploymentAspect"
class="org.jboss.wsf.stack.cxf.BusDeploymentAspect">
+ <property name="provides">BusHolder</property>
+ <property
name="requires">ResourceResolver,StackDescriptor</property>
+ <property name="relativeOrder">24</property> <!--
[JBDEPLOY-201] workaround -->
+ </bean>
</deployment>
Modified: stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as6.xml
===================================================================
---
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as6.xml 2010-03-26
17:23:50 UTC (rev 11871)
+++
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as6.xml 2010-03-26
17:59:21 UTC (rev 11872)
@@ -75,5 +75,11 @@
<property name="provides">JAXBIntros</property>
<property name="forJaxRpc">false</property>
</bean>
+
+ <bean name="WSCXFBusDeploymentAspect"
class="org.jboss.wsf.stack.cxf.BusDeploymentAspect">
+ <property name="provides">BusHolder</property>
+ <property
name="requires">ResourceResolver,StackDescriptor</property>
+ <property name="forJaxRpc">false</property>
+ </bean>
</deployment>