cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1043326 - in /cxf/trunk/rt/transports/http-osgi/src: main/java/org/apache/cxf/transport/http_osgi/ main/resources/META-INF/cxf/osgi/ main/resources/META-INF/spring/ test/java/org/apache/cxf/transport/http_osgi/
Date Wed, 08 Dec 2010 07:27:54 GMT
Author: cschneider
Date: Wed Dec  8 07:27:53 2010
New Revision: 1043326

URL: http://svn.apache.org/viewvc?rev=1043326&view=rev
Log:
CXF-3160 Patch 3: Reduce Code duplication between http transport variants - using DestinationRegistry
for all http transport variants

Removed:
    cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestinationRegistry.java
    cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestinationRegistryIntf.java
Modified:
    cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java
    cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java
    cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
    cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java
    cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/SpringOsgiServlet.java
    cxf/trunk/rt/transports/http-osgi/src/main/resources/META-INF/cxf/osgi/cxf-extension-osgi.xml
    cxf/trunk/rt/transports/http-osgi/src/main/resources/META-INF/spring/cxf-transport-osgi.xml
    cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiDestinationTest.java
    cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java
    cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactoryTest.java

Modified: cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java?rev=1043326&r1=1043325&r2=1043326&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java
(original)
+++ cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiDestination.java
Wed Dec  8 07:27:53 2010
@@ -25,6 +25,7 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.DestinationRegistry;
 
 
 public class OsgiDestination extends AbstractHTTPDestination {
@@ -33,9 +34,6 @@ public class OsgiDestination extends Abs
 
     private static final long serialVersionUID = 1L;
 
-    final OsgiDestinationRegistryIntf factory;
-    final String path;
-
     /**
      * Constructor, allowing substitution of configuration.
      *
@@ -48,13 +46,11 @@ public class OsgiDestination extends Abs
      */
     public OsgiDestination(Bus b,
                            EndpointInfo ei,
-                           OsgiDestinationRegistryIntf fact,
-                           String p)
+                           DestinationRegistry registry,
+                           String path)
         throws IOException {
         // would add the default port to the address
-        super(b, ei, false);
-        factory = fact;
-        path = p;
+        super(b, registry, ei, path, false);
     }
 
 
@@ -66,10 +62,4 @@ public class OsgiDestination extends Abs
         return bus;
     }
 
-    @Override
-    public void shutdown() {
-        factory.removeDestination(path);
-        super.shutdown();
-    }
-
 }

