You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2012/12/02 17:43:31 UTC

svn commit: r1416196 - in /cxf/dosgi/trunk/dsw/cxf-dsw/src: main/java/org/apache/cxf/dosgi/dsw/handlers/ main/java/org/apache/cxf/dosgi/dsw/service/ test/java/org/apache/cxf/dosgi/dsw/service/

Author: cschneider
Date: Sun Dec  2 16:43:30 2012
New Revision: 1416196

URL: http://svn.apache.org/viewvc?rev=1416196&view=rev
Log:
DOSGI-127 Use callingContext instead of DSWContext for call to HttpServiceManager

Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java?rev=1416196&r1=1416195&r2=1416196&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/HttpServiceManager.java Sun Dec  2 16:43:30 2012
@@ -65,13 +65,13 @@ public class HttpServiceManager {
         return value == null ? defaultValue : value;
     }
     
-    public Bus registerServletAndGetBus(String contextRoot, BundleContext dswContext,
+    public Bus registerServletAndGetBus(String contextRoot, BundleContext callingContext,
             ServiceReference sref) {
         CXFNonSpringServlet cxf = new CXFNonSpringServlet();
         try {
             HttpService httpService = getHttpService();
             httpService.registerServlet(contextRoot, cxf, new Hashtable<String, String>(), 
-                                       getHttpContext(dswContext, httpService));
+                                       getHttpContext(callingContext, httpService));
             registerUnexportHook(sref, contextRoot);
             
             LOG.info("Successfully registered CXF DOSGi servlet at " + contextRoot);

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java?rev=1416196&r1=1416195&r2=1416196&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/JaxRSPojoConfigurationTypeHandler.java Sun Dec  2 16:43:30 2012
@@ -127,7 +127,7 @@ public class JaxRSPojoConfigurationTypeH
             }
         }
 
-        Bus bus = contextRoot != null ? httpServiceManager.registerServletAndGetBus(contextRoot, dswContext, sref) : null;
+        Bus bus = contextRoot != null ? httpServiceManager.registerServletAndGetBus(contextRoot, callingContext, sref) : null;
 
         LOG.info("Creating a " + iClass.getName()
                  + " endpoint via JaxRSPojoConfigurationTypeHandler, address is " + address);

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java?rev=1416196&r1=1416195&r2=1416196&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java Sun Dec  2 16:43:30 2012
@@ -82,7 +82,7 @@ public class PojoConfigurationTypeHandle
         
         ServerFactoryBean factory = createServerFactoryBean(sref, iClass);
         if (contextRoot != null) {
-            Bus bus = httpServiceManager.registerServletAndGetBus(contextRoot, dswContext, sref);
+            Bus bus = httpServiceManager.registerServletAndGetBus(contextRoot, callingContext, sref);
             factory.setBus(bus);
         }
         factory.setServiceClass(iClass);

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java?rev=1416196&r1=1416195&r2=1416196&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java Sun Dec  2 16:43:30 2012
@@ -128,7 +128,7 @@ public class WsdlConfigurationTypeHandle
         DataBinding databinding = new JAXBDataBinding();
         JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
         if (contextRoot != null) {
-            Bus bus = httpServiceManager.registerServletAndGetBus(contextRoot, dswContext, sref);
+            Bus bus = httpServiceManager.registerServletAndGetBus(contextRoot, callingContext, sref);
             factory.setBus(bus);
         }
         factory.setServiceClass(iClass);

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java?rev=1416196&r1=1416195&r2=1416196&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java Sun Dec  2 16:43:30 2012
@@ -73,35 +73,31 @@ public class RemoteServiceAdminCore impl
 	public List<ExportRegistration> exportService(ServiceReference serviceReference, Map additionalProperties)
         throws IllegalArgumentException, UnsupportedOperationException {
 
-        // TODO This might be wrong as it gets the classname of servicereference
-        String ifaceName = serviceReference.getClass().getName();
+        Properties serviceProperties = getProperties(serviceReference);
+        if (additionalProperties != null) {
+            OsgiUtils.overlayProperties(serviceProperties, additionalProperties);
+        }
+
+        List<String> interfaces = getInterfaces(serviceProperties);
+        if (interfaces.size() == 0) {
+            LOG.error("export failed: no provided service interfaces found or service_exported_interfaces is null !!");
+            // TODO: publish error event ? not sure
+            return Collections.emptyList();
+        }
+        
+        if (isCreatedByThisRSA(serviceReference)) {
+            LOG.debug("Skipping export of this service as we created it ourself as a proxy {}", interfaces);
+            // TODO: publish error event ? Not sure
+            return Collections.emptyList();
+        }
+
         synchronized (exportedServices) {
             // check if it is already exported ....
             if (exportedServices.containsKey(serviceReference)) {
-                return copyExportRegistration(serviceReference, ifaceName);
-            }
-
-            if (isCreatedByThisRSA(serviceReference)) {
-                LOG.debug("proxy provided by this bundle ...  {} ", ifaceName);
-                // TODO: publish error event ? Not sure
-                return Collections.emptyList();
-            }
-
-            Properties serviceProperties = getProperties(serviceReference);
-            if (additionalProperties != null) {
-                OsgiUtils.overlayProperties(serviceProperties, additionalProperties);
-            }
-
-            List<String> interfaces = getInterfaces(serviceProperties);
-            if (interfaces.size() == 0) {
-                LOG.error("export failed: no provided service interfaces found or service_exported_interfaces is null !!");
-                // TODO: publish error event ? not sure
-                return Collections.emptyList();
+                LOG.debug("already exported this service. Returning existing exportRegs {} ", interfaces);
+                return copyExportRegistration(serviceReference);
             }
             LOG.info("interfaces selected for export: " + interfaces);
-
-            
-
             LinkedHashMap<String, ExportRegistrationImpl> exportRegs = new LinkedHashMap<String, ExportRegistrationImpl>(1);
             Object serviceObject = bctx.getService(serviceReference);
             BundleContext callingContext = serviceReference.getBundle().getBundleContext();
@@ -180,8 +176,7 @@ public class RemoteServiceAdminCore impl
         return serviceProperties;
     }
 
-    private List<ExportRegistration> copyExportRegistration(ServiceReference serviceReference, String ifaceName) {
-        LOG.debug("already exported ...  {} ", ifaceName);
+    private List<ExportRegistration> copyExportRegistration(ServiceReference serviceReference) {
         Collection<ExportRegistration> regs = exportedServices.get(serviceReference);
 
         List<EndpointDescription> copiedEndpoints = new ArrayList<EndpointDescription>();

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java?rev=1416196&r1=1416195&r2=1416196&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java Sun Dec  2 16:43:30 2012
@@ -52,7 +52,7 @@ public class RemoteServiceAdminCoreTest 
     @Test
     public void dontExportOwnServiceProxies() {
 
-        IMocksControl c = EasyMock.createNiceControl();
+        IMocksControl c = EasyMock.createControl();
         Bundle b = c.createMock(Bundle.class);
         BundleContext bc = c.createMock(BundleContext.class);
 
@@ -63,6 +63,7 @@ public class RemoteServiceAdminCoreTest 
 
         ServiceReference sref = c.createMock(ServiceReference.class);
         EasyMock.expect(sref.getBundle()).andReturn(b).anyTimes();
+        EasyMock.expect(sref.getPropertyKeys()).andReturn(new String[]{}).anyTimes();
 
 		ConfigTypeHandlerFactory configTypeHandlerFactory = c.createMock(ConfigTypeHandlerFactory.class);
         RemoteServiceAdminCore rsaCore = new RemoteServiceAdminCore(bc, configTypeHandlerFactory );