Author: alessio.soldano(a)jboss.com
Date: 2011-01-25 08:50:06 -0500 (Tue, 25 Jan 2011)
New Revision: 13598
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/SynchronizedBusDeploymentAspect.java
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/resources/jbossws-cxf-config-as6.xml
Log:
Adding a BusDeploymentAspect that directly asks for the default bus instead of leaving
that to the CXFInitializer and waiting for it (better suits AS 7)
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 2011-01-24
09:52:32 UTC (rev 13597)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2011-01-25
13:50:06 UTC (rev 13598)
@@ -33,7 +33,6 @@
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.ResourceResolver;
-import org.jboss.wsf.stack.cxf.config.CXFInitializer;
import org.jboss.wsf.stack.cxf.configuration.BusHolder;
import org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder;
import org.jboss.wsf.stack.cxf.configuration.SpringBusHolder;
@@ -52,75 +51,75 @@
{
@SuppressWarnings("unchecked")
- @Override
- public void start(Deployment dep)
+ protected void startDeploymentBus(Deployment dep)
{
- //ensure the default bus has been set on the server, then proceed
- CXFInitializer.waitForDefaultBusAvailability();
- //synchronize as this assumes nothing deals with the BusFactory threadlocals
associated with the system daemon
- //thread doing the deployments, iow multiple concurrent deployment are not
supported in this deployment aspect
- synchronized (this)
+ ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
+ try
{
- ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
- try
- {
- //start cleaning the BusFactory thread locals
- BusFactory.setThreadDefaultBus(null);
+ //start cleaning the BusFactory thread locals
+ BusFactory.setThreadDefaultBus(null);
- ArchiveDeployment aDep = (ArchiveDeployment) dep;
- //set the runtime classloader (pointing to the deployment unit) to allow CXF
accessing to the classes
- SecurityActions.setContextClassLoader(dep.getRuntimeClassLoader());
+ ArchiveDeployment aDep = (ArchiveDeployment) dep;
+ //set the runtime classloader (pointing to the deployment unit) to allow CXF
accessing to the classes
+ SecurityActions.setContextClassLoader(dep.getRuntimeClassLoader());
- ResourceResolver deploymentResolver = aDep.getResourceResolver();
- org.apache.cxf.resource.ResourceResolver resolver = new
JBossWSResourceResolver(deploymentResolver);
- Map<String, String> contextParams = (Map<String, String>)
dep.getProperty(WSConstants.STACK_CONTEXT_PARAMS);
- String jbosswsCxfXml = contextParams == null ? null :
contextParams.get(BusHolder.PARAM_CXF_BEANS_URL);
- BusHolder holder = null;
+ ResourceResolver deploymentResolver = aDep.getResourceResolver();
+ org.apache.cxf.resource.ResourceResolver resolver = new
JBossWSResourceResolver(deploymentResolver);
+ Map<String, String> contextParams = (Map<String, String>)
dep.getProperty(WSConstants.STACK_CONTEXT_PARAMS);
+ String jbosswsCxfXml = contextParams == null ? null :
contextParams.get(BusHolder.PARAM_CXF_BEANS_URL);
+ BusHolder holder = null;
- if (jbosswsCxfXml != null) // Spring available
+ if (jbosswsCxfXml != null) // Spring available
+ {
+ URL cxfServletURL = null;
+ try
{
- URL cxfServletURL = null;
- try
- {
- cxfServletURL =
deploymentResolver.resolve("WEB-INF/cxf-servlet.xml");
- }
- catch (IOException e)
- {
- } //ignore, cxf-servlet.xml is optional, we might even decide not to
support this
-
- try
- {
- holder = new SpringBusHolder(cxfServletURL,
deploymentResolver.resolve(jbosswsCxfXml));
- Configurer configurer =
holder.createServerConfigurer(dep.getAttachment(BindingCustomization.class),
- new WSDLFilePublisher(aDep), dep.getService().getEndpoints());
- holder.configure(new SoapTransportFactoryExt(), resolver, configurer);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e); //re-throw, jboss-cxf.xml is required
- }
+ cxfServletURL =
deploymentResolver.resolve("WEB-INF/cxf-servlet.xml");
}
- else
- //Spring not available
+ catch (IOException e)
{
- DDBeans metadata = dep.getAttachment(DDBeans.class);
- holder = new NonSpringBusHolder(metadata);
+ } //ignore, cxf-servlet.xml is optional, we might even decide not to support
this
+
+ try
+ {
+ holder = new SpringBusHolder(cxfServletURL,
deploymentResolver.resolve(jbosswsCxfXml));
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);
+ catch (Exception e)
+ {
+ throw new RuntimeException(e); //re-throw, jboss-cxf.xml is required
+ }
}
- finally
+ else
+ //Spring not available
{
- //clean threadlocals in BusFactory and restore the original classloader
- BusFactory.setThreadDefaultBus(null);
- SecurityActions.setContextClassLoader(origClassLoader);
+ DDBeans metadata = dep.getAttachment(DDBeans.class);
+ holder = new NonSpringBusHolder(metadata);
+ 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);
}
+ finally
+ {
+ //clean threadlocals in BusFactory and restore the original classloader
+ BusFactory.setThreadDefaultBus(null);
+ SecurityActions.setContextClassLoader(origClassLoader);
+ }
}
@Override
+ public void start(Deployment dep)
+ {
+ //Ask for the default bus to make sure it's created before the deployment
classloader is set
+ BusFactory.getDefaultBus();
+ this.startDeploymentBus(dep);
+ }
+
+ @Override
public void stop(Deployment dep)
{
BusHolder holder = dep.removeAttachment(BusHolder.class);
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/SynchronizedBusDeploymentAspect.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/SynchronizedBusDeploymentAspect.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/SynchronizedBusDeploymentAspect.java 2011-01-25
13:50:06 UTC (rev 13598)
@@ -0,0 +1,54 @@
+/*
+ * 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.deployment.aspect;
+
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.stack.cxf.config.CXFInitializer;
+
+/**
+ * A synchronized version of the bus deployment aspect that waits for the CXFInitializer
+ * and does single-thread deployment processing
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 25-Mar-2010
+ */
+public class SynchronizedBusDeploymentAspect extends BusDeploymentAspect
+{
+ @Override
+ protected void startDeploymentBus(Deployment dep)
+ {
+ //ensure the default bus has been set on the server, then proceed
+ CXFInitializer.waitForDefaultBusAvailability();
+ //synchronize as this assumes nothing deals with the BusFactory threadlocals
associated with the system daemon
+ //thread doing the deployments, iow multiple concurrent deployment are not
supported in this deployment aspect
+ synchronized (this)
+ {
+ super.startDeploymentBus(dep);
+ }
+ }
+
+ @Override
+ public void start(Deployment dep)
+ {
+ this.startDeploymentBus(dep);
+ }
+}
\ No newline at end of file
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 2011-01-24
09:52:32 UTC (rev 13597)
+++
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as6.xml 2011-01-25
13:50:06 UTC (rev 13598)
@@ -88,7 +88,7 @@
<property name="forJaxRpc">false</property>
</bean>
- <bean name="WSCXFBusDeploymentAspect"
class="org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect">
+ <bean name="WSCXFBusDeploymentAspect"
class="org.jboss.wsf.stack.cxf.deployment.aspect.SynchronizedBusDeploymentAspect">
<property name="provides">BusHolder</property>
<property
name="requires">ResourceResolver,StackDescriptor</property>
<property name="forJaxRpc">false</property>