Author: alessio.soldano(a)jboss.com
Date: 2010-10-06 11:52:06 -0400 (Wed, 06 Oct 2010)
New Revision: 13065
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/config/CXFInitializer.java
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSBusFactory.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/config/CXFStackConfigFactory.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/deployment/aspect/JMSEndpointDeploymentAspectDelegate.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-3144] Initialize default bus in a separate thread during boot
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSBusFactory.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSBusFactory.java 2010-10-06
14:32:48 UTC (rev 13064)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSBusFactory.java 2010-10-06
15:52:06 UTC (rev 13065)
@@ -26,7 +26,6 @@
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
-import org.jboss.logging.Logger;
import org.jboss.wsf.stack.cxf.client.util.SpringUtils;
/**
@@ -113,16 +112,6 @@
{
return getNonSpringBusFactory().createBus(extensions, properties);
}
-
- /**
- * Makes sure the default bus is initialized
- */
- public static void initializeDefaultBus()
- {
- long i = System.currentTimeMillis();
- getDefaultBus();
- Logger.getLogger(JBossWSBusFactory.class).info("Time taken for
initializeDefaultBus: " + (System.currentTimeMillis() - i));
- }
public JBossWSSpringBusFactory getSpringBusFactory()
{
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/config/CXFInitializer.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/config/CXFInitializer.java
(rev 0)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/config/CXFInitializer.java 2010-10-06
15:52:06 UTC (rev 13065)
@@ -0,0 +1,101 @@
+/*
+ * 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.config;
+
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.cxf.BusFactory;
+import org.jboss.logging.Logger;
+
+
+/**
+ * A bean installed during boot for initializing CXF
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 06-Opt-2010
+ *
+ */
+public class CXFInitializer
+{
+ private static Logger logger = Logger.getLogger(CXFInitializer.class);
+ private static CountDownLatch defaultBusCDL = new CountDownLatch(1);
+
+ public void create() throws Exception
+ {
+ Thread defaultBusInitThread = new Thread(new DefautBusInitializer(defaultBusCDL),
"JBossWS-CXF-DefaultBus-Init");
+ defaultBusInitThread.setDaemon(true);
+ defaultBusInitThread.start();
+ }
+
+ public void destroy() throws Exception
+ {
+ //NOOP
+ }
+
+ public static void waitForDefaultBusAvailability()
+ {
+ boolean trace = logger.isTraceEnabled();
+ if (trace)
+ logger.trace(Thread.currentThread() + " will wait for default bus
availability...");
+ try
+ {
+ defaultBusCDL.await();
+ if (trace)
+ logger.trace("Default bus now available: " +
BusFactory.getDefaultBus(false));
+ }
+ catch (InterruptedException e)
+ {
+ logger.error("Interrupted while waiting for default bus to be set!");
+ throw new RuntimeException(e);
+ }
+ }
+
+ private class DefautBusInitializer implements Runnable
+ {
+ private CountDownLatch cdl;
+
+ public DefautBusInitializer(CountDownLatch cdl)
+ {
+ this.cdl = cdl;
+ }
+
+ @Override
+ public void run()
+ {
+ long start = System.currentTimeMillis();
+ try
+ {
+ BusFactory.getDefaultBus();
+ if (logger.isTraceEnabled())
+ {
+ logger.info("Default bus started in " +
(System.currentTimeMillis() - start) + " ms by "
+ + Thread.currentThread());
+ }
+ }
+ finally
+ {
+ cdl.countDown();
+ }
+ }
+ }
+
+}
\ No newline at end of file
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/config/CXFStackConfigFactory.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/config/CXFStackConfigFactory.java 2010-10-06
14:32:48 UTC (rev 13064)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/config/CXFStackConfigFactory.java 2010-10-06
15:52:06 UTC (rev 13065)
@@ -23,7 +23,6 @@
import org.jboss.wsf.spi.management.StackConfig;
import org.jboss.wsf.spi.management.StackConfigFactory;
-import org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory;
/**
*
@@ -45,7 +44,6 @@
public String getImplementationTitle()
{
- JBossWSBusFactory.initializeDefaultBus();
return getClass().getPackage().getImplementationTitle();
}
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-10-06
14:32:48 UTC (rev 13064)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2010-10-06
15:52:06 UTC (rev 13065)
@@ -33,6 +33,7 @@
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;
@@ -54,6 +55,8 @@
@Override
public void start(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)
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointDeploymentAspectDelegate.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointDeploymentAspectDelegate.java 2010-10-06
14:32:48 UTC (rev 13064)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointDeploymentAspectDelegate.java 2010-10-06
15:52:06 UTC (rev 13065)
@@ -29,6 +29,7 @@
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.metadata.jms.JMSEndpointsMetaData;
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory;
+import org.jboss.wsf.stack.cxf.config.CXFInitializer;
/**
* To start the jms endpoints
@@ -40,6 +41,8 @@
@Override
public void start(Deployment dep)
{
+ //ensure the default bus has been set on the server, then proceed
+ CXFInitializer.waitForDefaultBusAvailability();
//TODO:handler JAXBIntro
if (dep.getAttachment(JMSEndpointsMetaData.class) != null)
{
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-10-06
14:32:48 UTC (rev 13064)
+++
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as5.xml 2010-10-06
15:52:06 UTC (rev 13065)
@@ -2,6 +2,9 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <!-- CXF initializer, starts default bus, etc. -->
+ <bean name="CXFInitializer"
class="org.jboss.wsf.stack.cxf.config.CXFInitializer" />
+
<!-- The registry for web service endpoints -->
<bean name="WSEndpointRegistry"
class="org.jboss.wsf.framework.management.ManagedEndpointRegistry">
<property name="mbeanServer"><inject
bean="WSMBeanServerLocator"
property="mbeanServer"/></property>
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-10-06
14:32:48 UTC (rev 13064)
+++
stack/cxf/trunk/modules/server/src/main/resources/jbossws-cxf-config-as6.xml 2010-10-06
15:52:06 UTC (rev 13065)
@@ -2,6 +2,9 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <!-- CXF initializer, starts default bus, etc. -->
+ <bean name="CXFInitializer"
class="org.jboss.wsf.stack.cxf.config.CXFInitializer" />
+
<!-- The registry for web service endpoints -->
<bean name="WSEndpointRegistry"
class="org.jboss.wsf.framework.management.ManagedEndpointRegistry">
<property name="mbeanServer"><inject
bean="WSMBeanServerLocator"
property="mbeanServer"/></property>