You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by da...@apache.org on 2009/05/29 12:45:57 UTC

svn commit: r779920 - in /cxf/dosgi/trunk: 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/cxf/dosgi/dsw/handlers/ samples/ samples/discovery/ s...

Author: davidb
Date: Fri May 29 10:45:55 2009
New Revision: 779920

URL: http://svn.apache.org/viewvc?rev=779920&view=rev
Log:
Sample for Discovery functionality. 
Will work writing documentation for the sample on the wiki.
Also: a further fix regarding the handling of proxies in the ServiceInvocationHandler.

Added:
    cxf/dosgi/trunk/samples/discovery/
    cxf/dosgi/trunk/samples/discovery/client/
    cxf/dosgi/trunk/samples/discovery/client/pom.xml   (with props)
    cxf/dosgi/trunk/samples/discovery/client/src/
    cxf/dosgi/trunk/samples/discovery/client/src/main/
    cxf/dosgi/trunk/samples/discovery/client/src/main/java/
    cxf/dosgi/trunk/samples/discovery/client/src/main/java/org/
    cxf/dosgi/trunk/samples/discovery/client/src/main/java/org/apache/
    cxf/dosgi/trunk/samples/discovery/client/src/main/java/org/apache/cxf/
    cxf/dosgi/trunk/samples/discovery/client/src/main/java/org/apache/cxf/dosgi/
    cxf/dosgi/trunk/samples/discovery/client/src/main/java/org/apache/cxf/dosgi/samples/
    cxf/dosgi/trunk/samples/discovery/client/src/main/java/org/apache/cxf/dosgi/samples/discovery/
    cxf/dosgi/trunk/samples/discovery/client/src/main/java/org/apache/cxf/dosgi/samples/discovery/consumer/
    cxf/dosgi/trunk/samples/discovery/client/src/main/java/org/apache/cxf/dosgi/samples/discovery/consumer/Activator.java   (with props)
    cxf/dosgi/trunk/samples/discovery/impl/
    cxf/dosgi/trunk/samples/discovery/impl/pom.xml   (with props)
    cxf/dosgi/trunk/samples/discovery/impl/src/
    cxf/dosgi/trunk/samples/discovery/impl/src/main/
    cxf/dosgi/trunk/samples/discovery/impl/src/main/java/
    cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/
    cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/
    cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/
    cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/
    cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/
    cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/discovery/
    cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/discovery/impl/
    cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/discovery/impl/Activator.java   (with props)
    cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/discovery/impl/DisplayServiceImpl.java   (with props)
    cxf/dosgi/trunk/samples/discovery/interface/
    cxf/dosgi/trunk/samples/discovery/interface/pom.xml   (with props)
    cxf/dosgi/trunk/samples/discovery/interface/src/
    cxf/dosgi/trunk/samples/discovery/interface/src/main/
    cxf/dosgi/trunk/samples/discovery/interface/src/main/java/
    cxf/dosgi/trunk/samples/discovery/interface/src/main/java/org/
    cxf/dosgi/trunk/samples/discovery/interface/src/main/java/org/apache/
    cxf/dosgi/trunk/samples/discovery/interface/src/main/java/org/apache/cxf/
    cxf/dosgi/trunk/samples/discovery/interface/src/main/java/org/apache/cxf/dosgi/
    cxf/dosgi/trunk/samples/discovery/interface/src/main/java/org/apache/cxf/dosgi/samples/
    cxf/dosgi/trunk/samples/discovery/interface/src/main/java/org/apache/cxf/dosgi/samples/discovery/
    cxf/dosgi/trunk/samples/discovery/interface/src/main/java/org/apache/cxf/dosgi/samples/discovery/DisplayService.java   (with props)
    cxf/dosgi/trunk/samples/discovery/pom.xml   (with props)
