cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r778390 - in /cxf/dosgi/trunk: 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/test/java/org/apache/c...
Date Mon, 25 May 2009 11:27:26 GMT
Author: davidb
Date: Mon May 25 11:27:25 2009
New Revision: 778390

URL: http://svn.apache.org/viewvc?rev=778390&view=rev
Log:
Fix for bug 2173 (CXF-DOSGi issues when used with Declarative Services).
* Implemented FindHook to support bundles consuming services via BundleContext.getServiceReference()
* Moved to Felix 1.8.0. Felix 1.4.1 doesn't have FindHook support yet and Felix 1.6.x doesn't seem to work with the Spring-DM system testing framework. In Felix 1.8.0 all seems to be well.
* Fixed Thread Context Loader issues in the ServiceInvocationHandler.
* Added new DOSGi/Declarative Services demo.
New unit tests.

Demo tested with the DS implementation of Equinox 3.5M6

Added:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHook.java   (contents, props changed)
      - copied, changed from r776311, cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java   (contents, props changed)
      - copied, changed from r776311, cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java
    cxf/dosgi/trunk/samples/ds/
    cxf/dosgi/trunk/samples/ds/client/
    cxf/dosgi/trunk/samples/ds/client/pom.xml   (with props)
    cxf/dosgi/trunk/samples/ds/client/src/
    cxf/dosgi/trunk/samples/ds/client/src/main/
    cxf/dosgi/trunk/samples/ds/client/src/main/java/
    cxf/dosgi/trunk/samples/ds/client/src/main/java/org/
    cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/
    cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/cxf/
    cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/cxf/dosgi/
    cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/cxf/dosgi/samples/
    cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/cxf/dosgi/samples/ds/
    cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/cxf/dosgi/samples/ds/consumer/
    cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/cxf/dosgi/samples/ds/consumer/AdderConsumer.java   (with props)
    cxf/dosgi/trunk/samples/ds/client/src/main/resources/
    cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/
    cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/component.xml   (with props)
    cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/remote-service/
    cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/remote-service/remote-services.xml   (with props)
    cxf/dosgi/trunk/samples/ds/impl/
    cxf/dosgi/trunk/samples/ds/impl/pom.xml   (with props)
    cxf/dosgi/trunk/samples/ds/impl/src/
    cxf/dosgi/trunk/samples/ds/impl/src/main/
    cxf/dosgi/trunk/samples/ds/impl/src/main/java/
    cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/
    cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/
    cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/cxf/
    cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/cxf/dosgi/
    cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/cxf/dosgi/samples/
    cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/cxf/dosgi/samples/ds/
    cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/cxf/dosgi/samples/ds/impl/
    cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/cxf/dosgi/samples/ds/impl/AdderServiceImpl.java   (with props)
    cxf/dosgi/trunk/samples/ds/impl/src/main/resources/
    cxf/dosgi/trunk/samples/ds/impl/src/main/resources/OSGI-INF/
    cxf/dosgi/trunk/samples/ds/impl/src/main/resources/OSGI-INF/component.xml   (with props)
    cxf/dosgi/trunk/samples/ds/interface/
    cxf/dosgi/trunk/samples/ds/interface/pom.xml   (with props)
    cxf/dosgi/trunk/samples/ds/interface/src/
    cxf/dosgi/trunk/samples/ds/interface/src/main/
    cxf/dosgi/trunk/samples/ds/interface/src/main/java/
    cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/
    cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/apache/
    cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/apache/cxf/
    cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/apache/cxf/dosgi/
    cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/apache/cxf/dosgi/samples/
    cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/apache/cxf/dosgi/samples/ds/
    cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/apache/cxf/dosgi/samples/ds/AdderService.java   (with props)
    cxf/dosgi/trunk/samples/ds/pom.xml   (with props)
Removed:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java
Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandler.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHookTest.java
    cxf/dosgi/trunk/parent/pom.xml
    cxf/dosgi/trunk/samples/pom.xml

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java?rev=778390&r1=778389&r2=778390&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java Mon May 25 11:27:25 2009
@@ -25,7 +25,7 @@
 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.CxfFindListenerHook;
 import org.apache.cxf.dosgi.dsw.hooks.CxfPublishHook;
 import org.apache.cxf.dosgi.dsw.qos.IntentMap;
 import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
@@ -37,6 +37,7 @@
 import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.hooks.service.FindHook;
 import org.osgi.framework.hooks.service.ListenerHook;
 import org.osgi.service.cm.ConfigurationException;
 import org.osgi.service.cm.ManagedService;
@@ -52,8 +53,8 @@
                                new LinkedBlockingQueue<Runnable>());
 
     CxfDistributionProvider dpService;
