cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r536891 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/endpoint/ api/src/main/java/org/apache/cxf/wsdl/ rt/core/src/main/java/org/apache/cxf/endpoint/ rt/core/src/main/java/org/apache/cxf/transport/ rt/core/src/test/java/org/ap...
Date Thu, 10 May 2007 15:47:11 GMT
Author: eglynn
Date: Thu May 10 08:47:09 2007
New Revision: 536891

URL: http://svn.apache.org/viewvc?view=rev&rev=536891
Log:
Adding minting logic to endpoint resolver.


Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/EndpointResolver.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/EndpointResolverRegistry.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointResolverRegistryImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractMultiplexDestination.java
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/EndpointResolverRegistryImplTest.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/EndpointResolver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/EndpointResolver.java?view=diff&rev=536891&r1=536890&r2=536891
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/EndpointResolver.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/EndpointResolver.java Thu
May 10 08:47:09 2007
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.endpoint;
 
+import javax.xml.namespace.QName;
+
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 
 
@@ -52,4 +54,20 @@
      */
     EndpointReferenceType renew(EndpointReferenceType logical,
                                 EndpointReferenceType physical);
+    
+    /**
+     * Mint a new abstract EPR for a given service name.
+     * 
+     * @param serviceName
+     * @return the newly minted EPR if appropriate, null otherwise
+     */
+    EndpointReferenceType mint(QName serviceName);
+    
+    /**
+     * Mint a new abstract EPR for a given concrete EPR
+     * 
+     * @param serviceName
+     * @return the newly minted EPR if appropriate, null otherwise
+     */
+    EndpointReferenceType mint(EndpointReferenceType physical);
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/EndpointResolverRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/EndpointResolverRegistry.java?view=diff&rev=536891&r1=536890&r2=536891
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/EndpointResolverRegistry.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/EndpointResolverRegistry.java
Thu May 10 08:47:09 2007
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.endpoint;
 
+import javax.xml.namespace.QName;
+
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 
 /**
@@ -77,4 +79,23 @@
      */
     EndpointReferenceType renew(EndpointReferenceType logical,
                                 EndpointReferenceType physical);
+    
+    /**
+     * Walk the list of registered EndpointResolvers, so as to mint a new 
+     * abstract EPR for a given service name.
+     * 
+     * @param serviceName
+     * @return the newly minted EPR if appropriate, null otherwise
+     */
+    EndpointReferenceType mint(QName serviceName);
+    
+    /**
+     * Walk the list of registered EndpointResolvers, so as to mint a new 
+     * abstract EPR for a gievn physical EPR.
+     * 
+     * @param serviceName
+     * @return the newly minted EPR if appropriate, null otherwise
+     */
+    EndpointReferenceType mint(EndpointReferenceType physical);
+
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java?view=diff&rev=536891&r1=536890&r2=536891
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/wsdl/EndpointReferenceUtils.java
Thu May 10 08:47:09 2007
@@ -621,6 +621,42 @@
         }
         return physical != null ? physical : logical;
     }
+    
+    /**
+     * Mint logical endpoint reference via the Bus EndpointResolverRegistry.
+     * 
+     * @param serviceName the given serviceName
+     * @return the newly minted EPR if appropriate, null otherwise
+     */
+    public static EndpointReferenceType mint(QName serviceName, Bus bus) {
+        EndpointReferenceType logical = null;
+        if (bus != null) {
+            EndpointResolverRegistry registry =
+                bus.getExtension(EndpointResolverRegistry.class);
+            if (registry != null) {
+                logical = registry.mint(serviceName);
+            }
+        }
+        return logical;
+    }
+    
+    /**
+     * Mint logical endpoint reference via the Bus EndpointResolverRegistry.
+     * 
+     * @param physical the concrete template EPR 
+     * @return the newly minted EPR if appropriate, null otherwise
+     */
+    public static EndpointReferenceType mint(EndpointReferenceType physical, Bus bus) {
+        EndpointReferenceType logical = null;
+        if (bus != null) {
+            EndpointResolverRegistry registry =
+                bus.getExtension(EndpointResolverRegistry.class);
+            if (registry != null) {
+                logical = registry.mint(physical);
+            }
+        }
+        return logical != null ? logical : physical;
+    }
                                              
     private static String getNameSpaceUri(Node node, String content, String namespaceURI)
{
         if (namespaceURI == null) {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointResolverRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointResolverRegistryImpl.java?view=diff&rev=536891&r1=536890&r2=536891
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointResolverRegistryImpl.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointResolverRegistryImpl.java
Thu May 10 08:47:09 2007
@@ -23,6 +23,7 @@
 import java.util.List;
 
 import javax.annotation.PostConstruct;
+import javax.xml.namespace.QName;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
@@ -120,6 +121,42 @@
             }
         }
         return fresh;
