Author: mmusaji
Date: 2013-03-06 06:36:51 -0500 (Wed, 06 Mar 2013)
New Revision: 17385
Modified:
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/AddressRewritingEndpointInfo.java
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/SoapTransportFactoryExt.java
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java
Log:
[BZ916944] Merged changes from JBWS-3571
Modified:
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2013-03-06
11:35:11 UTC (rev 17384)
+++
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2013-03-06
11:36:51 UTC (rev 17385)
@@ -200,8 +200,10 @@
String ctxUri = req.getRequestURI();
String baseUri = req.getRequestURL().toString() + "?" +
req.getQueryString();
EndpointInfo endpointInfo = dest.getEndpointInfo();
- endpointInfo.setProperty(WSDLGetInterceptor.AUTO_REWRITE_ADDRESS,
-
ServerConfig.UNDEFINED_HOSTNAME.equals(serverConfig.getWebServiceHost()));
+ if (serverConfig.isModifySOAPAddress()) {
+ endpointInfo.setProperty(WSDLGetInterceptor.AUTO_REWRITE_ADDRESS,
+
ServerConfig.UNDEFINED_HOSTNAME.equals(serverConfig.getWebServiceHost()));
+ }
for (QueryHandler queryHandler :
bus.getExtension(QueryHandlerRegistry.class).getHandlers())
{
Modified:
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2013-03-06
11:35:11 UTC (rev 17384)
+++
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/BusHolder.java 2013-03-06
11:36:51 UTC (rev 17385)
@@ -26,13 +26,11 @@
import java.util.Map;
import org.apache.cxf.Bus;
-import org.apache.cxf.binding.soap.SoapTransportFactory;
import org.apache.cxf.buslifecycle.BusLifeCycleListener;
import org.apache.cxf.buslifecycle.BusLifeCycleManager;
import org.apache.cxf.configuration.Configurer;
import org.apache.cxf.resource.ResourceManager;
import org.apache.cxf.resource.ResourceResolver;
-import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.workqueue.AutomaticWorkQueue;
import org.apache.cxf.workqueue.AutomaticWorkQueueImpl;
import org.apache.cxf.workqueue.WorkQueueManager;
@@ -76,12 +74,11 @@
* Update the Bus held by the this instance using the provided parameters.
* This basically prepares the bus for being used with JBossWS.
*
- * @param soapTransportFactory The SoapTransportFactory to configure, if any
* @param resolver The ResourceResolver to configure, if any
* @param configurer The JBossWSCXFConfigurer to install in the bus, if
any
* @param dep The current JBossWS-SPI Deployment
*/
- public void configure(SoapTransportFactory soapTransportFactory, ResourceResolver
resolver, Configurer configurer, Deployment dep)
+ public void configure(ResourceResolver resolver, Configurer configurer, Deployment
dep)
{
bus.setProperty(org.jboss.wsf.stack.cxf.client.Constants.DEPLOYMENT_BUS, true);
busHolderListener = new BusHolderLifeCycleListener();
@@ -92,7 +89,6 @@
bus.setExtension(configurer, Configurer.class);
}
setInterceptors(bus);
- setSoapTransportFactory(bus, soapTransportFactory);
setResourceResolver(bus, resolver);
//set MaximalAlternativeSelector on server side [JBWS-3149]
@@ -150,17 +146,6 @@
}
}
- protected static void setSoapTransportFactory(Bus bus, SoapTransportFactory factory)
- {
- if (factory != null)
- {
- DestinationFactoryManager dfm =
bus.getExtension(DestinationFactoryManager.class);
- factory.setBus(bus);
- dfm.registerDestinationFactory(org.jboss.ws.common.Constants.NS_SOAP11,
factory);
- dfm.registerDestinationFactory(org.jboss.ws.common.Constants.NS_SOAP12,
factory);
- }
- }
-
/**
* Adds work queues parsing simple values of properties in jboss-webservices.xml:
* cxf.queue.<queue-name>.<parameter> = value
Modified:
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2013-03-06
11:35:11 UTC (rev 17384)
+++
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/NonSpringBusHolder.java 2013-03-06
11:36:51 UTC (rev 17385)
@@ -30,7 +30,6 @@
import javax.xml.ws.handler.Handler;
import javax.xml.ws.soap.SOAPBinding;
-import org.apache.cxf.binding.soap.SoapTransportFactory;
import org.apache.cxf.configuration.Configurer;
import org.apache.cxf.resource.ResourceResolver;
import org.apache.cxf.service.invoker.Invoker;
@@ -79,18 +78,17 @@
* Update the Bus held by the this instance using the provided parameters.
* This basically prepares the bus for being used with JBossWS.
*
- * @param soapTransportFactory The SoapTransportFactory to configure, if any
* @param resolver The ResourceResolver to configure, if any
* @param configurer The JBossWSCXFConfigurer to install in the bus, if
any
*/
@Override
- public void configure(SoapTransportFactory soapTransportFactory, ResourceResolver
resolver, Configurer configurer, Deployment dep)
+ public void configure(ResourceResolver resolver, Configurer configurer, Deployment
dep)
{
if (configured)
{
throw new IllegalStateException(BundleUtils.getMessage(bundle,
"BUS_IS_ALREADY_CONFIGURED"));
}
- super.configure(soapTransportFactory, resolver, configurer, dep);
+ super.configure(resolver, configurer, dep);
for (DDEndpoint dde : metadata.getEndpoints())
{
@@ -115,6 +113,7 @@
addressingFeature.setResponses(dde.getAddressingResponses());
endpoint.getFeatures().add(addressingFeature);
}
+ endpoint.setPublishedEndpointUrl(dde.getPublishedEndpointUrl());
endpoint.publish();
endpoints.add(endpoint);
if (dde.isMtomEnabled())
Modified:
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2013-03-06
11:35:11 UTC (rev 17384)
+++
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/configuration/SpringBusHolder.java 2013-03-06
11:36:51 UTC (rev 17385)
@@ -29,7 +29,6 @@
import java.util.ResourceBundle;
import org.apache.cxf.Bus;
-import org.apache.cxf.binding.soap.SoapTransportFactory;
import org.apache.cxf.bus.spring.BusApplicationContext;
import org.apache.cxf.configuration.Configurer;
import org.apache.cxf.resource.ResourceResolver;
@@ -113,19 +112,18 @@
* Update the Bus held by the this instance using the provided parameters.
* This basically prepares the bus for being used with JBossWS.
*
- * @param soapTransportFactory The SoapTransportFactory to configure, if any
* @param resolver The ResourceResolver to configure, if any
* @param configurer The JBossWSCXFConfigurer to install in the bus, if
any
* @param dep The current JBossWS-SPI Deployment
*/
@Override
- public void configure(SoapTransportFactory soapTransportFactory, ResourceResolver
resolver, Configurer configurer, Deployment dep)
+ public void configure(ResourceResolver resolver, Configurer configurer, Deployment
dep)
{
if (configured)
{
throw new IllegalStateException(BundleUtils.getMessage(bundle,
"BUS_IS_ALREADY_CONFIGURED"));
}
- super.configure(soapTransportFactory, resolver, configurer, dep);
+ super.configure(resolver, configurer, dep);
if (additionalLocations != null)
{
for (URL jbossCxfXml : additionalLocations)
Modified:
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2013-03-06
11:35:11 UTC (rev 17384)
+++
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/aspect/BusDeploymentAspect.java 2013-03-06
11:36:51 UTC (rev 17385)
@@ -43,7 +43,6 @@
import org.jboss.wsf.stack.cxf.deployment.WSDLFilePublisher;
import org.jboss.wsf.stack.cxf.metadata.services.DDBeans;
import org.jboss.wsf.stack.cxf.resolver.JBossWSResourceResolver;
-import org.jboss.wsf.stack.cxf.transport.SoapTransportFactoryExt;
/**
* A deployment aspect that creates the CXF Bus early and attaches it to the endpoints
(wrapped in a BusHolder)
@@ -110,7 +109,7 @@
}
Configurer configurer =
holder.createServerConfigurer(dep.getAttachment(BindingCustomization.class),
new WSDLFilePublisher(aDep), dep.getService().getEndpoints(),
aDep.getRootFile());
- holder.configure(new SoapTransportFactoryExt(), resolver, configurer, dep);
+ holder.configure(resolver, configurer, dep);
dep.addAttachment(BusHolder.class, holder);
}
finally
Modified:
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java 2013-03-06
11:35:11 UTC (rev 17384)
+++
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java 2013-03-06
11:36:51 UTC (rev 17385)
@@ -21,6 +21,8 @@
*/
package org.jboss.wsf.stack.cxf.metadata;
+import java.io.IOException;
+import java.net.URL;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -39,10 +41,15 @@
import org.jboss.logging.Logger;
import org.jboss.ws.api.util.BundleUtils;
import org.jboss.ws.common.JavaUtils;
+import org.jboss.ws.common.deployment.SOAPAddressWSDLParser;
+import org.jboss.wsf.spi.SPIProvider;
+import org.jboss.wsf.spi.SPIProviderResolver;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.deployment.HttpEndpoint;
+import org.jboss.wsf.spi.management.ServerConfig;
+import org.jboss.wsf.spi.management.ServerConfigFactory;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainsMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData;
@@ -51,6 +58,7 @@
import org.jboss.wsf.spi.metadata.webservices.WebservicesFactory;
import org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData;
import org.jboss.wsf.stack.cxf.JBossWSInvoker;
+import org.jboss.wsf.stack.cxf.addressRewrite.SoapAddressRewriteHelper;
import org.jboss.wsf.stack.cxf.metadata.services.DDBeans;
import org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint;
@@ -66,6 +74,8 @@
private static final ResourceBundle bundle =
BundleUtils.getBundle(MetadataBuilder.class);
private static final Logger log = Logger.getLogger(MetadataBuilder.class);
+ private static ServerConfig serverConfig;
+
public MetadataBuilder()
{
@@ -73,6 +83,7 @@
public DDBeans build(Deployment dep)
{
+ Map<String, SOAPAddressWSDLParser> soapAddressWsdlParsers = new
HashMap<String, SOAPAddressWSDLParser>();
DDBeans dd = new DDBeans();
for (Endpoint ep : dep.getService().getEndpoints())
{
@@ -83,7 +94,8 @@
ddep.setInvoker(JBossWSInvoker.class.getName());
}
processWSDDContribution(ddep, (ArchiveDeployment)dep);
-
+ processAddressRewrite(ddep, (ArchiveDeployment)dep, soapAddressWsdlParsers);
+
log.info("Add " + ddep);
dd.addEndpoint(ddep);
}
@@ -217,22 +229,27 @@
Class<?> seiClass = null;
String seiName;
+ boolean missingServicePortAttr = false;
String name = (anWebService != null) ? anWebService.name() : "";
if (name.length() == 0)
name = JavaUtils.getJustClassName(sepClass);
String serviceName = (anWebService != null) ? anWebService.serviceName() :
anWebServiceProvider.serviceName();
- if (serviceName.length() == 0)
+ if (serviceName.length() == 0) {
+ missingServicePortAttr = true;
serviceName = JavaUtils.getJustClassName(sepClass) + "Service";
+ }
String serviceNS = (anWebService != null) ? anWebService.targetNamespace() :
anWebServiceProvider.targetNamespace();
if (serviceNS.length() == 0)
serviceNS = getTypeNamespace(JavaUtils.getPackageName(sepClass));
String portName = (anWebService != null) ? anWebService.portName() :
anWebServiceProvider.portName();
- if (portName.length() == 0)
+ if (portName.length() == 0) {
+ missingServicePortAttr = true;
portName = name + "Port";
+ }
if (anWebService != null && anWebService.endpointInterface().length() >
0)
{
@@ -258,6 +275,7 @@
throw new RuntimeException(BundleUtils.getMessage(bundle,
"ATTRIBUTES_NOT_FOUND", seiName));
}
+ final String annWsdlLocation = (anWebService != null) ? anWebService.wsdlLocation()
: anWebServiceProvider.wsdlLocation();
DDEndpoint result = new DDEndpoint();
@@ -273,9 +291,52 @@
props.put(k, ep.getProperty(k));
}
result.setProperties(props);
+ if (!missingServicePortAttr && annWsdlLocation.length() > 0) {
+ result.setAnnotationWsdlLocation(annWsdlLocation);
+ }
return result;
}
+ protected void processAddressRewrite(DDEndpoint ddep, ArchiveDeployment dep,
Map<String, SOAPAddressWSDLParser> soapAddressWsdlParsers)
+ {
+ String wsdlLocation = ddep.getWsdlLocation();
+ if (wsdlLocation == null) {
+ wsdlLocation = ddep.getAnnotationWsdlLocation();
+ }
+ if (wsdlLocation != null) {
+ try {
+ URL wsdlUrl = dep.getResourceResolver().resolve(wsdlLocation);
+
+ SOAPAddressWSDLParser parser = getCurrentSOAPAddressWSDLParser(wsdlUrl,
soapAddressWsdlParsers);
+ //do not try rewriting addresses for not-http binding
+ String wsdlAddress = parser.filterSoapAddress(ddep.getServiceName(),
ddep.getPortName(), SOAPAddressWSDLParser.SOAP_HTTP_NS);
+
+ final ServerConfig sc = getServerConfig();
+ String rewrittenWsdlAddress =
SoapAddressRewriteHelper.getRewrittenPublishedEndpointUrl(wsdlAddress, ddep.getAddress(),
sc);
+ //If "auto rewrite", leave "publishedEndpointUrl" unset so
that CXF do not force host/port values for
+ //wsdl imports and auto-rewrite them too; otherwise set the new address into
"publishedEndpointUrl",
+ //which causes CXF to override any address in the published wsdl.
+ if (!SoapAddressRewriteHelper.isAutoRewriteOn(sc)) {
+ ddep.setPublishedEndpointUrl(rewrittenWsdlAddress);
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private SOAPAddressWSDLParser getCurrentSOAPAddressWSDLParser(URL wsdlUrl,
Map<String, SOAPAddressWSDLParser> soapAddressWsdlParsers) {
+ final String key = wsdlUrl.toString();
+ SOAPAddressWSDLParser parser = soapAddressWsdlParsers.get(key);
+ if (parser != null) {
+ return parser;
+ } else {
+ parser = new SOAPAddressWSDLParser(wsdlUrl);
+ soapAddressWsdlParsers.put(key, parser);
+ return parser;
+ }
+ }
+
/**
* Extracts the typeNS given the package name
* Algorithm is based on the one specified in JAXWS v2.0 spec
@@ -308,4 +369,14 @@
return sb.toString();
}
+ private static synchronized ServerConfig getServerConfig()
+ {
+ if (serverConfig == null)
+ {
+ SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
+ serverConfig = spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();
+ }
+ return serverConfig;
+ }
+
}
Modified:
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java 2013-03-06
11:35:11 UTC (rev 17384)
+++
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/services/DDEndpoint.java 2013-03-06
11:36:51 UTC (rev 17385)
@@ -42,6 +42,8 @@
private String id;
private String address;
+
+ private String publishedEndpointUrl;
private String implementor;
@@ -72,6 +74,8 @@
//additional fields
private Class<?> epClass;
+ private String annotationWsdlLocation;
+
private int counter = 0;
public QName getPortName()
@@ -114,6 +118,16 @@
this.address = address;
}
+ public String getPublishedEndpointUrl()
+ {
+ return publishedEndpointUrl;
+ }
+
+ public void setPublishedEndpointUrl(String publishedEndpointUrl)
+ {
+ this.publishedEndpointUrl = publishedEndpointUrl;
+ }
+
public String getImplementor()
{
return implementor;
@@ -134,6 +148,16 @@
this.wsdlLocation = wsdlLocation;
}
+ public String getAnnotationWsdlLocation()
+ {
+ return annotationWsdlLocation;
+ }
+
+ public void setAnnotationWsdlLocation(String annotationWsdlLocation)
+ {
+ this.annotationWsdlLocation = annotationWsdlLocation;
+ }
+
public Class<?> getEpClass()
{
return epClass;
@@ -231,6 +255,10 @@
{
writer.write("<jaxws:endpoint id='" + this.id +
"'");
writer.write(" address='" + this.address + "'");
+ if (this.publishedEndpointUrl != null)
+ {
+ writer.write(" publishedEndpointUrl='" + this.publishedEndpointUrl
+ "'");
+ }
writer.write(" implementor='" + this.implementor +
"'");
if (this.serviceName != null)
{
@@ -242,7 +270,7 @@
}
if (this.wsdlLocation != null)
{
- writer.write(" wsdlLocationOverride='" + this.wsdlLocation +
"'");
+ writer.write(" wsdlLocation='" + this.wsdlLocation +
"'");
}
writer.write(">");
@@ -317,16 +345,16 @@
writer.write(" xmlns:" + prefix + "='" +
qname.getNamespaceURI() + "'");
}
- public String toString()
+ private StringBuilder basicToString()
{
StringBuilder str = new StringBuilder("Service");
str.append("\n id=" + this.id);
str.append("\n address=" + this.address);
str.append("\n implementor=" + this.implementor);
- str.append("\n invoker=" + this.invoker);
str.append("\n serviceName=" + this.serviceName);
str.append("\n portName=" + this.portName);
- str.append("\n wsdlLocation=" + this.wsdlLocation);
+ str.append("\n annotationWsdlLocation=" + this.annotationWsdlLocation);
+ str.append("\n wsdlLocationOverride=" + this.wsdlLocation);
str.append("\n mtomEnabled=" + this.mtomEnabled);
if (this.handlers != null && !this.handlers.isEmpty()) {
str.append("\n handlers=[");
@@ -335,6 +363,19 @@
str.append(it.hasNext() ? "," : "]");
}
}
+ return str;
+ }
+
+ public String toString()
+ {
+ return basicToString().toString();
+ }
+
+ public String toStringExtended()
+ {
+ StringBuilder str = basicToString();
+ str.append("\n publishedEndpointUrl=" + this.publishedEndpointUrl);
+ str.append("\n invoker=" + this.invoker);
if (this.properties != null && !this.properties.isEmpty())
{
str.append("\n properties=[");
Modified:
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/AddressRewritingEndpointInfo.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/AddressRewritingEndpointInfo.java 2013-03-06
11:35:11 UTC (rev 17384)
+++
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/AddressRewritingEndpointInfo.java 2013-03-06
11:36:51 UTC (rev 17385)
@@ -1,216 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.net.URI;
-import java.net.URL;
-
-import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.service.model.ServiceInfo;
-import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.management.ServerConfig;
-
-/**
- * A custom EndpointInfo that updates the SoapAddress extension
- * coming from the wsdl definition according to the JBossWS
- * soap address rewrite rules.
- *
- * @see org.apache.cxf.binding.soap.SoapTransportFactory.SoapEndpointInfo
- *
- * @author alessio.soldano(a)jboss.com
- * @since 03-Aug-2009
- *
- */
-public class AddressRewritingEndpointInfo extends EndpointInfo
-{
- private static Logger log = Logger.getLogger(AddressRewritingEndpointInfo.class);
-
- private ServerConfig serverConfig;
- SoapAddress saddress;
-
- AddressRewritingEndpointInfo(ServiceInfo serv, String trans, ServerConfig
serverConfig)
- {
- super(serv, trans);
- this.serverConfig = serverConfig;
- }
-
- /**
- * This is the method responsible for both setting the EndpointInfo address and
- * setting the soap:address in the wsdl.
- * While the former action is straightforward, the latter is performed according
- * to the JBossWS configuration: every time CXF updates the EndpointInfo address
- * (which usually happens twice) this makes sure a proper address is updated in
- * the wsdl.
- *
- * {@inheritDoc}
- */
- public void setAddress(String s)
- {
- String previousAddress = super.getAddress();
- super.setAddress(s);
- boolean setNewAddress = false;
- if (previousAddress == null)
- {
- setNewAddress = true;
- }
- else if (isRewriteAllowed(s) && isRewriteRequired(s, previousAddress))
- {
- String uriScheme = getUriScheme(s);
- //we set https if the transport guarantee is CONFIDENTIAL or the previous
address already used https
- //(if the original wsdl soap:address uses https we can't overwrite it with
http)
- if ("https".equalsIgnoreCase(getUriScheme(previousAddress)))
- {
- uriScheme = "https";
- }
- if (uriScheme == null)
- {
- uriScheme = "http";
- }
- //rewrite the candidate new address
- s = rewriteSoapAddress(s, uriScheme);
- setNewAddress = true;
- }
- if (setNewAddress && saddress != null)
- {
- log.info("Setting new service endpoint address in wsdl: " + s);
- saddress.setLocationURI(s);
- }
- }
-
- public void addExtensor(Object el)
- {
- super.addExtensor(el);
- if (el instanceof SoapAddress)
- {
- saddress = (SoapAddress)el;
- }
- }
-
- protected boolean isRewriteAllowed(String address)
- {
- //exclude non http addresses
- return (address != null &&
address.trim().toLowerCase().startsWith("http"));
- }
-
-
- protected boolean isRewriteRequired(String address, String previousAddress)
- {
- //JBWS-3297:rewrite is only needed when previousAddress(from wsdl) is different
with the published wsdl
- if (address.equals(previousAddress)) {
- return false;
- }
- //check config prop forcing address rewrite
- if (serverConfig.isModifySOAPAddress())
- {
- log.debug("Rewrite required because of configuration");
- return true;
- }
- //check if the previous address is not valid
- if (isInvalidAddress(previousAddress))
- {
- log.debug("Rewrite required because of invalid url");
- return true;
- }
- log.debug("Rewrite not required");
- return false;
- }
-
- protected boolean isInvalidAddress(String address)
- {
- if (address == null)
- {
- return true;
- }
- String s = address.trim();
- if (s.length() == 0 || s.contains("REPLACE_WITH_ACTUAL_URL"))
- {
- return true;
- }
- try
- {
- new URL(s);
- }
- catch (Exception e)
- {
- return true;
- }
- return false;
- }
-
- /**
- * Rewrite the provided address according to the current server
- * configuration and always using the specified uriScheme.
- *
- * @param s The source address
- * @param uriScheme The uriScheme to use for rewrite
- * @return The obtained address
- */
- protected String rewriteSoapAddress(String s, String uriScheme)
- {
- try
- {
- URL url = new URL(s);
- String path = url.getPath();
- String host = serverConfig.getWebServiceHost();
- String port = "";
- if ("https".equals(uriScheme))
- {
- int portNo = serverConfig.getWebServiceSecurePort();
- if (portNo != 443)
- {
- port = ":" + portNo;
- }
- }
- else
- {
- int portNo = serverConfig.getWebServicePort();
- if (portNo != 80)
- {
- port = ":" + portNo;
- }
- }
- String urlStr = uriScheme + "://" + host + port + path;
- log.debugf("Rewritten new candidate service endpoint address '%s'
to '%s'", s, urlStr);
- return urlStr;
- }
- catch (Exception e)
- {
- log.debugf("Invalid url provided, using it without rewriting: %s",
s);
- return s;
- }
- }
-
- private static String getUriScheme(String address)
- {
- try
- {
- URI addrURI = new URI(address);
- String scheme = addrURI.getScheme();
- return scheme;
- }
- catch (Exception e)
- {
- return null;
- }
- }
-}
Modified:
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/SoapTransportFactoryExt.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/SoapTransportFactoryExt.java 2013-03-06
11:35:11 UTC (rev 17384)
+++
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/server/src/main/java/org/jboss/wsf/stack/cxf/transport/SoapTransportFactoryExt.java 2013-03-06
11:36:51 UTC (rev 17385)
@@ -1,106 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * 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.
- *
- * 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.Iterator;
-import java.util.List;
-
-import org.apache.cxf.binding.soap.SoapTransportFactory;
-import org.apache.cxf.binding.soap.jms.interceptor.SoapJMSConstants;
-import org.apache.cxf.binding.soap.model.SoapBindingInfo;
-import org.apache.cxf.service.model.BindingInfo;
-import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.service.model.ServiceInfo;
-import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
-import org.apache.cxf.tools.util.SOAPBindingUtil;
-import org.jboss.wsf.spi.SPIProvider;
-import org.jboss.wsf.spi.SPIProviderResolver;
-import org.jboss.wsf.spi.management.ServerConfig;
-import org.jboss.wsf.spi.management.ServerConfigFactory;
-
-/**
- * A SoapTransportFactory extending @see
org.apache.cxf.binding.soap.SoapTransportFactory.
- * It overrides the EndpointInfo creation method to allow for the soap:address extension
- * of the wsdl to be overwritten according to the JBossWS configuration.
- *
- * @author alessio.soldano(a)jboss.com
- * @since 31-Jul-2009
- *
- */
-public class SoapTransportFactoryExt extends SoapTransportFactory
-{
- private ServerConfig serverConfig;
-
- @Override
- public EndpointInfo createEndpointInfo(ServiceInfo serviceInfo, BindingInfo b,
List<?> ees)
- {
- String transportURI = "http://schemas.xmlsoap.org/wsdl/soap/";
- if (b instanceof SoapBindingInfo)
- {
- SoapBindingInfo sbi = (SoapBindingInfo) b;
- transportURI = sbi.getTransportURI();
- }
- ServerConfig config = getServerConfig();
- EndpointInfo info = new AddressRewritingEndpointInfo(serviceInfo, transportURI,
config);
-
- if (ees != null)
- {
- for (@SuppressWarnings("rawtypes")Iterator itr = ees.iterator();
itr.hasNext();)
- {
- Object extensor = itr.next();
-
- if (SOAPBindingUtil.isSOAPAddress(extensor))
- {
- final SoapAddress sa = SOAPBindingUtil.getSoapAddress(extensor);
-
- info.addExtensor(sa);
- info.setAddress(sa.getLocationURI());
- if (isJMSSpecAddress(sa.getLocationURI()))
- {
-
info.setTransportId(SoapJMSConstants.SOAP_JMS_SPECIFICIATION_TRANSPORTID);
- }
- }
- else
- {
- info.addExtensor(extensor);
- }
- }
- }
-
- return info;
- }
-
- private boolean isJMSSpecAddress(String address)
- {
- return address != null && address.startsWith("jms:") &&
!"jms://".equals(address);
- }
-
- private ServerConfig getServerConfig()
- {
- if (serverConfig == null)
- {
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- serverConfig = spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();
- }
- return serverConfig;
- }
-}
Modified:
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java 2013-03-06
11:35:11 UTC (rev 17384)
+++
stack/cxf/branches/jbossws-cxf-4.0.6.GA_BZ-916944/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3098/BusHolderLifeCycleTestCase.java 2013-03-06
11:36:51 UTC (rev 17385)
@@ -63,7 +63,7 @@
Bus bus = holder.getBus();
TestLifeCycleListener listener = new TestLifeCycleListener();
bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(listener);
- holder.configure(null, null, null, null);
+ holder.configure(null, null, null);
holder.close();
assertEquals("preShutdown method on listener should be called exactly once;
number of actual calls: "
+ listener.getCount(), 1, listener.getCount());
@@ -74,7 +74,7 @@
Bus bus = holder.getBus();
TestLifeCycleListener listener = new TestLifeCycleListener();
bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(listener);
- holder.configure(null, null, null, null);
+ holder.configure(null, null, null);
bus.shutdown(true);
holder.close();
assertEquals("preShutdown method on listener should be called exactly once;
number of actual calls: "
@@ -86,7 +86,7 @@
Bus bus = holder.getBus();
TestLifeCycleListener listener = new TestLifeCycleListener();
bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(listener);
- holder.configure(null, null, null, null);
+ holder.configure(null, null, null);
assertEquals("preShutdown method on listener shouldn't be called before
holder is closed: number of actual calls: "
+ listener.getCount(), 0, listener.getCount());
holder.close();