+    CxfFindListenerHook lHook;
     CxfPublishHook pHook;
-    CxfListenerHook lHook;
     
     public void start(BundleContext context) throws Exception {
         // Disable the fast infoset as it's not compatible (yet) with OSGi
@@ -66,9 +67,10 @@
         
         dpService = registerDistributionProviderService();
 
-        pHook = new CxfPublishHook(context, dpService);
-        lHook = new CxfListenerHook(context, dpService);
-        context.registerService(ListenerHook.class.getName(), lHook, new Hashtable());        
+        pHook = new CxfPublishHook(context, dpService);        
+        lHook = new CxfFindListenerHook(context, dpService);
+        context.registerService(new String [] {FindHook.class.getName(), ListenerHook.class.getName()}, lHook, new Hashtable());
+        
         context.addServiceListener(this);                 
         checkExistingServices();        
     }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandler.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandler.java?rev=778390&r1=778389&r2=778390&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandler.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandler.java Mon May 25 11:27:25 2009
@@ -42,7 +42,9 @@
     }
     
     public Object invoke(Object proxy, Method m, Object[] params) throws Throwable {
+        ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
         try {
+            Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
             return m.invoke(serviceObject, params); 
         } catch (Throwable ex) {
             Throwable theCause = ex.getCause() == null ? ex : ex.getCause();
@@ -58,6 +60,8 @@
                         
             throw new InvocationTargetException(
                     new ServiceException(REMOTE_EXCEPTION_TYPE, theCause));
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldCl);
         }
     }
 

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java?rev=778390&r1=778389&r2=778390&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHook.java Mon May 25 11:27:25 2009
@@ -55,9 +55,9 @@
 
     private DiscoveredServiceTracker tracker;
     private Dictionary trackerProperties = new Hashtable();
-    private ServiceRegistration trackerRegistration;
     private Map<String, ServiceRegistration> discoveredServices =
         new HashMap<String, ServiceRegistration>();
