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/11/30 10:19:05 UTC

svn commit: r885363 - in /cxf/dosgi/trunk: discovery/distributed/ discovery/distributed/zookeeper-server-config/ discovery/distributed/zookeeper-server-config/src/ discovery/distributed/zookeeper-server-config/src/main/ discovery/distributed/zookeeper-...

Author: davidb
Date: Mon Nov 30 09:19:00 2009
New Revision: 885363

URL: http://svn.apache.org/viewvc?rev=885363&view=rev
Log:
Controller bundles that can start the Zookeeper Server as an OSGi bundle.

Added:
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/pom.xml   (with props)
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java   (with props)
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/pom.xml   (with props)
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Activator.java   (with props)
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedService.java   (with props)
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ActivatorTest.java   (with props)
    cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedServiceTest.java   (with props)
Modified:
    cxf/dosgi/trunk/discovery/distributed/pom.xml
    cxf/dosgi/trunk/discovery/distributed/zookeeper-wrapper/pom.xml
    cxf/dosgi/trunk/parent/pom.xml

Modified: cxf/dosgi/trunk/discovery/distributed/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/pom.xml?rev=885363&r1=885362&r2=885363&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/pom.xml (original)
+++ cxf/dosgi/trunk/discovery/distributed/pom.xml Mon Nov 30 09:19:00 2009
@@ -37,6 +37,8 @@
 
     <modules>
       <module>zookeeper-wrapper</module>
+      <module>zookeeper-server</module>
+      <module>zookeeper-server-config</module>
       <module>cxf-discovery</module>
     </modules> 
 </project>