Modified:
    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/handlers/ServiceInvocationHandlerTest.java
    cxf/dosgi/trunk/samples/pom.xml

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=779920&r1=779919&r2=779920&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 Fri May 29 10:45:55 2009
@@ -21,6 +21,7 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -46,6 +47,9 @@
     
     public Object invoke(Object proxy, Method m, Object[] params) throws Throwable {
         if (OBJECT_METHODS.contains(m)) {
+            if (m.getName().equals("equals")) {
+                params = new Object[] {Proxy.getInvocationHandler(params[0])};
+            }
             return m.invoke(this, params);
         }
 

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=779920&r1=779919&r2=779920&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 Fri May 29 10:45:55 2009
@@ -238,7 +238,7 @@
             if (!duplicate) {
                 LOG.info("registering proxy for endpoint ID: " + endpointId);
             } else {
-                LOG.warning("ignoring duplicate notification for endpoint ID: "
+                LOG.info("ignoring duplicate notification for endpoint ID: "
                             + endpointId);  
             }
             return !duplicate;

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java?rev=779920&r1=779919&r2=779920&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java (original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ServiceInvocationHandlerTest.java Fri May 29 10:45:55 2009
@@ -1,6 +1,7 @@
 package org.apache.cxf.dosgi.dsw.handlers;
 
 import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -41,16 +42,15 @@
             }            
         };
 
+        Object proxy = Proxy.newProxyInstance(
+                getClass().getClassLoader(), new Class [] {Runnable.class}, sih);                
+        
         assertEquals(true, 
-                sih.invoke(null, OBJECT_METHODS.get("equals"), new Object [] {sih}));
+                sih.invoke(null, OBJECT_METHODS.get("equals"), new Object [] {proxy}));
         assertEquals(System.identityHashCode(sih), 
                 sih.invoke(null, OBJECT_METHODS.get("hashCode"), new Object [] {}));
         assertEquals("somestring", 
                 sih.invoke(null, OBJECT_METHODS.get("toString"), new Object [] {}));
-        assertEquals(Arrays.asList("equals", "hashCode", "toString"), called);
-//        assertEquals("This one used to throw an exception", sih, sih);
-//        assertEquals(System.identityHashCode(sih), sih.hashCode());
-//        assertEquals("somestring", sih.toString());
-        
+        assertEquals(Arrays.asList("equals", "hashCode", "toString"), called);        
     }
 }

Added: cxf/dosgi/trunk/samples/discovery/client/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/discovery/client/pom.xml?rev=779920&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/discovery/client/pom.xml (added)
+++ cxf/dosgi/trunk/samples/discovery/client/pom.xml Fri May 29 10:45:55 2009
@@ -0,0 +1,74 @@
+<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-discovery-client</artifactId>
+  <packaging>bundle</packaging>
+  <name>Distributed OSGI Discovery Sample Client Bundle</name>
+  <version>1.1-SNAPSHOT</version>
+
+  <parent>
+    <groupId>org.apache.cxf.dosgi.samples</groupId>
+    <artifactId>cxf-dosgi-ri-bundles-discovery-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>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.osgi.foundation</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency> 
+    <dependency>
+      <groupId>org.apache.cxf.dosgi.samples</groupId>
+      <artifactId>cxf-dosgi-ri-samples-discovery-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 Discovery sample.</Bundle-Description>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Bundle-Activator>org.apache.cxf.dosgi.samples.discovery.consumer.Activator</Bundle-Activator>
+            <Import-Package>
+              org.apache.cxf.dosgi.samples.discovery, 
+              org.osgi.framework, 
+              org.osgi.util.tracker
+            </Import-Package> 
+            <Private-Package>org.apache.cxf.dosgi.samples.discovery.consumer</Private-Package> 
+          </instructions>
+        </configuration>
+      </plugin> 
+    </plugins>
+  </build>    
+</project>

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

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

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

