cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r701057 - in /cxf/sandbox/dosgi: ./ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ dsw/cxf-dsw/src/main/java/org/apa...
Date Thu, 02 Oct 2008 09:40:57 GMT
Author: eglynn
Date: Thu Oct  2 02:40:56 2008
New Revision: 701057

URL: http://svn.apache.org/viewvc?rev=701057&view=rev
Log:
Applied patch for CXF-1836 on behalf of David Bosschaert.


Added:
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/CxfDistributionProvider.java   (with props)
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java   (with props)
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java   (with props)
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java   (with props)
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java   (with props)
Modified:
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractHook.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java
    cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
    cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/dsw/DistributionProvider.java
    cxf/sandbox/dosgi/pom.xml

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java Thu Oct  2 02:40:56 2008
@@ -26,9 +26,9 @@
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
-
 import org.apache.cxf.dosgi.dsw.hooks.CxfListenerHook;
 import org.apache.cxf.dosgi.dsw.hooks.CxfPublishHook;
+import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.apache.cxf.dosgi.dsw.service.DistributionProviderImpl;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
@@ -58,13 +58,13 @@
         context.registerService(ManagedService.class.getName(), 
                                 this, getDefaults());
         
-        pHook = new CxfPublishHook(context);
-        lHook = new CxfListenerHook(context);
-        context.registerService(ListenerHook.class.getName(), lHook, new Hashtable());
-
+        CxfDistributionProvider dpService = new DistributionProviderImpl();
         context.registerService(DistributionProvider.class.getName(), 
-                                new DistributionProviderImpl(),
-                                new Hashtable());
+                dpService, new Hashtable());
+
+        pHook = new CxfPublishHook(context, dpService);
+        lHook = new CxfListenerHook(context, dpService);
+        context.registerService(ListenerHook.class.getName(), lHook, new Hashtable());
         
         context.addServiceListener(this);
                  

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java Thu Oct  2 02:40:56 2008
@@ -23,12 +23,15 @@
 
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
+import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 
 public abstract class AbstractConfigurationHandler implements ConfigurationTypeHandler {
+    private final CxfDistributionProvider distributionProvider;
+    private final Map<String, Object> handlerProps;
     
-    private Map<String, Object> handlerProps;
-    
-    protected AbstractConfigurationHandler(Map<String, Object> handlerProps) {
+    protected AbstractConfigurationHandler(CxfDistributionProvider dp, 
+                                           Map<String, Object> handlerProps) {
+        this.distributionProvider = dp;
         this.handlerProps = handlerProps;
     }
     
@@ -52,6 +55,10 @@
         return OsgiUtils.toBoolean(value);        
     }
     
+    protected CxfDistributionProvider getDistributionProvider() {
+        return distributionProvider;
+    }
+    
     protected Object getProxy(Object serviceProxy, Class<?> iType) {
         return Proxy.newProxyInstance(iType.getClassLoader(),
                       new Class[] {iType},

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java Thu Oct  2 02:40:56 2008
@@ -21,9 +21,9 @@
 import java.util.Map;
 import java.util.logging.Logger;
 
-
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
+import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.osgi.service.discovery.ServiceDescription;
 
 public final class ConfigTypeHandlerFactory {
@@ -39,16 +39,17 @@
         return FACTORY;
     }
     
-    public ConfigurationTypeHandler getHandler(ServiceDescription sd,
+    public ConfigurationTypeHandler getHandler(ServiceDescription sd, 
+                                               CxfDistributionProvider dp,
                                                Map<String, Object> handlerProperties) {
         String type = OsgiUtils.getProperty(sd, Constants.CONFIG_TYPE_PROPERTY);
         if (type == null || Constants.POJO_CONFIG_TYPE.equalsIgnoreCase(type)) {
             if (type == null) {
                 LOG.info("Defaulting to pojo configuration type ");
             }
-            return new PojoConfigurationTypeHandler(handlerProperties);
+            return new PojoConfigurationTypeHandler(dp, handlerProperties);
         } else if (Constants.WSDL_CONFIG_TYPE.equalsIgnoreCase(type)) {
-            return new WsdlConfigurationTypeHandler(handlerProperties);
+            return new WsdlConfigurationTypeHandler(dp, handlerProperties);
         }
         
         LOG.info("Configuration type " + type + " is not supported");

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigurationTypeHandler.java Thu Oct  2 02:40:56 2008
@@ -20,10 +20,12 @@
 
 import org.apache.cxf.endpoint.Server;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.discovery.ServiceDescription;
 
 public interface ConfigurationTypeHandler {
-    Server createServer(BundleContext dswContext,
+    Server createServer(ServiceReference serviceReference,
+                        BundleContext dswContext,
                         BundleContext callingContext, 
                         ServiceDescription sd, 
                         Class<?> iClass, 

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandler.java Thu Oct  2 02:40:56 2008
@@ -29,12 +29,14 @@
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.qos.IntentMap;
+import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.discovery.ServiceDescription;
 
 public class PojoConfigurationTypeHandler extends AbstractConfigurationHandler {
@@ -43,10 +45,20 @@
     
     private IntentMap masterMap;
     
-    public PojoConfigurationTypeHandler(Map<String, Object> handlerProps) {
-        super(handlerProps);
+    public PojoConfigurationTypeHandler(CxfDistributionProvider dp, Map<String, Object> handlerProps) {
+        super(dp, handlerProps);
     }
-    
+
+    // Isolated so that it can be substituted for testing
+    ClientProxyFactoryBean createClientProxyFactoryBean() {
+        return new ClientProxyFactoryBean();
+    }
+
+    // Isolated so that it can be substituted for testing
+    ServerFactoryBean createServerFactoryBean() {
+        return new ServerFactoryBean();
+    }
+
     public Object createProxy(BundleContext dswContext,
                               BundleContext callingContext,
                               Class<?> iClass, ServiceDescription sd) {
@@ -63,7 +75,7 @@
 
 
         try {
-            ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
+            ClientProxyFactoryBean factory = createClientProxyFactoryBean();
             factory.setServiceClass(iClass);
             factory.setAddress(address);
             factory.getServiceFactory().setDataBinding(new AegisDatabinding());
@@ -81,7 +93,8 @@
         return null;
     }
 
-    public Server createServer(BundleContext dswContext,
+    public Server createServer(ServiceReference serviceReference,
+                               BundleContext dswContext,
                                BundleContext callingContext, 
                                ServiceDescription sd, 
                                Class<?> iClass,
@@ -96,7 +109,7 @@
         LOG.info("Creating a " + sd.getInterfaceName()
             + " endpoint from CXF PublishHook, address is " + address);
         
-        ServerFactoryBean factory = new ServerFactoryBean();
+        ServerFactoryBean factory = createServerFactoryBean();
         factory.setServiceClass(iClass);
         factory.setAddress(address);
         factory.getServiceFactory().setDataBinding(new AegisDatabinding());
@@ -104,10 +117,12 @@
 
         applyIntents(dswContext, callingContext, factory.getFeatures(), factory, sd);
 
-        return factory.create();
+        Server server = factory.create();        
+        getDistributionProvider().addExposedService(serviceReference);
+        return server;
     }
 
-    private void applyIntents(BundleContext dswContext,
+    void applyIntents(BundleContext dswContext,
                                              BundleContext callingContext,
                                      List<AbstractFeature> features,
                                      AbstractEndpointFactory factory,

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandler.java Thu Oct  2 02:40:56 2008
@@ -29,16 +29,19 @@
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
+import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.apache.cxf.endpoint.Server;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.discovery.ServiceDescription;
 
 public class WsdlConfigurationTypeHandler extends AbstractConfigurationHandler {
 
     private static final Logger LOG = Logger.getLogger(WsdlConfigurationTypeHandler.class.getName());
     
-    public WsdlConfigurationTypeHandler(Map<String, Object> handlerProps) {
-        super(handlerProps);
+    public WsdlConfigurationTypeHandler(CxfDistributionProvider dp,
+                                        Map<String, Object> handlerProps) {
+        super(dp, handlerProps);
     }
     
     public Object createProxy(BundleContext dswContext,
@@ -74,7 +77,8 @@
         
     }
 
-    public Server createServer(BundleContext dswContext,
+    public Server createServer(ServiceReference sr,
+                               BundleContext dswContext,
                                BundleContext callingContext,
                                ServiceDescription sd, 
                                Class<?> iClass, 

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java Thu Oct  2 02:40:56 2008
@@ -26,11 +26,11 @@
 import java.util.Map;
 import java.util.logging.Logger;
 
-
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.handlers.ClientServiceFactory;
 import org.apache.cxf.dosgi.dsw.handlers.ConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceReference;
@@ -40,8 +40,8 @@
     
     private static final Logger LOG = Logger.getLogger(AbstractClientHook.class.getName());
 
-    protected AbstractClientHook(BundleContext bc) {
-        super(bc);
+    protected AbstractClientHook(BundleContext bc, CxfDistributionProvider dp) {
+        super(bc, dp);
     }
     
     protected List<ServiceDescription> processClientDescriptions(BundleContext requestingContext, 
@@ -61,7 +61,7 @@
             }
             
             ConfigurationTypeHandler handler = 
-                ServiceHookUtils.getHandler(sd, getHandlerProperties());
+                ServiceHookUtils.getHandler(sd, getDistributionProvider(), getHandlerProperties());
             if (handler == null) {
                 continue;
             }

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractHook.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractHook.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractHook.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractHook.java Thu Oct  2 02:40:56 2008
@@ -27,6 +27,7 @@
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.OsgiService;
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
+import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.apache.cxf.dosgi.dsw.service.ServiceDescriptionImpl;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -34,15 +35,17 @@
 import org.osgi.service.discovery.ServiceDescription;
 
 public abstract class AbstractHook {
-
-    private volatile BundleContext bc;
+    private final CxfDistributionProvider distributionProvider;
+    
+    private volatile BundleContext bc;    
     private volatile boolean checkBundleForMetadata = true;
     private volatile boolean useMasterMap = true;
     private volatile String defaultPort;
     private volatile String defaultHost;
     
-    public AbstractHook(BundleContext bc) {
+    public AbstractHook(BundleContext bc, CxfDistributionProvider dp) {
         this.bc = bc;
+        this.distributionProvider = dp;
     }
     
     protected BundleContext getContext() {
@@ -120,6 +123,7 @@
         return sb.toString();
     }
     
-    
-    
+    protected CxfDistributionProvider getDistributionProvider() {
+        return distributionProvider;
+    }        
 }

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java Thu Oct  2 02:40:56 2008
@@ -21,6 +21,7 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.hooks.service.ListenerHook;
@@ -40,8 +41,8 @@
              }
          }; 
     
-    public CxfListenerHook(BundleContext bc) {
-        super(bc);
+    public CxfListenerHook(BundleContext bc, CxfDistributionProvider dp) {
+        super(bc, dp);
     }
     
     public void added(ListenerHook.Listener listener) {

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHook.java Thu Oct  2 02:40:56 2008
@@ -22,10 +22,10 @@
 import java.util.LinkedHashMap;
 import java.util.Map;
 
-
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.handlers.ConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.apache.cxf.endpoint.Server;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -36,8 +36,8 @@
     private Map<ServiceReference, EndpointInfo> endpoints
         = new LinkedHashMap<ServiceReference, EndpointInfo>();
     
-    public CxfPublishHook(BundleContext bc) {
-        super(bc);
+    public CxfPublishHook(BundleContext bc, CxfDistributionProvider dpService) {
+        super(bc, dpService);
     }
         
     public void publishEndpoint(ServiceReference sref) {
@@ -64,7 +64,8 @@
         Server server = null;
         boolean isPublished = false;
         server = ServiceHookUtils.createServer(
-                                 getHandler(sd, getHandlerProperties()), 
+                                 getHandler(sd, getHandlerProperties()),
+                                 sref,
                                  getContext(), 
                                  sref.getBundle().getBundleContext(), 
                                  sd, 
@@ -105,8 +106,8 @@
         return Collections.unmodifiableMap(endpoints);
     }
     
-    protected ConfigurationTypeHandler getHandler(ServiceDescription sd, 
+    protected ConfigurationTypeHandler getHandler(ServiceDescription sd,
                                                   Map<String, Object> props) {
-        return ServiceHookUtils.getHandler(sd, props);
+        return ServiceHookUtils.getHandler(sd, getDistributionProvider(), props);
     }
 }

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtils.java Thu Oct  2 02:40:56 2008
@@ -21,13 +21,13 @@
 import java.util.Map;
 import java.util.logging.Logger;
 
-
 import org.apache.cxf.dosgi.dsw.ClassUtils;
 import org.apache.cxf.dosgi.dsw.Constants;
 import org.apache.cxf.dosgi.dsw.OsgiService;
 import org.apache.cxf.dosgi.dsw.OsgiUtils;
 import org.apache.cxf.dosgi.dsw.handlers.ConfigTypeHandlerFactory;
 import org.apache.cxf.dosgi.dsw.handlers.ConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.apache.cxf.endpoint.Server;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -61,6 +61,7 @@
     }
     
     public static Server createServer(ConfigurationTypeHandler handler,
+                                      ServiceReference serviceReference,
                                       BundleContext dswContext,
                                       BundleContext callingContext, 
                                       ServiceDescription sd,
@@ -75,7 +76,8 @@
                                                                sd.getInterfaceName());
         if (interfaceClass != null) {
             try {
-                return handler.createServer(dswContext,
+                return handler.createServer(serviceReference,
+                                            dswContext,                                            
                                             callingContext, 
                                             sd, 
                                             interfaceClass, 
@@ -116,8 +118,9 @@
     }
     
     public static ConfigurationTypeHandler getHandler(ServiceDescription sd,
-                                                  Map<String, Object> dswProperties) {
-        return ConfigTypeHandlerFactory.getInstance().getHandler(sd, 
+                                                      CxfDistributionProvider dp,
+                                                      Map<String, Object> dswProperties) {
+        return ConfigTypeHandlerFactory.getInstance().getHandler(sd, dp,
                                                                  dswProperties);
     }
     

Added: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/CxfDistributionProvider.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/CxfDistributionProvider.java?rev=701057&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/CxfDistributionProvider.java (added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/CxfDistributionProvider.java Thu Oct  2 02:40:56 2008
@@ -0,0 +1,26 @@
+/** 
+  * Licensed to the Apache Software Foundation (ASF) under one 
+  * or more contributor license agreements. See the NOTICE file 
+  * distributed with this work for additional information 
+  * regarding copyright ownership. The ASF licenses this file 
+  * to you under the Apache License, Version 2.0 (the 
+  * "License"); you may not use this file except in compliance 
+  * with the License. You may obtain a copy of the License at 
+  * 
+  * http://www.apache.org/licenses/LICENSE-2.0 
+  * 
+  * Unless required by applicable law or agreed to in writing, 
+  * software distributed under the License is distributed on an 
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+  * KIND, either express or implied. See the License for the 
+  * specific language governing permissions and limitations 
+  * under the License. 
+  */
+package org.apache.cxf.dosgi.dsw.service;
+
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.dsw.DistributionProvider;
+
+public interface CxfDistributionProvider extends DistributionProvider {
+    void addExposedService(ServiceReference serviceReference);   
+}

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/CxfDistributionProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/CxfDistributionProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImpl.java Thu Oct  2 02:40:56 2008
@@ -19,17 +19,26 @@
 package org.apache.cxf.dosgi.dsw.service;
 
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.dsw.DistributionProvider;
 
 
-public class DistributionProviderImpl implements DistributionProvider {
-
+public class DistributionProviderImpl implements DistributionProvider, CxfDistributionProvider {
+    private Set<ServiceReference> exposedServices = new HashSet<ServiceReference>(); 
+    
     public Map getPublicationProperties(ServiceReference sr) {
         return Collections.EMPTY_MAP;
     }
+    
+    public ServiceReference[] getExposedServices() {
+        synchronized (exposedServices) {
+            return exposedServices.toArray(new ServiceReference[exposedServices.size()]);
+        }
+    }
 
     public ServiceReference[] getPublishedServices() {
         return new ServiceReference[]{};
@@ -39,5 +48,11 @@
         return new ServiceReference[]{};
     }
 
+    public void addExposedService(ServiceReference sr) {
+        synchronized (exposedServices) {
+            exposedServices.add(sr);
+        }
+    }
+
     
 }

Added: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java?rev=701057&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java (added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java Thu Oct  2 02:40:56 2008
@@ -0,0 +1,72 @@
+/** 
+  * Licensed to the Apache Software Foundation (ASF) under one 
+  * or more contributor license agreements. See the NOTICE file 
+  * distributed with this work for additional information 
+  * regarding copyright ownership. The ASF licenses this file 
+  * to you under the Apache License, Version 2.0 (the 
+  * "License"); you may not use this file except in compliance 
+  * with the License. You may obtain a copy of the License at 
+  * 
+  * http://www.apache.org/licenses/LICENSE-2.0 
+  * 
+  * Unless required by applicable law or agreed to in writing, 
+  * software distributed under the License is distributed on an 
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+  * KIND, either express or implied. See the License for the 
+  * specific language governing permissions and limitations 
+  * under the License. 
+  */
+package org.apache.cxf.dosgi.dsw.handlers;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
+import org.apache.cxf.dosgi.dsw.service.DistributionProviderImpl;
+import org.apache.cxf.dosgi.dsw.service.ServiceDescriptionImpl;
+import org.osgi.service.discovery.ServiceDescription;
+
+
+public class ConfigTypeHandlerFactoryTest extends TestCase {
+    public void testGetDefaultHandler() {
+        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
+        
+        ServiceDescription sd = new ServiceDescriptionImpl("MyInterface");
+        CxfDistributionProvider dp = new DistributionProviderImpl();
+        ConfigurationTypeHandler handler = f.getHandler(sd, dp, new HashMap<String, Object>());
+        assertTrue(handler instanceof PojoConfigurationTypeHandler);        
+        assertSame(dp, ((PojoConfigurationTypeHandler) handler).getDistributionProvider());
+    }
+    
+    public void testGetPojoHandler() {
+        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
+        
+        Map<String, Object> sdProps = new HashMap<String, Object>();
+        sdProps.put(Constants.CONFIG_TYPE_PROPERTY, Constants.POJO_CONFIG_TYPE);
+        ServiceDescription sd = new ServiceDescriptionImpl(
+                Collections.singletonList("MyInterface"), sdProps);
+
+        CxfDistributionProvider dp = new DistributionProviderImpl();
+        ConfigurationTypeHandler handler = f.getHandler(sd, dp, new HashMap<String, Object>());
+        assertTrue(handler instanceof PojoConfigurationTypeHandler);        
+        assertSame(dp, ((PojoConfigurationTypeHandler) handler).getDistributionProvider());
+    }
+
+    public void testGetWSDLHandler() {
+        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
+        
+        Map<String, Object> sdProps = new HashMap<String, Object>();
+        sdProps.put(Constants.CONFIG_TYPE_PROPERTY, Constants.WSDL_CONFIG_TYPE);
+        ServiceDescription sd = new ServiceDescriptionImpl(
+                Collections.singletonList("MyInterface"), sdProps);
+        
+        CxfDistributionProvider dp = new DistributionProviderImpl();
+        ConfigurationTypeHandler handler = f.getHandler(sd, dp, new HashMap<String, Object>());
+        assertTrue(handler instanceof WsdlConfigurationTypeHandler);        
+        assertSame(dp, ((WsdlConfigurationTypeHandler) handler).getDistributionProvider());
+    }
+}

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java?rev=701057&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java (added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java Thu Oct  2 02:40:56 2008
@@ -0,0 +1,87 @@
+/** 
+  * Licensed to the Apache Software Foundation (ASF) under one 
+  * or more contributor license agreements. See the NOTICE file 
+  * distributed with this work for additional information 
+  * regarding copyright ownership. The ASF licenses this file 
+  * to you under the Apache License, Version 2.0 (the 
+  * "License"); you may not use this file except in compliance 
+  * with the License. You may obtain a copy of the License at 
+  * 
+  * http://www.apache.org/licenses/LICENSE-2.0 
+  * 
+  * Unless required by applicable law or agreed to in writing, 
+  * software distributed under the License is distributed on an 
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+  * KIND, either express or implied. See the License for the 
+  * specific language governing permissions and limitations 
+  * under the License. 
+  */
+package org.apache.cxf.dosgi.dsw.handlers;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.dosgi.dsw.Constants;
+import org.apache.cxf.dosgi.dsw.service.DistributionProviderImpl;
+import org.apache.cxf.endpoint.AbstractEndpointFactory;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
+import org.easymock.classextension.EasyMock;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.discovery.ServiceDescription;
+
+
+public class PojoConfigurationTypeHandlerTest extends TestCase {
+    private Map<String, Object> handlerProps;
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        
+        handlerProps = new HashMap<String, Object>();
+        handlerProps.put(Constants.DEFAULT_HOST_CONFIG, "somehost");
+        handlerProps.put(Constants.DEFAULT_PORT_CONFIG, "54321");
+    }
+
+    public void testCreateServerPopulatesDistributionProvider() {
+        String myService = "Hi";
+        
+        ReflectionServiceFactoryBean sf = EasyMock.createNiceMock(ReflectionServiceFactoryBean.class);
+        EasyMock.replay(sf);
+        
+        final ServerFactoryBean sfb = EasyMock.createNiceMock(ServerFactoryBean.class);
+        EasyMock.expect(sfb.getServiceFactory()).andReturn(sf).anyTimes();        
+        EasyMock.replay(sfb);
+        
+        DistributionProviderImpl dp = new DistributionProviderImpl();
+        PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dp, handlerProps) {
+            @Override
+            ServerFactoryBean createServerFactoryBean() {
+                return sfb;
+            }
+
+            @Override
+            void applyIntents(BundleContext dswContext, BundleContext callingContext,
+                List<AbstractFeature> features, AbstractEndpointFactory factory, ServiceDescription sd) {}
+        };
+        
+        ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
+        BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
+        BundleContext callingContext = EasyMock.createNiceMock(BundleContext.class);
+        ServiceDescription sd = EasyMock.createNiceMock(ServiceDescription.class);
+        EasyMock.replay(sr);
+        EasyMock.replay(dswContext);
+        EasyMock.replay(callingContext);
+        EasyMock.replay(sd);
+        
+        assertEquals("Precondition failed", 0, dp.getExposedServices().length);
+        p.createServer(sr, dswContext, callingContext, sd, String.class, myService);
+        assertEquals(1, dp.getExposedServices().length);
+        assertSame(sr, dp.getExposedServices()[0]);
+    }
+}

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java Thu Oct  2 02:40:56 2008
@@ -22,7 +22,7 @@
 import java.util.Hashtable;
 import java.util.List;
 
-import org.apache.cxf.dosgi.dsw.hooks.CxfListenerHook;
+import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
 import org.junit.Assert;
@@ -41,7 +41,6 @@
         control = EasyMock.createNiceControl();
     }
     
-    @SuppressWarnings("unchecked")
     @Test
     public void testSyncListenerHook() throws Exception {
         
@@ -67,7 +66,7 @@
                                        control.createMock(ServiceReference.class));
         control.replay();
      
-        CxfListenerHook hook = new CxfListenerHook(dswContext);
+        CxfListenerHook hook = new CxfListenerHook(dswContext, null);
         
         // TODO : if the next call ends up being executed in a thread of its own then
         // update the test accordingly, use Futures for ex
@@ -77,8 +76,18 @@
         
         List<ServiceReference> registeredRefs = dswContext.getRegisteredReferences();
         assertNotNull(registeredRefs);
-        assertEquals(1, registeredRefs.size());
+        assertEquals(1, registeredRefs.size());        
+    }
+    
+    @Test
+    public void testConstructorAndGetters() {
+        BundleContext bc = control.createMock(BundleContext.class);
+        CxfDistributionProvider dp = control.createMock(CxfDistributionProvider.class);
+        control.replay();
         
+        CxfListenerHook clh = new CxfListenerHook(bc, dp);
+        assertSame(bc, clh.getContext());
+        assertSame(dp, clh.getDistributionProvider());
     }
 
 }

Modified: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java (original)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfPublishHookTest.java Thu Oct  2 02:40:56 2008
@@ -100,7 +100,7 @@
         
         public TestPublishHook(BundleContext bc, TestService serviceObject,
                                Server s) {
-            super(bc);
+            super(bc, null);
             this.serviceObject = serviceObject;
             this.server = s;
         }
@@ -115,7 +115,8 @@
                     throw new UnsupportedOperationException();
                 }
 
-                public Server createServer(BundleContext dswContext, BundleContext callingContext, 
+                public Server createServer(ServiceReference sr, 
+                                           BundleContext dswContext, BundleContext callingContext, 
                                            ServiceDescription sd, Class<?> iClass, Object serviceBean) {
                     Assert.assertSame(serviceBean, serviceObject);
                     TestPublishHook.this.setCalled();

Added: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java?rev=701057&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java (added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java Thu Oct  2 02:40:56 2008
@@ -0,0 +1,70 @@
+/** 
+  * Licensed to the Apache Software Foundation (ASF) under one 
+  * or more contributor license agreements. See the NOTICE file 
+  * distributed with this work for additional information 
+  * regarding copyright ownership. The ASF licenses this file 
+  * to you under the Apache License, Version 2.0 (the 
+  * "License"); you may not use this file except in compliance 
+  * with the License. You may obtain a copy of the License at 
+  * 
+  * http://www.apache.org/licenses/LICENSE-2.0 
+  * 
+  * Unless required by applicable law or agreed to in writing, 
+  * software distributed under the License is distributed on an 
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+  * KIND, either express or implied. See the License for the 
+  * specific language governing permissions and limitations 
+  * under the License. 
+  */
+package org.apache.cxf.dosgi.dsw.hooks;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.dosgi.dsw.handlers.ConfigurationTypeHandler;
+import org.apache.cxf.dosgi.dsw.service.ServiceDescriptionImpl;
+import org.apache.cxf.endpoint.Server;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.discovery.ServiceDescription;
+
+
+public class ServiceHookUtilsTest extends TestCase {
+    public void testCreateServer() {
+        IMocksControl control = EasyMock.createNiceControl();
+        
+        Server srvr = control.createMock(Server.class);
+        ServiceReference serviceReference = control.createMock(ServiceReference.class);
+        BundleContext dswContext = control.createMock(BundleContext.class);
+        BundleContext callingContext = control.createMock(BundleContext.class);
+        ServiceDescription sd = new ServiceDescriptionImpl("java.lang.String");
+        Object service = "hi";
+
+        ConfigurationTypeHandler handler = control.createMock(ConfigurationTypeHandler.class);
+        handler.createServer(serviceReference, dswContext, callingContext, sd, String.class, service);
+        EasyMock.expectLastCall().andReturn(srvr);
+        control.replay();
+        
+        assertSame(srvr, 
+            ServiceHookUtils.createServer(handler, serviceReference, dswContext, callingContext, sd, service));        
+    }
+
+    public void testNoServerWhenNoInterfaceSpecified() {
+        IMocksControl control = EasyMock.createNiceControl();
+        
+        Server srvr = control.createMock(Server.class);
+        ServiceReference serviceReference = control.createMock(ServiceReference.class);
+        BundleContext dswContext = control.createMock(BundleContext.class);
+        BundleContext callingContext = control.createMock(BundleContext.class);
+        ServiceDescription sd = control.createMock(ServiceDescription.class);
+        Object service = "hi";
+
+        ConfigurationTypeHandler handler = control.createMock(ConfigurationTypeHandler.class);
+        handler.createServer(serviceReference, dswContext, callingContext, sd, String.class, service);
+        EasyMock.expectLastCall().andReturn(srvr);
+        control.replay();
+        
+        assertNull(ServiceHookUtils.createServer(handler, serviceReference, dswContext, callingContext, sd, service));        
+    }
+}

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/ServiceHookUtilsTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java?rev=701057&view=auto
==============================================================================
--- cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java (added)
+++ cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java Thu Oct  2 02:40:56 2008
@@ -0,0 +1,68 @@
+/** 
+  * Licensed to the Apache Software Foundation (ASF) under one 
+  * or more contributor license agreements. See the NOTICE file 
+  * distributed with this work for additional information 
+  * regarding copyright ownership. The ASF licenses this file 
+  * to you under the Apache License, Version 2.0 (the 
+  * "License"); you may not use this file except in compliance 
+  * with the License. You may obtain a copy of the License at 
+  * 
+  * http://www.apache.org/licenses/LICENSE-2.0 
+  * 
+  * Unless required by applicable law or agreed to in writing, 
+  * software distributed under the License is distributed on an 
+  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
+  * KIND, either express or implied. See the License for the 
+  * specific language governing permissions and limitations 
+  * under the License. 
+  */
+package org.apache.cxf.dosgi.dsw.service;
+
+import junit.framework.TestCase;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceReference;
+
+public class DistributionProviderImplTest extends TestCase {
+    public void testExposedServices() {
+        DistributionProviderImpl dp = new DistributionProviderImpl();
+        
+        assertEquals(0, dp.getExposedServices().length);
+        ServiceReference sr = new TestServiceReference();
+        ServiceReference sr2 = new TestServiceReference();
+        
+        dp.addExposedService(sr);
+        assertEquals(1, dp.getExposedServices().length);
+        assertSame(sr, dp.getExposedServices()[0]);
+
+        dp.addExposedService(sr);
+        assertEquals(1, dp.getExposedServices().length);
+        assertSame(sr, dp.getExposedServices()[0]);
+
+        dp.addExposedService(sr2);
+        assertEquals(2, dp.getExposedServices().length);
+        
+    }   
+    
+    private static class TestServiceReference implements ServiceReference {
+        public Bundle getBundle() {
+            return null;
+        }
+
+        public Object getProperty(String arg0) {
+            return null;
+        }
+
+        public String[] getPropertyKeys() {
+            return null;
+        }
+
+        public Bundle[] getUsingBundles() {
+            return null;
+        }
+
+        public boolean isAssignableTo(Bundle arg0, String arg1) {
+            return false;
+        }        
+    }
+}

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/sandbox/dosgi/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/DistributionProviderImplTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/dsw/DistributionProvider.java
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/dsw/DistributionProvider.java?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/dsw/DistributionProvider.java (original)
+++ cxf/sandbox/dosgi/felix/framework/src/main/java/org/osgi/service/dsw/DistributionProvider.java Thu Oct  2 02:40:56 2008
@@ -22,7 +22,7 @@
 import org.osgi.framework.ServiceReference;
 
 public interface DistributionProvider {
-
+    ServiceReference[] getExposedServices();
     ServiceReference[] getRemoteServices();
     ServiceReference[] getPublishedServices();
     

Modified: cxf/sandbox/dosgi/pom.xml
URL: http://svn.apache.org/viewvc/cxf/sandbox/dosgi/pom.xml?rev=701057&r1=701056&r2=701057&view=diff
==============================================================================
--- cxf/sandbox/dosgi/pom.xml (original)
+++ cxf/sandbox/dosgi/pom.xml Thu Oct  2 02:40:56 2008
@@ -16,4 +16,15 @@
         <module>systests</module>
     </modules>
  
+    <reporting>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-surefire-report-plugin</artifactId>
+          <configuration>
+            <aggregate>true</aggregate>
+          </configuration>
+        </plugin>
+      </plugins>
+    </reporting>
 </project>



Mime
View raw message