Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Code Block
-> install http://repo1.maven.org/maven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-discovery-clientinterface/1.12/cxf-dosgi-ri-samples-discovery-clientinterface-1.12.jar
-> installstart http://repo1.maven.org/maven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-discovery-interfaceclient/1.12/cxf-dosgi-ri-samples-discovery-interfaceclient-1.12.jar
-> start 7
-> start 8
-> ps
START LEVEL 1
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (1.8.0)
[   1] [Active     ] [    1] Apache Felix Shell Service (1.2.0)
[   2] [Active     ] [    1] Apache Felix Shell TUI (1.2.0)
[   3] [Active     ] [    1] Apache Felix Bundle Repository (1.4.0)
[   4] [Resolved   ] [    1] OSGi R4 Compendium Bundle (4.1.0)
[   5] [Active     ] [    1] Distributed OSGi Distribution Software Single-Bundle Distribution
[   6] [Active     ] [    1] Distributed OSGI OSGiDiscovery Zookeeper-BasedSample DiscoveryClient Single-Bundle Distribution
[   7] [Active     ] [    1] Distributed OSGI Discovery Sample Client Bundle
[   8] [Active     ] [    1] Distributed OSGI Discovery Sample Interface Bundle
Interface Bundle

After a brief moment, After a brief moment, you will see messages appearing on the controller side. These are the messages sent to all registered displays. Since there are none, they won't show up anywhere just yet.

...

Code Block
java
java
public class Activator implements BundleActivator {
    private ServiceRegistration reg;

    public void start(BundleContext bc) throws Exception {        
        Dictionary props = new Hashtable();
        
        String host = getHostName(); // obtain the current host name
        int port = getPort();        // find a free port
        
        props.put("osgiservice.remoteexported.interfaces", "*");
        props.put("osgiservice.remoteexported.configuration.typeconfigs", "pojoorg.apache.cxf.ws");
        props.put("osgiorg.remoteapache.configurationcxf.pojows.address", "http://" + host + ":" + port + "/display");

        reg = bc.registerService(DisplayService.class.getName(), 
                new DisplayServiceImpl(host + ":" + port), props);
    }

    public void stop(BundleContext bc) throws Exception {
        reg.unregister();
    }
}

...

Code Block
-> install http://repo1.maven.org/maven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-discovery-interface/1.12/cxf-dosgi-ri-samples-discovery-interface-1.12.jar
-> start 7
-> install http://repo1.maven.org/maven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-discovery-impl/1.12/cxf-dosgi-ri-samples-discovery-impl-1.12.jar
-> start 8
-> ps
START LEVEL 1
   ID   State         Level  Name
[   0] [Active     ] [    0] System Bundle (1.8.0)
[   1] [Active     ] [    1] Apache Felix Shell Service (1.2.0)
[   2] [Active     ] [    1] Apache Felix Shell TUI (1.2.0)
[   3] [Active     ] [    1] Apache Felix Bundle Repository (1.4.0)
[   4] [Resolved   ] [    1] OSGi R4 Compendium Bundle (4.1.0)
[   5] [Active     ] [    1] Distributed OSGi Distribution Software Single-Bundle Distribution (1.1.0.SNAPSHOT)
[   6] [Active     ] [    1] Distributed OSGI OSGiDiscovery Zookeeper-BasedSample DiscoveryInterface Single-Bundle
[  Distribution (1.1.0.SNAPSHOT)
[   7] [Active     ] [    1] Distributed OSGI Discovery Sample Interface Bundle
[   8] [ 7] [Active     ] [    1] Distributed OSGI Discovery Sample Implementation Bundle

...

ZooKeeper comes with a client program (zkCli) that allows you to look in the ZooKeeper virtual filesystem. All of the OSGi-registered services are stored in a virtual directory under the node /osgi/service_registry. The virtual directory name is based on the fully qualified name of the interface that is implemented by the remote service. So in the case of the DisplayService the remote service metadata is stored under /osgi/service_registry/org/apache/cxf/dosgi/samples/discovery/DisplayService:

Code Block
$ bin/zkCli.cmd localhost:2181

-> ls /osgi/service_registry/org/apache/cxf/dosgi/samples/discovery/DisplayService
Processing ls
[myhost#1816##display]

...

Code Block
-> get /osgi/service_registry/org/apache/cxf/dosgi/samples/discovery/DisplayService/myhost#1816##displaymyhost#52807##display
Processing get
#
#Tue Jun 09 14:52:39 BST 2009
osgi.remote.endpoint.location=http\://myhost\:1816/display
osgi.remote.interfaces=*
osgi.remote.configuration.pojo.address=http\://myhost\:1816/display
osgi.remote.configuration.type=pojo
osgi.remote.endpoint.id=0ffe1fbf-c029-4096-bc14-3c7d77470dfd

cZxid = 511
ctime = Tue Jun 09 14:52:39 BST 2009
mZxid = 511
mtime = Tue Jun 09 14:52:39 BST 2009
pZxid = 511<?xml version="1.0" encoding="UTF-8"?>
<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0">
  <endpoint-description>
    <property name="endpoint.framework.uuid" value="b151dd13-69fe-4d99-8006-fcdafeb48db8" />
    <property name="endpoint.id" value="http://myhost:52807/display" />
    <property name="endpoint.package.version.org.apache.cxf.dosgi.samples.discovery" value="0.0.0" />
    <property name="endpoint.service.id" value-type="Long" value="16" />
    <property name="objectClass">
      <array>
        <value>org.apache.cxf.dosgi.samples.discovery.DisplayService</value>
      </array>
    </property>
    <property name="org.apache.cxf.ws.address" value="http://myhost:52807/display" />
    <property name="service.imported" value="true" />
    <property name="service.imported.configs">
      <array>
        <value>org.apache.cxf.ws</value>
      </array>
    </property>
    <property name="service.intents">
      <array>
        <value>SOAP.1_1</value>
        <value>HTTP</value>
        <value>SOAP</value>
      </array>
    </property>
  </endpoint-description>
</endpoint-descriptions>

cZxid = 0x13
ctime = Fri Jun 25 15:57:09 BST 2010
mZxid = 0x13
mtime = Fri Jun 25 15:57:09 BST 2010
pZxid = 0x13
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 815631244713656340x1296f9228b40004
dataLength = 3381150
numChildren = 0

Other Resources

Introducing Dynamic Discovery into OSGi Distributed Applications - http://blog.akquinet.de/2009/09/23/introducing-dynamic-discovery-into-osgi-distributed-applications/Image Removed