Added: cxf/dosgi/trunk/samples/discovery/client/src/main/java/org/apache/cxf/dosgi/samples/discovery/consumer/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/discovery/client/src/main/java/org/apache/cxf/dosgi/samples/discovery/consumer/Activator.java?rev=779920&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/discovery/client/src/main/java/org/apache/cxf/dosgi/samples/discovery/consumer/Activator.java (added)
+++ cxf/dosgi/trunk/samples/discovery/client/src/main/java/org/apache/cxf/dosgi/samples/discovery/consumer/Activator.java Fri May 29 10:45:55 2009
@@ -0,0 +1,86 @@
+/** 
+  * 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.discovery.consumer;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.cxf.dosgi.samples.discovery.DisplayService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class Activator implements BundleActivator {
+    private ServiceTracker tracker;
+    private Map<DisplayService, String> displays = new ConcurrentHashMap<DisplayService, String>();
+    private ScheduledExecutorService scheduler;
+    private ScheduledFuture<?> handle;
+
+    public void start(BundleContext bc) throws Exception {
+        tracker = new ServiceTracker(bc, DisplayService.class.getName(), null) {
+            public Object addingService(ServiceReference reference) {
+                Object svc = super.addingService(reference);
+                if (svc instanceof DisplayService) {
+                    DisplayService d = (DisplayService) svc;
+                    System.out.println("Adding display: " + d.getID() + " (" + d + ")");
+                    displays.put(d, d.getID());
+                }
+                return svc;
+            }
+
+            public void removedService(ServiceReference reference, Object service) {
+                String value = displays.remove(service);
+                System.out.println("Removed display: " + value);
+                super.removedService(reference, service);
+            }            
+        };        
+        tracker.open();
+        
+        scheduler = Executors.newScheduledThreadPool(1);
+        Runnable printer = new Runnable() {
+            int counter = 0;
+            public void run() {
+                counter++;
+                String text = "some text " + counter;
+                System.out.println("Sending text to displays: " + text);
+                for (Iterator<Entry<DisplayService, String>> it = displays.entrySet().iterator(); it.hasNext(); ) {
+                    Entry<DisplayService, String> entry = it.next();
+                    try {
+                        entry.getKey().displayText(text);
+                    } catch (Throwable th) {
+                        System.out.println("Could not send message to display: " + entry.getValue());
+                    }
+                }
+            }            
+        };
+        handle = scheduler.scheduleAtFixedRate(printer, 5, 5, TimeUnit.SECONDS);
+    }
+
+    public void stop(BundleContext bc) throws Exception {
+        handle.cancel(true);
+        tracker.close();
+    }
+}

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

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

Added: cxf/dosgi/trunk/samples/discovery/impl/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/discovery/impl/pom.xml?rev=779920&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/discovery/impl/pom.xml (added)
+++ cxf/dosgi/trunk/samples/discovery/impl/pom.xml Fri May 29 10:45:55 2009
@@ -0,0 +1,73 @@
+<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-discovery-impl</artifactId>
+  <packaging>bundle</packaging>
+  <name>Distributed OSGI Discovery Sample Implementation Bundle</name>
+  <version>1.1-SNAPSHOT</version>
+
+  <parent>
+    <groupId>org.apache.cxf.dosgi.samples</groupId>
+    <artifactId>cxf-dosgi-ri-bundles-discovery-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>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.osgi.foundation</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency> 
+    <dependency>
+      <groupId>org.apache.cxf.dosgi.samples</groupId>
+      <artifactId>cxf-dosgi-ri-samples-discovery-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 Discovery sample.</Bundle-Description>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Bundle-Activator>org.apache.cxf.dosgi.samples.discovery.impl.Activator</Bundle-Activator>
+            <Import-Package>
+              org.apache.cxf.dosgi.samples.discovery,
+              org.osgi.framework
+            </Import-Package> 
+            <Private-Package>org.apache.cxf.dosgi.samples.discovery.impl</Private-Package> 
+          </instructions>
+        </configuration>
+      </plugin> 
+    </plugins>
+  </build>    
+</project>

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

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

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

Added: cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/discovery/impl/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/discovery/impl/Activator.java?rev=779920&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/discovery/impl/Activator.java (added)
+++ cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/discovery/impl/Activator.java Fri May 29 10:45:55 2009
@@ -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.samples.discovery.impl;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.UnknownHostException;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.cxf.dosgi.samples.discovery.DisplayService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class Activator implements BundleActivator {
+    private ServiceRegistration reg;
+
+    public void start(BundleContext bc) throws Exception {        
+        Dictionary props = new Hashtable();
+        
+        String host = getHostName();
+        int port = getPort();
+        
+        props.put("osgi.remote.interfaces", "*");
+        props.put("osgi.remote.configuration.type", "pojo");
+        props.put("osgi.remote.configuration.pojo.address", getAddress(host, port));
+
+        reg = bc.registerService(DisplayService.class.getName(), 
+                new DisplayServiceImpl(host + ":" + port), props);
+    }
+
+    private static String getAddress(String host, int port) throws Exception {        
+        return "http://" + host + ":" + port + "/display";
+    }
+
+    private static String getHostName() {
+        try {
+            return InetAddress.getLocalHost().getCanonicalHostName();
+        } catch (UnknownHostException e) {
+            return "localhost";
+        }
+    }
+
+    private static int getPort() throws IOException {
+        return new ServerSocket(0).getLocalPort();
+    }
+
+    public void stop(BundleContext bc) throws Exception {
+        reg.unregister();
+    }
+
+}

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

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

Added: cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/discovery/impl/DisplayServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/discovery/impl/DisplayServiceImpl.java?rev=779920&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/discovery/impl/DisplayServiceImpl.java (added)
+++ cxf/dosgi/trunk/samples/discovery/impl/src/main/java/org/apache/cxf/dosgi/samples/discovery/impl/DisplayServiceImpl.java Fri May 29 10:45:55 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.discovery.impl;
+
+import org.apache.cxf.dosgi.samples.discovery.DisplayService;
+
+public class DisplayServiceImpl implements DisplayService {
+    private final String id;
+    
+    public DisplayServiceImpl(String id) {
+        this.id = id;
+        System.out.println("Created DisplayService [" + id + "]");
+    }
+    
+    public boolean displayText(String text) {
+        System.out.println("DisplayService [" + id + "]: " + text);
+        return true;
+    }
+
+    public String getID() {
+        return id;
+    }    
+}

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

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

Added: cxf/dosgi/trunk/samples/discovery/interface/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/discovery/interface/pom.xml?rev=779920&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/discovery/interface/pom.xml (added)
+++ cxf/dosgi/trunk/samples/discovery/interface/pom.xml Fri May 29 10:45:55 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-discovery-interface</artifactId>
+  <packaging>bundle</packaging>
+  <name>Distributed OSGI Discovery Sample Interface Bundle</name>
+  <version>1.1-SNAPSHOT</version>
+
+  <parent>
+    <groupId>org.apache.cxf.dosgi.samples</groupId>
+    <artifactId>cxf-dosgi-ri-bundles-discovery-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 Discovery sample.</Bundle-Description>
+            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+            <Import-Package />
+            <Export-Package>org.apache.cxf.dosgi.samples.discovery</Export-Package> 
+          </instructions>
+        </configuration>
+      </plugin> 
+    </plugins>
+  </build>    
+</project>

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

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

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

Added: cxf/dosgi/trunk/samples/discovery/interface/src/main/java/org/apache/cxf/dosgi/samples/discovery/DisplayService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/discovery/interface/src/main/java/org/apache/cxf/dosgi/samples/discovery/DisplayService.java?rev=779920&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/discovery/interface/src/main/java/org/apache/cxf/dosgi/samples/discovery/DisplayService.java (added)
+++ cxf/dosgi/trunk/samples/discovery/interface/src/main/java/org/apache/cxf/dosgi/samples/discovery/DisplayService.java Fri May 29 10:45:55 2009
@@ -0,0 +1,24 @@
+/** 
+  * 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.discovery;
+
+public interface DisplayService {
+    boolean displayText(String text);
+    String getID();
+}

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

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

Added: cxf/dosgi/trunk/samples/discovery/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/samples/discovery/pom.xml?rev=779920&view=auto
==============================================================================
--- cxf/dosgi/trunk/samples/discovery/pom.xml (added)
+++ cxf/dosgi/trunk/samples/discovery/pom.xml Fri May 29 10:45:55 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-discovery-parent</artifactId>
+    <packaging>pom</packaging>
+    <name>Distributed OSGI Discovery 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/discovery/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: cxf/dosgi/trunk/samples/discovery/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=779920&r1=779919&r2=779920&view=diff
==============================================================================
--- cxf/dosgi/trunk/samples/pom.xml (original)
+++ cxf/dosgi/trunk/samples/pom.xml Fri May 29 10:45:55 2009
@@ -20,5 +20,6 @@
       <module>greeter</module>
       <module>spring_dm</module>
       <module>ds</module>
+      <module>discovery</module>
     </modules> 
 </project>