Author: asoldano
Date: 2014-06-03 10:40:42 -0400 (Tue, 03 Jun 2014)
New Revision: 18712
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/WSDLSoapAddressRewriteInterceptor.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/util/WSDLSoapAddressRewriteUtils.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java
stack/cxf/branches/rsearls/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java
Log:
Misc cleanup
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2014-06-03
10:16:17 UTC (rev 18711)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/RequestHandlerImpl.java 2014-06-03
14:40:42 UTC (rev 18712)
@@ -52,7 +52,6 @@
import org.jboss.util.NotImplementedException;
import org.jboss.ws.common.management.AbstractServerConfig;
import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.deployment.Service;
import org.jboss.wsf.spi.invocation.InvocationContext;
import org.jboss.wsf.spi.invocation.RequestHandler;
import org.jboss.wsf.spi.management.EndpointMetrics;
@@ -137,7 +136,6 @@
{
throw
Messages.MESSAGES.cannotObtainRegistry(DestinationRegistry.class.getName());
}
-
requestURI = pathPattern.matcher(requestURI).replaceAll("/");
//first try looking up the destination in the registry map
final AbstractHTTPDestination dest = destRegistry.getDestinationForPath(requestURI,
true);
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java 2014-06-03
10:16:17 UTC (rev 18711)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java 2014-06-03
14:40:42 UTC (rev 18712)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.addressRewrite;
import java.util.HashMap;
@@ -8,7 +29,7 @@
* characters are simply kept in a char array. For all other more exotic source
* characters, a proper hash map is used to store the mapping.
*/
-class CharMap {
+final class CharMap {
private final char[] map = new char[256];
private final Map<Character, Character> extendedMap = new HashMap<Character,
Character>();
@@ -31,38 +52,14 @@
add(source, destination);
}
- /**
- * Adds the given source and destination characters to this char map.. If
- * the strings do not have the same length, subsequent characters in the
- * longer string are ignored. The first mapping is defined as
- * {@code source[0] --> destination[0]}, all other mappings in an analogous
- * way with matching character indices in the two strings.
- *
- * @param source
- * source characters
- * @param destination
- * destination characters
- * @throws IllegalArgumentException
- * if any of the destination characters is the zero character
- */
- public void add(String source, String destination) {
+ private void add(String source, String destination) {
final int len = Math.min(source.length(), destination.length());
for (int i = 0; i < len; i++) {
add(source.charAt(i), destination.charAt(i));
}
}
- /**
- * Adds the given mapping {@code source --> destination} to this char map.
- *
- * @param source
- * source character
- * @param destination
- * destination character
- * @throws IllegalArgumentException
- * if the destination character is the zero character
- */
- public void add(char source, char destination) {
+ private void add(char source, char destination) {
if (destination == 0) {
throw new IllegalArgumentException("cannot map to zero character");
}
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java 2014-06-03
10:16:17 UTC (rev 18711)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java 2014-06-03
14:40:42 UTC (rev 18712)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.addressRewrite;
import java.util.Arrays;
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java 2014-06-03
10:16:17 UTC (rev 18711)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java 2014-06-03
14:40:42 UTC (rev 18712)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.addressRewrite;
public final class SedArguments
@@ -2,39 +23,17 @@
{
-
private boolean isGlobal = false;
-
private boolean isIgnoreCase = false;
-
private boolean isTranslate = false;
-
private boolean isSubstitute = false;
-
- // operand: <script>
private String script;
-
private boolean scriptIsSet = false;
-
- // operand: <regexp>
private String regexp;
-
private boolean regexpIsSet = false;
-
- // operand: <string1>
private String string1;
-
private boolean string1IsSet = false;
-
- // operand: <replacement>
private String replacement;
-
private boolean replacementIsSet = false;
-
- // operand: <string2>
private String string2;
-
private boolean string2IsSet = false;
-
- // operand: <occurrence>
private int[] occurrence;
-
private boolean occurrenceIsSet = false;
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java 2014-06-03
10:16:17 UTC (rev 18711)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java 2014-06-03
14:40:42 UTC (rev 18712)
@@ -25,7 +25,6 @@
import java.net.URI;
import java.net.URL;
-import org.apache.cxf.common.util.StringUtils;
import org.jboss.wsf.spi.management.ServerConfig;
@@ -33,6 +32,7 @@
* Helper for rewriting soap:address in published wsdl
*
* @author alessio.soldano(a)jboss.com
+ * @author rsears(a)redhat.com
* @since 30-Nov-2012
*/
public class SoapAddressRewriteHelper
@@ -48,7 +48,7 @@
* @param serverConfig The current ServerConfig
* @return The rewritten soap:address to be used in the wsdl
*/
- public static String getRewrittenPublishedEndpointUrl(String wsdlAddress, String
epAddress, ServerConfig serverConfig, String contextRoot) {
+ public static String getRewrittenPublishedEndpointUrl(String wsdlAddress, String
epAddress, ServerConfig serverConfig) {
if (wsdlAddress == null) {
return null;
}
@@ -57,7 +57,7 @@
final String origUriScheme = getUriScheme(wsdlAddress); //will be https if the
user wants a https address in the wsdl
final String newUriScheme = getUriScheme(epAddress); //will be https if the user
set confidential transport for the endpoint
final String uriScheme = (origUriScheme.equals(HTTPS) ||
newUriScheme.equals(HTTPS)) ? HTTPS : HTTP;
- return rewriteSoapAddress(serverConfig, wsdlAddress, epAddress, uriScheme,
serverConfig.getWebServicePathRewriteRule(), contextRoot);
+ return rewriteSoapAddress(serverConfig, wsdlAddress, epAddress, uriScheme);
}
else
{
@@ -65,6 +65,41 @@
}
}
+ /**
+ * Rewrite and get address to be used for CXF published endpoint url prop (rewritten
wsdl address).
+ * This method is to be used for code-first endpoints, when no wsdl is provided by the
user.
+ *
+ * @param address The container computed endpoint address
+ * @param serverConfig The current ServerConfig
+ * @return
+ */
+ public static String getRewrittenPublishedEndpointUrl(String address, ServerConfig
serverConfig)
+ {
+ try
+ {
+ if (isPathRewriteRequired(serverConfig))
+ {
+ final URL url = new URL(address);
+ final String path = url.getPath();
+ final String tmpPath =
SEDProcessor.newInstance(serverConfig.getWebServicePathRewriteRule()).processLine(path);
+ final String newUrl=url.toString().replace(path, tmpPath);
+
+ ADDRESS_REWRITE_LOGGER.addressRewritten(address, newUrl);
+ return newUrl;
+ }
+ else
+ {
+ ADDRESS_REWRITE_LOGGER.rewriteNotRequired(address);
+ return address;
+ }
+ }
+ catch (Exception e)
+ {
+ ADDRESS_REWRITE_LOGGER.invalidAddressProvidedUseItWithoutRewriting(address,
"");
+ return address;
+ }
+ }
+
public static boolean isAutoRewriteOn(ServerConfig serverConfig)
{
return serverConfig.isModifySOAPAddress() &&
ServerConfig.UNDEFINED_HOSTNAME.equals(serverConfig.getWebServiceHost());
@@ -119,7 +154,7 @@
* @param uriScheme The uriScheme to use for rewrite
* @return The obtained address
*/
- private static String rewriteSoapAddress(ServerConfig serverConfig, String
origAddress, String newAddress, String uriScheme, String additionalCcontext, String
contextRoot)
+ private static String rewriteSoapAddress(ServerConfig serverConfig, String
origAddress, String newAddress, String uriScheme)
{
try
{
@@ -148,11 +183,11 @@
sb.append("://");
sb.append(host);
sb.append(port);
- // replace original context-root with replacement context
- if (additionalCcontext != null && additionalCcontext.length() > 0) {
- String tmpPath =
SEDProcessor.newInstance(additionalCcontext).processLine(path);
- sb.append(tmpPath);
- } else
+
+ if (isPathRewriteRequired(serverConfig)) {
+
sb.append(SEDProcessor.newInstance(serverConfig.getWebServicePathRewriteRule()).processLine(path));
+ }
+ else
{
sb.append(path);
}
@@ -183,34 +218,11 @@
}
- public static String rewriteSoapAddress(ServerConfig serverConfig, String address)
- {
- try
- {
- final String additionalCcontext = serverConfig.getWebServicePathRewriteRule();
- if (isSoapAddressRewrite(serverConfig))
- {
- final URL url = new URL(address);
- final String path = url.getPath();
- final String tmpPath =
SEDProcessor.newInstance(additionalCcontext).processLine(path);
- final String newUrl=url.toString().replace(path, tmpPath);
-
- ADDRESS_REWRITE_LOGGER.addressRewritten(address, newUrl);
- return newUrl;
- } else
- {
- ADDRESS_REWRITE_LOGGER.rewriteNotRequired(address);
- return address;
- }
-
- } catch (Exception e)
- {
- ADDRESS_REWRITE_LOGGER.invalidAddressProvidedUseItWithoutRewriting(address,
"");
- return address;
+ public static boolean isPathRewriteRequired(ServerConfig sc){
+ if (!sc.isModifySOAPAddress()) {
+ return false;
}
+ final String pathRewriteRule = sc.getWebServicePathRewriteRule();
+ return pathRewriteRule != null && !pathRewriteRule.isEmpty();
}
-
- public static boolean isSoapAddressRewrite(ServerConfig sc){
- return (sc.isModifySOAPAddress() &&
!StringUtils.isEmpty(sc.getWebServicePathRewriteRule()));
- }
}
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2014-06-03
10:16:17 UTC (rev 18711)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2014-06-03
14:40:42 UTC (rev 18712)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2014, 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.
*
@@ -21,9 +21,19 @@
*/
package org.jboss.wsf.stack.cxf.deployment;
+import java.io.IOException;
+import java.security.AccessController;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
import org.apache.cxf.Bus;
import org.apache.cxf.configuration.Configurer;
import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.frontend.WSDLGetInterceptor;
import org.apache.cxf.frontend.WSDLGetUtils;
import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
@@ -38,13 +48,6 @@
import org.jboss.wsf.stack.cxf.Loggers;
import org.jboss.wsf.stack.cxf.addressRewrite.SoapAddressRewriteHelper;
import org.jboss.wsf.stack.cxf.interceptor.WSDLSoapAddressRewriteInterceptor;
-import javax.xml.namespace.QName;
-import java.io.IOException;
-import java.security.AccessController;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
/**
@@ -78,7 +81,7 @@
// A custom interceptor is required when the server config attributes for
rewriting
// the path in a WSDL URL (i.e., <soap:address location= ...) are set
- setCustomInterceptor();
+ replaceWSDLGetInterceptor();
//allow for configuration so that the wsdlPublisher can be set be the
JBossWSCXFConfigurer
configureObject(this);
@@ -88,16 +91,14 @@
}
/**
- * A custom interceptor is required when the server config attributes for rewriting
- * the path in a WSDL URL (i.e., <soap:address location= ...) are set
+ * Replaces the WSDLGetInInterceptor with a custom interceptor that also does proper
soap:address rewrite
*/
- private void setCustomInterceptor(){
- if (SoapAddressRewriteHelper.isSoapAddressRewrite(getServerConfig())) {
- Collection<Endpoint> epList = super.getService().getEndpoints().values();
- for (Endpoint ep : epList) {
- List<Interceptor<? extends Message>> inList =
ep.getInInterceptors();
- for (Interceptor in : inList) {
- if (in instanceof org.apache.cxf.frontend.WSDLGetInterceptor) {
+ private void replaceWSDLGetInterceptor(){
+ if (SoapAddressRewriteHelper.isPathRewriteRequired(getServerConfig())) {
+ for (Endpoint ep : getService().getEndpoints().values()) {
+ final List<Interceptor<? extends Message>> inList =
ep.getInInterceptors();
+ for (Interceptor<? extends Message> in : inList) {
+ if (in instanceof WSDLGetInterceptor) {
int index = inList.indexOf(in);
if (index > -1) {
inList.remove(index);
@@ -229,7 +230,7 @@
} else {
//- wsdl-first handling
if (ei.getAddress().contains(ServerConfig.UNDEFINED_HOSTNAME)){
- String epurl =
SoapAddressRewriteHelper.rewriteSoapAddress(servConfig, ei.getAddress());
+ String epurl =
SoapAddressRewriteHelper.getRewrittenPublishedEndpointUrl(ei.getAddress(), servConfig);
ei.setAddress(epurl);
}
}
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/WSDLSoapAddressRewriteInterceptor.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/WSDLSoapAddressRewriteInterceptor.java 2014-06-03
10:16:17 UTC (rev 18711)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/WSDLSoapAddressRewriteInterceptor.java 2014-06-03
14:40:42 UTC (rev 18712)
@@ -1,3 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.interceptor;
import org.apache.cxf.binding.soap.interceptor.EndpointSelectionInterceptor;
@@ -22,7 +43,9 @@
/**
* This is a customization of org.apache.cxf.frontend.WSDLGetInterceptor. It
* enables the handling of rewriting the path of a URL.
- * Date: 5/19/14
+ *
+ * @author rsearls(a)redhat.com
+ * @since 19-May-2014
*/
public class WSDLSoapAddressRewriteInterceptor extends
AbstractPhaseInterceptor<Message> {
public static final WSDLSoapAddressRewriteInterceptor INSTANCE =
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/util/WSDLSoapAddressRewriteUtils.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/util/WSDLSoapAddressRewriteUtils.java 2014-06-03
10:16:17 UTC (rev 18711)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/util/WSDLSoapAddressRewriteUtils.java 2014-06-03
14:40:42 UTC (rev 18712)
@@ -1,5 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, 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.interceptor.util;
+import java.net.URLDecoder;
+import java.security.AccessController;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Logger;
+
+import javax.wsdl.Definition;
+import javax.wsdl.extensions.schema.SchemaReference;
+import javax.wsdl.xml.WSDLWriter;
+import javax.xml.transform.dom.DOMSource;
+
import org.apache.cxf.Bus;
import org.apache.cxf.catalog.OASISCatalogManager;
import org.apache.cxf.common.logging.LogUtils;
@@ -16,29 +49,18 @@
import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
import org.jboss.ws.common.management.AbstractServerConfig;
import org.jboss.wsf.spi.management.ServerConfig;
-import org.jboss.wsf.stack.cxf.addressRewrite.SEDProcessor;
import org.jboss.wsf.stack.cxf.addressRewrite.SoapAddressRewriteHelper;
import org.jboss.wsf.stack.cxf.interceptor.WSDLSoapAddressRewriteInterceptor;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
-import javax.wsdl.Definition;
-import javax.wsdl.extensions.schema.SchemaReference;
-import javax.wsdl.xml.WSDLWriter;
-import javax.xml.transform.dom.DOMSource;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.security.AccessController;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Logger;
-import org.apache.cxf.common.util.StringUtils;
-
-
/**
- * User: rsearls
- * Date: 5/19/14
+ * This is an extension of the org.apache.cxf.frontend.WSDLGetUtils; currently this
+ * is needed for properly setting the publishedEndpointURL in the code-first scenario
+ * when a path rewrite rule is specified in the server configuration.
+ *
+ * @author rsearls(a)redhat.com
+ *
*/
public class WSDLSoapAddressRewriteUtils extends WSDLGetUtils {
@@ -141,10 +163,10 @@
base = epurl;
} else {
// When using replacement path, must set replacement path in the active
url.
- ServerConfig sc = getServerConfig();
- if (SoapAddressRewriteHelper.isSoapAddressRewrite(getServerConfig())
+ final ServerConfig sc = getServerConfig();
+ if (SoapAddressRewriteHelper.isPathRewriteRequired(sc)
&&
endpointInfo.getAddress().contains(ServerConfig.UNDEFINED_HOSTNAME)) {
- String epurl = SoapAddressRewriteHelper.rewriteSoapAddress(sc,
base);
+ String epurl =
SoapAddressRewriteHelper.getRewrittenPublishedEndpointUrl(base, sc);
updatePublishedEndpointUrl(epurl, def, endpointInfo.getName());
base = epurl;
}
@@ -202,20 +224,6 @@
}
}
- @Override
- public void updateWSDLPublishedEndpointAddress(Definition def, EndpointInfo
endpointInfo)
- {
- synchronized (def) {
- //writing a def is not threadsafe. Sync on it to make sure
- //we don't get any ConcurrentModificationExceptions
- if (endpointInfo.getProperty(PUBLISHED_ENDPOINT_URL) != null) {
- String epurl =
- String.valueOf(endpointInfo.getProperty(PUBLISHED_ENDPOINT_URL));
- updatePublishedEndpointUrl(epurl, def, endpointInfo.getName());
- }
- }
- }
-
private static ServerConfig getServerConfig() {
if(System.getSecurityManager() == null) {
return AbstractServerConfig.getServerIntegrationServerConfig();
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java 2014-06-03
10:16:17 UTC (rev 18711)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/metadata/MetadataBuilder.java 2014-06-03
14:40:42 UTC (rev 18712)
@@ -21,6 +21,25 @@
*/
package org.jboss.wsf.stack.cxf.metadata;
+import static org.jboss.wsf.stack.cxf.Loggers.METADATA_LOGGER;
+import static org.jboss.wsf.stack.cxf.Messages.MESSAGES;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+import java.util.StringTokenizer;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.WebServiceProvider;
+import javax.xml.ws.soap.MTOM;
+import javax.xml.ws.soap.SOAPBinding;
+
import org.jboss.ws.common.JavaUtils;
import org.jboss.ws.common.deployment.SOAPAddressWSDLParser;
import org.jboss.ws.common.management.AbstractServerConfig;
@@ -40,19 +59,6 @@
import org.jboss.wsf.stack.cxf.metadata.services.DDBeans;
import org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint;
-import javax.jws.WebService;
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingType;
-import javax.xml.ws.WebServiceProvider;
-import javax.xml.ws.soap.MTOM;
-import javax.xml.ws.soap.SOAPBinding;
-import java.net.URL;
-import java.security.AccessController;
-import java.util.*;
-
-import static org.jboss.wsf.stack.cxf.Loggers.METADATA_LOGGER;
-import static org.jboss.wsf.stack.cxf.Messages.MESSAGES;
-
/**
* Builds the DDBeans metadata used for generating the jboss-cxf.xml deployment
descriptor
*
@@ -288,8 +294,7 @@
//do not try rewriting addresses for not-http binding
String wsdlAddress = parser.filterSoapAddress(ddep.getServiceName(),
ddep.getPortName(), SOAPAddressWSDLParser.SOAP_HTTP_NS);
- String rewrittenWsdlAddress =
- SoapAddressRewriteHelper.getRewrittenPublishedEndpointUrl(wsdlAddress,
ddep.getAddress(), sc, dep.getService().getContextRoot());
+ String rewrittenWsdlAddress =
SoapAddressRewriteHelper.getRewrittenPublishedEndpointUrl(wsdlAddress, ddep.getAddress(),
sc);
//If "auto rewrite", leave "publishedEndpointUrl" unset
so that CXF does 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.
@@ -302,9 +307,8 @@
} else {
//same comment as above regarding auto rewrite...
if (!SoapAddressRewriteHelper.isAutoRewriteOn(sc)) {
- //- code-first handling
- String base = SoapAddressRewriteHelper.rewriteSoapAddress(sc,
ddep.getAddress());
- ddep.setPublishedEndpointUrl(base); //force computed address for code first
endpoints
+ //force computed address for code first endpoints
+
ddep.setPublishedEndpointUrl(SoapAddressRewriteHelper.getRewrittenPublishedEndpointUrl(ddep.getAddress(),
sc));
}
}
}
Modified:
stack/cxf/branches/rsearls/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java
===================================================================
---
stack/cxf/branches/rsearls/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java 2014-06-03
10:16:17 UTC (rev 18711)
+++
stack/cxf/branches/rsearls/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java 2014-06-03
14:40:42 UTC (rev 18712)
@@ -530,13 +530,14 @@
}
/**
- * Test soap:address rewrite. The new address contains the webServicePath setting.
+ * Test soap:address rewrite when a path rewrite rule is specified.
+ *
* @throws Exception
*/
- public void testRewriteContext() throws Exception
+ public void testRewriteWithPathRule() throws Exception
{
setModifySOAPAddress(true);
- final String addContext = "xx/jaxws-jbws2150";
+ final String expectedContext = "xx/jaxws-jbws2150";
final String sedCmd = "s/jaxws-jbws2150/xx\\/jaxws-jbws2150/g";
setWebServicePathRewriteRule(sedCmd);
deploy("jaxws-jbws2150.war");
@@ -554,19 +555,19 @@
Definition definition = getWSDLDefinition(wsdlLocation);
String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
- assertEquals("http://" + serverHost + ":8080/" +
addContext + "/ValidURL", address);
+ assertEquals("http://" + serverHost + ":8080/" +
expectedContext + "/ValidURL", address);
address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
- assertEquals("http://" + serverHost + ":8080/" +
addContext + "/InvalidURL", address);
+ assertEquals("http://" + serverHost + ":8080/" +
expectedContext + "/InvalidURL", address);
address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
- assertEquals("https://" + serverHost + ":8443/" +
addContext + "/ValidSecureURL", address);
+ assertEquals("https://" + serverHost + ":8443/" +
expectedContext + "/ValidSecureURL", address);
address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
- assertEquals("https://" + serverHost + ":8443/" +
addContext + "/InvalidSecureURL", address);
+ assertEquals("https://" + serverHost + ":8443/" +
expectedContext + "/InvalidSecureURL", address);
//check wsdl import (which is bound to the endpoint currently serving the
wsdl)
- assertTrue(getWsdlImportAddress(definition).contains(addContext));
+ assertTrue(getWsdlImportAddress(definition).contains(expectedContext));
}
}
finally
@@ -576,14 +577,14 @@
}
/**
- * Test soap:address rewrite. The new address contains the webServicePath setting.
+ * Test soap:address rewrite for code-first endpoints when a path rewrite rule is
specified
*
* @throws Exception
*/
- public void testRewriteCodeFirstContext() throws Exception
+ public void testRewriteCodeFirstPathRule() throws Exception
{
setModifySOAPAddress(true);
- final String addContext = "xx/jaxws-jbws2150-codefirst";
+ final String expectedContext = "xx/jaxws-jbws2150-codefirst";
final String sedCmd =
"s/jaxws-jbws2150-codefirst/xx\\/jaxws-jbws2150-codefirst/g";
setWebServicePathRewriteRule(sedCmd);
deploy("jaxws-jbws2150-codefirst.war");
@@ -594,7 +595,7 @@
Definition definition = getWSDLDefinition(wsdlLocation);
String address = getPortAddress(definition, "CodeFirstService",
"CodeFirstPort");
- assertEquals("http://" + serverHost + ":8080/" + addContext
+"/CodeFirstService", address);
+ assertEquals("http://" + serverHost + ":8080/" +
expectedContext +"/CodeFirstService", address);
}
finally
{
@@ -603,14 +604,15 @@
}
/**
- * Test soap:address rewrite with code-first endpoint and context set
+ * Test soap:address rewrite for code-first endpoints when a path rewrite rule is
specified and auto-rewrite is on
+ * (wsdl host prop set to ServerConfig.UNDEFINED_HOSTNAME)
*
* @throws Exception
*/
- public void testAutoRewriteCodeFirstContext() throws Exception
+ public void testAutoRewriteCodeFirstPathRule() throws Exception
{
setModifySOAPAddress(true);
- final String addContext = "xx/jaxws-jbws2150-codefirst";
+ final String expectedContext = "xx/jaxws-jbws2150-codefirst";
final String sedCmd =
"s/jaxws-jbws2150-codefirst/xx\\/jaxws-jbws2150-codefirst/g";
setWebServicePathRewriteRule(sedCmd);
setWebServiceHost(ServerConfig.UNDEFINED_HOSTNAME);
@@ -622,11 +624,11 @@
Definition definition = getWSDLDefinition(wsdlLocation);
String address = getPortAddress(definition, "CodeFirstService",
"CodeFirstPort");
- assertEquals("http://" + serverHost + ":8080/" + addContext
+"/CodeFirstService", address);
+ assertEquals("http://" + serverHost + ":8080/" +
expectedContext +"/CodeFirstService", address);
if (isTestsuiteServerHostLocalhost()) {
definition =
getWSDLDefinition("http://127.0.0.1:8080/jaxws-jbws2150-codefirst/CodeFirstService?wsdl");
address = getPortAddress(definition, "CodeFirstService",
"CodeFirstPort");
- assertEquals("http://127.0.0.1:8080/" + addContext
+"/CodeFirstService", address);
+ assertEquals("http://127.0.0.1:8080/" + expectedContext
+"/CodeFirstService", address);
}
}
finally
@@ -636,16 +638,14 @@
}
/**
- * Test soap:address rewrite with host configured to ServerConfig.UNDEFINED_HOSTNAME
and context set
- *
- * (see MetadataBuilder#processAddressRewrite)
+ * Test soap:address rewrite with host configured to ServerConfig.UNDEFINED_HOSTNAME
and path rewrite rule specified
*
* @throws Exception
*/
- public void testAutoRewriteContext() throws Exception
+ public void testAutoRewritePathRule() throws Exception
{
setModifySOAPAddress(true);
- final String addContext = "xx/jaxws-jbws2150";
+ final String expectedContext = "xx/jaxws-jbws2150";
final String sedCmd = "s/jaxws-jbws2150/xx\\/jaxws-jbws2150/g";
setWebServicePathRewriteRule(sedCmd);
setWebServiceHost(ServerConfig.UNDEFINED_HOSTNAME);
@@ -670,19 +670,19 @@
Definition definition = getWSDLDefinition(wsdlLocation);
String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
- assertEquals("http://" + host + ":8080/" + addContext +
"/ValidURL", address);
+ assertEquals("http://" + host + ":8080/" +
expectedContext + "/ValidURL", address);
address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
- assertEquals("http://" + host + ":8080/" + addContext +
"/InvalidURL", address);
+ assertEquals("http://" + host + ":8080/" +
expectedContext + "/InvalidURL", address);
address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
- assertEquals("http://" + host + ":8080/" + addContext +
"/ValidSecureURL", address);
+ assertEquals("http://" + host + ":8080/" +
expectedContext + "/ValidSecureURL", address);
address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
- assertEquals("http://" + host + ":8080/" + addContext +
"/InvalidSecureURL", address);
+ assertEquals("http://" + host + ":8080/" +
expectedContext + "/InvalidSecureURL", address);
//check wsdl import (which is bound to the endpoint currently serving the
wsdl)
- assertTrue(getWsdlImportAddress(definition).contains(addContext));
+ assertTrue(getWsdlImportAddress(definition).contains(expectedContext));
}
}
finally