cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject git commit: [CXF-5984] Provide a simple way start a decoupled servlet endpoint
Date Wed, 10 Sep 2014 09:08:46 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes c0ee2ba90 -> ddb5a9740


[CXF-5984] Provide a simple way start a decoupled servlet endpoint


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ddb5a974
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ddb5a974
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ddb5a974

Branch: refs/heads/3.0.x-fixes
Commit: ddb5a9740861a2242d97ee582f751cde564e324d
Parents: c0ee2ba
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Tue Sep 2 15:12:32 2014 +0200
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Wed Sep 10 11:08:27 2014 +0200

----------------------------------------------------------------------
 .../cxf/ws/addressing/WSAContextUtils.java      |  2 +
 .../ws/addressing/impl/MAPAggregatorImpl.java   |  9 +++
 .../ws/addressing/impl/MAPAggregatorTest.java   | 70 ++++++++++++++++++++
 3 files changed, 81 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ddb5a974/core/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java b/core/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java
index f8e3117..aa727e0 100644
--- a/core/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java
+++ b/core/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java
@@ -29,6 +29,8 @@ import org.apache.cxf.message.Message;
 public final class WSAContextUtils {
     public static final String REPLYTO_PROPERTY =
         "org.apache.cxf.ws.addressing.replyto";
+    public static final String DECOUPLED_ENDPOINT_BASE_PROPERTY =
+        "org.apache.cxf.ws.addressing.decoupled.endpoint.base";
 
     private static final String USING_PROPERTY =
         "org.apache.cxf.ws.addressing.using";    

http://git-wip-us.apache.org/repos/asf/cxf/blob/ddb5a974/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
----------------------------------------------------------------------
diff --git a/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
b/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
index c535694..15ca563 100644
--- a/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
+++ b/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorImpl.java
@@ -932,6 +932,15 @@ public class MAPAggregatorImpl extends MAPAggregator {
                 }
             }
             if (dest != null) {
+                // if the decoupled endpoint context prop is set and the address is relative,
return the absolute url.
+                final String replyTo = dest.getAddress().getAddress().getValue();  
+                if (replyTo.startsWith("/")) {
+                    String debase = 
+                        (String)message.getContextualProperty(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY);
+                    if (debase != null) {
+                        return EndpointReferenceUtils.getEndpointReference(debase + replyTo);
+                    }
+                }
                 return dest.getAddress();
             }
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/ddb5a974/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorTest.java
b/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorTest.java
index 7ec7ca1..95c612b 100644
--- a/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorTest.java
+++ b/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/impl/MAPAggregatorTest.java
@@ -35,9 +35,13 @@ import javax.xml.ws.ResponseWrapper;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.Binding;
+import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.SoapFault;
+import org.apache.cxf.binding.soap.model.SoapBindingInfo;
+import org.apache.cxf.bus.extension.ExtensionManagerBus;
 import org.apache.cxf.bus.managers.PhaseManagerImpl;
 import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointImpl;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Exchange;
@@ -46,6 +50,7 @@ import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.phase.PhaseManager;
 import org.apache.cxf.service.Service;
+import org.apache.cxf.service.ServiceImpl;
 import org.apache.cxf.service.model.BindingFaultInfo;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.BindingMessageInfo;
@@ -58,14 +63,19 @@ import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.DestinationFactoryManager;
 import org.apache.cxf.ws.addressing.AddressingProperties;
 import org.apache.cxf.ws.addressing.AttributedURIType;
 import org.apache.cxf.ws.addressing.ContextUtils;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.ws.addressing.EndpointReferenceUtils;
 import org.apache.cxf.ws.addressing.JAXWSAConstants;
 import org.apache.cxf.ws.addressing.Names;
+import org.apache.cxf.ws.addressing.WSAContextUtils;
 import org.easymock.EasyMock;
 import org.easymock.IMocksControl;
+
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -446,6 +456,66 @@ public class MAPAggregatorTest extends Assert {
         assertEquals("http://foo/bar/SEI/opRequest", action);
     }
     
+    @Test
+    public void testGetReplyToUsingBaseAddress() throws Exception {
+        Message message = new MessageImpl();  
+        Exchange exchange = new ExchangeImpl();
+        message.setExchange(exchange);
+
+        final String localReplyTo =  "/SoapContext/decoupled";
+        final String decoupledEndpointBase = "http://localhost:8181/cxf";
+        final String replyTo =  decoupledEndpointBase + localReplyTo;
+        
+        ServiceInfo s = new ServiceInfo();
+        Service svc = new ServiceImpl(s);
+        EndpointInfo ei = new EndpointInfo();
+        InterfaceInfo ii = s.createInterface(new QName("FooInterface"));
+        s.setInterface(ii);
+        ii.addOperation(new QName("fooOp"));
+        SoapBindingInfo b = new SoapBindingInfo(s, "http://schemas.xmlsoap.org/soap/", Soap11.getInstance());
+        b.setTransportURI("http://schemas.xmlsoap.org/soap/http");
+        ei.setBinding(b);
+        
+        ei.setAddress("http://nowhere.com/bar/foo");
+        ei.setName(new QName("http://nowhere.com/port", "foo"));
+        Bus bus = new ExtensionManagerBus();
+        DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
+        DestinationFactory df = control.createMock(DestinationFactory.class);
+        Destination d = control.createMock(Destination.class);
+        bus.setExtension(dfm, DestinationFactoryManager.class);
+        EasyMock.expect(dfm.getDestinationFactoryForUri(localReplyTo)).andReturn(df);
+        EasyMock.expect(df.getDestination(
+            EasyMock.anyObject(EndpointInfo.class), EasyMock.anyObject(Bus.class))).andReturn(d);
+        EasyMock.expect(d.getAddress()).andReturn(EndpointReferenceUtils.getEndpointReference(localReplyTo));
+        
+        Endpoint ep = new EndpointImpl(bus, svc, ei);
+        exchange.put(Endpoint.class, ep);
+        exchange.put(Bus.class, bus);
+        exchange.setOutMessage(message);
+        setUpMessageProperty(message,
+                             REQUESTOR_ROLE,
+                             Boolean.TRUE);
+        message.getContextualProperty(WSAContextUtils.REPLYTO_PROPERTY);
+        message.setContextualProperty(WSAContextUtils.REPLYTO_PROPERTY, localReplyTo);
+        message.setContextualProperty(WSAContextUtils.DECOUPLED_ENDPOINT_BASE_PROPERTY, decoupledEndpointBase);
+        
+        AddressingProperties maps = new AddressingProperties();
+        AttributedURIType id = 
+            ContextUtils.getAttributedURI("urn:uuid:12345");
+        maps.setMessageID(id);
+        maps.setAction(ContextUtils.getAttributedURI(""));
+        setUpMessageProperty(message,
+                             CLIENT_ADDRESSING_PROPERTIES,
+                             maps);
+        control.replay();
+        aggregator.mediate(message, false);
+        AddressingProperties props = 
+            (AddressingProperties)message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND);
+
+        assertEquals(replyTo, props.getReplyTo().getAddress().getValue());
+        control.verify();
+    }
+    
     private Message setUpMessage(boolean requestor, 
                                  boolean outbound,
                                  boolean oneway) 


Mime
View raw message