Author: alessio.soldano(a)jboss.com
Date: 2010-05-05 02:35:09 -0400 (Wed, 05 May 2010)
New Revision: 12162
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/ConfigurerInstaller.java
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/DelegatingConfigurer.java
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSCXFConfigurer.java
stack/cxf/trunk/modules/client/src/main/resources/META-INF/cxf/cxf-extension-jbossws.xml
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/JBossWSServerCXFConfigurer.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jaxbintros/JAXBIntroTestCase.java
Log:
[JBWS-3016] Install JBossWSCXFConfigurer by default on client side too
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/ConfigurerInstaller.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/ConfigurerInstaller.java
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/ConfigurerInstaller.java 2010-05-05
06:35:09 UTC (rev 12162)
@@ -0,0 +1,59 @@
+/*
+ * 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 org.apache.cxf.Bus;
+import org.apache.cxf.configuration.Configurer;
+
+
+/**
+ * A simple bean created through cxf-extension-jbossws.xml in order to
+ * install the JBossWS configurer.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 04-May-2010
+ */
+public class ConfigurerInstaller
+{
+ private Bus bus;
+
+ public ConfigurerInstaller()
+ {
+ //NOOP
+ }
+
+ public Bus getBus()
+ {
+ return bus;
+ }
+
+ public void setBus(Bus bus)
+ {
+ this.bus = bus;
+ updateConfigurer();
+ }
+
+ protected void updateConfigurer()
+ {
+ bus.setExtension(new JBossWSCXFConfigurer(bus.getExtension(Configurer.class)),
Configurer.class);
+ }
+}
Property changes on:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/ConfigurerInstaller.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/DelegatingConfigurer.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/DelegatingConfigurer.java
(rev 0)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/DelegatingConfigurer.java 2010-05-05
06:35:09 UTC (rev 12162)
@@ -0,0 +1,72 @@
+/*
+ * 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 org.apache.cxf.configuration.Configurer;
+
+/**
+ * A CXF configurer that allows for custom configuration before delegating to another
configurer;
+ * this is installed by JBossWS' {@see
org.jboss.wsf.stack.cxf.client.configuration.ConfigurerInstaller}
+ * (see cxf-extension-jbossws.xml) to allow for custom client side configuration while
leaving
+ * Apache CXF the freedom of setting the initial configurer.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 04-May-2010
+ */
+public abstract class DelegatingConfigurer implements Configurer
+{
+ protected Configurer delegate;
+
+ public DelegatingConfigurer(Configurer delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void configureBean(Object beanInstance)
+ {
+ internalConfigure(beanInstance);
+ if (delegate != null)
+ {
+ delegate.configureBean(beanInstance);
+ }
+ }
+
+ @Override
+ public void configureBean(String name, Object beanInstance)
+ {
+ internalConfigure(beanInstance);
+ if (delegate != null)
+ {
+ delegate.configureBean(name, beanInstance);
+ }
+ }
+
+ /**
+ * Performs custom configurations on the provided bean instance
+ * before delegating to the other configurer.
+ *
+ * @param beanInstance
+ */
+ protected abstract void internalConfigure(Object beanInstance);
+
+}
Property changes on:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/DelegatingConfigurer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSCXFConfigurer.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSCXFConfigurer.java 2010-05-05
04:31:58 UTC (rev 12161)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSCXFConfigurer.java 2010-05-05
06:35:09 UTC (rev 12162)
@@ -36,42 +36,22 @@
* @author alessio.soldano(a)jboss.com
* @since 05-Oct-2009
*/
-public class JBossWSCXFConfigurer implements Configurer
+public class JBossWSCXFConfigurer extends DelegatingConfigurer
{
protected BindingCustomization customization;
- private Configurer delegate;
public JBossWSCXFConfigurer(Configurer delegate)
{
- this.delegate = delegate;
+ super(delegate);
}
public JBossWSCXFConfigurer(Configurer delegate, BindingCustomization customization)
{
- this(delegate);
+ super(delegate);
this.customization = customization;
}
@Override
- public void configureBean(Object beanInstance)
- {
- internalConfigure(beanInstance);
- if (delegate != null)
- {
- delegate.configureBean(beanInstance);
- }
- }
-
- @Override
- public void configureBean(String name, Object beanInstance)
- {
- internalConfigure(beanInstance);
- if (delegate != null)
- {
- delegate.configureBean(name, beanInstance);
- }
- }
-
protected void internalConfigure(Object beanInstance)
{
if (beanInstance instanceof AbstractWSDLBasedEndpointFactory)
@@ -92,6 +72,26 @@
*/
protected synchronized void configureEndpointFactory(AbstractWSDLBasedEndpointFactory
factory)
{
+ //Configure binding customization
+ if (customization != null)
+ {
+ ReflectionServiceFactoryBean serviceFactory = factory.getServiceFactory();
+ //customize default databinding (early pulls in ServiceFactory default
databinding and configure it, as it's lazily loaded)
+ serviceFactory.reset();
+ DataBinding serviceFactoryDataBinding = serviceFactory.getDataBinding(true);
+ setBindingCustomization(serviceFactoryDataBinding, customization);
+ serviceFactory.setDataBinding(serviceFactoryDataBinding);
+ //customize user provided databinding (CXF later overrides the ServiceFactory
databinding using the user provided one)
+ if (factory.getDataBinding() == null)
+ {
+ //set the endpoint factory's databinding to prevent CXF resetting
everything because user did not provide anything
+ factory.setDataBinding(serviceFactoryDataBinding);
+ }
+ else
+ {
+ setBindingCustomization(factory.getDataBinding(), customization);
+ }
+ }
//add other configurations here below
}
Modified:
stack/cxf/trunk/modules/client/src/main/resources/META-INF/cxf/cxf-extension-jbossws.xml
===================================================================
---
stack/cxf/trunk/modules/client/src/main/resources/META-INF/cxf/cxf-extension-jbossws.xml 2010-05-05
04:31:58 UTC (rev 12161)
+++
stack/cxf/trunk/modules/client/src/main/resources/META-INF/cxf/cxf-extension-jbossws.xml 2010-05-05
06:35:09 UTC (rev 12162)
@@ -1,6 +1,10 @@
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="http://cxf.apache.org/core
http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+ <bean id="clientConfigurerInstaller"
class="org.jboss.wsf.stack.cxf.client.configuration.ConfigurerInstaller">
+ <property name="bus" ref="cxf"/>
+ </bean>
+
<!--
<bean id="logInbound"
class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
<bean id="logOutbound"
class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
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 2010-05-05
04:31:58 UTC (rev 12161)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2010-05-05
06:35:09 UTC (rev 12162)
@@ -49,7 +49,7 @@
import org.springframework.core.io.InputStreamResource;
/**
- * An wrapper of the Bus for performing most of the configurations required on it by
JBossWS
+ * A 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
@@ -110,7 +110,7 @@
* @param configurer The JBossWSCXFConfigurer to install in the bus, 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, JBossWSCXFConfigurer configurer) throws IOException
+ public void configure(URL jbossCxfXml, SoapTransportFactory soapTransportFactory,
ResourceResolver resolver, Configurer configurer) throws IOException
{
if (configured)
{
@@ -130,17 +130,19 @@
}
/**
- * A convenient method for getting a jbossws cxf configurer delegating to the cxf
configurer
- * that's currently installed in the hold bus.
+ * A convenient method for getting a jbossws cxf server configurer delegating to the
+ * cxf configurer that's currently installed in the hold bus.
*
* @param customization The binding customization to set in the configurer, if any
* @param wsdlPublisher The wsdl file publisher to set in the configurer, if any
* @return The new jbossws cxf configurer
*/
- public JBossWSCXFConfigurer createConfigurer(BindingCustomization customization,
WSDLFilePublisher wsdlPublisher)
+ public Configurer createServerConfigurer(BindingCustomization customization,
WSDLFilePublisher wsdlPublisher)
{
- Configurer delegate = bus.getExtension(Configurer.class);
- return new JBossWSServerCXFConfigurer(delegate, customization, wsdlPublisher);
+ //the JBossWSCXFConfigurer should already be set through
cxf-extensions-jbossws.xml
+ JBossWSCXFConfigurer delegate =
(JBossWSCXFConfigurer)bus.getExtension(Configurer.class);
+ delegate.setBindingCustomization(customization);
+ return new JBossWSServerCXFConfigurer(delegate, wsdlPublisher);
}
/**
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/JBossWSServerCXFConfigurer.java
===================================================================
---
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/JBossWSServerCXFConfigurer.java 2010-05-05
04:31:58 UTC (rev 12161)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/JBossWSServerCXFConfigurer.java 2010-05-05
06:35:09 UTC (rev 12162)
@@ -22,21 +22,17 @@
package org.jboss.wsf.stack.cxf.configuration;
import org.apache.cxf.configuration.Configurer;
-import org.apache.cxf.databinding.DataBinding;
-import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
-import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
-import org.jboss.wsf.spi.binding.BindingCustomization;
-import org.jboss.wsf.stack.cxf.client.configuration.JBossWSCXFConfigurer;
+import org.jboss.wsf.stack.cxf.client.configuration.DelegatingConfigurer;
import org.jboss.wsf.stack.cxf.deployment.EndpointImpl;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
/**
- * A JBossWSCXFConfigured to be used on server side
+ * A JBossWS CXF Configurer to be used on server side
*
* @author alessio.soldano(a)jboss.com
* @since 31-Mar-2010
*/
-public class JBossWSServerCXFConfigurer extends JBossWSCXFConfigurer
+public class JBossWSServerCXFConfigurer extends DelegatingConfigurer
{
private WSDLFilePublisher wsdlPublisher;
@@ -45,48 +41,21 @@
super(delegate);
}
- public JBossWSServerCXFConfigurer(Configurer delegate, BindingCustomization
customization, WSDLFilePublisher wsdlPublisher)
+ public JBossWSServerCXFConfigurer(Configurer delegate, WSDLFilePublisher
wsdlPublisher)
{
- super(delegate, customization);
+ super(delegate);
this.wsdlPublisher = wsdlPublisher;
}
@Override
protected void internalConfigure(Object beanInstance)
{
- super.internalConfigure(beanInstance);
if (beanInstance instanceof EndpointImpl)
{
configureEndpoint((EndpointImpl)beanInstance);
}
}
- @Override
- protected synchronized void configureEndpointFactory(AbstractWSDLBasedEndpointFactory
factory)
- {
- //Configure binding customization
- if (customization != null)
- {
- ReflectionServiceFactoryBean serviceFactory = factory.getServiceFactory();
- //customize default databinding (early pulls in ServiceFactory default
databinding and configure it, as it's lazily loaded)
- serviceFactory.reset();
- DataBinding serviceFactoryDataBinding = serviceFactory.getDataBinding(true);
- setBindingCustomization(serviceFactoryDataBinding, customization);
- serviceFactory.setDataBinding(serviceFactoryDataBinding);
- //customize user provided databinding (CXF later overrides the ServiceFactory
databinding using the user provided one)
- if (factory.getDataBinding() == null)
- {
- //set the endpoint factory's databinding to prevent CXF resetting
everything because user did not provide anything
- factory.setDataBinding(serviceFactoryDataBinding);
- }
- else
- {
- setBindingCustomization(factory.getDataBinding(), customization);
- }
- }
- //add other configurations here below
- }
-
protected synchronized void configureEndpoint(EndpointImpl endpoint)
{
//Configure wsdl file publisher
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-05-05
04:31:58 UTC (rev 12161)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2010-05-05
06:35:09 UTC (rev 12162)
@@ -26,6 +26,7 @@
import java.util.Map;
import org.apache.cxf.BusFactory;
+import org.apache.cxf.configuration.Configurer;
import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
import org.jboss.wsf.common.integration.WSConstants;
import org.jboss.wsf.spi.binding.BindingCustomization;
@@ -33,7 +34,6 @@
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.JBossWSCXFConfigurer;
import org.jboss.wsf.stack.cxf.configuration.BusHolder;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
import org.jboss.wsf.stack.cxf.resolver.JBossWSResourceResolver;
@@ -77,7 +77,7 @@
{
URL jbossCxfXml =
deploymentResolver.resolve(contextParams.get(BusHolder.PARAM_CXF_BEANS_URL));
org.apache.cxf.resource.ResourceResolver resolver = new
JBossWSResourceResolver(deploymentResolver);
- JBossWSCXFConfigurer configurer =
holder.createConfigurer(dep.getAttachment(BindingCustomization.class), new
WSDLFilePublisher(aDep));
+ Configurer configurer =
holder.createServerConfigurer(dep.getAttachment(BindingCustomization.class), new
WSDLFilePublisher(aDep));
holder.configure(jbossCxfXml, new SoapTransportFactoryExt(), resolver,
configurer);
}
catch (IOException e)
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jaxbintros/JAXBIntroTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jaxbintros/JAXBIntroTestCase.java 2010-05-05
04:31:58 UTC (rev 12161)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jaxbintros/JAXBIntroTestCase.java 2010-05-05
06:35:09 UTC (rev 12162)
@@ -54,14 +54,13 @@
private String endpointAddress = "http://" + getServerHost() +
":8080/jaxws-cxf-jaxbintros/EndpointService";
private Bus bus;
- private Configurer originalConfigurer;
+ private JBossWSCXFConfigurer configurer;
public static Test suite()
{
return new JBossWSTestSetup(JAXBIntroTestCase.class,
"jaxws-cxf-jaxbintros.jar");
}
- @SuppressWarnings("unchecked")
public void testWSDLAccess() throws Exception
{
URL wsdlURL = new URL(endpointAddress + "?wsdl");
@@ -105,7 +104,7 @@
}
finally
{
- restoreConfigurer();
+ unsetBindingCustomizationOnClientSide();
}
}
@@ -135,22 +134,20 @@
*
* @throws Exception
*/
+ @SuppressWarnings("unchecked")
private void setBindingCustomizationOnClientSide() throws Exception
{
BindingCustomization jaxbCustomizations = new JAXBBindingCustomization();
BindingCustomizationFactory.populateBindingCustomization(getResourceURL("jaxws/cxf/jaxbintros/META-INF/jaxb-intros.xml").openStream(),
jaxbCustomizations);
bus = BusFactory.getThreadDefaultBus();
- originalConfigurer = bus.getExtension(Configurer.class);
- JBossWSCXFConfigurer configurer = new JBossWSCXFConfigurer(originalConfigurer);
+ configurer = (JBossWSCXFConfigurer)bus.getExtension(Configurer.class);
configurer.setBindingCustomization(jaxbCustomizations);
- bus.setExtension(configurer, Configurer.class);
-
}
-
- private void restoreConfigurer()
+
+ private void unsetBindingCustomizationOnClientSide()
{
- bus.setExtension(originalConfigurer, Configurer.class);
+ if (configurer != null)
+ configurer.setBindingCustomization(null);
}
-
}