[jbossws-commits] JBossWS SVN: r12756 - in stack/cxf/branches/cxf-2.3/modules: server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect and 1 other directory.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Fri Aug 6 14:14:15 EDT 2010
Author: alessio.soldano at jboss.com
Date: 2010-08-06 14:14:15 -0400 (Fri, 06 Aug 2010)
New Revision: 12756
Added:
stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointDeploymentAspectDelegate.java
stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointRegistryDeploymentAspectDelegate.java
Modified:
stack/cxf/branches/cxf-2.3/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/util/SpringUtils.java
stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointDeploymentAspect.java
stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointRegistryDeploymentAspect.java
Log:
svn merge -r 12730:12743 https://svn.jboss.org/repos/jbossws/stack/cxf/trunk .
Modified: stack/cxf/branches/cxf-2.3/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/util/SpringUtils.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/util/SpringUtils.java 2010-08-06 17:36:32 UTC (rev 12755)
+++ stack/cxf/branches/cxf-2.3/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/util/SpringUtils.java 2010-08-06 18:14:15 UTC (rev 12756)
@@ -30,6 +30,13 @@
*/
public class SpringUtils
{
+ public static final boolean SPRING_AVAILABLE;
+ static
+ {
+ SPRING_AVAILABLE =
+ isSpringAvailable(SpringUtils.class.getClassLoader(),
+ Thread.currentThread().getContextClassLoader());
+ }
/**
* Check if Spring is available using the provided classloader
*
@@ -44,6 +51,10 @@
}
for (ClassLoader cl : loaders)
{
+ if (cl == null)
+ {
+ continue;
+ }
try
{
cl.loadClass("org.springframework.context.ApplicationContext");
Modified: stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointDeploymentAspect.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointDeploymentAspect.java 2010-08-06 17:36:32 UTC (rev 12755)
+++ stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointDeploymentAspect.java 2010-08-06 18:14:15 UTC (rev 12756)
@@ -21,20 +21,9 @@
*/
package org.jboss.wsf.stack.cxf.deployment.aspect;
-import java.net.URL;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.bus.spring.SpringBusFactory;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.endpoint.ServerRegistry;
-import org.apache.cxf.transport.jms.JMSConfiguration;
-import org.apache.cxf.transport.jms.JMSDestination;
import org.jboss.wsf.common.integration.JMSDeploymentAspect;
import org.jboss.wsf.spi.deployment.Deployment;
-import org.jboss.wsf.spi.metadata.jms.JMSEndpointsMetaData;
-import org.jboss.wsf.stack.cxf.configuration.BusHolder;
-import org.springframework.jms.connection.SingleConnectionFactory;
+import org.jboss.wsf.stack.cxf.client.util.SpringUtils;
/**
* To start the jms endpoints
@@ -43,81 +32,31 @@
*/
public class JMSEndpointDeploymentAspect extends JMSDeploymentAspect
{
- private BusHolder busHolder = null;
+ private JMSEndpointDeploymentAspectDelegate aspect;
+ public JMSEndpointDeploymentAspect()
+ {
+ if (SpringUtils.SPRING_AVAILABLE)
+ {
+ aspect = new JMSEndpointDeploymentAspectDelegate();
+ }
+ }
+
+
@Override
public void start(Deployment dep)
{
- //TODO:handler JAXBIntro
- if (dep.getAttachment(JMSEndpointsMetaData.class) != null)
+ if (aspect != null)
{
- JMSEndpointsMetaData jmsEndpoints = dep.getAttachment(JMSEndpointsMetaData.class);
- URL url = jmsEndpoints.getDescriptorURL();
-
- ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
- try
- {
- SecurityActions.setContextClassLoader(dep.getRuntimeClassLoader());
- SpringBusFactory bf = new SpringBusFactory();
- Bus bus = bf.createBus(url);
- dep.addAttachment(Bus.class, bus);
- }
- catch (Exception e)
- {
- log.error("Failed to deploy jms endpoints deployment " + url);
- throw new RuntimeException(e);
- }
-
- finally
- {
- BusFactory.setDefaultBus(null);
- SecurityActions.setContextClassLoader(origClassLoader);
- }
+ aspect.start(dep);
}
}
-
- @Override
+
public void stop(Deployment dep)
{
- log.debug("Undeploying jms endpoints in " + dep.getSimpleName());
- if (busHolder != null && busHolder.getBus() != null)
+ if (aspect != null)
{
- //CXF uses WrappedConnectionFactory to create "jmsListener". DefaultMessageListenerContainer.shutdown() can not colse all the jms connections.
- //We need to explicitly call detroy() to close connection. This should be fixed in CXF side.
- SingleConnectionFactory connectionFactory = null;
- Server jmsServer = null;
- ServerRegistry serRegistry = busHolder.getBus().getExtension(ServerRegistry.class);
- for (Server server : serRegistry.getServers())
- {
- if (server.getDestination() != null && server.getDestination() instanceof JMSDestination)
- {
- JMSDestination jmsDestination = (JMSDestination) server.getDestination();
- JMSConfiguration jmsConfig = jmsDestination.getJmsConfig();
- if (jmsConfig.getWrappedConnectionFactory() != null
- && jmsConfig.getWrappedConnectionFactory() instanceof SingleConnectionFactory)
- {
- connectionFactory = (SingleConnectionFactory) jmsConfig
- .getWrappedConnectionFactory();
- jmsServer = server;
- }
-
- }
-
- }
-
- if (jmsServer != null)
- {
- jmsServer.stop();
- }
-
- if (connectionFactory != null)
- {
- connectionFactory.destroy();
- }
- //TODO:Remove above code after fix CXF-2788
- //close LifecycleListener if exists
- busHolder.getBus().shutdown(false);
- busHolder.close();
+ aspect.stop(dep);
}
}
}
Copied: stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointDeploymentAspectDelegate.java (from rev 12743, stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointDeploymentAspectDelegate.java)
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointDeploymentAspectDelegate.java (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointDeploymentAspectDelegate.java 2010-08-06 18:14:15 UTC (rev 12756)
@@ -0,0 +1,124 @@
+/*
+ * 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 java.net.URL;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerRegistry;
+import org.apache.cxf.transport.jms.JMSConfiguration;
+import org.apache.cxf.transport.jms.JMSDestination;
+import org.jboss.wsf.common.integration.JMSDeploymentAspect;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.metadata.jms.JMSEndpointsMetaData;
+import org.jboss.wsf.stack.cxf.configuration.BusHolder;
+import org.springframework.jms.connection.SingleConnectionFactory;
+
+/**
+ * To start the jms endpoints
+ *
+ * @author <a href="ema at redhat.com">Jim Ma</a>
+ */
+public class JMSEndpointDeploymentAspectDelegate extends JMSDeploymentAspect
+{
+ private BusHolder busHolder = null;
+
+ @Override
+ public void start(Deployment dep)
+ {
+ //TODO:handler JAXBIntro
+ if (dep.getAttachment(JMSEndpointsMetaData.class) != null)
+ {
+ JMSEndpointsMetaData jmsEndpoints = dep.getAttachment(JMSEndpointsMetaData.class);
+ URL url = jmsEndpoints.getDescriptorURL();
+
+ ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
+ try
+ {
+ SecurityActions.setContextClassLoader(dep.getRuntimeClassLoader());
+ SpringBusFactory bf = new SpringBusFactory();
+ Bus bus = bf.createBus(url);
+ dep.addAttachment(Bus.class, bus);
+ }
+ catch (Exception e)
+ {
+ log.error("Failed to deploy jms endpoints deployment " + url);
+ throw new RuntimeException(e);
+ }
+
+ finally
+ {
+ BusFactory.setDefaultBus(null);
+ SecurityActions.setContextClassLoader(origClassLoader);
+ }
+ }
+ }
+
+ @Override
+ public void stop(Deployment dep)
+ {
+ log.debug("Undeploying jms endpoints in " + dep.getSimpleName());
+ if (busHolder != null && busHolder.getBus() != null)
+ {
+ //CXF uses WrappedConnectionFactory to create "jmsListener". DefaultMessageListenerContainer.shutdown() can not colse all the jms connections.
+ //We need to explicitly call detroy() to close connection. This should be fixed in CXF side.
+ SingleConnectionFactory connectionFactory = null;
+ Server jmsServer = null;
+ ServerRegistry serRegistry = busHolder.getBus().getExtension(ServerRegistry.class);
+ for (Server server : serRegistry.getServers())
+ {
+ if (server.getDestination() != null && server.getDestination() instanceof JMSDestination)
+ {
+ JMSDestination jmsDestination = (JMSDestination) server.getDestination();
+ JMSConfiguration jmsConfig = jmsDestination.getJmsConfig();
+ if (jmsConfig.getWrappedConnectionFactory() != null
+ && jmsConfig.getWrappedConnectionFactory() instanceof SingleConnectionFactory)
+ {
+ connectionFactory = (SingleConnectionFactory) jmsConfig
+ .getWrappedConnectionFactory();
+ jmsServer = server;
+ }
+
+ }
+
+ }
+
+ if (jmsServer != null)
+ {
+ jmsServer.stop();
+ }
+
+ if (connectionFactory != null)
+ {
+ connectionFactory.destroy();
+ }
+ //TODO:Remove above code after fix CXF-2788
+ //close LifecycleListener if exists
+ busHolder.getBus().shutdown(false);
+ busHolder.close();
+ }
+ }
+}
+
Modified: stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointRegistryDeploymentAspect.java
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointRegistryDeploymentAspect.java 2010-08-06 17:36:32 UTC (rev 12755)
+++ stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointRegistryDeploymentAspect.java 2010-08-06 18:14:15 UTC (rev 12756)
@@ -21,25 +21,9 @@
*/
package org.jboss.wsf.stack.cxf.deployment.aspect;
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.endpoint.ServerRegistry;
-import org.apache.cxf.frontend.MethodDispatcher;
-import org.apache.cxf.frontend.SimpleMethodDispatcher;
-import org.apache.cxf.transport.Destination;
-import org.apache.cxf.transport.jms.JMSConfiguration;
-import org.apache.cxf.transport.jms.JMSDestination;
import org.jboss.wsf.common.integration.JMSDeploymentAspect;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.deployment.Deployment;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.deployment.JMSEndpoint;
-import org.jboss.wsf.spi.management.EndpointRegistry;
-import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+import org.jboss.wsf.stack.cxf.client.util.SpringUtils;
/**
* The DeploymentAspect to register the jms endpoints
@@ -48,71 +32,33 @@
*/
public class JMSEndpointRegistryDeploymentAspect extends JMSDeploymentAspect
{
- private EndpointRegistry registry = null;
- @Override
- public void start(Deployment dep)
+ private JMSEndpointRegistryDeploymentAspectDelegate aspect;
+
+ public JMSEndpointRegistryDeploymentAspect()
{
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- if (registry == null)
- registry = spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
- Bus bus = dep.getAttachment(Bus.class);
- Map<String, JMSConfiguration> jmsConfigMap = createEndpointJmsConfigMap(bus);
- for (Endpoint endpoint : dep.getService().getEndpoints())
+ if (SpringUtils.SPRING_AVAILABLE)
{
- JMSEndpoint jmsEndpoint = (JMSEndpoint)endpoint;
- String endpointImplClass = jmsEndpoint.getTargetBeanName();
- JMSConfiguration jmsConfig = jmsConfigMap.get(endpointImplClass);
- if (jmsConfig != null)
- {
- jmsEndpoint.setTargetDestination(jmsConfig.getTargetDestination());
- jmsEndpoint.setReplyDestination(jmsConfig.getReplyDestination());
- }
-
- registry.register(jmsEndpoint);
+ aspect = new JMSEndpointRegistryDeploymentAspectDelegate();
}
}
- public void stop(Deployment dep)
+
+ @Override
+ public void start(Deployment dep)
{
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- if (registry == null)
- registry = spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
- for (Endpoint ep : dep.getService().getEndpoints())
+ if (aspect != null)
{
- registry.unregister(ep);
+ aspect.start(dep);
}
}
-
- private Map<String, JMSConfiguration> createEndpointJmsConfigMap(Bus bus)
+
+ public void stop(Deployment dep)
{
- Map<String, JMSConfiguration> endpointJmsConfigMap = new java.util.HashMap<String, JMSConfiguration>();
- ServerRegistry serverRegsitry = bus.getExtension(ServerRegistry.class);
- for (Server server : serverRegsitry.getServers())
+ if (aspect != null)
{
- Destination destination = server.getDestination();
- if (destination instanceof JMSDestination)
- {
- JMSConfiguration jmsConfiguration = ((JMSDestination)destination).getJmsConfig();
- String implClassName = getEndpointClassName(server);
- if (implClassName != null)
- {
- endpointJmsConfigMap.put(implClassName, jmsConfiguration);
- }
- }
+ aspect.stop(dep);
}
- return endpointJmsConfigMap;
}
-
- private String getEndpointClassName(Server server)
- {
- MethodDispatcher methodDispatcher = (SimpleMethodDispatcher) server.getEndpoint().getService().get(
- MethodDispatcher.class.getName());
- if (methodDispatcher != null && methodDispatcher instanceof SimpleMethodDispatcher)
- {
- Method method = ((SimpleMethodDispatcher)methodDispatcher).getPrimaryMethod(server.getEndpoint().getEndpointInfo().getInterface()
- .getOperations().iterator().next());
- return method != null ? method.getDeclaringClass().getName() : null;
- }
- return null;
- }
+
+
}
Copied: stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointRegistryDeploymentAspectDelegate.java (from rev 12743, stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointRegistryDeploymentAspectDelegate.java)
===================================================================
--- stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointRegistryDeploymentAspectDelegate.java (rev 0)
+++ stack/cxf/branches/cxf-2.3/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/JMSEndpointRegistryDeploymentAspectDelegate.java 2010-08-06 18:14:15 UTC (rev 12756)
@@ -0,0 +1,118 @@
+/*
+ * 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 java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.endpoint.ServerRegistry;
+import org.apache.cxf.frontend.MethodDispatcher;
+import org.apache.cxf.frontend.SimpleMethodDispatcher;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.jms.JMSConfiguration;
+import org.apache.cxf.transport.jms.JMSDestination;
+import org.jboss.wsf.common.integration.JMSDeploymentAspect;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.deployment.Deployment;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.JMSEndpoint;
+import org.jboss.wsf.spi.management.EndpointRegistry;
+import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+
+/**
+ * The DeploymentAspect to register the jms endpoints
+ *
+ * @author <a href="ema at redhat.com">Jim Ma</a>
+ */
+class JMSEndpointRegistryDeploymentAspectDelegate extends JMSDeploymentAspect
+{
+ private EndpointRegistry registry = null;
+ @Override
+ public void start(Deployment dep)
+ {
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ if (registry == null)
+ registry = spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
+ Bus bus = dep.getAttachment(Bus.class);
+ Map<String, JMSConfiguration> jmsConfigMap = createEndpointJmsConfigMap(bus);
+ for (Endpoint endpoint : dep.getService().getEndpoints())
+ {
+ JMSEndpoint jmsEndpoint = (JMSEndpoint)endpoint;
+ String endpointImplClass = jmsEndpoint.getTargetBeanName();
+ JMSConfiguration jmsConfig = jmsConfigMap.get(endpointImplClass);
+ if (jmsConfig != null)
+ {
+ jmsEndpoint.setTargetDestination(jmsConfig.getTargetDestination());
+ jmsEndpoint.setReplyDestination(jmsConfig.getReplyDestination());
+ }
+
+ registry.register(jmsEndpoint);
+ }
+ }
+
+ public void stop(Deployment dep)
+ {
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ if (registry == null)
+ registry = spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
+ for (Endpoint ep : dep.getService().getEndpoints())
+ {
+ registry.unregister(ep);
+ }
+ }
+
+ private Map<String, JMSConfiguration> createEndpointJmsConfigMap(Bus bus)
+ {
+ Map<String, JMSConfiguration> endpointJmsConfigMap = new java.util.HashMap<String, JMSConfiguration>();
+ ServerRegistry serverRegsitry = bus.getExtension(ServerRegistry.class);
+ for (Server server : serverRegsitry.getServers())
+ {
+ Destination destination = server.getDestination();
+ if (destination instanceof JMSDestination)
+ {
+ JMSConfiguration jmsConfiguration = ((JMSDestination)destination).getJmsConfig();
+ String implClassName = getEndpointClassName(server);
+ if (implClassName != null)
+ {
+ endpointJmsConfigMap.put(implClassName, jmsConfiguration);
+ }
+ }
+ }
+ return endpointJmsConfigMap;
+ }
+
+ private String getEndpointClassName(Server server)
+ {
+ MethodDispatcher methodDispatcher = (SimpleMethodDispatcher) server.getEndpoint().getService().get(
+ MethodDispatcher.class.getName());
+ if (methodDispatcher != null && methodDispatcher instanceof SimpleMethodDispatcher)
+ {
+ Method method = ((SimpleMethodDispatcher)methodDispatcher).getPrimaryMethod(server.getEndpoint().getEndpointInfo().getInterface()
+ .getOperations().iterator().next());
+ return method != null ? method.getDeclaringClass().getName() : null;
+ }
+ return null;
+ }
+}
More information about the jbossws-commits
mailing list