cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r764760 - in /cxf/dosgi/trunk/discovery/distributed/cxf-discovery: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/cxf/ src/main/java/org/apache/cxf/dosgi/ src/main/java/org/apache/cxf/...
Date Tue, 14 Apr 2009 12:44:41 GMT
Author: davidb
Date: Tue Apr 14 12:44:40 2009
New Revision: 764760

URL: http://svn.apache.org/viewvc?rev=764760&view=rev
Log:
Class implementing the RFC 119 Discovery interface + unit test.
This code is not part of the build yet. I am excluding it until DOSGi 1.0 has been released.

Added:
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/pom.xml   (with props)
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveryServiceImpl.java
  (with props)
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/
    cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveryServiceImplTest.java
  (with props)

Added: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/pom.xml
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/pom.xml?rev=764760&view=auto
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/pom.xml (added)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/pom.xml Tue Apr 14 12:44:40 2009
@@ -0,0 +1,110 @@
+<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</artifactId>
+    <packaging>bundle</packaging>
+    <name>CXF Distributed OSGI Distributed Discovery Service Bundle</name>
+    <version>1.0-SNAPSHOT</version>
+
+    <parent>
+        <groupId>org.apache.cxf.dosgi</groupId>
+        <artifactId>cxf-dosgi-ri-parent</artifactId>
+        <version>1.0-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>
+        </dependency> 
+
+        <dependency>
+            <groupId>org.apache.cxf.dosgi</groupId>
+            <artifactId>cxf-dosgi-ri-discovery-distributed-zookeeper-wrapper</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.cxf.dosgi</groupId>
+            <artifactId>cxf-dosgi-ri-discovery-local</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
+        <!-- is this really needed? -->
+        <dependency> 
+            <groupId>org.apache.log4j</groupId> 
+            <artifactId>com.springsource.org.apache.log4j</artifactId> 
+            <version>${log4j.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.osgi</groupId>
+            <artifactId>spring-osgi-core</artifactId>
+            <version>${spring.osgi.version}</version>
+        </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>CXF Zookeeper-based Discovery Service Bundle</Bundle-Name>
+                        <Bundle-Description>This bundle contains an implementation
of the Distributed OSGi Discovery Service using Zookeeper</Bundle-Description>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Import-Package>
+                            org.apache.zookeeper.*;version="[3.0.0,4.0.0)",
+                            org.apache.cxf.dosgi.discovery.local;version=${pom.version},
+                            org.osgi.framework;version="[1.4.0,2.0.0)",
+                            org.osgi.service.discovery;version="[1.0.0,2.0.0)",
+                            org.osgi.util.tracker;version="[1.3.0,2.0.0)",
+                            org.springframework.beans.factory;version="[2.5.0,3.0.0)",
+                            org.springframework.osgi.context;version="[1.2.0,2.0.0)",
+                            *
+                        </Import-Package>
+                        <Export-Package>org.apache.cxf.dosgi.discovery.zookeeper;version=${pom.version}</Export-Package>
+                    </instructions>
+                </configuration>
+            </plugin> 
+        </plugins>
+    </build>    
+</project>

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

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

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

Added: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveryServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveryServiceImpl.java?rev=764760&view=auto
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveryServiceImpl.java
(added)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveryServiceImpl.java
Tue Apr 14 12:44:40 2009
@@ -0,0 +1,92 @@
+/** 
+  * 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;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.logging.Logger;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.discovery.Discovery;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.osgi.context.BundleContextAware;
+
+public class DiscoveryServiceImpl implements Discovery, InitializingBean, DisposableBean,
BundleContextAware {
+    private static final String SERVICE_PID = "org.apache.cxf.dosgi.discovery.zookeeper";
+
+    private static final Logger LOG = Logger.getLogger(DiscoveryServiceImpl.class.getName());
+    
+    private String zooKeeperHost = "localhost";
+    private int zooKeeperPort;
+    private int zooKeeperTimeout = 10000;
+
+    private BundleContext bundleContext;
+
+    private ServiceRegistration reg;
+
+    public String getZooKeeperHost() {
+        return zooKeeperHost;
+    }
+    
+    public void setZooKeeperHost(String host) {
+        LOG.info("Setting host to: " + host);
+        zooKeeperHost = host;
+    }
+    
+    public int getZooKeeperPort() {
+        return zooKeeperPort;
+    }
+    
+    public void setZooKeeperPort(int port) {
+        LOG.info("Setting port to: " + port);
+        zooKeeperPort = port;
+    }    
+
+    public int getZooKeeperTimeout() {
+        return zooKeeperTimeout;
+    }
+    
+    public void setZooKeeperTimeout(int timeout) {
+        LOG.info("Setting timeout to: " + timeout);
+        zooKeeperTimeout = timeout;
+    }
+
+    @Override
+    public void setBundleContext(BundleContext bc) {
+        bundleContext = bc;
+    }
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
+        props.put(Constants.SERVICE_PID, SERVICE_PID);
+        props.put("zookeeper.host", getZooKeeperHost());
+        props.put("zookeeper.port", getZooKeeperPort());
+        props.put("zookeeper.timeout", getZooKeeperTimeout());
+        reg = bundleContext.registerService(Discovery.class.getName(), this, props);
+    }
+
+    @Override
+    public void destroy() throws Exception {
+        reg.unregister();
+    }    
+}

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

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

Added: cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveryServiceImplTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveryServiceImplTest.java?rev=764760&view=auto
==============================================================================
--- cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveryServiceImplTest.java
(added)
+++ cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/DiscoveryServiceImplTest.java
Tue Apr 14 12:44:40 2009
@@ -0,0 +1,84 @@
+/** 
+  * 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;
+
+import java.util.Dictionary;
+
+import junit.framework.TestCase;
+
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.discovery.Discovery;
+
+public class DiscoveryServiceImplTest extends TestCase {
+    public void testSettings() {
+        DiscoveryServiceImpl dsi = new DiscoveryServiceImpl();
+        
+        String host = "somehost";
+        dsi.setZooKeeperHost(host);
+        assertEquals(host, dsi.getZooKeeperHost());
+        
+        int port = 9898;
+        dsi.setZooKeeperPort(port);
+        assertEquals(port, dsi.getZooKeeperPort());
+        
+        int timeout = 123456;
+        dsi.setZooKeeperTimeout(timeout);
+        assertEquals(timeout, dsi.getZooKeeperTimeout());
+    }
+    
+    public void testRegisterService() throws Exception {
+        DiscoveryServiceImpl dsi = new DiscoveryServiceImpl();
+        dsi.setZooKeeperPort(23456);
+        
+        final ServiceRegistration sreg = EasyMock.createMock(ServiceRegistration.class);
+        sreg.unregister();
+        EasyMock.replay(sreg);       
+
+        BundleContext bc = EasyMock.createMock(BundleContext.class);
+        EasyMock.expect(bc.registerService(
+            EasyMock.eq(Discovery.class.getName()), EasyMock.eq(dsi), (Dictionary<?, ?>)
EasyMock.anyObject())).
+            andAnswer(new IAnswer<ServiceRegistration>(){        
+
+            @SuppressWarnings("unchecked")
+            @Override
+            public ServiceRegistration answer() throws Throwable {
+                Dictionary<String, Object> props = 
+                    (Dictionary<String, Object>) EasyMock.getCurrentArguments()[2];
+                assertEquals("localhost", props.get("zookeeper.host"));
+                assertEquals(23456, props.get("zookeeper.port"));
+                assertEquals(10000, props.get("zookeeper.timeout"));
+                assertEquals("org.apache.cxf.dosgi.discovery.zookeeper", props.get(Constants.SERVICE_PID));
+                
+                return sreg;
+            }
+        });
+        EasyMock.replay(bc);
+        
+        dsi.setBundleContext(bc);
+        dsi.afterPropertiesSet();
+        EasyMock.verify(bc);
+        
+        dsi.destroy();
+        EasyMock.verify(sreg);
+    }
+}

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

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



Mime
View raw message