Added: cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/pom.xml?rev=885363&view=auto
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/pom.xml (added)
+++ cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/pom.xml Mon Nov 30 09:19:00 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</groupId>
+    <artifactId>cxf-dosgi-ri-discovery-distributed-zookeeper-server-config</artifactId>
+    <packaging>bundle</packaging>
+    <name>CXF Distributed OSGI Distributed Discovery Zookeeper Server Control Configuration Bundle</name>
+    <description>This bundle provides some default OSGi Configuration Admin data and is only useful for use in the OSGi CT suite</description>
+    <version>1.2-SNAPSHOT</version>
+
+    <parent>
+      <groupId>org.apache.cxf.dosgi</groupId>
+      <artifactId>cxf-dosgi-ri-parent</artifactId>
+      <version>1.2-SNAPSHOT</version>
+      <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+    <properties>
+        <topDirectoryLocation>../../..</topDirectoryLocation>
+    </properties>
+    
+    <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>          
+    </dependencies> 
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>ZooKeeper server configuration bundle</Bundle-Name>
+                        <Bundle-Description>This bundle can configure the ZooKeeper server in an OSGi Framework</Bundle-Description>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Activator>org.apache.cxf.dosgi.discovery.zookeeper.server.config.Activator</Bundle-Activator>
+                        <Import-Package>*</Import-Package>
+                        <Private-Package>org.apache.cxf.dosgi.discovery.zookeeper.server.config</Private-Package>
+                        <Export-Package/>
+                    </instructions>
+                </configuration>
+            </plugin> 
+        </plugins>
+    </build>    
+</project>

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java?rev=885363&view=auto
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java (added)
+++ cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java Mon Nov 30 09:19:00 2009
@@ -0,0 +1,59 @@
+/**
+ * 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.discovery.zookeeper.server.config;
+
+import java.io.IOException;
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class Activator implements BundleActivator {
+    private static final String PID = "org.apache.cxf.dosgi.discovery.zookeeper.server";
+    private ServiceTracker st;
+
+    public void start(BundleContext context) throws Exception {
+        st = new ServiceTracker(context, ConfigurationAdmin.class.getName(), null) {
+            @Override
+            public Object addingService(ServiceReference reference) {
+                Object svc = super.addingService(reference);
+                if (svc instanceof ConfigurationAdmin) {
+                    try {
+                        Configuration cfg = ((ConfigurationAdmin) svc).getConfiguration(PID, null);
+                        Hashtable<String, Object> props = new Hashtable<String, Object>();
+                        props.put("clientPort", 2181);
+                        cfg.update(props);
+                        System.out.println("Set zookeeper client port to 2181");
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+                return svc;
+            }            
+        };
+        st.open();
+	}
+    
+	public void stop(BundleContext context) throws Exception {
+	    st.close();
+	}
+}

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/zookeeper-server/pom.xml?rev=885363&view=auto
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/zookeeper-server/pom.xml (added)
+++ cxf/dosgi/trunk/discovery/distributed/zookeeper-server/pom.xml Mon Nov 30 09:19:00 2009
@@ -0,0 +1,98 @@
+<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</groupId>
+    <artifactId>cxf-dosgi-ri-discovery-distributed-zookeeper-server</artifactId>
+    <packaging>bundle</packaging>
+    <name>CXF Distributed OSGI Distributed Discovery Zookeeper Server Control Bundle</name>
+    <version>1.2-SNAPSHOT</version>
+
+    <parent>
+      <groupId>org.apache.cxf.dosgi</groupId>
+      <artifactId>cxf-dosgi-ri-parent</artifactId>
+      <version>1.2-SNAPSHOT</version>
+      <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+    <properties>
+        <topDirectoryLocation>../../..</topDirectoryLocation>
+    </properties>
+    
+    <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</groupId>
+            <artifactId>cxf-dosgi-ri-discovery-distributed-zookeeper-wrapper</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
+        <!-- This is a zookeeper dependency that we apparently have to list here -->
+        <dependency> 
+            <groupId>org.apache.log4j</groupId> 
+            <artifactId>com.springsource.org.apache.log4j</artifactId> 
+            <version>${log4j.version}</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>  
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymockclassextension</artifactId>
+            <scope>test</scope>
+        </dependency> 
+    </dependencies> 
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>ZooKeeper server control bundle</Bundle-Name>
+                        <Bundle-Description>This bundle can run the ZooKeeper server in an OSGi Framework</Bundle-Description>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Bundle-Activator>org.apache.cxf.dosgi.discovery.zookeeper.server.Activator</Bundle-Activator>
+                        <Import-Package>*</Import-Package>
+                        <Private-Package>org.apache.cxf.dosgi.discovery.zookeeper.server</Private-Package>
+                        <Export-Package/>
+                    </instructions>
+                </configuration>
+            </plugin> 
+        </plugins>
+    </build>    
+</project>

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Activator.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Activator.java?rev=885363&view=auto
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Activator.java (added)
+++ cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Activator.java Mon Nov 30 09:19:00 2009
@@ -0,0 +1,49 @@
+/**
+ * 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.discovery.zookeeper.server;
+
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class Activator implements BundleActivator {
+    ManagedService ms;
+    ServiceRegistration reg;
+
+    public void start(BundleContext context) throws Exception {
+        ms = new ManagedService(context);
+        Hashtable<String, Object> props = new Hashtable<String, Object>();
+        ms.setDefaults(props);
+
+        // cannot use the org.osgi.service.cm.ManagedService class object directly from 
+        // Activator because we have an optional dependency on it...
+        reg = context.registerService(org.osgi.service.cm.ManagedService.class.getName(), ms, props);
+        ms.setRegistration(reg);
+	}
+    
+	public void stop(BundleContext context) throws Exception {
+	    if (reg != null) {
+	        reg.unregister();
+	    }
+	    if (ms != null) {
+	        ms.shutdown();
+	    }
+	}
+}

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

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

Added: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedService.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedService.java?rev=885363&view=auto
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedService.java (added)
+++ cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedService.java Mon Nov 30 09:19:00 2009
@@ -0,0 +1,145 @@
+/**
+ * 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.discovery.zookeeper.server;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import org.apache.log4j.Logger;
+import org.apache.zookeeper.server.ServerConfig;
+import org.apache.zookeeper.server.ZooKeeperServerMain;
+import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+
+public class ManagedService implements org.osgi.service.cm.ManagedService {
+    private static final Logger LOG = Logger.getLogger(ManagedService.class);
+
+    private final BundleContext bundleContext;
+    ServiceRegistration serviceRegistration;
+    MyZooKeeperServerMain main;
+    Thread zkMainThread;
+    
+    public ManagedService(BundleContext ctx) {
+        bundleContext = ctx;
+    }
+    
+    public synchronized void shutdown() {
+        if (main != null) {
+            LOG.info("Shutting down ZooKeeper server");
+            main.shutdown();
+            main = null;
+            zkMainThread = null;
+        }
+    }
+    
+    @SuppressWarnings("unchecked")
+    public void setDefaults(Dictionary dict) throws IOException {
+        setDefault(dict, "tickTime", "2000");        
+        setDefault(dict, "initLimit", "10");
+        setDefault(dict, "syncLimit", "5");
+        setDefault(dict, "dataDir", new File(bundleContext.getDataFile(""), "zkdata").getCanonicalPath());        
+        setDefault(dict, Constants.SERVICE_PID, "org.apache.cxf.dosgi.discovery.zookeeper.server");    
+    }
+    
+    @SuppressWarnings("unchecked")
+    private void setDefault(Dictionary dict, String key, String value) {
+        if (dict.get(key) == null) {
+            dict.put(key, value);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public synchronized void updated(Dictionary dict) throws ConfigurationException {
+        if (dict == null) {
+            // stop server... TODO
+            return;
+        }
+        
+        if (main != null) {
+            // reconfiguration not yet supported
+            return;
+        }
+        
+        if (dict.get("clientPort") == null) {
+            LOG.info("Ignoring configuration update because required property 'clientPort' isn't set.");
+            return;
+        }
+        
+        Properties props = new Properties();
+        for (Enumeration e = dict.keys(); e.hasMoreElements(); ) {
+            Object key = e.nextElement();
+            props.put(key, dict.get(key));
+        }
+        
+        try {
+            setDefaults(props);
+            if (serviceRegistration != null) {
+                serviceRegistration.setProperties(props);
+            }
+            
+            QuorumPeerConfig config = new QuorumPeerConfig();
+            config.parseProperties(props);
+            final ServerConfig serverConfig = new ServerConfig();
+            serverConfig.readFrom(config);
+            
+            main = getZooKeeperMain();
+            zkMainThread = new Thread(new Runnable() {
+                public void run() {
+                    try {
+                        main.runFromConfig(serverConfig);
+                    } catch (IOException e) {
+                        LOG.error("Problem running ZooKeeper server.", e);
+                    }                    
+                }                
+            });
+            startThread();
+            
+            LOG.info("Applied configuration update :" + props);
+        } catch (Exception th) {
+            LOG.error("Problem applying configuration update: " + props, th);            
+        }
+    }
+
+    // Isolated for testing
+    void startThread() {
+        zkMainThread.start();
+    }
+
+    // Isolated for testing
+    MyZooKeeperServerMain getZooKeeperMain() {
+        return new MyZooKeeperServerMain();
+    }
+
+    public void setRegistration(ServiceRegistration reg) {
+        serviceRegistration = reg;
+    }
+    
+    static class MyZooKeeperServerMain extends ZooKeeperServerMain {
+        @Override
+        protected void shutdown() {
+            super.shutdown();
+            // Make the shutdown accessible from here.
+        }        
+    }
+}

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ActivatorTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ActivatorTest.java?rev=885363&view=auto
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ActivatorTest.java (added)
+++ cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ActivatorTest.java Mon Nov 30 09:19:00 2009
@@ -0,0 +1,71 @@
+/**
+ * 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.discovery.zookeeper.server;
+
+import java.io.File;
+import java.util.Hashtable;
+
+import junit.framework.TestCase;
+
+import org.easymock.classextension.EasyMock;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ManagedService;
+
+public class ActivatorTest extends TestCase {
+    public void testActivator() throws Exception {
+        Hashtable<String, Object> props = new Hashtable<String, Object>();
+        props.put("tickTime", "2000");
+        props.put("initLimit", "10");
+        props.put("syncLimit", "5");
+        props.put("dataDir", new File(System.getProperty("java.io.tmpdir") + "/zkdata").getCanonicalFile().toString());
+        props.put(Constants.SERVICE_PID, "org.apache.cxf.dosgi.discovery.zookeeper.server");
+        
+        ServiceRegistration sreg = EasyMock.createMock(ServiceRegistration.class);
+        BundleContext bc = EasyMock.createStrictMock(BundleContext.class);
+        EasyMock.expect(bc.getDataFile(""))
+            .andReturn(new File(System.getProperty("java.io.tmpdir")));
+        EasyMock.expect(bc.registerService(
+            EasyMock.eq(ManagedService.class.getName()), EasyMock.anyObject(), EasyMock.eq(props)))
+                .andReturn(sreg);
+        EasyMock.replay(bc);
+        EasyMock.replay(sreg);
+                
+        Activator a = new Activator();
+        a.start(bc);
+        assertNotNull(a.ms.serviceRegistration);        
+        
+        a.ms = EasyMock.createMock(org.apache.cxf.dosgi.discovery.zookeeper.server.ManagedService.class);
+        a.ms.shutdown();
+        EasyMock.expectLastCall();
+        EasyMock.replay(a.ms);
+        
+        EasyMock.reset(bc);
+        EasyMock.reset(sreg);
+        sreg.unregister();
+        EasyMock.expectLastCall();
+        EasyMock.replay(bc);
+        EasyMock.replay(sreg);
+
+        a.stop(bc);
+        EasyMock.verify(bc);
+        EasyMock.verify(sreg);
+        EasyMock.verify(a.ms);
+    }
+}

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ActivatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ActivatorTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedServiceTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedServiceTest.java?rev=885363&view=auto
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedServiceTest.java (added)
+++ cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedServiceTest.java Mon Nov 30 09:19:00 2009
@@ -0,0 +1,104 @@
+/**
+ * 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.discovery.zookeeper.server;
+
+import java.io.File;
+import java.util.Hashtable;
+
+import junit.framework.TestCase;
+
+import org.apache.zookeeper.server.ServerConfig;
+import org.easymock.IAnswer;
+import org.easymock.classextension.EasyMock;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+
+public class ManagedServiceTest extends TestCase {
+    public void testManagedService() throws Exception {
+        final File tempDir = new File(System.getProperty("java.io.tmpdir"));
+
+        final ManagedService.MyZooKeeperServerMain zkMain = 
+            EasyMock.createMock(ManagedService.MyZooKeeperServerMain.class);
+        zkMain.runFromConfig((ServerConfig) EasyMock.anyObject());
+        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+            public Object answer() throws Throwable {
+                ServerConfig sc = (ServerConfig) EasyMock.getCurrentArguments()[0];
+                assertEquals(new File(tempDir, "zkdata").getCanonicalFile().toString(), 
+                    sc.getDataDir());
+                assertEquals(1234, sc.getClientPort());
+                assertEquals(2000, sc.getTickTime());
+                return null;
+            }
+        });
+        EasyMock.replay(zkMain);       
+        
+        BundleContext bc = EasyMock.createMock(BundleContext.class);
+        EasyMock.expect(bc.getDataFile("")).andReturn(tempDir);
+        EasyMock.replay(bc);
+        
+        final StringBuilder threadStatus = new StringBuilder();
+        ManagedService ms = new ManagedService(bc) {
+            @Override
+            ManagedService.MyZooKeeperServerMain getZooKeeperMain() {
+                return zkMain;
+            }
+
+            @Override
+            void startThread() {
+                threadStatus.append("started");
+            }                        
+        };
+        
+        ServiceRegistration sreg = EasyMock.createMock(ServiceRegistration.class);
+        final Hashtable<String, Object> expected = new Hashtable<String, Object>();        
+        expected.put("tickTime", "2000");
+        expected.put("initLimit", "10");
+        expected.put("syncLimit", "5");
+        expected.put("dataDir", new File(tempDir, "zkdata").getCanonicalFile().toString());
+        expected.put(Constants.SERVICE_PID, "org.apache.cxf.dosgi.discovery.zookeeper.server");
+        expected.put("clientPort", "1234");
+        sreg.setProperties(expected);
+        EasyMock.expectLastCall();
+        EasyMock.replay(sreg);
+        ms.setRegistration(sreg);
+        
+        Hashtable<String, Object> props = new Hashtable<String, Object>();
+        props.put(Constants.SERVICE_PID, "org.apache.cxf.dosgi.discovery.zookeeper.server");
+        props.put("clientPort", "1234");
+        
+        ms.updated(props);
+        EasyMock.verify(sreg);
+
+        assertEquals("started", threadStatus.toString());
+        ms.zkMainThread.run();
+        
+        EasyMock.verify(zkMain);
+        EasyMock.verify(bc);   
+        
+        EasyMock.reset(zkMain);
+        zkMain.shutdown();
+        EasyMock.expectLastCall();
+        EasyMock.verify();
+        
+        assertNotNull(ms.main);
+        ms.shutdown();
+        assertNull(ms.main);
+        assertNull(ms.zkMainThread);
+    }
+}

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedServiceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ManagedServiceTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/dosgi/trunk/discovery/distributed/zookeeper-wrapper/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/zookeeper-wrapper/pom.xml?rev=885363&r1=885362&r2=885363&view=diff
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/zookeeper-wrapper/pom.xml (original)
+++ cxf/dosgi/trunk/discovery/distributed/zookeeper-wrapper/pom.xml Mon Nov 30 09:19:00 2009
@@ -62,7 +62,10 @@
                         <Bundle-Name>ZooKeeper wrapper bundle</Bundle-Name>
                         <Bundle-Description>This bundle wraps the ZooKeeper library</Bundle-Description>
                         <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
-                        <Import-Package>*</Import-Package>
+                        <Import-Package>
+                            !jline*,
+                            *
+                        </Import-Package>
                         <Export-Package>*;version=${zookeeper.version}</Export-Package> 
                     </instructions>
                 </configuration>

Modified: cxf/dosgi/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/parent/pom.xml?rev=885363&r1=885362&r2=885363&view=diff
==============================================================================
--- cxf/dosgi/trunk/parent/pom.xml (original)
+++ cxf/dosgi/trunk/parent/pom.xml Mon Nov 30 09:19:00 2009
@@ -22,7 +22,7 @@
         <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>
+        <zookeeper.version>3.2.1</zookeeper.version>
 
         <servicemix.specs.version>1.3.0</servicemix.specs.version>