+    ServiceRegistration trackerRegistration;
 
     protected AbstractClientHook(BundleContext bc, CxfDistributionProvider dp) {
         super(bc, dp);
@@ -194,29 +194,38 @@
         LOG.info("lookup discovery service: interface: " + interfaceName
                  + " filter: " + filterValue);
 
+        boolean change = false;
         if (interfaceName != null) {
-            append(trackerProperties,
+            change |= append(trackerProperties,
                    INTERFACE_MATCH_CRITERIA,
                    interfaceName); 
         }
 
         if (filterValue != null) {
-            append(trackerProperties,
+            change |= append(trackerProperties,
                    FILTER_MATCH_CRITERIA,
                    filterValue); 
         }
 
-        trackerRegistration.setProperties(trackerProperties);
+        if (change) {
+            trackerRegistration.setProperties(trackerProperties);
+        }
     }
 
     @SuppressWarnings("unchecked")
-    private void append(Dictionary properties, String key, String additional) {
+    private boolean append(Dictionary properties, String key, String additional) {
         Collection existing = (Collection)properties.get(key);
         if (existing == null) {
             existing = new ArrayList<String>();
             properties.put(key, existing);
         }
-        existing.add(additional);
+        
+        if (!existing.contains(additional)) {
+            existing.add(additional);
+            return true;
+        } else {
+            return false;
+        }
     }
 
     /**

Copied: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHook.java (from r776311, cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java)
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHook.java?p2=cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHook.java&p1=cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java&r1=776311&r2=778390&rev=778390&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHook.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHook.java Mon May 25 11:27:25 2009
@@ -18,6 +18,8 @@
   */
 package org.apache.cxf.dosgi.dsw.hooks;
 
+import static org.osgi.service.discovery.ServicePublication.SERVICE_INTERFACE_NAME;
+
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -29,13 +31,11 @@
 import org.apache.cxf.dosgi.dsw.service.CxfDistributionProvider;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.framework.hooks.service.FindHook;
 import org.osgi.framework.hooks.service.ListenerHook;
 
-import static org.osgi.service.discovery.ServicePublication.SERVICE_INTERFACE_NAME;
-
-public class CxfListenerHook extends AbstractClientHook implements ListenerHook {
-
-    private static final Logger LOG = Logger.getLogger(CxfListenerHook.class.getName());
+public class CxfFindListenerHook extends AbstractClientHook implements ListenerHook, FindHook {
+    private static final Logger LOG = Logger.getLogger(CxfFindListenerHook.class.getName());
 
     
     private final static String CLASS_NAME_EXPRESSION =
@@ -57,7 +57,7 @@
         SYSTEM_PACKAGES.add("java.net.ContentHandler");
     }
     
-    public CxfListenerHook(BundleContext bc, CxfDistributionProvider dp) {
+    public CxfFindListenerHook(BundleContext bc, CxfDistributionProvider dp) {
         super(bc, dp);
     }
     
@@ -68,7 +68,7 @@
     public void removed(Collection /*<? extends ListenerHook.ListenerInfo>*/ listener) {
         // todo add this in - need to unregister the endpoints
     }
-
+    
     private void handleListeners(Collection/*<? extends ListenerHook.ListenerInfo>*/ listeners) {
         for (Iterator/*<? extends ListenerHook.ListenerInfo>*/ it = listeners.iterator(); it.hasNext(); ) {
             ListenerHook.ListenerInfo listener = (ListenerHook.ListenerInfo) it.next();
@@ -90,6 +90,11 @@
         }
     }
     
+    public void find(BundleContext context, String className, String filter, boolean allServices, 
+            Collection /* <? extends ServiceReference> */ references) {
+        lookupDiscoveryService(className, filter);
+    }
+
     private String getClassNameFromFilter(String filter) {
         if (filter != null) {
             Matcher matcher = CLASS_NAME_PATTERN.matcher(filter);

Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHook.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHook.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHook.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java?rev=778390&r1=778389&r2=778390&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/ActivatorTest.java Mon May 25 11:27:25 2009
@@ -21,29 +21,19 @@
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.hooks.service.FindHook;
+import org.osgi.framework.hooks.service.ListenerHook;
+import org.osgi.service.discovery.DiscoveredServiceTracker;
 import org.osgi.service.distribution.DistributionProvider;
 
 public class ActivatorTest extends TestCase{
-    @SuppressWarnings("unchecked")
     private BundleContext getMockBundleContext() {
         IMocksControl control = EasyMock.createNiceControl();
         
         Bundle b = control.createMock(Bundle.class);
         Hashtable<String, String> ht = new Hashtable<String, String>();
-        EasyMock.expect(b.getHeaders()).andReturn(ht).anyTimes();
-        
-        final Map<Object, Dictionary> services = new HashMap<Object, Dictionary>();
+        EasyMock.expect(b.getHeaders()).andReturn(ht).anyTimes();        
         BundleContext bc = control.createMock(BundleContext.class);
-        EasyMock.expect(bc.registerService(
-            (String) EasyMock.anyObject(),
-            EasyMock.anyObject(), 
-            (Dictionary) EasyMock.anyObject())).andAnswer(new IAnswer<ServiceRegistration>() {
-                public ServiceRegistration answer() throws Throwable {
-                    services.put(EasyMock.getCurrentArguments()[1],
-                        (Dictionary) EasyMock.getCurrentArguments()[2]);
-                    return null;
-                }                
-            }).anyTimes();            
 
         EasyMock.expect(b.getBundleContext()).andReturn(bc).anyTimes();
         EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
@@ -95,6 +85,16 @@
                     return null;
                 }                
             }).anyTimes();            
+        EasyMock.expect(bc.registerService(
+            (String []) EasyMock.anyObject(),
+            EasyMock.anyObject(), 
+            (Dictionary) EasyMock.anyObject())).andAnswer(new IAnswer<ServiceRegistration>() {
+                public ServiceRegistration answer() throws Throwable {
+                    services.put(EasyMock.getCurrentArguments()[1],
+                        (Dictionary) EasyMock.getCurrentArguments()[2]);
+                    return null;
+                }                
+            }).anyTimes();            
 
         EasyMock.expect(b.getBundleContext()).andReturn(bc).anyTimes();
         EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
@@ -116,7 +116,6 @@
         assertEquals("Precondition failed", 0, services.size());
         a.start(bc);
         
-        assertEquals(4, services.size());
         CxfDistributionProvider dp = null;
         for (Object o : services.keySet()) {
             if (o instanceof CxfDistributionProvider) {
@@ -176,6 +175,63 @@
         assertSame(sref, key);
         
     }
+    
+    public void testListenerHookRegistered() throws Exception {
+        testServiceRegistered(ListenerHook.class);
+    } 
+
+    public void testFindHookRegistered() throws Exception {
+        testServiceRegistered(FindHook.class);
+    } 
+    
+    public void testDiscoveredServiceTrackerRegistered() throws Exception {
+        testServiceRegistered(DiscoveredServiceTracker.class);
+    } 
+
+    private void testServiceRegistered(Class serviceClass) throws Exception {
+        IMocksControl control = EasyMock.createNiceControl();
+        
+        Bundle b = control.createMock(Bundle.class);
+        Hashtable<String, String> ht = new Hashtable<String, String>();
+        EasyMock.expect(b.getHeaders()).andReturn(ht).anyTimes();
+
+        final Map<Object, Dictionary> services = new HashMap<Object, Dictionary>();
+        BundleContext bc = control.createMock(BundleContext.class);
+        EasyMock.expect(bc.registerService(
+            (String) EasyMock.anyObject(),
+            EasyMock.anyObject(), 
+            (Dictionary) EasyMock.anyObject())).andAnswer(new IAnswer<ServiceRegistration>() {
+                public ServiceRegistration answer() throws Throwable {
+                    services.put(EasyMock.getCurrentArguments()[1],
+                        (Dictionary) EasyMock.getCurrentArguments()[2]);
+                    return null;
+                }                
+            }).anyTimes();            
+        EasyMock.expect(bc.registerService(
+            (String []) EasyMock.anyObject(),
+            EasyMock.anyObject(), 
+            (Dictionary) EasyMock.anyObject())).andAnswer(new IAnswer<ServiceRegistration>() {
+                public ServiceRegistration answer() throws Throwable {
+                    services.put(EasyMock.getCurrentArguments()[1],
+                        (Dictionary) EasyMock.getCurrentArguments()[2]);
+                    return null;
+                }                
+            }).anyTimes();            
+
+        EasyMock.expect(b.getBundleContext()).andReturn(bc).anyTimes();
+        EasyMock.expect(bc.getBundle()).andReturn(b).anyTimes();
+        control.replay();
+
+        Activator a = new Activator();
+        a.start(bc);
+        
+        for (Object svc : services.keySet()) {
+            if (serviceClass.isAssignableFrom(svc.getClass())) {
+                return;
+            }
+        }
+        fail("Should have a service registered of type: " + serviceClass);
+    }
 
     private static class TestServiceImpl implements TestService {}    
 }

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHookTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHookTest.java?rev=778390&r1=778389&r2=778390&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHookTest.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/AbstractClientHookTest.java Mon May 25 11:27:25 2009
@@ -18,16 +18,20 @@
   */
 package org.apache.cxf.dosgi.dsw.hooks;
 
+import java.util.Arrays;
+import java.util.Dictionary;
 import java.util.HashMap;
+import java.util.Hashtable;
 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.easymock.EasyMock;
 import org.easymock.IMocksControl;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.discovery.DiscoveredServiceTracker;
 import org.osgi.service.discovery.ServiceEndpointDescription;
 
 public class AbstractClientHookTest extends TestCase {
@@ -48,4 +52,138 @@
         Map<String, Object> props = ch.getProperties(sed);
         assertTrue(Boolean.valueOf((String) props.get("osgi.remote")));
     }
+    
+    public void testLookupDiscoveryServiceInterface() {
+        ServiceRegistration sr = EasyMock.createMock(ServiceRegistration.class);
+        EasyMock.replay(sr);
+
+        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+        EasyMock.replay(bc);
+        
+        AbstractClientHook ch = new AbstractClientHook(bc, null) {};
+        // Put a mock service registration in there so we can check how its called
+        ch.trackerRegistration = sr;
+
+        ch.lookupDiscoveryService(null, null);
+        EasyMock.verify(sr);
+        
+        // pass in an interface
+        EasyMock.reset(sr);
+        Dictionary d = new Hashtable();
+        d.put(DiscoveredServiceTracker.INTERFACE_MATCH_CRITERIA, Arrays.asList("a"));
+        sr.setProperties(d);
+        EasyMock.replay(sr);
+        
+        ch.lookupDiscoveryService("a", null);
+        EasyMock.verify(sr);
+
+        // try again with the same value, should not trigger a callback since it's already there
+        EasyMock.reset(sr);
+        EasyMock.replay(sr);
+
+        ch.lookupDiscoveryService("a", null);
+        EasyMock.verify(sr);
+
+        // pass in another interface
+        EasyMock.reset(sr);
+        d = new Hashtable();
+        d.put(DiscoveredServiceTracker.INTERFACE_MATCH_CRITERIA, Arrays.asList("a", "b"));
+        sr.setProperties(d);
+        EasyMock.replay(sr);
+
+        ch.lookupDiscoveryService("b", null);
+        EasyMock.verify(sr);
+
+        // try again with the same value, should not trigger a callback since it's already there
+        EasyMock.reset(sr);
+        EasyMock.replay(sr);
+
+        ch.lookupDiscoveryService("a", null);
+        ch.lookupDiscoveryService("b", null);
+        EasyMock.verify(sr);
+    }
+    
+    public void testLookupDiscoveryServiceFilter() {
+        ServiceRegistration sr = EasyMock.createMock(ServiceRegistration.class);
+        EasyMock.replay(sr);
+
+        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+        EasyMock.replay(bc);
+        
+        AbstractClientHook ch = new AbstractClientHook(bc, null) {};
+        // Put a mock service registration in there so we can check how its called
+        ch.trackerRegistration = sr;
+
+        ch.lookupDiscoveryService(null, null);
+        EasyMock.verify(sr);
+        
+        // pass in an interface
+        EasyMock.reset(sr);
+        Dictionary d = new Hashtable();
+        d.put(DiscoveredServiceTracker.FILTER_MATCH_CRITERIA, Arrays.asList("a"));
+        sr.setProperties(d);
+        EasyMock.replay(sr);
+        
+        ch.lookupDiscoveryService(null, "a");
+        EasyMock.verify(sr);
+
+        // try again with the same value, should not trigger a callback since it's already there
+        EasyMock.reset(sr);
+        EasyMock.replay(sr);
+
+        ch.lookupDiscoveryService(null, "a");
+        EasyMock.verify(sr);
+
+        // pass in another interface
+        EasyMock.reset(sr);
+        d = new Hashtable();
+        d.put(DiscoveredServiceTracker.FILTER_MATCH_CRITERIA, Arrays.asList("a", "b"));
+        sr.setProperties(d);
+        EasyMock.replay(sr);
+
+        ch.lookupDiscoveryService(null, "b");
+        EasyMock.verify(sr);
+
+        // try again with the same value, should not trigger a callback since it's already there
+        EasyMock.reset(sr);
+        EasyMock.replay(sr);
+
+        ch.lookupDiscoveryService(null, "a");
+        ch.lookupDiscoveryService(null, "b");
+        EasyMock.verify(sr);
+    }
+    
+    public void testLookupDiscoveryServiceBoth() {
+        ServiceRegistration sr = EasyMock.createMock(ServiceRegistration.class);
+        EasyMock.replay(sr);
+
+        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+        EasyMock.replay(bc);
+        
+        AbstractClientHook ch = new AbstractClientHook(bc, null) {};
+        // Put a mock service registration in there so we can check how its called
+        ch.trackerRegistration = sr;
+
+        ch.lookupDiscoveryService(null, null);
+        EasyMock.verify(sr);
+        
+        // pass in an interface
+        EasyMock.reset(sr);
+        Dictionary d = new Hashtable();
+        d.put(DiscoveredServiceTracker.FILTER_MATCH_CRITERIA, Arrays.asList("a"));
+        d.put(DiscoveredServiceTracker.INTERFACE_MATCH_CRITERIA, Arrays.asList("x"));
+        sr.setProperties(d);
+        EasyMock.replay(sr);
+        
+        ch.lookupDiscoveryService("x", "a");
+        EasyMock.verify(sr);
+
+        // try again with the same value, should not trigger a callback since it's already there
+        EasyMock.reset(sr);
+        EasyMock.replay(sr);
+
+        ch.lookupDiscoveryService(null, "a");
+        ch.lookupDiscoveryService("x", "a");
+        EasyMock.verify(sr);
+    }        
 }

Copied: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java (from r776311, cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java)
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java?p2=cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java&p1=cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java&r1=776311&r2=778390&rev=778390&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfListenerHookTest.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java Mon May 25 11:27:25 2009
@@ -22,6 +22,7 @@
 import static org.osgi.service.discovery.DiscoveredServiceNotification.UNAVAILABLE;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Dictionary;
@@ -48,7 +49,7 @@
 import org.osgi.service.discovery.ServiceEndpointDescription;
 import org.osgi.service.discovery.ServicePublication;
 
-public class CxfListenerHookTest extends Assert {
+public class CxfFindListenerHookTest extends Assert {
 
     private IMocksControl control;
     
@@ -217,7 +218,7 @@
 
         control.replay();
      
-        CxfListenerHook hook = new CxfListenerHook(dswContext, null);
+        CxfFindListenerHook hook = new CxfFindListenerHook(dswContext, null);
 
         ListenerHook.ListenerInfo info = new ListenerHook.ListenerInfo() {
             public BundleContext getBundleContext() {
@@ -226,6 +227,10 @@
 
             public String getFilter() {
                 return filter;
+            }
+
+            public boolean isRemoved() {
+                return false;
             }            
         };
         hook.added(Collections.singleton(info));
@@ -272,11 +277,32 @@
         CxfDistributionProvider dp = control.createMock(CxfDistributionProvider.class);
         control.replay();
         
-        CxfListenerHook clh = new CxfListenerHook(bc, dp);
+        CxfFindListenerHook clh = new CxfFindListenerHook(bc, dp);
         assertSame(bc, clh.getContext());
         assertSame(dp, clh.getDistributionProvider());
     }
 
+    @Test
+    public void testFindHook() {
+        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+        
+        final List<String> lookupCalls = new ArrayList<String>();        
+        CxfFindListenerHook fh = new CxfFindListenerHook(bc, null) {
+            @Override
+            protected synchronized void lookupDiscoveryService(
+                    String interfaceName, String filterValue) {
+                lookupCalls.add(interfaceName);
+                lookupCalls.add(filterValue);
+            }            
+        };
+        
+        String clazz = "my.app.Class";
+        String filter = "&(A=B)(C=D)";
+        fh.find(null, clazz, filter, true, null);
+        
+        assertEquals(Arrays.asList(clazz, filter), lookupCalls);
+    }
+    
     private void notifyAvailable(DiscoveredServiceTracker tracker,
                                  Collection interfaces,
                                  Collection filters, 

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

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

Propchange: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/hooks/CxfFindListenerHookTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: cxf/dosgi/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/parent/pom.xml?rev=778390&r1=778389&r2=778390&view=diff
==============================================================================
--- cxf/dosgi/trunk/parent/pom.xml (original)
+++ cxf/dosgi/trunk/parent/pom.xml Mon May 25 11:27:25 2009
@@ -19,7 +19,7 @@
          OSGi bundles. -->
     <properties>
         <cxf.version>2.2.1</cxf.version>
-        <felix.version>1.4.1</felix.version>
+        <felix.version>1.8.0</felix.version>
         <spring.version>2.5.6</spring.version>
         <spring.osgi.version>1.2.0</spring.osgi.version>
         <zookeeper.version>3.0.0</zookeeper.version>

Added: cxf/dosgi/trunk/samples/ds/client/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/ds/client/pom.xml?rev=778390&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/ds/client/pom.xml (added)
+++ cxf/dosgi/trunk/samples/ds/client/pom.xml Mon May 25 11:27:25 2009
@@ -0,0 +1,66 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!--
+  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.
+-->
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.cxf.dosgi.samples</groupId>
+  <artifactId>cxf-dosgi-ri-samples-ds-client</artifactId>
+  <packaging>bundle</packaging>
+  <name>Distributed OSGI Declarative Services Sample Client Bundle</name>
+  <version>1.1-SNAPSHOT</version>
+
+  <parent>
+    <groupId>org.apache.cxf.dosgi.samples</groupId>
+    <artifactId>cxf-dosgi-ri-bundles-ds-parent</artifactId>
+    <version>1.1-SNAPSHOT</version>
+  </parent>
+
+  <dependencies>
+    <dependency> 
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.framework</artifactId>
+      <version>${felix.version}</version>
+      <scope>provided</scope>
+    </dependency> 
+    <dependency>
+      <groupId>org.apache.cxf.dosgi.samples</groupId>
+      <artifactId>cxf-dosgi-ri-samples-ds-interface</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies> 
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            <Bundle-Name>${pom.name}</Bundle-Name>
+            <Bundle-Description>This bundle contains the client-side implementation of the Distributed OSGi with Declarative Services sample.</Bundle-Description>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Import-Package>org.apache.cxf.dosgi.samples.ds,
+                            org.osgi.service.component</Import-Package> 
+            <Private-Package>org.apache.cxf.dosgi.samples.ds.consumer</Private-Package> 
+            <Service-Component>OSGI-INF/component.xml</Service-Component>
+          </instructions>
+        </configuration>
+      </plugin> 
+    </plugins>
+  </build>    
+</project>

Propchange: cxf/dosgi/trunk/samples/ds/client/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/ds/client/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/dosgi/trunk/samples/ds/client/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/cxf/dosgi/samples/ds/consumer/AdderConsumer.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/cxf/dosgi/samples/ds/consumer/AdderConsumer.java?rev=778390&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/cxf/dosgi/samples/ds/consumer/AdderConsumer.java (added)
+++ cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/cxf/dosgi/samples/ds/consumer/AdderConsumer.java Mon May 25 11:27:25 2009
@@ -0,0 +1,39 @@
+/** 
+  * 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.samples.ds.consumer;
+
+import org.apache.cxf.dosgi.samples.ds.AdderService;
+import org.osgi.service.component.ComponentContext;
+
+public class AdderConsumer {
+    private AdderService adder;
+    
+    public void bindAdder(AdderService a) {
+        adder = a;
+    }
+    
+    public void unbindAdder(AdderService a) {
+        adder = null;
+    }
+    
+    public void start(ComponentContext cc) {
+        System.out.println("Declarative Service consumer component.");
+        System.out.println("Using adder service: 1 + 1 = " + adder.add(1, 1));
+    }
+}

Propchange: cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/cxf/dosgi/samples/ds/consumer/AdderConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/ds/client/src/main/java/org/apache/cxf/dosgi/samples/ds/consumer/AdderConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/component.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/component.xml?rev=778390&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/component.xml (added)
+++ cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/component.xml Mon May 25 11:27:25 2009
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+    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.
+  -->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="DS Consumer Sample" activate="start">
+   <implementation class="org.apache.cxf.dosgi.samples.ds.consumer.AdderConsumer"/>
+   <reference interface="org.apache.cxf.dosgi.samples.ds.AdderService" name="AdderService" cardinality="1..1" policy="dynamic" bind="bindAdder" unbind="unbindAdder"/>
+</scr:component>
+

Propchange: cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/component.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/component.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/component.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/remote-service/remote-services.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/remote-service/remote-services.xml?rev=778390&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/remote-service/remote-services.xml (added)
+++ cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/remote-service/remote-services.xml Mon May 25 11:27:25 2009
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+    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.
+  -->
+<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
+  <service-description>
+    <provide interface="org.apache.cxf.dosgi.samples.ds.AdderService" />
+    <property name="osgi.remote.interfaces">*</property>
+    <property name="osgi.remote.configuration.type">pojo</property>
+    <property name="osgi.remote.configuration.pojo.address">http://localhost:9090/adder</property>
+  </service-description>
+</service-descriptions>

Propchange: cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/remote-service/remote-services.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/remote-service/remote-services.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/dosgi/trunk/samples/ds/client/src/main/resources/OSGI-INF/remote-service/remote-services.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/dosgi/trunk/samples/ds/impl/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/ds/impl/pom.xml?rev=778390&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/ds/impl/pom.xml (added)
+++ cxf/dosgi/trunk/samples/ds/impl/pom.xml Mon May 25 11:27:25 2009
@@ -0,0 +1,59 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!--
+  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.
+-->
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.cxf.dosgi.samples</groupId>
+  <artifactId>cxf-dosgi-ri-samples-ds-impl</artifactId>
+  <packaging>bundle</packaging>
+  <name>Distributed OSGI Declarative Services Sample Implementation Bundle</name>
+  <version>1.1-SNAPSHOT</version>
+
+  <parent>
+    <groupId>org.apache.cxf.dosgi.samples</groupId>
+    <artifactId>cxf-dosgi-ri-bundles-ds-parent</artifactId>
+    <version>1.1-SNAPSHOT</version>
+  </parent>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.cxf.dosgi.samples</groupId>
+      <artifactId>cxf-dosgi-ri-samples-ds-interface</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies> 
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            <Bundle-Name>${pom.name}</Bundle-Name>
+            <Bundle-Description>This bundle contains the server-side implementation of the Distributed OSGi with Declarative Services sample.</Bundle-Description>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Import-Package>org.apache.cxf.dosgi.samples.ds</Import-Package> 
+            <Private-Package>org.apache.cxf.dosgi.samples.ds.impl</Private-Package> 
+            <Service-Component>OSGI-INF/component.xml</Service-Component>
+          </instructions>
+        </configuration>
+      </plugin> 
+    </plugins>
+  </build>    
+</project>

Propchange: cxf/dosgi/trunk/samples/ds/impl/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/ds/impl/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/dosgi/trunk/samples/ds/impl/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/cxf/dosgi/samples/ds/impl/AdderServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/cxf/dosgi/samples/ds/impl/AdderServiceImpl.java?rev=778390&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/cxf/dosgi/samples/ds/impl/AdderServiceImpl.java (added)
+++ cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/cxf/dosgi/samples/ds/impl/AdderServiceImpl.java Mon May 25 11:27:25 2009
@@ -0,0 +1,29 @@
+/** 
+  * 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.samples.ds.impl;
+
+import org.apache.cxf.dosgi.samples.ds.AdderService;
+
+public class AdderServiceImpl implements AdderService {
+    public int add(int a, int b) {
+        int result = a + b;
+        System.out.println("Adder service invoked: " + a + " + " + b + " = " + result);
+        return result;
+    }	
+}

Propchange: cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/cxf/dosgi/samples/ds/impl/AdderServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/ds/impl/src/main/java/org/apache/cxf/dosgi/samples/ds/impl/AdderServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/dosgi/trunk/samples/ds/impl/src/main/resources/OSGI-INF/component.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/ds/impl/src/main/resources/OSGI-INF/component.xml?rev=778390&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/ds/impl/src/main/resources/OSGI-INF/component.xml (added)
+++ cxf/dosgi/trunk/samples/ds/impl/src/main/resources/OSGI-INF/component.xml Mon May 25 11:27:25 2009
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+    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.
+  -->
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="DS Service Sample">
+  <implementation class="org.apache.cxf.dosgi.samples.ds.impl.AdderServiceImpl"/>
+  
+  <property name="osgi.remote.interfaces">*</property>
+  <property name="osgi.remote.configuration.type" value="pojo" />
+  <property name="osgi.remote.configuration.pojo.address" value="http://localhost:9090/adder" />
+  
+  <service>
+    <provide interface="org.apache.cxf.dosgi.samples.ds.AdderService"/>
+  </service>
+</scr:component>

Propchange: cxf/dosgi/trunk/samples/ds/impl/src/main/resources/OSGI-INF/component.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/ds/impl/src/main/resources/OSGI-INF/component.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/dosgi/trunk/samples/ds/impl/src/main/resources/OSGI-INF/component.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/dosgi/trunk/samples/ds/interface/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/ds/interface/pom.xml?rev=778390&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/ds/interface/pom.xml (added)
+++ cxf/dosgi/trunk/samples/ds/interface/pom.xml Mon May 25 11:27:25 2009
@@ -0,0 +1,51 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <!--
+  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.
+  -->
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.cxf.dosgi.samples</groupId>
+  <artifactId>cxf-dosgi-ri-samples-ds-interface</artifactId>
+  <packaging>bundle</packaging>
+  <name>Distributed OSGI Declarative Services Sample Interface Bundle</name>
+  <version>1.1-SNAPSHOT</version>
+
+  <parent>
+    <groupId>org.apache.cxf.dosgi.samples</groupId>
+    <artifactId>cxf-dosgi-ri-bundles-ds-parent</artifactId>
+    <version>1.1-SNAPSHOT</version>
+  </parent>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <configuration>
+          <instructions>
+            <Bundle-Name>${pom.name}</Bundle-Name>
+            <Bundle-Description>This bundle contains the interfaces of the Distributed OSGi with Declarative Services sample.</Bundle-Description>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Import-Package />
+            <Export-Package>org.apache.cxf.dosgi.samples.ds</Export-Package> 
+          </instructions>
+        </configuration>
+      </plugin> 
+    </plugins>
+  </build>    
+</project>

Propchange: cxf/dosgi/trunk/samples/ds/interface/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/ds/interface/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/dosgi/trunk/samples/ds/interface/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/apache/cxf/dosgi/samples/ds/AdderService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/apache/cxf/dosgi/samples/ds/AdderService.java?rev=778390&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/apache/cxf/dosgi/samples/ds/AdderService.java (added)
+++ cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/apache/cxf/dosgi/samples/ds/AdderService.java Mon May 25 11:27:25 2009
@@ -0,0 +1,23 @@
+/** 
+  * 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.samples.ds;
+
+public interface AdderService {
+    int add(int a, int b);
+}

Propchange: cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/apache/cxf/dosgi/samples/ds/AdderService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/ds/interface/src/main/java/org/apache/cxf/dosgi/samples/ds/AdderService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/dosgi/trunk/samples/ds/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/ds/pom.xml?rev=778390&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/ds/pom.xml (added)
+++ cxf/dosgi/trunk/samples/ds/pom.xml Mon May 25 11:27:25 2009
@@ -0,0 +1,42 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+<!--
+  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.
+-->
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.cxf.dosgi.samples</groupId>
+    <artifactId>cxf-dosgi-ri-bundles-ds-parent</artifactId>
+    <packaging>pom</packaging>
+    <name>Distributed OSGI Declarative Services Sample</name>
+    <version>1.1-SNAPSHOT</version>
+
+    <parent>
+      <groupId>org.apache.cxf.dosgi</groupId>
+      <artifactId>cxf-dosgi-ri-parent</artifactId>
+      <version>1.1-SNAPSHOT</version>
+      <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+    
+    <modules>    
+      <module>interface</module>
+      <module>impl</module>
+      <module>client</module>
+    </modules> 
+
+</project>

Propchange: cxf/dosgi/trunk/samples/ds/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/samples/ds/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/dosgi/trunk/samples/ds/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: cxf/dosgi/trunk/samples/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/pom.xml?rev=778390&r1=778389&r2=778390&view=diff
==============================================================================
--- cxf/dosgi/trunk/samples/pom.xml (original)
+++ cxf/dosgi/trunk/samples/pom.xml Mon May 25 11:27:25 2009
@@ -19,5 +19,6 @@
     <modules>
       <module>greeter</module>
       <module>spring_dm</module>
+      <module>ds</module>
     </modules> 
 </project>



Mime
View raw message