Author: alessio.soldano(a)jboss.com
Date: 2011-10-27 05:18:37 -0400 (Thu, 27 Oct 2011)
New Revision: 15171
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
Log:
[JBWS-3280] Porting to JBossWSSpringBusFactory the Apache CXF SpringBusFactory logic for
avoiding creating a Spring Bus when no spring descriptor is found (basically for client
side usage)
Modified:
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java
===================================================================
---
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java 2011-10-27
07:29:53 UTC (rev 15170)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/configuration/JBossWSSpringBusFactory.java 2011-10-27
09:18:37 UTC (rev 15171)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2011, 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.
*
@@ -34,6 +34,7 @@
import org.apache.cxf.configuration.Configurer;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.Resource;
/**
* A JBossWS version of @see{org.apache.cxf.bus.spring.SpringBusFactory} that
@@ -46,6 +47,8 @@
public class JBossWSSpringBusFactory extends SpringBusFactory
{
private static final Logger LOG =
LogUtils.getL7dLogger(JBossWSSpringBusFactory.class);
+
+ private boolean customContextProvided = false;
public JBossWSSpringBusFactory()
{
@@ -55,18 +58,27 @@
public JBossWSSpringBusFactory(ApplicationContext context)
{
super(context);
+ this.customContextProvided = (context != null);
}
/**
- * 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.
+ * This overrides the Apache CXF method to delegate to
+ * @see{org.jboss.wsf.stack.cxf.client.configuration.JBossWSNonSpringBusFactory}
+ * when there's no need for a Spring bus.
*/
@Override
public Bus createBus(String cfgFiles[], boolean includeDefaults)
{
try
{
+ String userCfgFile =
System.getProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME);
+ String sysCfgFileUrl =
System.getProperty(Configurer.USER_CFG_FILE_PROPERTY_URL);
+ Resource r =
BusApplicationContext.findResource(Configurer.DEFAULT_USER_CFG_FILE);
+ if (!customContextProvided && userCfgFile == null && cfgFiles ==
null && sysCfgFileUrl == null
+ && (r == null || !r.exists()) && includeDefaults)
+ {
+ return new JBossWSNonSpringBusFactory().createBus();
+ }
return finishCreatingBus(createApplicationContext(cfgFiles, includeDefaults));
}
catch (BeansException ex)
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 2011-10-27
07:29:53 UTC (rev 15170)
+++
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2011-10-27
09:18:37 UTC (rev 15171)
@@ -86,7 +86,10 @@
*/
protected void createBus(URL location)
{
- bus = new JBossWSSpringBusFactory().createBus();
+ //use createBus(URL[] urls) method instead of createBus() to bypass
+ //the cxf/jbossws-cxf check on actual need for spring bus (we know
+ //it's required here as we have the jbossws-cxf.xml descriptor)
+ bus = new JBossWSSpringBusFactory().createBus((URL[])null);
ctx = bus.getExtension(BusApplicationContext.class);
//Load additional configurations from cxf-servlet.xml
if (location != null)
Show replies by date