+    }
+    
+    /**
+     * Walk the list of registered EndpointResolvers, so as to mint a new 
+     * abstract EPR for a given service name.
+     * 
+     * @param serviceName
+     * @return the newly minted EPR if appropriate, null otherwise
+     */
+    public EndpointReferenceType mint(QName serviceName) {
+        EndpointReferenceType logical = null;
+        for (EndpointResolver resolver : resolvers) {
+            logical = resolver.mint(serviceName);
+            if (logical != null) {
+                break;
+            }
+        }
+        return logical;
+    }
+    
+    /**
+     * Walk the list of registered EndpointResolvers, so as to mint a new 
+     * abstract EPR for a gievn physical EPR.
+     * 
+     * @param serviceName
+     * @return the newly minted EPR if appropriate, null otherwise
+     */
+    public EndpointReferenceType mint(EndpointReferenceType physical) {
+        EndpointReferenceType logical = null;
+        for (EndpointResolver resolver : resolvers) {
+            logical = resolver.mint(physical);
+            if (logical != null) {
+                break;
+            }
+        }
+        return logical;        
     }
     
     /**

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java?view=diff&rev=536891&r1=536890&r2=536891
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractDestination.java
Thu May 10 08:47:09 2007
@@ -23,6 +23,7 @@
 import java.io.InputStream;
 import java.util.logging.Logger;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -39,11 +40,19 @@
 
     protected final EndpointReferenceType reference;
     protected final EndpointInfo endpointInfo;
+    protected final Bus bus;
     
     public AbstractDestination(EndpointReferenceType ref,
                                EndpointInfo ei) {
+        this(null, ref, ei);
+    }
+    
+    public AbstractDestination(Bus b,
+                               EndpointReferenceType ref,
+                               EndpointInfo ei) {
         reference = ref;
         endpointInfo = ei;
+        bus = b;
     }
     
     /**

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractMultiplexDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractMultiplexDestination.java?view=diff&rev=536891&r1=536890&r2=536891
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractMultiplexDestination.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/AbstractMultiplexDestination.java
Thu May 10 08:47:09 2007
@@ -23,6 +23,7 @@
 import javax.xml.bind.JAXBElement;
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.ws.addressing.AddressingProperties;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
@@ -36,8 +37,8 @@
     private static final QName MULTIPLEX_ID_QNAME = new QName("http://multiplex.transport.cxf.apache.org",
                                                               "id");
 
-    public AbstractMultiplexDestination(EndpointReferenceType ref, EndpointInfo ei) {
-        super(ref, ei);
+    public AbstractMultiplexDestination(Bus b, EndpointReferenceType ref, EndpointInfo ei)
{
+        super(b, ref, ei);
     }
 
     /**
@@ -51,7 +52,8 @@
       
      */
     public EndpointReferenceType getAddressWithId(String id) {
-        EndpointReferenceType epr = EndpointReferenceUtils.duplicate(reference);
+        EndpointReferenceType epr = EndpointReferenceUtils.duplicate(
+            EndpointReferenceUtils.mint(reference, bus));
         ReferenceParametersType newParams = new org.apache.cxf.ws.addressing.ObjectFactory()
             .createReferenceParametersType();
         

Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/EndpointResolverRegistryImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/EndpointResolverRegistryImplTest.java?view=diff&rev=536891&r1=536890&r2=536891
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/EndpointResolverRegistryImplTest.java
(original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/EndpointResolverRegistryImplTest.java
Thu May 10 08:47:09 2007
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.endpoint;
 
+import javax.xml.namespace.QName;
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.easymock.classextension.EasyMock;
@@ -38,6 +40,7 @@
     private EndpointReferenceType physical;
     private EndpointReferenceType fresh;
     private IMocksControl control;
+    private QName serviceName;
 
     @Before
     public void setUp() {
@@ -48,14 +51,16 @@
         logical = control.createMock(EndpointReferenceType.class);
         physical = control.createMock(EndpointReferenceType.class);
         fresh = control.createMock(EndpointReferenceType.class);
+        serviceName = new QName("namespace", "local");
     }
-    
+
     @After
     public void tearDown() {
         resolver1 = null;
         resolver2 = null;
         logical = null;
         physical = null;
+        serviceName = null;
     }
 
     @Test
@@ -193,5 +198,83 @@
 
         control.verify();
         assertNull("unexpected physical EPR", renewed);
+    }
+    
+    @Test
+    public void testMintFromServiceName() {
+        registry.init();
+        registry.register(resolver1);
+        registry.register(resolver2);
+        resolver1.mint(serviceName);
+        EasyMock.expectLastCall().andReturn(logical);
+        control.replay();
+     
+        EndpointReferenceType minted = registry.mint(serviceName);
+        
+        control.verify();
+        assertSame("unexpected minted EPR", logical, minted);
+        
+        control.reset();
+        resolver1.mint(serviceName);
+        EasyMock.expectLastCall().andReturn(null);
+        resolver2.mint(serviceName);
+        EasyMock.expectLastCall().andReturn(logical);
+        control.replay();
+        
+        minted = registry.mint(serviceName);
+        
+        control.verify();
+        assertSame("unexpected minted EPR", logical, minted);
+
+        control.reset();
+        resolver1.mint(serviceName);
+        EasyMock.expectLastCall().andReturn(null);
+        resolver2.mint(serviceName);
+        EasyMock.expectLastCall().andReturn(null);
+        control.replay();
+
+        minted = registry.mint(serviceName);
+
+        control.verify();
+        assertNull("unexpected minted EPR", minted);
+    }
+    
+    @Test
+    public void testMintFromPhysical() {
+        registry.init();
+        registry.register(resolver1);
+        registry.register(resolver2);
+        resolver1.mint(physical);
+        EasyMock.expectLastCall().andReturn(logical);
+        control.replay();
+     
+        EndpointReferenceType minted = registry.mint(physical);
+        
+        control.verify();
+        assertSame("unexpected minted EPR", logical, minted);
+        
+        control.reset();
+        resolver1.mint(physical);
+        EasyMock.expectLastCall().andReturn(null);
+        resolver2.mint(physical);
+        EasyMock.expectLastCall().andReturn(logical);
+        control.replay();
+        
+        minted = registry.mint(physical);
+        
+        control.verify();
+        assertSame("unexpected minted EPR", logical, minted);
+
+        control.reset();
+        resolver1.mint(physical);
+        EasyMock.expectLastCall().andReturn(null);
+        resolver2.mint(physical);
+        EasyMock.expectLastCall().andReturn(null);
+        control.replay();
+
+        minted = registry.mint(physical);
+
+        control.verify();
+        assertNull("unexpected minted EPR", minted);
     }
 }

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?view=diff&rev=536891&r1=536890&r2=536891
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Thu May 10 08:47:09 2007
@@ -99,7 +99,7 @@
                                    EndpointInfo ei,
                                    boolean dp)
         throws IOException {
-        super(getTargetReference(getAddressValue(ei, dp), b), ei);  
+        super(b, getTargetReference(getAddressValue(ei, dp), b), ei);  
         bus = b;
         conduitInitiator = ci;
         

Modified: incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java?view=diff&rev=536891&r1=536890&r2=536891
==============================================================================
--- incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
(original)
+++ incubator/cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
Thu May 10 08:47:09 2007
@@ -79,7 +79,7 @@
     public JMSDestination(Bus b,
                           ConduitInitiator ci,
                           EndpointInfo info) throws IOException {
-        super(getTargetReference(info, b), info);    
+        super(b, getTargetReference(info, b), info);    
         
         base = new JMSTransportBase(b, endpointInfo, true, BASE_BEAN_NAME_SUFFIX, this);
 



Mime
View raw message