Author: alessio.soldano(a)jboss.com
Date: 2011-04-22 12:21:34 -0400 (Fri, 22 Apr 2011)
New Revision: 14187
Removed:
stack/cxf/branches/cxf24/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSBusApplicationContext.java
Modified:
stack/cxf/branches/cxf24/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java
stack/cxf/branches/cxf24/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringConfigurer.java
stack/cxf/branches/cxf24/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/JBossWSServerSpringConfigurer.java
stack/cxf/branches/cxf24/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
Log:
Fix spring bus creation
Deleted:
stack/cxf/branches/cxf24/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSBusApplicationContext.java
===================================================================
---
stack/cxf/branches/cxf24/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSBusApplicationContext.java 2011-04-22
14:47:08 UTC (rev 14186)
+++
stack/cxf/branches/cxf24/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSBusApplicationContext.java 2011-04-22
16:21:34 UTC (rev 14187)
@@ -1,121 +0,0 @@
-/*
- * 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 java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.cxf.bus.spring.BusApplicationContext;
-import org.springframework.context.ApplicationContext;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-
-/**
- * A JBossWS version of @see{org.apache.cxf.bus.spring.BusApplicationContext} that
- * allows for getting the default bus configuration from the JBossWS
- * integration.
- *
- * @author alessio.soldano(a)jboss.com
- * @since 25-May-2010
- *
- */
-public class JBossWSBusApplicationContext extends BusApplicationContext
-{
- private static final String JBWS_INTEGRATION_CXF_CFG_FILE =
"META-INF/cxf/jbossws-cxf.xml";
-
- private static final String JBWS_CXF_EXT_CFG_FILE =
"classpath*:META-INF/cxf/cxf-extension-jbossws.xml";
-
- private static final String DEFAULT_CXF_EXT_CFG_FILE =
"classpath*:META-INF/cxf/cxf.extension";
-
- private final boolean jbwsIncludeDefaults;
- private final boolean ready;
-
- public JBossWSBusApplicationContext(String[] cf, boolean include, ApplicationContext
parent)
- {
- super(cf, false, parent);
- this.jbwsIncludeDefaults = include;
- this.ready = true;
- refresh();
- }
-
- public JBossWSBusApplicationContext(URL[] url, boolean include, ApplicationContext
parent)
- {
- super(url, false, parent);
- this.jbwsIncludeDefaults = include;
- this.ready = true;
- refresh();
- }
-
- @Override
- protected Resource[] getConfigResources()
- {
- List<Resource> resources = new ArrayList<Resource>();
- if (ready)
- {
- if (jbwsIncludeDefaults)
- {
- try
- {
- PathMatchingResourcePatternResolver resolver = new
PathMatchingResourcePatternResolver(Thread
- .currentThread().getContextClassLoader());
- //jbossws-cxf.xml with our integration defaults for the Bus
- Collections.addAll(resources,
resolver.getResources(JBWS_INTEGRATION_CXF_CFG_FILE));
- //cxf-extensions-jbossws.xml, for customers' jbossws additions
- Collections.addAll(resources,
resolver.getResources(JBWS_CXF_EXT_CFG_FILE));
- //CXF vanilla extensions, need to load them here as super skips defaults
loading
- Resource[] exts = resolver.getResources(DEFAULT_CXF_EXT_CFG_FILE);
- for (Resource r : exts)
- {
- InputStream is = r.getInputStream();
- BufferedReader rd = new BufferedReader(new InputStreamReader(is,
"UTF-8"));
- String line = rd.readLine();
- while (line != null)
- {
- if (!"".equals(line))
- {
- resources.add(resolver.getResource(line));
- }
- line = rd.readLine();
- }
- is.close();
- }
-
- }
- catch (IOException ex)
- {
- // ignore
- }
- }
- //recurse to super; this loads everything else the user specified
- Resource[] superResources = super.getConfigResources();
- if (superResources != null)
- Collections.addAll(resources, superResources);
- }
- return resources.isEmpty() ? null : (Resource[]) resources.toArray(new
Resource[resources.size()]);
- }
-}
Modified:
stack/cxf/branches/cxf24/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java
===================================================================
---
stack/cxf/branches/cxf24/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java 2011-04-22
14:47:08 UTC (rev 14186)
+++
stack/cxf/branches/cxf24/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java 2011-04-22
16:21:34 UTC (rev 14187)
@@ -22,16 +22,17 @@
package org.jboss.wsf.stack.cxf.client.configuration;
import java.net.URL;
-//import java.util.logging.Level;
-//import java.util.logging.Logger;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.BusApplicationContext;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.buslifecycle.BusLifeCycleListener;
import org.apache.cxf.buslifecycle.BusLifeCycleManager;
-//import org.apache.cxf.common.logging.LogUtils;
-//import org.springframework.beans.BeansException;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.configuration.Configurer;
+import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
/**
@@ -44,7 +45,7 @@
*/
public class JBossWSSpringBusFactory extends SpringBusFactory
{
-// private static final Logger LOG =
LogUtils.getL7dLogger(JBossWSSpringBusFactory.class);
+ private static final Logger LOG =
LogUtils.getL7dLogger(JBossWSSpringBusFactory.class);
public JBossWSSpringBusFactory()
{
@@ -56,91 +57,92 @@
super(context);
}
+ /**
+ * We override the Apache CXF method to skip the checks on cxf.xml conf file as that
would prevent
+ * creating a Spring version of the bus when the jbossws-cxf.xml is available;
generally speaking
+ * the JBossWS-CXF integration requires a Spring bus to be created by Spring bus
factories.
+ */
@Override
public Bus createBus(String cfgFiles[], boolean includeDefaults)
{
-// try
-// {
-// return finishCreatingBus(createApplicationContext(cfgFiles,
includeDefaults));
-// }
-// catch (BeansException ex)
-// {
-// LogUtils.log(LOG, Level.WARNING, "APP_CONTEXT_CREATION_FAILED_MSG",
ex, (Object[]) null);
-// throw new RuntimeException(ex);
-// }
- Bus bus = super.createBus(cfgFiles, includeDefaults);
- finalizeBusCreation(bus);
- return bus;
+ try
+ {
+ return finishCreatingBus(createApplicationContext(cfgFiles, includeDefaults));
+ }
+ catch (BeansException ex)
+ {
+ LogUtils.log(LOG, Level.WARNING, "APP_CONTEXT_CREATION_FAILED_MSG",
ex, (Object[]) null);
+ throw new RuntimeException(ex);
+ }
}
@Override
public Bus createBus(URL[] urls, boolean includeDefaults)
{
-// try
-// {
-// return finishCreatingBus(new JBossWSBusApplicationContext(urls,
includeDefaults, getApplicationContext()));
-// }
-// catch (BeansException ex)
-// {
-// LogUtils.log(LOG, Level.WARNING, "APP_CONTEXT_CREATION_FAILED_MSG",
ex, (Object[]) null);
-// throw new RuntimeException(ex);
-// }
- Bus bus = super.createBus(urls, includeDefaults);
- finalizeBusCreation(bus);
+ try
+ {
+ return finishCreatingBus(new BusApplicationContext(urls, includeDefaults,
getApplicationContext()));
+ }
+ catch (BeansException ex)
+ {
+ LogUtils.log(LOG, Level.WARNING, "APP_CONTEXT_CREATION_FAILED_MSG",
ex, (Object[]) null);
+ throw new RuntimeException(ex);
+ }
+ }
+
+ private Bus finishCreatingBus(BusApplicationContext bac)
+ {
+ final Bus bus = (Bus) bac.getBean(Bus.DEFAULT_BUS_ID);
+
+ bus.setExtension(bac, BusApplicationContext.class);
+
+ setConfigurer(bus);
+
+ possiblySetDefaultBus(bus);
+
+ initializeBus(bus);
+
+ registerAppContextLifeCycleListener(bus, bac);
return bus;
}
+
+ private BusApplicationContext createApplicationContext(String cfgFiles[], boolean
includeDefaults)
+ {
+ try
+ {
+ return new BusApplicationContext(cfgFiles, includeDefaults,
getApplicationContext());
+ }
+ catch (BeansException ex)
+ {
+ LogUtils.log(LOG, Level.WARNING,
"INITIAL_APP_CONTEXT_CREATION_FAILED_MSG", ex, (Object[]) null);
+ ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
+ if (contextLoader != BusApplicationContext.class.getClassLoader())
+ {
+
Thread.currentThread().setContextClassLoader(BusApplicationContext.class.getClassLoader());
+ try
+ {
+ return new BusApplicationContext(cfgFiles, includeDefaults,
getApplicationContext());
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(contextLoader);
+ }
+ }
+ else
+ {
+ throw ex;
+ }
+ }
+ }
- private static void finalizeBusCreation(Bus bus)
+ private void setConfigurer(Bus bus)
{
- //TODO!! also set our custom configurer
- BusApplicationContext bac = bus.getExtension(BusApplicationContext.class);
- registerAppContextLifeCycleListener(bus, bac);
+ JBossWSSpringConfigurer configurer = new
JBossWSSpringConfigurer(bus.getExtension(Configurer.class));
+ configurer.setCustomizer(new BeanCustomizer());
+ bus.setExtension(configurer, Configurer.class);
}
-// private Bus finishCreatingBus(BusApplicationContext bac)
-// {
-// final Bus bus = (Bus) bac.getBean(Bus.DEFAULT_BUS_ID);
-//
-// bus.setExtension(bac, BusApplicationContext.class);
-//
-// possiblySetDefaultBus(bus);
-//
-// initializeBus(bus);
-//
-// registerAppContextLifeCycleListener(bus, bac);
-// return bus;
-// }
-//
-// private BusApplicationContext createApplicationContext(String cfgFiles[], boolean
includeDefaults)
-// {
-// try
-// {
-// return new JBossWSBusApplicationContext(cfgFiles, includeDefaults,
getApplicationContext());
-// }
-// catch (BeansException ex)
-// {
-// LogUtils.log(LOG, Level.WARNING,
"INITIAL_APP_CONTEXT_CREATION_FAILED_MSG", ex, (Object[]) null);
-// ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
-// if (contextLoader != BusApplicationContext.class.getClassLoader())
-// {
-//
Thread.currentThread().setContextClassLoader(BusApplicationContext.class.getClassLoader());
-// try
-// {
-// return new JBossWSBusApplicationContext(cfgFiles, includeDefaults,
getApplicationContext());
-// }
-// finally
-// {
-// Thread.currentThread().setContextClassLoader(contextLoader);
-// }
-// }
-// else
-// {
-// throw ex;
-// }
-// }
-// }
-
- static void registerAppContextLifeCycleListener(final Bus bus, final
BusApplicationContext bac)
+ void registerAppContextLifeCycleListener(final Bus bus, final BusApplicationContext
bac)
{
BusLifeCycleManager lm = bus.getExtension(BusLifeCycleManager.class);
if (null != lm)
Modified:
stack/cxf/branches/cxf24/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringConfigurer.java
===================================================================
---
stack/cxf/branches/cxf24/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringConfigurer.java 2011-04-22
14:47:08 UTC (rev 14186)
+++
stack/cxf/branches/cxf24/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringConfigurer.java 2011-04-22
16:21:34 UTC (rev 14187)
@@ -21,30 +21,37 @@
*/
package org.jboss.wsf.stack.cxf.client.configuration;
-import org.apache.cxf.configuration.spring.ConfigurerImpl;
+import org.apache.cxf.configuration.Configurer;
/**
- * A CXF configurer (Spring based) that sets JBossWS stuff / customizations / properties
etc. in CXF configurable beans
+ * A CXF delegate configurer that sets JBossWS stuff / customizations / properties etc.
in CXF configurable beans
+ * (to be used for Spring based bus)
*
* @author alessio.soldano(a)jboss.com
* @since 05-Oct-2009
*/
-public class JBossWSSpringConfigurer extends ConfigurerImpl implements JBossWSConfigurer
+public class JBossWSSpringConfigurer implements JBossWSConfigurer
{
private BeanCustomizer customizer;
+ private Configurer delegate;
+
+ public JBossWSSpringConfigurer(Configurer delegate)
+ {
+ this.delegate = delegate;
+ }
@Override
public void configureBean(Object beanInstance)
{
customConfigure(beanInstance);
- super.configureBean(beanInstance);
+ delegate.configureBean(beanInstance);
}
@Override
public void configureBean(String name, Object beanInstance)
{
customConfigure(beanInstance);
- super.configureBean(name, beanInstance);
+ delegate.configureBean(name, beanInstance);
}
protected synchronized void customConfigure(Object beanInstance)
Modified:
stack/cxf/branches/cxf24/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/JBossWSServerSpringConfigurer.java
===================================================================
---
stack/cxf/branches/cxf24/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/JBossWSServerSpringConfigurer.java 2011-04-22
14:47:08 UTC (rev 14186)
+++
stack/cxf/branches/cxf24/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/JBossWSServerSpringConfigurer.java 2011-04-22
16:21:34 UTC (rev 14187)
@@ -21,6 +21,8 @@
*/
package org.jboss.wsf.stack.cxf.configuration;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.configuration.spring.ConfigurerImpl;
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringConfigurer;
import org.springframework.context.ApplicationContext;
@@ -33,8 +35,12 @@
*/
public class JBossWSServerSpringConfigurer extends JBossWSSpringConfigurer
{
- public JBossWSServerSpringConfigurer(ApplicationContext ctx)
+ public JBossWSServerSpringConfigurer(Configurer delegate, ApplicationContext ctx)
{
- setApplicationContext(ctx);
+ super(delegate);
+ if (delegate instanceof ConfigurerImpl)
+ {
+ ((ConfigurerImpl)delegate).setApplicationContext(ctx);
+ }
}
}
Modified:
stack/cxf/branches/cxf24/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
===================================================================
---
stack/cxf/branches/cxf24/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2011-04-22
14:47:08 UTC (rev 14186)
+++
stack/cxf/branches/cxf24/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2011-04-22
16:21:34 UTC (rev 14187)
@@ -159,7 +159,7 @@
customizer.setBindingCustomization(customization);
customizer.setWsdlPublisher(wsdlPublisher);
customizer.setDeploymentEndpoints(depEndpoints);
- JBossWSServerSpringConfigurer serverConfigurer = new
JBossWSServerSpringConfigurer(ctx);
+ JBossWSServerSpringConfigurer serverConfigurer = new
JBossWSServerSpringConfigurer(bus.getExtension(Configurer.class), ctx);
serverConfigurer.setCustomizer(customizer);
return serverConfigurer;
}