[jbossws-commits] JBossWS SVN: r15898 - in stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf: transport and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Thu Mar 8 04:00:59 EST 2012


Author: alessio.soldano at jboss.com
Date: 2012-03-08 04:00:57 -0500 (Thu, 08 Mar 2012)
New Revision: 15898

Added:
   stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringServerBeanCustomizer.java
   stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/JBossJMSConfiguration.java
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/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
Log:
[JBWS-3454] Adding Spring-aware ServerBeanCustomizer and providing initial server side JMSConfiguration customization


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	2012-03-07 08:15:26 UTC (rev 15897)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java	2012-03-08 09:00:57 UTC (rev 15898)
@@ -37,6 +37,8 @@
 import org.jboss.ws.common.Constants;
 import org.jboss.wsf.spi.deployment.Endpoint;
 import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+import org.jboss.wsf.stack.cxf.client.configuration.BeanCustomizer;
+import org.jboss.wsf.stack.cxf.client.util.SpringUtils;
 import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
 import org.jboss.wsf.stack.cxf.interceptor.EnableOneWayDecoupledFaultInterceptor;
 import org.jboss.wsf.stack.cxf.interceptor.EndpointAssociationInterceptor;
@@ -52,6 +54,7 @@
 public abstract class BusHolder
 {
    public static final String PARAM_CXF_BEANS_URL = "jbossws.cxf.beans.url";
+   private static boolean springAvailable = SpringUtils.isSpringAvailable(BusHolder.class.getClassLoader());
    protected Bus bus;
    protected BusHolderLifeCycleListener busHolderListener;
    
@@ -147,6 +150,19 @@
          dfm.registerDestinationFactory(Constants.NS_SOAP12, factory);
       }
    }
+   
+   /**
+    * Create a new instance of server side BeanCustomizer, the actual type depending on
+    * Spring being available in the BusHolder defining classloader; please note that given
+    * both CXF and JBWS prefer non-Spring Bus factories when Spring is not actually needed
+    * (even if available), the choice of the BeanCustomizer to use is unrelated to the
+    * current BusHolder type.
+    * 
+    * @return a ServerBeanCustomizer instance
+    */
+   protected static ServerBeanCustomizer createBeanCustomizer() {
+      return !springAvailable ? new ServerBeanCustomizer() : new SpringServerBeanCustomizer();
+   }
 
    /**
     * Return the hold 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	2012-03-07 08:15:26 UTC (rev 15897)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java	2012-03-08 09:00:57 UTC (rev 15898)
@@ -179,7 +179,7 @@
    public Configurer createServerConfigurer(BindingCustomization customization, WSDLFilePublisher wsdlPublisher,
          List<Endpoint> depEndpoints, UnifiedVirtualFile root)
    {
-      ServerBeanCustomizer customizer = new ServerBeanCustomizer();
+      ServerBeanCustomizer customizer = createBeanCustomizer();
       customizer.setBindingCustomization(customization);
       customizer.setWsdlPublisher(wsdlPublisher);
       customizer.setDeploymentEndpoints(depEndpoints);

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	2012-03-07 08:15:26 UTC (rev 15897)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/ServerBeanCustomizer.java	2012-03-08 09:00:57 UTC (rev 15898)
@@ -65,7 +65,7 @@
       {
          configureEndpoint((EndpointImpl) beanInstance);
       }
-      if (beanInstance instanceof ServerFactoryBean)
+      else if (beanInstance instanceof ServerFactoryBean)
       {
          ServerFactoryBean factory = (ServerFactoryBean) beanInstance;
 

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	2012-03-07 08:15:26 UTC (rev 15897)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java	2012-03-08 09:00:57 UTC (rev 15898)
@@ -160,7 +160,7 @@
          List<Endpoint> depEndpoints, UnifiedVirtualFile root)
    {
       ApplicationContext ctx = bus.getExtension(BusApplicationContext.class);
-      ServerBeanCustomizer customizer = new ServerBeanCustomizer();
+      ServerBeanCustomizer customizer = createBeanCustomizer();
       customizer.setBindingCustomization(customization);
       customizer.setWsdlPublisher(wsdlPublisher);
       customizer.setDeploymentEndpoints(depEndpoints);

Added: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringServerBeanCustomizer.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringServerBeanCustomizer.java	                        (rev 0)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringServerBeanCustomizer.java	2012-03-08 09:00:57 UTC (rev 15898)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, 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.configuration;
+
+import org.apache.cxf.transport.jms.JMSOldConfigHolder;
+import org.jboss.wsf.stack.cxf.transport.JBossJMSConfiguration;
+
+/**
+ * A Spring-aware version of the server side customizer
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 08-Mar-2012
+ */
+public class SpringServerBeanCustomizer extends ServerBeanCustomizer
+{
+   @Override
+   public void customize(Object beanInstance)
+   {
+      if (beanInstance instanceof JMSOldConfigHolder)
+      {
+         JMSOldConfigHolder jmsConfHolder = (JMSOldConfigHolder)beanInstance;
+         jmsConfHolder.setJmsConfig(new JBossJMSConfiguration());
+      }
+      super.customize(beanInstance);
+   }
+}

Added: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/JBossJMSConfiguration.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/JBossJMSConfiguration.java	                        (rev 0)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/JBossJMSConfiguration.java	2012-03-08 09:00:57 UTC (rev 15898)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, 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.transport;
+
+import java.util.Properties;
+
+import org.apache.cxf.transport.jms.JMSConfiguration;
+import org.apache.cxf.transport.jms.JNDIConfiguration;
+import org.springframework.jndi.JndiTemplate;
+
+/**
+ * A JBoss AS version of Apache CXF JMSConfiguration
+ * 
+ * @see org.apache.cxf.binding.soap.SoapTransportFactory.SoapEndpointInfo
+ * 
+ * @author alessio.soldano at jboss.com
+ * @since 07-Mar-2012
+ * 
+ */
+public class JBossJMSConfiguration extends JMSConfiguration
+{
+   @Override
+   public void setJndiTemplate(JndiTemplate jndiTemplate)
+   {
+      //erase props to have correct JBoss AS server side jndi lookup
+      jndiTemplate.setEnvironment(new Properties());
+      super.setJndiTemplate(jndiTemplate);
+   }
+
+   @Override
+   public void setJndiConfig(JNDIConfiguration jndiConfig)
+   {
+      //erase props and set correct connection factory for JBoss AS server side connection lookup
+      jndiConfig.setEnvironment(new Properties());
+      jndiConfig.setConnectionPassword(null);
+      jndiConfig.setConnectionUserName(null);
+      jndiConfig.setJndiConnectionFactoryName("java:/ConnectionFactory");
+      super.setJndiConfig(jndiConfig);
+   }
+
+}



More information about the jbossws-commits mailing list