Modified: cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java?rev=1043326&r1=1043325&r2=1043326&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java
(original)
+++ cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServlet.java
Wed Dec  8 07:27:53 2010
@@ -25,14 +25,15 @@ import javax.servlet.http.HttpServletRes
 
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.transport.http.DestinationRegistry;
 import org.apache.cxf.transport.servlet.AbstractHTTPServlet;
 
 public class OsgiServlet extends AbstractHTTPServlet {
     
-    private OsgiDestinationRegistryIntf transport;
+    private DestinationRegistry transport;
     private OsgiServletController controller;
     
-    public OsgiServlet(OsgiDestinationRegistryIntf transport) {
+    public OsgiServlet(DestinationRegistry transport) {
         this.transport = transport;
     }
 
@@ -45,7 +46,7 @@ public class OsgiServlet extends Abstrac
     public void destroy() {
     }
 
-    public OsgiDestinationRegistryIntf getTransport() {
+    public DestinationRegistry getTransport() {
         return transport;
     }
 

Modified: cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java?rev=1043326&r1=1043325&r2=1043326&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
(original)
+++ cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiServletController.java
Wed Dec  8 07:27:53 2010
@@ -38,6 +38,7 @@ import org.apache.cxf.resource.ResourceM
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.DestinationRegistry;
 import org.apache.cxf.transport.servlet.AbstractServletController;
 import org.apache.cxf.transports.http.QueryHandler;
 import org.apache.cxf.transports.http.QueryHandlerRegistry;
@@ -46,8 +47,8 @@ import org.apache.cxf.wsdl.http.AddressT
 public class OsgiServletController extends AbstractServletController {
     private static final Logger LOG = LogUtils.getL7dLogger(OsgiServlet.class);
       
-    private OsgiDestinationRegistryIntf destinationRegistry;
-    public OsgiServletController(OsgiDestinationRegistryIntf destinationRegistry, ServletConfig
config) {
+    private DestinationRegistry destinationRegistry;
+    public OsgiServletController(DestinationRegistry destinationRegistry, ServletConfig config)
{
         super(config);
         this.destinationRegistry = destinationRegistry;
     }

Modified: cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java?rev=1043326&r1=1043325&r2=1043326&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java
(original)
+++ cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactory.java
Wed Dec  8 07:27:53 2010
@@ -26,13 +26,12 @@ import org.apache.cxf.transport.Destinat
 import org.apache.cxf.transport.DestinationFactory;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 import org.apache.cxf.transport.http.AbstractHTTPTransportFactory;
+import org.apache.cxf.transport.http.DestinationRegistry;
 
 public class OsgiTransportFactory extends AbstractHTTPTransportFactory implements DestinationFactory
{
-
-    private OsgiDestinationRegistryIntf registry;
-
-    public void setRegistry(OsgiDestinationRegistryIntf registry) {
-        this.registry = registry;
+    
+    public OsgiTransportFactory(DestinationRegistry registry) {
+        super(registry);
     }
 
     public Destination getDestination(EndpointInfo endpointInfo) throws IOException {
@@ -42,7 +41,7 @@ public class OsgiTransportFactory extend
         }
         AbstractHTTPDestination d = registry.getDestinationForPath(endpointInfo.getAddress());
         if (d == null) {
-            String path = OsgiDestinationRegistry.getTrimmedPath(endpointInfo.getAddress());
+            String path = registry.getTrimmedPath(endpointInfo.getAddress());
             d = new OsgiDestination(getBus(), endpointInfo, registry, path);
             registry.addDestination(path, d);
         }

Modified: cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/SpringOsgiServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/SpringOsgiServlet.java?rev=1043326&r1=1043325&r2=1043326&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/SpringOsgiServlet.java
(original)
+++ cxf/trunk/rt/transports/http-osgi/src/main/java/org/apache/cxf/transport/http_osgi/SpringOsgiServlet.java
Wed Dec  8 07:27:53 2010
@@ -22,6 +22,7 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.cxf.transport.http.DestinationRegistry;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 
@@ -29,7 +30,7 @@ public class SpringOsgiServlet extends O
 
     private ApplicationContext applicationContext;
 
-    public SpringOsgiServlet(OsgiDestinationRegistryIntf transport) {
+    public SpringOsgiServlet(DestinationRegistry transport) {
         super(transport);
     }
 

Modified: cxf/trunk/rt/transports/http-osgi/src/main/resources/META-INF/cxf/osgi/cxf-extension-osgi.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/main/resources/META-INF/cxf/osgi/cxf-extension-osgi.xml?rev=1043326&r1=1043325&r2=1043326&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/main/resources/META-INF/cxf/osgi/cxf-extension-osgi.xml
(original)
+++ cxf/trunk/rt/transports/http-osgi/src/main/resources/META-INF/cxf/osgi/cxf-extension-osgi.xml
Wed Dec  8 07:27:53 2010
@@ -27,9 +27,10 @@ http://www.springframework.org/schema/os
     <bean id="org.apache.cxf.transport.http_osgi.OsgiTransportFactory"
           class="org.apache.cxf.transport.http_osgi.OsgiTransportFactory"
           init-method="init">
+          
+        <constructor-arg ref="osgiDestinationRegistry"/>
 
         <property name="bus" ref="cxf"/>
-        <property name="registry" ref="osgiDestinationRegistry" />
         <property name="transportIds">
             <set>
                 <value>http://cxf.apache.org/bindings/xformat</value>

Modified: cxf/trunk/rt/transports/http-osgi/src/main/resources/META-INF/spring/cxf-transport-osgi.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/main/resources/META-INF/spring/cxf-transport-osgi.xml?rev=1043326&r1=1043325&r2=1043326&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/main/resources/META-INF/spring/cxf-transport-osgi.xml
(original)
+++ cxf/trunk/rt/transports/http-osgi/src/main/resources/META-INF/spring/cxf-transport-osgi.xml
Wed Dec  8 07:27:53 2010
@@ -35,7 +35,7 @@ http://www.springframework.org/schema/co
 
     <ctx:property-placeholder properties-ref="cxfOsgiProperties"/>
 
-    <bean id="destinationRegistry" class="org.apache.cxf.transport.http_osgi.OsgiDestinationRegistry"
/>
+    <bean id="destinationRegistry" class="org.apache.cxf.transport.http.DestinationRegistryImpl"
/>
 
     <bean id="osgiServlet" class="org.apache.cxf.transport.http_osgi.SpringOsgiServlet">
         <constructor-arg ref="destinationRegistry"/>
@@ -48,7 +48,7 @@ http://www.springframework.org/schema/co
         </osgi:service-properties>
     </osgi:service>
 
-    <osgi:service ref="destinationRegistry" interface="org.apache.cxf.transport.http_osgi.OsgiDestinationRegistryIntf">
+    <osgi:service ref="destinationRegistry" interface="org.apache.cxf.transport.http.DestinationRegistry">
     </osgi:service>
 
 </beans>

Modified: cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiDestinationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiDestinationTest.java?rev=1043326&r1=1043325&r2=1043326&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiDestinationTest.java
(original)
+++ cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiDestinationTest.java
Wed Dec  8 07:27:53 2010
@@ -21,6 +21,7 @@ package org.apache.cxf.transport.http_os
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.http.DestinationRegistry;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
 import org.junit.After;
@@ -34,14 +35,14 @@ public class OsgiDestinationTest extends
     private static final String ADDRESS = "http://bar/snafu";
     private IMocksControl control; 
     private Bus bus;
-    private OsgiDestinationRegistryIntf registry;
+    private DestinationRegistry registry;
     private EndpointInfo endpoint;
 
     @Before
     public void setUp() {
         control = EasyMock.createNiceControl();
         bus = control.createMock(Bus.class);
-        registry = control.createMock(OsgiDestinationRegistryIntf.class);
+        registry = control.createMock(DestinationRegistry.class);
         endpoint = new EndpointInfo();
         endpoint.setAddress(ADDRESS);
     }

Modified: cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java?rev=1043326&r1=1043325&r2=1043326&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java
(original)
+++ cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiServletTest.java
Wed Dec  8 07:27:53 2010
@@ -45,6 +45,7 @@ import org.apache.cxf.service.model.Inte
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.DestinationRegistry;
 import org.apache.cxf.transport.http.HTTPSession;
 import org.apache.cxf.transports.http.QueryHandler;
 import org.apache.cxf.transports.http.QueryHandlerRegistry;
@@ -78,7 +79,7 @@ public class OsgiServletTest extends Ass
         "<html><body>No service was found.</body></html>";
     private IMocksControl control; 
     private Bus bus;
-    private OsgiDestinationRegistryIntf registry;
+    private DestinationRegistry registry;
     private OsgiDestination destination;
     private ServletConfig config;
     private ServletContext context;
@@ -95,7 +96,7 @@ public class OsgiServletTest extends Ass
     public void setUp() {
         control = EasyMock.createNiceControl();
         bus = control.createMock(Bus.class);
-        registry = control.createMock(OsgiDestinationRegistryIntf.class);
+        registry = control.createMock(DestinationRegistry.class);
         destination = control.createMock(OsgiDestination.class);
         context = control.createMock(ServletContext.class);
         config = control.createMock(ServletConfig.class);

Modified: cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactoryTest.java?rev=1043326&r1=1043325&r2=1043326&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactoryTest.java
(original)
+++ cxf/trunk/rt/transports/http-osgi/src/test/java/org/apache/cxf/transport/http_osgi/OsgiTransportFactoryTest.java
Wed Dec  8 07:27:53 2010
@@ -24,6 +24,8 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Destination;
 import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.DestinationRegistry;
 
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
@@ -38,13 +40,13 @@ public class OsgiTransportFactoryTest ex
     private IMocksControl control; 
     private OsgiTransportFactory factory;
     private Bus bus;
-    private OsgiDestinationRegistryIntf registry;
+    private DestinationRegistry registry;
 
     @Before
     public void setUp() {
         control = EasyMock.createNiceControl();
-        factory = new OsgiTransportFactory();
-        registry = control.createMock(OsgiDestinationRegistryIntf.class);
+        registry = control.createMock(DestinationRegistry.class);
+        factory = new OsgiTransportFactory(registry);
         bus = control.createMock(Bus.class);
         bus.getExtension(DestinationFactoryManager.class);
         EasyMock.expectLastCall().andReturn(null).anyTimes();
@@ -60,10 +62,13 @@ public class OsgiTransportFactoryTest ex
     
     @Test
     public void testGetDestination() throws Exception {
-        registry.addDestination(EasyMock.eq("/snafu"), EasyMock.isA(OsgiDestination.class));
+        registry.getDestinationForPath(EasyMock.eq("snafu"));
+        EasyMock.expectLastCall().andReturn(null);
+        registry.addDestination(EasyMock.eq("/snafu"), EasyMock.isA(AbstractHTTPDestination.class));
+        registry.getTrimmedPath(EasyMock.eq("snafu"));
+        EasyMock.expectLastCall().andReturn("/snafu").anyTimes();
         control.replay();
-        
-        factory.setRegistry(registry);
+
         factory.setBus(bus);
 
         EndpointInfo endpoint = new EndpointInfo();



Mime
View raw message