Author: jim.ma
Date: 2012-12-25 09:47:32 -0500 (Tue, 25 Dec 2012)
New Revision: 17183
Modified:
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/CXFInstanceProviderDeploymentAspect.java
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java
stack/cxf/branches/JBWS-3396/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/aegis/jaxws/WEB-INF/jbossws-cxf.xml
stack/cxf/branches/JBWS-3396/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java
Log:
[JBWS-3395/JBWS-3396]:Enable parse the spring configuration xml generated from web.xml
Modified:
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
---
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2012-12-25
14:28:30 UTC (rev 17182)
+++
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2012-12-25
14:47:32 UTC (rev 17183)
@@ -64,6 +64,8 @@
public abstract class BusHolder
{
public static final String PARAM_CXF_BEANS_URL = "jbossws.cxf.beans.url";
+ public static final String PARAM_CXF_GEN_URL = "jbossws.cxf.gen.url";
+
protected Bus bus;
protected BusHolderLifeCycleListener busHolderListener;
Modified:
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
===================================================================
---
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2012-12-25
14:28:30 UTC (rev 17182)
+++
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2012-12-25
14:47:32 UTC (rev 17183)
@@ -47,6 +47,7 @@
import org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringConfigurer;
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
import org.jboss.wsf.stack.cxf.spring.handler.NamespaceHandlerResolver;
+import
org.jboss.wsf.stack.cxf.spring.parser.JaxwsEndpointDefinitionParser.JBossWSSpringEndpointImpl;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
@@ -64,17 +65,26 @@
private boolean configured = false;
protected BusApplicationContext ctx;
+
+ protected GenericApplicationContext jbosswsCxfContext;
protected List<GenericApplicationContext> additionalCtx = new
LinkedList<GenericApplicationContext>();
private ConfiguredBeanLocator delegatingBeanLocator;
protected URL[] additionalLocations;
+
+ protected URL jbosswsCXF;
- public SpringBusHolder(URL location, URL... additionalLocations)
+ public SpringBusHolder(URL location, URL jbosswscxf, URL... additionalLocations)
{
super();
+ createBus(location);
+ jbosswsCXF = jbosswscxf;
this.additionalLocations = additionalLocations;
- createBus(location);
+ if (jbosswsCxfContext != null &&
jbosswsCxfContext.getBeanNamesForType(JBossWSSpringEndpointImpl.class).length >=1)
+ {
+ this.additionalLocations = new URL[]{};
+ }
}
/**
@@ -106,6 +116,7 @@
DEPLOYMENT_LOGGER.unableToLoadAdditionalConfigurationFrom(location, e);
}
}
+
//Force servlet transport to prevent CXF from using Jetty / http server or other
transports
bus.setExtension(new ServletDestinationFactory(), HttpDestinationFactory.class);
}
@@ -127,17 +138,33 @@
throw MESSAGES.busAlreadyConfigured(ctx);
}
super.configure(resolver, configurer, wsmd);
- if (additionalLocations != null)
+
+ if (jbosswsCXF != null)
{
- for (URL jbossCxfXml : additionalLocations)
+ try
{
+ jbosswsCxfContext = loadAdditionalConfig(ctx, jbosswsCXF);
+ }
+ catch (IOException e)
+ {
+ DEPLOYMENT_LOGGER.unableToLoadAdditionalConfigurationFrom(jbosswsCXF, e);
+ }
+ }
+
+
+ if (jbosswsCxfContext != null
+ &&
jbosswsCxfContext.getBeansOfType(JBossWSSpringEndpointImpl.class).isEmpty() &&
additionalLocations != null)
+ {
+
+ for (URL additionXml : additionalLocations)
+ {
try
{
- loadAdditionalConfig(ctx, jbossCxfXml);
+ loadAdditionalConfig(jbosswsCxfContext, additionXml);
}
catch (IOException e)
{
- throw MESSAGES.unableToLoadConfigurationFrom(jbossCxfXml, e);
+ throw MESSAGES.unableToLoadConfigurationFrom(additionXml, e);
}
}
}
@@ -174,13 +201,13 @@
return serverConfigurer;
}
- protected GenericApplicationContext loadAdditionalConfig(ApplicationContext ctx, URL
locationUrl)
+ protected GenericApplicationContext loadAdditionalConfig(ApplicationContext parent ,
URL locationUrl)
throws IOException
{
if (locationUrl == null)
throw MESSAGES.unableToLoadAdditionalConfigFromNull();
InputStream is = locationUrl.openStream();
- GenericApplicationContext childCtx = new GenericApplicationContext(ctx);
+ GenericApplicationContext childCtx = new GenericApplicationContext(parent);
additionalCtx.add(childCtx);
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(childCtx);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
Modified:
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
===================================================================
---
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2012-12-25
14:28:30 UTC (rev 17182)
+++
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2012-12-25
14:47:32 UTC (rev 17183)
@@ -88,6 +88,7 @@
final ResourceResolver deploymentResolver = aDep.getResourceResolver();
final org.apache.cxf.resource.ResourceResolver resolver = new
JBossWSResourceResolver(deploymentResolver);
Map<String, String> contextParams = (Map<String, String>)
dep.getProperty(WSConstants.STACK_CONTEXT_PARAMS);
+ String jbosswsGenXml = contextParams == null ? null :
contextParams.get(BusHolder.PARAM_CXF_GEN_URL);
String jbosswsCxfXml = contextParams == null ? null :
contextParams.get(BusHolder.PARAM_CXF_BEANS_URL);
BusHolder holder = null;
@@ -101,7 +102,8 @@
// Spring available and jbossws-cxf.xml provided
final URL cxfServletUrl =
deploymentResolver.resolveFailSafe("WEB-INF/cxf-servlet.xml"); // TODO: decide
not to support this?
final URL jbosswsCxfUrl = getResourceUrl(deploymentResolver, jbosswsCxfXml);
- holder = new SpringBusHolder(cxfServletUrl, jbosswsCxfUrl);
+ final URL genCxfUrl = getResourceUrl(deploymentResolver, jbosswsGenXml);
+ holder = new SpringBusHolder(cxfServletUrl, jbosswsCxfUrl, new
URL[]{genCxfUrl});
}
else
{
Modified:
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/CXFInstanceProviderDeploymentAspect.java
===================================================================
---
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/CXFInstanceProviderDeploymentAspect.java 2012-12-25
14:28:30 UTC (rev 17182)
+++
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/CXFInstanceProviderDeploymentAspect.java 2012-12-25
14:47:32 UTC (rev 17183)
@@ -44,13 +44,8 @@
boolean springAvailable = SpringUtils.isSpringAvailable();
for (final Endpoint ep : dep.getService().getEndpoints())
{
- final ServerFactoryBean factory = ep.getAttachment(ServerFactoryBean.class);
- //TODO: remove this after JBWS-3396 resolved
- if (factory == null && springAvailable)
- {
- throw Messages.MESSAGES.endpointNotDefineInJbwsCxf(ep.getTargetBeanName());
- }
- ep.setInstanceProvider(new CXFInstanceProvider(factory));
+ final ServerFactoryBean factory = ep.getAttachment(ServerFactoryBean.class);
+ ep.setInstanceProvider(new CXFInstanceProvider(factory));
}
}
Modified:
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java
===================================================================
---
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java 2012-12-25
14:28:30 UTC (rev 17182)
+++
stack/cxf/branches/JBWS-3396/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/DescriptorDeploymentAspect.java 2012-12-25
14:47:32 UTC (rev 17183)
@@ -42,6 +42,8 @@
import org.jboss.wsf.stack.cxf.metadata.MetadataBuilder;
import org.jboss.wsf.stack.cxf.metadata.services.DDBeans;
+import com.ibm.wsdl.util.xml.DOMUtils;
+
/**
* A deployer that locates or generates cxf.xml
*
@@ -59,25 +61,23 @@
URL cxfURL = null;
if (SpringUtils.isSpringAvailable())
{
- //only try reading jbossws-cxf.xml if Spring available...
cxfURL = getCXFConfigFromDeployment(dep);
- //... but do not generate it if it's not provided
- //or unless it's explicitly required to be generated
- if (cxfURL == null && PREFER_SPRING_DESCRIPTOR_GENERATION)
+ if (cxfURL != null)
{
- DDBeans dd = generateMetadataFromDeployment(dep);
- cxfURL = dd.createFileURL();
- DEPLOYMENT_LOGGER.jbwscxfConfGenerated(cxfURL);
+ putCXFConfigToDeployment(dep, BusHolder.PARAM_CXF_BEANS_URL, cxfURL);
}
}
- if (cxfURL == null)
+ if (cxfURL == null) //no spring or no jbossws-cxf.xml
{
generateMetadataFromDeployment(dep);
}
- else
- {
+ else
+ {
DEPLOYMENT_LOGGER.actualConfFromFile(cxfURL);
- putCXFConfigToDeployment(dep, cxfURL);
+ DDBeans dd = generateMetadataFromDeployment(dep);
+ URL generated = dd.createFileURL();
+ DEPLOYMENT_LOGGER.jbwscxfConfGenerated(cxfURL);
+ putCXFConfigToDeployment(dep, BusHolder.PARAM_CXF_GEN_URL, generated);
}
}
@@ -147,11 +147,12 @@
* Puts CXF config file reference to the stack specific context properties.
*
* @param dep webservice deployment
- * @param cxfURL CXF DD URL
+ * @param key the key to put in the context parameter
+ * @param value the cxf spring configuration url to put in the context parameter
* @see org.jboss.ws.common.integration.WSConstants.STACK_CONTEXT_PARAMS
*/
@SuppressWarnings("unchecked")
- private void putCXFConfigToDeployment(Deployment dep, URL cxfURL)
+ private void putCXFConfigToDeployment(Deployment dep, String key, URL value)
{
// get property map
Map<String, String> contextParams = (Map<String,
String>)dep.getProperty(WSConstants.STACK_CONTEXT_PARAMS);
@@ -162,7 +163,7 @@
dep.setProperty(WSConstants.STACK_CONTEXT_PARAMS, contextParams);
}
// put cxf config URL to the property map
- contextParams.put(BusHolder.PARAM_CXF_BEANS_URL, cxfURL.toExternalForm());
+ contextParams.put(key, value.toExternalForm());
}
}
Modified:
stack/cxf/branches/JBWS-3396/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/aegis/jaxws/WEB-INF/jbossws-cxf.xml
===================================================================
---
stack/cxf/branches/JBWS-3396/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/aegis/jaxws/WEB-INF/jbossws-cxf.xml 2012-12-25
14:28:30 UTC (rev 17182)
+++
stack/cxf/branches/JBWS-3396/modules/testsuite/cxf-spring-tests/src/test/resources/jaxws/cxf/aegis/jaxws/WEB-INF/jbossws-cxf.xml 2012-12-25
14:47:32 UTC (rev 17183)
@@ -7,18 +7,9 @@
<bean id="aegisBean"
class="org.apache.cxf.aegis.databinding.AegisDatabinding"
scope="prototype" />
-
- <bean id="aegis-service-factory"
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
- scope="prototype">
+ <!--Test for JBWS-3396 -->
+ <bean
name="{http://aegis.cxf.jaxws.ws.test.jboss.org/}AegisGroupQueryImpl...
abstract="true">
<property name="dataBinding" ref="aegisBean" />
</bean>
-
- <jaxws:endpoint id='AegisGroupQueryService'
- address='http://@jboss.bind.address@:8080/jaxws-aegis'
- implementor='org.jboss.test.ws.jaxws.cxf.aegis.AegisGroupQueryImpl'>
- <jaxws:serviceFactory>
- <ref bean='aegis-service-factory' />
- </jaxws:serviceFactory>
- </jaxws:endpoint>
-
-</beans>
+</beans>
+
Modified:
stack/cxf/branches/JBWS-3396/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java
===================================================================
---
stack/cxf/branches/JBWS-3396/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java 2012-12-25
14:28:30 UTC (rev 17182)
+++
stack/cxf/branches/JBWS-3396/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java 2012-12-25
14:47:32 UTC (rev 17183)
@@ -46,9 +46,9 @@
{
if (SpringUtils.isSpringAvailable(Thread.currentThread().getContextClassLoader()))
{
- simpleShutdownTest(new SpringBusHolder(null, new URL[]{}));
- shutdownTestWithInnerShutdown(new SpringBusHolder(null, new URL[]{}));
- shutdownTestWithNoShutdown(new SpringBusHolder(null, new URL[]{}));
+ simpleShutdownTest(new SpringBusHolder(null, null, new URL[]{}));
+ shutdownTestWithInnerShutdown(new SpringBusHolder(null, null, new URL[]{}));
+ shutdownTestWithNoShutdown(new SpringBusHolder(null, null, new URL[]{}));
}
else
{