Versions Compared

Key

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

...

Running the controller

Code Block
-> install httpshttp://repositoryrepo1.apachemaven.org/contentmaven2/groups/snapshots/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-discovery-clientinterface/1.1-SNAPSHOT2/cxf-dosgi-ri-samples-discovery-clientinterface-1.1-SNAPSHOT2.jar
-> installstart httpshttp://repositoryrepo1.apachemaven.org/content/groups/snapshotsmaven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-discovery-interfaceclient/1.1-SNAPSHOT2/cxf-dosgi-ri-samples-discovery-interfaceclient-1.1-SNAPSHOT2.jar

-> start 7
-> start 8
-> ps
START LEVEL 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 Zookeeper-Based Discovery Single-Bundle Distribution
[   7] [Active     ] [    1] Distributed OSGI Discovery Sample Client Bundle
[   87] [Active     ] [    1] Distributed OSGI Discovery Sample Interface Bundle

...

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();
    }
}

...

Once the provider side bundles are started:

Code Block
-> install httpshttp://repositoryrepo1.apachemaven.org/content/groups/snapshotsmaven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-discovery-interface/1.1-SNAPSHOT2/cxf-dosgi-ri-samples-discovery-interface-1.1-SNAPSHOT2.jar
-> start 7
-> install httpshttp://repositoryrepo1.apachemaven.org/content/groups/snapshots/orgmaven2/org/apache/cxf/dosgi/samples/cxf-dosgi-ri-samples-discovery-impl/1.1-SNAPSHOT2/cxf-dosgi-ri-samples-discovery-impl-1.1-SNAPSHOT2.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 Zookeeper-BasedOSGI Discovery Single-BundleSample Distribution (1.1.0.SNAPSHOT)Interface Bundle
[   7] [Active     ] [    1] Distributed OSGI Discovery Sample InterfaceImplementation Bundle
[   8] [Active     ] [    1] Distributed OSGI Discovery Sample Implementation Bundle

You will You will start seeing the messages appear on the remote display:

...

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