Author: rsearls
Date: 2014-06-11 11:57:09 -0400 (Wed, 11 Jun 2014)
New Revision: 18726
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/interceptor/WSDLSoapAddressRewriteInterceptor.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/util/WSDLSoapAddressRewriteUtils.java
Log:
revised code in accordance with CXF-5792 patch integration
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-09
12:19:56 UTC (rev 18725)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/deployment/EndpointImpl.java 2014-06-11
15:57:09 UTC (rev 18726)
@@ -33,7 +33,6 @@
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;
@@ -91,21 +90,13 @@
}
/**
- * Replaces the WSDLGetInInterceptor with a custom interceptor that also does proper
soap:address rewrite
+ * Add interceptor that enables the desired soap:address rewrite
*/
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);
- inList.add(index, WSDLSoapAddressRewriteInterceptor.INSTANCE);
- }
- }
- }
+ List<Interceptor<? extends Message>> inInterceptors =
getInInterceptors();
+ if(!inInterceptors.contains(WSDLSoapAddressRewriteInterceptor.INSTANCE)){
+ inInterceptors.add(WSDLSoapAddressRewriteInterceptor.INSTANCE);
}
}
}
@@ -150,8 +141,7 @@
/**
* Publish the contract to a file using the configured wsdl publisher
- *
- * @param endpoint
+ *
*/
protected void publishContractToFilesystem()
{
@@ -245,4 +235,5 @@
}
return
AccessController.doPrivileged(AbstractServerConfig.GET_SERVER_INTEGRATION_SERVER_CONFIG);
}
+
}
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-09
12:19:56 UTC (rev 18725)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/WSDLSoapAddressRewriteInterceptor.java 2014-06-11
15:57:09 UTC (rev 18726)
@@ -21,123 +21,31 @@
*/
package org.jboss.wsf.stack.cxf.interceptor;
-import org.apache.cxf.binding.soap.interceptor.EndpointSelectionInterceptor;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.common.util.UrlUtils;
-import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.frontend.WSDLGetInterceptor;
-import org.apache.cxf.frontend.WSDLGetOutInterceptor;
-import org.apache.cxf.interceptor.*;
+import org.apache.cxf.frontend.WSDLGetUtils;
+import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageImpl;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
-import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor;
import org.jboss.wsf.stack.cxf.interceptor.util.WSDLSoapAddressRewriteUtils;
-import org.w3c.dom.Document;
-import java.util.Iterator;
-import java.util.Map;
-
/**
- * This is a customization of org.apache.cxf.frontend.WSDLGetInterceptor. It
- * enables the handling of rewriting the path of a URL.
- *
+ * This inInterceptor registers a custom WSDLGetUtils which will preform the desired
+ * soap:address rewrite
+ *
* @author rsearls(a)redhat.com
* @since 19-May-2014
*/
public class WSDLSoapAddressRewriteInterceptor extends
AbstractPhaseInterceptor<Message> {
public static final WSDLSoapAddressRewriteInterceptor INSTANCE =
new WSDLSoapAddressRewriteInterceptor();
- private static final String TRANSFORM_SKIP = "transform.skip";
- private Interceptor<Message> wsdlGetOutInterceptor =
WSDLGetOutInterceptor.INSTANCE;
public WSDLSoapAddressRewriteInterceptor() {
- super(Phase.READ);
- getAfter().add(EndpointSelectionInterceptor.class.getName());
+ // this must run before WSDLGetInterceptor which is in Phase.READ
+ super(Phase.POST_STREAM);
}
- public WSDLSoapAddressRewriteInterceptor(Interceptor<Message> outInterceptor) {
- this();
- // Let people override the wsdlGetOutInterceptor
- wsdlGetOutInterceptor = outInterceptor;
- }
-
public void handleMessage(Message message) throws Fault {
- String method = (String)message.get(Message.HTTP_REQUEST_METHOD);
- String query = (String)message.get(Message.QUERY_STRING);
-
- if (!"GET".equals(method) || StringUtils.isEmpty(query)) {
- return;
- }
-
- String baseUri = (String)message.get(Message.REQUEST_URL);
- String ctx = (String)message.get(Message.PATH_INFO);
-
- Map<String, String> map = UrlUtils.parseQueryString(query);
- if (isRecognizedQuery(map, baseUri, ctx,
message.getExchange().getEndpoint().getEndpointInfo())) {
- Document doc = getDocument(message, baseUri, map, ctx);
-
- Endpoint e = message.getExchange().get(Endpoint.class);
- Message mout = new MessageImpl();
- mout.setExchange(message.getExchange());
- mout = e.getBinding().createMessage(mout);
-
mout.setInterceptorChain(OutgoingChainInterceptor.getOutInterceptorChain(message.getExchange()));
- message.getExchange().setOutMessage(mout);
-
- mout.put(WSDLGetInterceptor.DOCUMENT_HOLDER, doc);
- mout.put(Message.CONTENT_TYPE, "text/xml");
-
- // just remove the interceptor which should not be used
- cleanUpOutInterceptors(mout);
-
- // notice this is being added after the purge above, don't swap the order!
- mout.getInterceptorChain().add(wsdlGetOutInterceptor);
-
- message.getExchange().put(TRANSFORM_SKIP, Boolean.TRUE);
- // skip the service executor and goto the end of the chain.
- message.getInterceptorChain().doInterceptStartingAt(
- message,
- OutgoingChainInterceptor.class.getName());
- }
+ message.setContextualProperty(WSDLGetUtils.class.getName(), new
WSDLSoapAddressRewriteUtils());
}
- protected void cleanUpOutInterceptors(Message outMessage) {
- // TODO - how can I improve this to provide a specific interceptor chain that just
has the
- // stax, gzip and message sender components, while also ensuring that GZIP is only
provided
- // if its already configured for the endpoint.
- Iterator<Interceptor<? extends Message>> iterator =
outMessage.getInterceptorChain().iterator();
- while (iterator.hasNext()) {
- Interceptor<? extends Message> inInterceptor = iterator.next();
- if (!inInterceptor.getClass().equals(StaxOutInterceptor.class)
- && !inInterceptor.getClass().equals(GZIPOutInterceptor.class)
- && !inInterceptor.getClass().equals(MessageSenderInterceptor.class))
{
- outMessage.getInterceptorChain().remove(inInterceptor);
- }
- }
-
- }
-
- private Document getDocument(Message message, String base, Map<String, String>
params, String ctxUri) {
- // cannot have two wsdl's being generated for the same endpoint at the same
- // time as the addresses may get mixed up
- // For WSDL's the WSDLWriter does not share any state between documents.
- // For XSD's, the WSDLSoapAddressRewriteUtils makes a copy of any XSD schema
documents before updating
- // any addresses and returning them, so for both WSDL and XSD this is the only part
that needs
- // to be synchronized.
- synchronized (message.getExchange().getEndpoint()) {
- return new WSDLSoapAddressRewriteUtils().getDocument(message, base, params,
ctxUri,
- message.getExchange().getEndpoint().getEndpointInfo());
- }
- }
-
- private boolean isRecognizedQuery(Map<String, String> map, String baseUri,
String ctx,
- EndpointInfo endpointInfo) {
- if (map.containsKey("wsdl") || map.containsKey("xsd")) {
- return true;
- }
- return false;
- }
-
}
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-09
12:19:56 UTC (rev 18725)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/interceptor/util/WSDLSoapAddressRewriteUtils.java 2014-06-11
15:57:09 UTC (rev 18726)
@@ -73,8 +73,27 @@
}
- @Override
- public Document getDocument(Message message,
+ @Override
+ public String getPublishableEndpointUrl(Definition def, String epurl,
+ EndpointInfo endpointInfo){
+
+ if (endpointInfo.getProperty(PUBLISHED_ENDPOINT_URL) != null) {
+ epurl = String.valueOf(endpointInfo.getProperty(PUBLISHED_ENDPOINT_URL));
+ updatePublishedEndpointUrl(epurl, def, endpointInfo.getName());
+ } else {
+ // When using replacement path, must set replacement path in the active url.
+ final ServerConfig sc = getServerConfig();
+ if (SoapAddressRewriteHelper.isPathRewriteRequired(sc)
+ &&
endpointInfo.getAddress().contains(ServerConfig.UNDEFINED_HOSTNAME)) {
+ epurl = SoapAddressRewriteHelper.getRewrittenPublishedEndpointUrl(epurl,
sc);
+ updatePublishedEndpointUrl(epurl, def, endpointInfo.getName());
+ }
+ }
+ return epurl;
+ }
+
+ //@Override
+ public Document XXgetDocument(Message message,
String base,
Map<String, String> params,
String ctxUri,
@@ -133,11 +152,12 @@
Definition def = builder.build(new HashMap<String, SchemaInfo>());
mp.put("", def);
- updateDefinition(bus, def, mp, smp, base, endpointInfo, "");
+ updateDefinition(bus, def, mp, smp, base, "");
}
Document doc;
+ //- xsd, mp, wsdl, bus, base, endpointInfo
if (xsd == null) {
Definition def = mp.get(wsdl);
if (def == null) {
@@ -178,6 +198,7 @@
doc = wsdlWriter.getDocument(def);
}
} else {
+ //-- xsd, smp, bus, base, wsdl,
SchemaReference si = smp.get(xsd);
if (si == null) {
String xsd2 =
resolveWithCatalogs(OASISCatalogManager.getCatalogManager(bus),