http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImplTest.java ---------------------------------------------------------------------- diff --git a/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImplTest.java b/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImplTest.java deleted file mode 100644 index 53b6139..0000000 --- a/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/InterfaceDataMonitorListenerImplTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/** - * 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 junit.framework.TestCase; - -public class InterfaceDataMonitorListenerImplTest extends TestCase { - - public void testDUMMY() { - assertTrue(true); - } - -// public void testChange() throws Exception { -// final List<DiscoveredServiceNotification> dsnCallbacks = new ArrayList<DiscoveredServiceNotification>(); -// DiscoveredServiceTracker dst = new DiscoveredServiceTracker() { -// public void serviceChanged(DiscoveredServiceNotification dsn) { -// dsnCallbacks.add(dsn); -// } -// }; -// -// //---------------------------------------------------------------- -// // Test DiscoveredServiceNotification.AVAILABLE -// //---------------------------------------------------------------- -// Properties initial = new Properties(); -// initial.put("a", "b"); -// initial.put(ServicePublication.ENDPOINT_LOCATION, "http://somehost:12345/some/context"); -// ByteArrayOutputStream propBytes = new ByteArrayOutputStream(); -// initial.store(propBytes, ""); -// -// ZooKeeper zk = EasyMock.createMock(ZooKeeper.class); -// EasyMock.expect(zk.getChildren(Utils.getZooKeeperPath(String.class.getName()), false)) -// .andReturn(Arrays.asList("x#y#z")); -// EasyMock.expect(zk.getData(Utils.getZooKeeperPath(String.class.getName()) + "/x#y#z", false, null)) -// .andReturn(propBytes.toByteArray()); -// EasyMock.replay(zk); -// -// InterfaceDataMonitorListenerImpl dml = new InterfaceDataMonitorListenerImpl(zk, String.class.getName(), dst); -// -// assertEquals("Precondition failed", 0, dsnCallbacks.size()); -// dml.change(); -// assertEquals(1, dsnCallbacks.size()); -// DiscoveredServiceNotification dsn = dsnCallbacks.iterator().next(); -// assertEquals(Collections.singleton(String.class.getName()), dsn.getInterfaces()); -// assertEquals(DiscoveredServiceNotification.AVAILABLE, dsn.getType()); -// assertEquals(0, dsn.getFilters().size()); -// ServiceEndpointDescription sed = dsn.getServiceEndpointDescription(); -// assertEquals(Collections.singleton(String.class.getName()), sed.getProvidedInterfaces()); -// -// Properties expected = new Properties(); -// expected.load(new ByteArrayInputStream(propBytes.toByteArray())); -// expected.put("service.exported.configs", "org.apache.cxf.ws"); -// expected.put("org.apache.cxf.ws.address", "http://somehost:12345/some/context"); -// -// assertEquals(expected, sed.getProperties()); -// EasyMock.verify(zk); -// -// // Again with the same data -// EasyMock.reset(zk); -// EasyMock.expect(zk.getChildren(Utils.getZooKeeperPath(String.class.getName()), false)) -// .andReturn(Arrays.asList("x#y#z")); -// EasyMock.expect(zk.getData(Utils.getZooKeeperPath(String.class.getName()) + "/x#y#z", false, null)) -// .andReturn(propBytes.toByteArray()); -// EasyMock.replay(zk); -// -// dsnCallbacks.clear(); -// assertEquals("Precondition failed", 0, dsnCallbacks.size()); -// dml.change(); -// assertEquals(0, dsnCallbacks.size()); -// -// EasyMock.verify(zk); -// //---------------------------------------------------------------- -// // Test DiscoveredServiceNotification.MODIFIED -// //---------------------------------------------------------------- -// Properties modified = new Properties(); -// modified.put("c", "d"); -// modified.put(ServicePublication.ENDPOINT_LOCATION, "http://somehost:999/some/context"); -// modified.put("service.exported.configs", "org.apache.cxf.rs"); -// ByteArrayOutputStream modBytes = new ByteArrayOutputStream(); -// modified.store(modBytes, ""); -// -// EasyMock.reset(zk); -// EasyMock.expect(zk.getChildren(Utils.getZooKeeperPath(String.class.getName()), false)) -// .andReturn(Arrays.asList("x#y#z")); -// EasyMock.expect(zk.getData(Utils.getZooKeeperPath(String.class.getName()) + "/x#y#z", false, null)) -// .andReturn(modBytes.toByteArray()); -// EasyMock.replay(zk); -// -// dsnCallbacks.clear(); -// assertEquals("Precondition failed", 0, dsnCallbacks.size()); -// dml.change(); -// assertEquals(1, dsnCallbacks.size()); -// DiscoveredServiceNotification dsn2 = dsnCallbacks.iterator().next(); -// assertEquals(Collections.singleton(String.class.getName()), dsn2.getInterfaces()); -// assertEquals(DiscoveredServiceNotification.MODIFIED, dsn2.getType()); -// assertEquals(0, dsn2.getFilters().size()); -// ServiceEndpointDescription sed2 = dsn2.getServiceEndpointDescription(); -// assertEquals(Collections.singleton(String.class.getName()), sed2.getProvidedInterfaces()); -// assertEquals(modified, sed2.getProperties()); -// -// EasyMock.verify(zk); -// -// //---------------------------------------------------------------- -// // Test DiscoveredServiceNotification.MODIFIED2 -// //---------------------------------------------------------------- -// Properties modified2 = new Properties(); -// modified2.put("c", "d2"); -// modified2.put(ServicePublication.ENDPOINT_LOCATION, "http://somehost:112/some/context"); -// modified2.put("service.exported.configs", "org.apache.cxf.ws"); -// modified2.put("org.apache.cxf.ws.address", "http://somewhereelse/123"); -// ByteArrayOutputStream modBytes2 = new ByteArrayOutputStream(); -// modified2.store(modBytes2, ""); -// -// EasyMock.reset(zk); -// EasyMock.expect(zk.getChildren(Utils.getZooKeeperPath(String.class.getName()), false)) -// .andReturn(Arrays.asList("x#y#z")); -// EasyMock.expect(zk.getData(Utils.getZooKeeperPath(String.class.getName()) + "/x#y#z", false, null)) -// .andReturn(modBytes2.toByteArray()); -// EasyMock.replay(zk); -// -// dsnCallbacks.clear(); -// assertEquals("Precondition failed", 0, dsnCallbacks.size()); -// dml.change(); -// assertEquals(1, dsnCallbacks.size()); -// DiscoveredServiceNotification dsn3 = dsnCallbacks.iterator().next(); -// assertEquals(Collections.singleton(String.class.getName()), dsn3.getInterfaces()); -// assertEquals(DiscoveredServiceNotification.MODIFIED, dsn3.getType()); -// assertEquals(0, dsn3.getFilters().size()); -// ServiceEndpointDescription sed3 = dsn3.getServiceEndpointDescription(); -// assertEquals(Collections.singleton(String.class.getName()), sed3.getProvidedInterfaces()); -// assertEquals(modified2, sed3.getProperties()); -// -// EasyMock.verify(zk); -// //---------------------------------------------------------------- -// // Test DiscoveredServiceNotification.UNAVAILABLE -// //---------------------------------------------------------------- -// EasyMock.reset(zk); -// EasyMock.expect(zk.getChildren(Utils.getZooKeeperPath(String.class.getName()), false)) -// .andReturn(Collections.<String>emptyList()); -// EasyMock.replay(zk); -// -// dsnCallbacks.clear(); -// assertEquals("Precondition failed", 0, dsnCallbacks.size()); -// dml.change(); -// assertEquals(1, dsnCallbacks.size()); -// DiscoveredServiceNotification dsn4 = dsnCallbacks.iterator().next(); -// assertEquals(Collections.singleton(String.class.getName()), dsn4.getInterfaces()); -// assertEquals(DiscoveredServiceNotification.UNAVAILABLE, dsn4.getType()); -// assertEquals(0, dsn4.getFilters().size()); -// ServiceEndpointDescription sed4 = dsn4.getServiceEndpointDescription(); -// assertEquals(Collections.singleton(String.class.getName()), sed4.getProvidedInterfaces()); -// assertEquals(modified2, sed4.getProperties()); -// -// EasyMock.verify(zk); -// -// // Try the same again... -// EasyMock.reset(zk); -// EasyMock.expect(zk.getChildren(Utils.getZooKeeperPath(String.class.getName()), false)) -// .andReturn(Collections.<String>emptyList()); -// EasyMock.replay(zk); -// -// dsnCallbacks.clear(); -// assertEquals("Precondition failed", 0, dsnCallbacks.size()); -// dml.change(); -// assertEquals("Should not receive a callback again...", 0, dsnCallbacks.size()); -// EasyMock.verify(zk); -// } -}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java ---------------------------------------------------------------------- diff --git a/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java b/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java deleted file mode 100644 index e63b805..0000000 --- a/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * 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.publish; - -import java.util.Dictionary; -import java.util.List; - -import junit.framework.TestCase; - -import org.apache.zookeeper.ZooKeeper; -import org.easymock.classextension.EasyMock; -import org.easymock.classextension.IMocksControl; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.remoteserviceadmin.EndpointListener; - -public class PublishingEndpointListenerFactoryTest extends TestCase { - - @SuppressWarnings("unchecked") - public void testScope() { - IMocksControl c = EasyMock.createNiceControl(); - - BundleContext ctx = c.createMock(BundleContext.class); - ZooKeeper zk = c.createMock(ZooKeeper.class); - @SuppressWarnings("rawtypes") - ServiceRegistration sreg = c.createMock(ServiceRegistration.class); - - PublishingEndpointListenerFactory eplf = new PublishingEndpointListenerFactory(zk, ctx); - - EasyMock.expect(ctx.registerService(EasyMock.eq(EndpointListener.class.getName()), EasyMock.eq(eplf), - (Dictionary<String, String>)EasyMock.anyObject())).andReturn(sreg).once(); - - EasyMock.expect(ctx.getProperty(EasyMock.eq("org.osgi.framework.uuid"))).andReturn("myUUID").anyTimes(); - - c.replay(); - eplf.start(); - c.verify(); - - } - - @SuppressWarnings("unchecked") - public void testServiceFactory() { - IMocksControl c = EasyMock.createNiceControl(); - - BundleContext ctx = c.createMock(BundleContext.class); - ZooKeeper zk = c.createMock(ZooKeeper.class); - @SuppressWarnings("rawtypes") - ServiceRegistration sreg = c.createMock(ServiceRegistration.class); - - PublishingEndpointListenerFactory eplf = new PublishingEndpointListenerFactory(zk, ctx); - - EasyMock.expect(ctx.registerService(EasyMock.eq(EndpointListener.class.getName()), EasyMock.eq(eplf), - (Dictionary<String, String>)EasyMock.anyObject())).andReturn(sreg).once(); - - EasyMock.expect(ctx.getProperty(EasyMock.eq("org.osgi.framework.uuid"))).andReturn("myUUID").anyTimes(); - - PublishingEndpointListener eli = c.createMock(PublishingEndpointListener.class); - eli.close(); - EasyMock.expectLastCall().once(); - - c.replay(); - eplf.start(); - - PublishingEndpointListener service = eplf.getService(null, null); - assertNotNull(service); - assertTrue(service instanceof EndpointListener); - - List<PublishingEndpointListener> listeners = eplf.getListeners(); - assertEquals(1, listeners.size()); - assertEquals(service, listeners.get(0)); - - eplf.ungetService(null, null, service); - listeners = eplf.getListeners(); - assertEquals(0, listeners.size()); - - eplf.ungetService(null, null, eli); // no call to close - listeners.add(eli); - eplf.ungetService(null, null, eli); // call to close - listeners = eplf.getListeners(); - assertEquals(0, listeners.size()); - - c.verify(); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java ---------------------------------------------------------------------- diff --git a/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java b/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java deleted file mode 100644 index aa1b68e..0000000 --- a/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * 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.publish; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import junit.framework.TestCase; - -import org.apache.cxf.dosgi.endpointdesc.EndpointDescriptionParser; -import org.apache.cxf.dosgi.endpointdesc.PropertiesMapper; -import org.apache.zookeeper.CreateMode; -import org.apache.zookeeper.KeeperException; -import org.apache.zookeeper.ZooDefs.Ids; -import org.apache.zookeeper.ZooKeeper; -import org.easymock.IAnswer; -import org.easymock.classextension.EasyMock; -import org.easymock.classextension.IMocksControl; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.Filter; -import org.osgi.framework.FrameworkUtil; -import org.osgi.framework.ServiceListener; -import org.osgi.framework.ServiceReference; -import org.osgi.service.remoteserviceadmin.EndpointDescription; -import org.osgi.service.remoteserviceadmin.RemoteConstants; -import org.osgi.xmlns.rsa.v1_0.EndpointDescriptionType; -import org.osgi.xmlns.rsa.v1_0.PropertyType; - -public class PublishingEndpointListenerTest extends TestCase { - - public void testEndpointRemovalAdding() throws KeeperException, InterruptedException { - IMocksControl c = EasyMock.createNiceControl(); - - BundleContext ctx = c.createMock(BundleContext.class); - ZooKeeper zk = c.createMock(ZooKeeper.class); - - String path = "/osgi/service_registry/myClass/google.de#80##test"; - EasyMock.expect(zk.create(EasyMock.eq(path), - (byte[])EasyMock.anyObject(), EasyMock.eq(Ids.OPEN_ACL_UNSAFE), - EasyMock.eq(CreateMode.EPHEMERAL))).andReturn("").once(); - - zk.delete(EasyMock.eq("/osgi/service_registry/myClass/google.de#80##test"), EasyMock.eq(-1)); - EasyMock.expectLastCall().once(); - - c.replay(); - - PublishingEndpointListener eli = new PublishingEndpointListener(zk, ctx); - - Map<String, Object> props = new HashMap<String, Object>(); - props.put(Constants.OBJECTCLASS, new String[] { - "myClass" - }); - props.put(RemoteConstants.ENDPOINT_ID, "http://google.de:80/test"); - props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myConfig"); - - EndpointDescription endpoint = new EndpointDescription(props); - - eli.endpointAdded(endpoint, null); - eli.endpointAdded(endpoint, null); // should do nothing - - eli.endpointRemoved(endpoint, null); - eli.endpointRemoved(endpoint, null); // should do nothing - - c.verify(); - } - - public void testDiscoveryPlugin() throws Exception { - DiscoveryPlugin plugin1 = new DiscoveryPlugin() { - public String process(Map<String, Object> mutableProperties, String endpointKey) { - String eid = (String) mutableProperties.get("endpoint.id"); - mutableProperties.put("endpoint.id", eid + "/appended"); - return endpointKey; - } - }; - @SuppressWarnings("unchecked") - ServiceReference<DiscoveryPlugin> sr1 = EasyMock.createMock(ServiceReference.class); - - DiscoveryPlugin plugin2 = new DiscoveryPlugin() { - public String process(Map<String, Object> mutableProperties, String endpointKey) { - mutableProperties.put("foo", "bar"); - return endpointKey.replaceAll("localhost", "some.machine"); - } - }; - @SuppressWarnings("unchecked") - ServiceReference<DiscoveryPlugin> sr2 = EasyMock.createMock(ServiceReference.class); - - BundleContext ctx = EasyMock.createMock(BundleContext.class); - EasyMock.expect(ctx.createFilter(EasyMock.isA(String.class))).andAnswer(new IAnswer<Filter>() { - public Filter answer() throws Throwable { - return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]); - } - }).anyTimes(); - ctx.addServiceListener(EasyMock.isA(ServiceListener.class), - EasyMock.eq("(objectClass=" + DiscoveryPlugin.class.getName() + ")")); - EasyMock.expect(ctx.getService(sr1)).andReturn(plugin1).anyTimes(); - EasyMock.expect(ctx.getService(sr2)).andReturn(plugin2).anyTimes(); - EasyMock.expect(ctx.getServiceReferences(DiscoveryPlugin.class.getName(), null)) - .andReturn(new ServiceReference[]{sr1, sr2}).anyTimes(); - EasyMock.replay(ctx); - - Map<String, Object> props = new HashMap<String, Object>(); - props.put(Constants.OBJECTCLASS, new String[] {"org.foo.myClass"}); - props.put(RemoteConstants.ENDPOINT_ID, "http://localhost:9876/test"); - props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myConfig"); - EndpointDescription endpoint = new EndpointDescription(props); - - Map<String, Object> expectedProps = new HashMap<String, Object>(props); - expectedProps.put("endpoint.id", "http://localhost:9876/test/appended"); - expectedProps.put("foo", "bar"); - expectedProps.put("service.imported", "true"); - - final ZooKeeper zk = EasyMock.createNiceMock(ZooKeeper.class); - String expectedFullPath = "/osgi/service_registry/org/foo/myClass/some.machine#9876##test"; - - List<PropertyType> props2 = new PropertiesMapper().fromProps(expectedProps); - EndpointDescriptionType epd = new EndpointDescriptionType(); - epd.getProperty().addAll(props2); - byte[] data = new EndpointDescriptionParser().getData(epd); - EasyMock.expect(zk.create( - EasyMock.eq(expectedFullPath), - EasyMock.aryEq(data), - EasyMock.eq(Ids.OPEN_ACL_UNSAFE), - EasyMock.eq(CreateMode.EPHEMERAL))).andReturn(""); - EasyMock.replay(zk); - - PublishingEndpointListener eli = new PublishingEndpointListener(zk, ctx); - - List<EndpointDescription> endpoints = getEndpoints(eli); - assertEquals("Precondition", 0, endpoints.size()); - eli.endpointAdded(endpoint, null); - assertEquals(1, endpoints.size()); - - //TODO enable - //EasyMock.verify(zk); - } - - @SuppressWarnings("unchecked") - private List<EndpointDescription> getEndpoints(PublishingEndpointListener eli) throws Exception { - Field field = eli.getClass().getDeclaredField("endpoints"); - field.setAccessible(true); - return (List<EndpointDescription>) field.get(eli); - } - - public void testClose() throws KeeperException, InterruptedException { - IMocksControl c = EasyMock.createNiceControl(); - - BundleContext ctx = c.createMock(BundleContext.class); - ZooKeeper zk = c.createMock(ZooKeeper.class); - - String path = "/osgi/service_registry/myClass/google.de#80##test"; - EasyMock.expect(zk.create(EasyMock.eq(path), - (byte[])EasyMock.anyObject(), EasyMock.eq(Ids.OPEN_ACL_UNSAFE), - EasyMock.eq(CreateMode.EPHEMERAL))).andReturn("").once(); - - zk.delete(EasyMock.eq("/osgi/service_registry/myClass/google.de#80##test"), EasyMock.eq(-1)); - EasyMock.expectLastCall().once(); - - c.replay(); - - PublishingEndpointListener eli = new PublishingEndpointListener(zk, ctx); - - Map<String, Object> props = new HashMap<String, Object>(); - props.put(Constants.OBJECTCLASS, new String[] { - "myClass" - }); - props.put(RemoteConstants.ENDPOINT_ID, "http://google.de:80/test"); - props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myConfig"); - - EndpointDescription endpoint = new EndpointDescription(props); - - eli.endpointAdded(endpoint, null); - - eli.close(); // should result in zk.delete(...) - - c.verify(); - } - - public void testGetKey() throws Exception { - assertEquals("somehost#9090##org#example#TestEndpoint", - PublishingEndpointListener.getKey("http://somehost:9090/org/example/TestEndpoint")); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java ---------------------------------------------------------------------- diff --git a/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java b/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java deleted file mode 100644 index 7d6f67f..0000000 --- a/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * 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.subscribe; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.zookeeper.ZooKeeper; -import org.easymock.IAnswer; -import org.easymock.classextension.EasyMock; -import org.easymock.classextension.IMocksControl; -import org.junit.Test; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.service.remoteserviceadmin.EndpointListener; - -import static org.junit.Assert.assertEquals; - -public class InterfaceMonitorManagerTest { - - @Test - public void testEndpointListenerTrackerCustomizer() { - IMocksControl c = EasyMock.createNiceControl(); - - BundleContext ctx = c.createMock(BundleContext.class); - ZooKeeper zk = c.createMock(ZooKeeper.class); - - @SuppressWarnings("unchecked") - ServiceReference<EndpointListener> sref = c.createMock(ServiceReference.class); - @SuppressWarnings("unchecked") - ServiceReference<EndpointListener> sref2 = c.createMock(ServiceReference.class); - - final Map<String, ?> p = new HashMap<String, Object>(); - - EasyMock.expect(sref.getPropertyKeys()).andAnswer(new IAnswer<String[]>() { - public String[] answer() throws Throwable { - return p.keySet().toArray(new String[p.size()]); - } - }).anyTimes(); - - EasyMock.expect(sref.getProperty((String)EasyMock.anyObject())).andAnswer(new IAnswer<Object>() { - public Object answer() throws Throwable { - String key = (String)(EasyMock.getCurrentArguments()[0]); - return p.get(key); - } - }).anyTimes(); - - EasyMock.expect(sref2.getPropertyKeys()).andAnswer(new IAnswer<String[]>() { - public String[] answer() throws Throwable { - return p.keySet().toArray(new String[p.size()]); - } - }).anyTimes(); - - EasyMock.expect(sref2.getProperty((String)EasyMock.anyObject())).andAnswer(new IAnswer<Object>() { - public Object answer() throws Throwable { - String key = (String)(EasyMock.getCurrentArguments()[0]); - return p.get(key); - } - }).anyTimes(); - - final List<IMocksControl> controls = new ArrayList<IMocksControl>(); - - InterfaceMonitorManager eltc = new InterfaceMonitorManager(ctx, zk); - - c.replay(); - - // sref has no scope -> nothing should happen - - assertEquals(0, eltc.getEndpointListenerScopes().size()); - assertEquals(0, eltc.getInterests().size()); - - //p.put(EndpointListener.ENDPOINT_LISTENER_SCOPE, ); - - eltc.addInterest(sref, "(objectClass=mine)", "mine"); - - assertEquals(1, eltc.getEndpointListenerScopes().size()); - assertEquals(1, eltc.getEndpointListenerScopes().get(sref).size()); - assertEquals("(objectClass=mine)", eltc.getEndpointListenerScopes().get(sref).get(0)); - assertEquals(1, eltc.getInterests().size()); - - eltc.addInterest(sref, "(objectClass=mine)", "mine"); - - assertEquals(1, eltc.getEndpointListenerScopes().size()); - assertEquals(1, eltc.getEndpointListenerScopes().get(sref).size()); - assertEquals("(objectClass=mine)", eltc.getEndpointListenerScopes().get(sref).get(0)); - assertEquals(1, eltc.getInterests().size()); - - eltc.addInterest(sref2, "(objectClass=mine)", "mine"); - - assertEquals(2, eltc.getEndpointListenerScopes().size()); - assertEquals(1, eltc.getEndpointListenerScopes().get(sref).size()); - assertEquals(1, eltc.getEndpointListenerScopes().get(sref2).size()); - assertEquals("(objectClass=mine)", eltc.getEndpointListenerScopes().get(sref).get(0)); - assertEquals("(objectClass=mine)", eltc.getEndpointListenerScopes().get(sref2).get(0)); - assertEquals(1, eltc.getInterests().size()); - - eltc.removeInterest(sref); - - assertEquals(1, eltc.getEndpointListenerScopes().size()); - assertEquals(1, eltc.getEndpointListenerScopes().get(sref2).size()); - assertEquals("(objectClass=mine)", eltc.getEndpointListenerScopes().get(sref2).get(0)); - assertEquals(1, eltc.getInterests().size()); - - eltc.removeInterest(sref); - - assertEquals(1, eltc.getEndpointListenerScopes().size()); - assertEquals(1, eltc.getEndpointListenerScopes().get(sref2).size()); - assertEquals("(objectClass=mine)", eltc.getEndpointListenerScopes().get(sref2).get(0)); - assertEquals(1, eltc.getInterests().size()); - - eltc.removeInterest(sref2); - - assertEquals(0, eltc.getEndpointListenerScopes().size()); - assertEquals(0, eltc.getInterests().size()); - - c.verify(); - for (IMocksControl control : controls) { - control.verify(); - } - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java ---------------------------------------------------------------------- diff --git a/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java b/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java deleted file mode 100644 index 67afb16..0000000 --- a/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * 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.subscribe; - -import java.util.Collections; - -import junit.framework.TestCase; - -import org.apache.cxf.dosgi.discovery.zookeeper.util.Utils; -import org.apache.zookeeper.KeeperException; -import org.apache.zookeeper.WatchedEvent; -import org.apache.zookeeper.Watcher.Event.EventType; -import org.apache.zookeeper.Watcher.Event.KeeperState; -import org.apache.zookeeper.ZooKeeper; -import org.apache.zookeeper.data.Stat; -import org.easymock.classextension.EasyMock; -import org.easymock.classextension.IMocksControl; -import org.osgi.service.remoteserviceadmin.EndpointListener; - -import static org.easymock.EasyMock.eq; -import static org.easymock.EasyMock.expect; - -public class InterfaceMonitorTest extends TestCase { - - public void testInterfaceMonitor() throws KeeperException, InterruptedException { - IMocksControl c = EasyMock.createControl(); - - ZooKeeper zk = c.createMock(ZooKeeper.class); - expect(zk.getState()).andReturn(ZooKeeper.States.CONNECTED).anyTimes(); - - String scope = "(myProp=test)"; - String interf = "es.schaaf.test"; - String node = Utils.getZooKeeperPath(interf); - - EndpointListener endpointListener = c.createMock(EndpointListener.class); - InterfaceMonitor im = new InterfaceMonitor(zk, interf, endpointListener, scope); - zk.exists(eq(node), eq(im), eq(im), EasyMock.anyObject()); - EasyMock.expectLastCall().once(); - - expect(zk.exists(eq(node), eq(false))).andReturn(new Stat()).anyTimes(); - expect(zk.getChildren(eq(node), eq(false))).andReturn(Collections.<String> emptyList()).once(); - expect(zk.getChildren(eq(node), eq(im))).andReturn(Collections.<String> emptyList()).once(); - - c.replay(); - im.start(); - // simulate a zk callback - WatchedEvent we = new WatchedEvent(EventType.NodeCreated, KeeperState.SyncConnected, node); - im.process(we); - c.verify(); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java ---------------------------------------------------------------------- diff --git a/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java b/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java deleted file mode 100644 index 08c830c..0000000 --- a/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * 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.util; - -import java.util.Arrays; - -import junit.framework.TestCase; - -import org.easymock.classextension.EasyMock; -import org.easymock.classextension.IMocksControl; -import org.osgi.framework.ServiceReference; -import org.osgi.service.remoteserviceadmin.EndpointListener; - -public class UtilsTest extends TestCase { - - public void testGetZooKeeperPath() { - assertEquals(Utils.PATH_PREFIX + '/' + "org/example/Test", - Utils.getZooKeeperPath("org.example.Test")); - - // used for the recursive discovery - assertEquals(Utils.PATH_PREFIX, Utils.getZooKeeperPath(null)); - assertEquals(Utils.PATH_PREFIX, Utils.getZooKeeperPath("")); - } - - public void testGetStringPlusProperty() { - String[] out = Utils.getStringPlusProperty("MyString"); - assertEquals(1, out.length); - assertEquals("MyString", out[0]); - - out = Utils.getStringPlusProperty(new String[]{"MyString"}); - assertEquals(1, out.length); - assertEquals("MyString", out[0]); - - out = Utils.getStringPlusProperty(Arrays.asList("MyString")); - assertEquals(1, out.length); - assertEquals("MyString", out[0]); - - out = Utils.getStringPlusProperty(Arrays.asList(1)); - assertEquals(0, out.length); - - out = Utils.getStringPlusProperty(new Object()); - assertEquals(0, out.length); - - out = Utils.getStringPlusProperty(null); - assertEquals(0, out.length); - } - - public void testRemoveEmpty() { - String[] out = Utils.removeEmpty(new String[0]); - assertEquals(0, out.length); - - out = Utils.removeEmpty(new String[]{null}); - assertEquals(0, out.length); - - out = Utils.removeEmpty(new String[]{""}); - assertEquals(0, out.length); - - out = Utils.removeEmpty(new String[]{"hi"}); - assertEquals(1, out.length); - assertEquals("hi", out[0]); - - out = Utils.removeEmpty(new String[]{"", "hi", null}); - assertEquals(1, out.length); - assertEquals("hi", out[0]); - - out = Utils.removeEmpty(new String[]{"hi", null, "", ""}); - assertEquals(1, out.length); - assertEquals("hi", out[0]); - - out = Utils.removeEmpty(new String[]{"", "hi", null, "", "", "bye", null}); - assertEquals(2, out.length); - assertEquals("hi", out[0]); - assertEquals("bye", out[1]); - } - - public void testGetScopes() { - IMocksControl c = EasyMock.createNiceControl(); - - String[] scopes = new String[]{"myScope=test", ""}; - - @SuppressWarnings("unchecked") - ServiceReference<EndpointListener> sref = c.createMock(ServiceReference.class); - EasyMock.expect(sref.getProperty(EasyMock.eq(EndpointListener.ENDPOINT_LISTENER_SCOPE))) - .andReturn(scopes).anyTimes(); - - c.replay(); - - String[] ret = Utils.getScopes(sref); - - c.verify(); - assertEquals(1, ret.length); - assertEquals(scopes[0], ret[0]); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/pom.xml ---------------------------------------------------------------------- diff --git a/discovery/distributed/pom.xml b/discovery/distributed/pom.xml deleted file mode 100644 index e33a09f..0000000 --- a/discovery/distributed/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version='1.0' encoding='UTF-8' ?> -<!-- - 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. ---> -<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"> - - <modelVersion>4.0.0</modelVersion> - <groupId>org.apache.cxf.dosgi</groupId> - <artifactId>cxf-dosgi-ri-discovery-distributed-parent</artifactId> - <version>1.8-SNAPSHOT</version> - <packaging>pom</packaging> - <name>Distributed OSGI Distributed Discovery Parent</name> - <url>http://cxf.apache.org</url> - - <parent> - <groupId>org.apache.cxf.dosgi</groupId> - <artifactId>cxf-dosgi-ri-parent</artifactId> - <version>1.8-SNAPSHOT</version> - <relativePath>../../parent/pom.xml</relativePath> - </parent> - - <modules> - <module>zookeeper-server</module> - <module>zookeeper-server-config</module> - <module>cxf-discovery</module> - </modules> -</project> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/zookeeper-server-config/pom.xml ---------------------------------------------------------------------- diff --git a/discovery/distributed/zookeeper-server-config/pom.xml b/discovery/distributed/zookeeper-server-config/pom.xml deleted file mode 100644 index 83073dc..0000000 --- a/discovery/distributed/zookeeper-server-config/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ -<?xml version='1.0' encoding='UTF-8' ?> -<!-- - 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. ---> -<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"> - - <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>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.8-SNAPSHOT</version> - - <parent> - <groupId>org.apache.cxf.dosgi</groupId> - <artifactId>cxf-dosgi-ri-parent</artifactId> - <version>1.8-SNAPSHOT</version> - <relativePath>../../../parent/pom.xml</relativePath> - </parent> - - <properties> - <topDirectoryLocation>../../..</topDirectoryLocation> - </properties> - - <dependencies> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.core</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.compendium</artifactId> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </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>Configures the ZooKeeper server in an OSGi Framework</Bundle-Description> - <Bundle-SymbolicName>${project.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> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java ---------------------------------------------------------------------- diff --git a/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java b/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java deleted file mode 100644 index a00c7b0..0000000 --- a/discovery/distributed/zookeeper-server-config/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/config/Activator.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * 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.net.ServerSocket; -import java.util.Dictionary; -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.service.cm.ManagedService; -import org.osgi.util.tracker.ServiceTracker; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Activator implements BundleActivator { - - private static final Logger LOG = LoggerFactory.getLogger(Activator.class); - private static final String ZOOKEEPER_PORT = "org.apache.cxf.dosgi.discovery.zookeeper.port"; - private static final String PID = "org.apache.cxf.dosgi.discovery.zookeeper.server"; - private ServiceTracker<ConfigurationAdmin, ConfigurationAdmin> st; - - public void start(BundleContext context) throws Exception { - synchronized (Activator.class) { - // Only one thread gets to set the port number - if (System.getProperty(ZOOKEEPER_PORT) == null) { - String port = getFreePort(); - System.setProperty(ZOOKEEPER_PORT, port); - LOG.info("Global ZooKeeper port: {}", port); - } - } - - st = new ServiceTracker<ConfigurationAdmin, ConfigurationAdmin>(context, ConfigurationAdmin.class, null) { - @Override - public ConfigurationAdmin addingService(ServiceReference<ConfigurationAdmin> reference) { - ConfigurationAdmin service = super.addingService(reference); - try { - Configuration cfg = service.getConfiguration(PID, null); - Dictionary<String, Object> props = new Hashtable<String, Object>(); - String zp = System.getProperty(ZOOKEEPER_PORT); - props.put("clientPort", zp); - cfg.update(props); - LOG.debug("Set ZooKeeper client port to {}", zp); - } catch (IOException e) { - LOG.error("Failed to configure ZooKeeper server!", e); - } - return service; - } - }; - st.open(); - - // The following section is done synchronously otherwise it doesn't happen in time for the CT - ServiceReference[] refs = context.getServiceReferences(ManagedService.class.getName(), - "(service.pid=org.apache.cxf.dosgi.discovery.zookeeper)"); - if (refs == null || refs.length == 0) { - throw new RuntimeException("This bundle must be started after the bundle with the ZooKeeper " - + "Discovery Managed Service was started."); - } - - Dictionary<String, Object> props = new Hashtable<String, Object>(); - props.put("zookeeper.host", "127.0.0.1"); - props.put("zookeeper.port", System.getProperty(ZOOKEEPER_PORT)); - - ManagedService ms = (ManagedService) context.getService(refs[0]); - try { - ms.updated(props); - } finally { - if (ms != null) { - context.ungetService(refs[0]); - } - } - LOG.debug("Passed the zookeeper.host property to the ZooKeeper Client managed service."); - } - - private String getFreePort() { - try { - ServerSocket ss = new ServerSocket(0); - String port = "" + ss.getLocalPort(); - ss.close(); - return port; - } catch (IOException e) { - LOG.error("Failed to find a free port!", e); - return null; - } - } - - public void stop(BundleContext context) throws Exception { - st.close(); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/zookeeper-server/pom.xml ---------------------------------------------------------------------- diff --git a/discovery/distributed/zookeeper-server/pom.xml b/discovery/distributed/zookeeper-server/pom.xml deleted file mode 100644 index 442210e..0000000 --- a/discovery/distributed/zookeeper-server/pom.xml +++ /dev/null @@ -1,114 +0,0 @@ -<?xml version='1.0' encoding='UTF-8' ?> -<!-- - 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. ---> -<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"> - - <modelVersion>4.0.0</modelVersion> - <artifactId>cxf-dosgi-ri-discovery-distributed-zookeeper-server</artifactId> - <packaging>bundle</packaging> - <name>CXF DOSGi ZooKeeper Server Control Bundle</name> - <description>Runs the ZooKeeper server</description> - - <parent> - <groupId>org.apache.cxf.dosgi</groupId> - <artifactId>cxf-dosgi-ri-parent</artifactId> - <version>1.8-SNAPSHOT</version> - <relativePath>../../../parent/pom.xml</relativePath> - </parent> - - <properties> - <topDirectoryLocation>../../..</topDirectoryLocation> - </properties> - - <dependencies> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.core</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.compendium</artifactId> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.apache.zookeeper</groupId> - <artifactId>zookeeper</artifactId> - <version>${zookeeper.version}</version> - <exclusions> - <exclusion> - <groupId>com.sun.jdmk</groupId> - <artifactId>jmxtools</artifactId> - </exclusion> - <exclusion> - <groupId>com.sun.jmx</groupId> - <artifactId>jmxri</artifactId> - </exclusion> - <exclusion> - <artifactId>slf4j-log4j12</artifactId> - <groupId>org.slf4j</groupId> - </exclusion> - <exclusion> - <artifactId>jline</artifactId> - <groupId>jline</groupId> - </exclusion> - <exclusion> - <artifactId>netty</artifactId> - <groupId>io.netty</groupId> - </exclusion> - <exclusion> - <artifactId>log4j</artifactId> - <groupId>log4j</groupId> - </exclusion> - </exclusions> - </dependency> - - <!-- We need the newer log4j as the one from ZooKeeper has some ugly dependencies --> - - <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-SymbolicName>${project.artifactId}</Bundle-SymbolicName> - <Bundle-Activator>org.apache.cxf.dosgi.discovery.zookeeper.server.Activator</Bundle-Activator> - <Export-Package> - !* - </Export-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Activator.java ---------------------------------------------------------------------- diff --git a/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Activator.java b/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Activator.java deleted file mode 100644 index 6adf700..0000000 --- a/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Activator.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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.Dictionary; -import java.util.Hashtable; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; - -public class Activator implements BundleActivator { - - ZookeeperStarter zkStarter; - - public void start(BundleContext context) throws Exception { - zkStarter = new ZookeeperStarter(context); - Dictionary<String, Object> props = new Hashtable<String, Object>(); - props.put(Constants.SERVICE_PID, "org.apache.cxf.dosgi.discovery.zookeeper.server"); - context.registerService(org.osgi.service.cm.ManagedService.class.getName(), zkStarter, props); - } - - public void stop(BundleContext context) throws Exception { - if (zkStarter != null) { - zkStarter.shutdown(); - } - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Utils.java ---------------------------------------------------------------------- diff --git a/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Utils.java b/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Utils.java deleted file mode 100644 index fe3c663..0000000 --- a/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Utils.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * 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.ArrayList; -import java.util.Dictionary; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -/** - * General purpose utility methods. - */ -public final class Utils { - - private Utils() { - // prevent instantiation - } - - /** - * Remove entries whose values are empty from the given dictionary. - * - * @param dict a dictionary - */ - public static void removeEmptyValues(Dictionary<String, ?> dict) { - List<String> keysToRemove = new ArrayList<String>(); - Enumeration<String> keys = dict.keys(); - while (keys.hasMoreElements()) { - String key = keys.nextElement(); - Object value = dict.get(key); - if (value instanceof String && "".equals(value)) { - keysToRemove.add(key); - } - } - for (String key : keysToRemove) { - dict.remove(key); - } - } - - /** - * Puts the given key-value pair in the given dictionary if the key does not - * already exist in it or if its existing value is null. - * - * @param dict a dictionary - * @param key the key - * @param value the default value to set - */ - public static void setDefault(Dictionary<String, String> dict, String key, String value) { - if (dict.get(key) == null) { - dict.put(key, value); - } - } - - /** - * Converts the given Dictionary to a Map. - * - * @param dict a dictionary - * @param <K> the key type - * @param <V> the value type - * @return the converted map, or an empty map if the given dictionary is null - */ - public static <K, V> Map<K, V> toMap(Dictionary<K, V> dict) { - Map<K, V> map = new HashMap<K, V>(); - if (dict != null) { - Enumeration<K> keys = dict.keys(); - while (keys.hasMoreElements()) { - K key = keys.nextElement(); - map.put(key, dict.get(key)); - } - } - return map; - } - - /** - * Converts a Dictionary into a Properties instance. - * - * @param dict a dictionary - * @param <K> the key type - * @param <V> the value type - * @return the properties - */ - public static <K, V> Properties toProperties(Dictionary<K, V> dict) { - Properties props = new Properties(); - for (Enumeration<K> e = dict.keys(); e.hasMoreElements();) { - K key = e.nextElement(); - props.put(key, dict.get(key)); - } - return props; - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java ---------------------------------------------------------------------- diff --git a/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java b/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java deleted file mode 100644 index bd5618f..0000000 --- a/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * 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.Map; - -import org.apache.zookeeper.server.ServerConfig; -import org.apache.zookeeper.server.ZooKeeperServerMain; -import org.apache.zookeeper.server.quorum.QuorumPeerConfig; -import org.apache.zookeeper.server.quorum.QuorumPeerConfig.ConfigException; -import org.apache.zookeeper.server.quorum.QuorumPeerMain; -import org.osgi.framework.BundleContext; -import org.osgi.service.cm.ConfigurationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ZookeeperStarter implements org.osgi.service.cm.ManagedService { - - private static final Logger LOG = LoggerFactory.getLogger(ZookeeperStarter.class); //NOPMD - using log4j here - - protected ZookeeperServer main; - private final BundleContext bundleContext; - private Thread zkMainThread; - private Map<String, ?> curConfiguration; - - public ZookeeperStarter(BundleContext ctx) { - bundleContext = ctx; - } - - synchronized void shutdown() { - if (main != null) { - LOG.info("Shutting down ZooKeeper server"); - try { - main.shutdown(); - if (zkMainThread != null) { - zkMainThread.join(); - } - } catch (Throwable e) { - LOG.error(e.getMessage(), e); - } - main = null; - zkMainThread = null; - } - } - - private void setDefaults(Dictionary<String, String> dict) throws IOException { - Utils.removeEmptyValues(dict); // to avoid NumberFormatExceptions - Utils.setDefault(dict, "tickTime", "2000"); - Utils.setDefault(dict, "initLimit", "10"); - Utils.setDefault(dict, "syncLimit", "5"); - Utils.setDefault(dict, "clientPort", "2181"); - Utils.setDefault(dict, "dataDir", new File(bundleContext.getDataFile(""), "zkdata").getCanonicalPath()); - } - - @SuppressWarnings("unchecked") - public synchronized void updated(Dictionary<String, ?> dict) throws ConfigurationException { - LOG.debug("Received configuration update for Zookeeper Server: " + dict); - try { - if (dict != null) { - setDefaults((Dictionary<String, String>)dict); - } - Map<String, ?> configMap = Utils.toMap(dict); - if (!configMap.equals(curConfiguration)) { // only if something actually changed - shutdown(); - curConfiguration = configMap; - // config is null if it doesn't exist, is being deleted or has not yet been loaded - // in which case we just stop running - if (dict != null) { - startFromConfig(parseConfig(dict)); - LOG.info("Applied configuration update: " + dict); - } - } - } catch (Exception th) { - LOG.error("Problem applying configuration update: " + dict, th); - } - } - - private QuorumPeerConfig parseConfig(Dictionary<String, ?> dict) throws IOException, ConfigException { - QuorumPeerConfig config = new QuorumPeerConfig(); - config.parseProperties(Utils.toProperties(dict)); - return config; - } - - protected void startFromConfig(final QuorumPeerConfig config) { - int numServers = config.getServers().size(); - main = numServers > 1 ? new MyQuorumPeerMain(config) : new MyZooKeeperServerMain(config); - zkMainThread = new Thread(new Runnable() { - public void run() { - try { - main.startup(); - } catch (Throwable e) { - LOG.error("Problem running ZooKeeper server.", e); - } - } - }); - zkMainThread.start(); - } - - interface ZookeeperServer { - void startup() throws IOException; - void shutdown(); - } - - static class MyQuorumPeerMain extends QuorumPeerMain implements ZookeeperServer { - - private QuorumPeerConfig config; - - MyQuorumPeerMain(QuorumPeerConfig config) { - this.config = config; - } - - public void startup() throws IOException { - runFromConfig(config); - } - - public void shutdown() { - if (null != quorumPeer) { - quorumPeer.shutdown(); - } - } - } - - static class MyZooKeeperServerMain extends ZooKeeperServerMain implements ZookeeperServer { - - private QuorumPeerConfig config; - - MyZooKeeperServerMain(QuorumPeerConfig config) { - this.config = config; - } - - public void startup() throws IOException { - ServerConfig serverConfig = new ServerConfig(); - serverConfig.readFrom(config); - runFromConfig(serverConfig); - } - - public void shutdown() { - try { - super.shutdown(); - } catch (Exception e) { - LOG.error("Error shutting down ZooKeeper", e); - } - } - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/zookeeper-server/src/main/resources/OSGI-INF/metatype/zookeeper.xml ---------------------------------------------------------------------- diff --git a/discovery/distributed/zookeeper-server/src/main/resources/OSGI-INF/metatype/zookeeper.xml b/discovery/distributed/zookeeper-server/src/main/resources/OSGI-INF/metatype/zookeeper.xml deleted file mode 100644 index efd9403..0000000 --- a/discovery/distributed/zookeeper-server/src/main/resources/OSGI-INF/metatype/zookeeper.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<MetaData xmlns="http://www.osgi.org/xmlns/metadata/v1.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation=" - http://www.osgi.org/xmlns/metadata/v1.0.0 http://www.osgi.org/xmlns/metatype/v1.1.0/metatype.xsd - "> - <OCD description="" name="Zookeeper server config" id="org.apache.cxf.dosgi.discovery.zookeeper.server"> - <AD id="clientPort" required="false" type="String" default="2181" description=""/> - <AD id="tickTime" required="false" type="String" default="2000" description=""/> - <AD id="initLimit" required="false" type="String" default="10" description=""/> - <AD id="syncLimit" required="false" type="String" default="5" description=""/> - </OCD> - <Designate pid="org.apache.cxf.dosgi.discovery.zookeeper.server"> - <Object ocdref="org.apache.cxf.dosgi.discovery.zookeeper.server"/> - </Designate> -</MetaData> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarterTest.java ---------------------------------------------------------------------- diff --git a/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarterTest.java b/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarterTest.java deleted file mode 100644 index 17ca117..0000000 --- a/discovery/distributed/zookeeper-server/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarterTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * 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.Dictionary; -import java.util.Hashtable; - -import junit.framework.TestCase; - -import org.apache.cxf.dosgi.discovery.zookeeper.server.ZookeeperStarter.MyZooKeeperServerMain; -import org.apache.zookeeper.server.quorum.QuorumPeerConfig; -import org.easymock.classextension.EasyMock; -import org.easymock.classextension.IMocksControl; -import org.osgi.framework.BundleContext; - -import static org.easymock.EasyMock.expect; -import static org.easymock.classextension.EasyMock.replay; -import static org.easymock.classextension.EasyMock.verify; - -public class ZookeeperStarterTest extends TestCase { - - public void testUpdateConfig() throws Exception { - final File tempDir = new File("target"); - IMocksControl control = EasyMock.createControl(); - BundleContext bc = control.createMock(BundleContext.class); - expect(bc.getDataFile("")).andReturn(tempDir); - final MyZooKeeperServerMain mockServer = control.createMock(MyZooKeeperServerMain.class); - control.replay(); - - ZookeeperStarter starter = new ZookeeperStarter(bc) { - @Override - protected void startFromConfig(QuorumPeerConfig config) { - assertEquals(1234, config.getClientPortAddress().getPort()); - assertTrue(config.getDataDir().contains(tempDir + File.separator + "zkdata")); - assertEquals(2000, config.getTickTime()); - assertEquals(10, config.getInitLimit()); - assertEquals(5, config.getSyncLimit()); - this.main = mockServer; - } - }; - Dictionary<String, Object> props = new Hashtable<String, Object>(); - props.put("clientPort", "1234"); - starter.updated(props); - assertNotNull(starter.main); - - control.verify(); - } - - public void testRemoveConfiguration() throws Exception { - BundleContext bc = EasyMock.createMock(BundleContext.class); - MyZooKeeperServerMain zkServer = EasyMock.createMock(MyZooKeeperServerMain.class); - zkServer.shutdown(); - EasyMock.expectLastCall(); - - replay(zkServer); - - ZookeeperStarter starter = new ZookeeperStarter(bc); - starter.main = zkServer; - starter.updated(null); - - verify(zkServer); - assertNull("main should be null", starter.main); - } -} http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/pom.xml ---------------------------------------------------------------------- diff --git a/discovery/local/pom.xml b/discovery/local/pom.xml deleted file mode 100644 index 8fa118f..0000000 --- a/discovery/local/pom.xml +++ /dev/null @@ -1,99 +0,0 @@ -<?xml version='1.0' encoding='UTF-8' ?> -<!-- - 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. ---> -<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"> - - <modelVersion>4.0.0</modelVersion> - <artifactId>cxf-dosgi-ri-discovery-local</artifactId> - <packaging>bundle</packaging> - <name>CXF Local Discovery Service Bundle</name> - <description>The CXF Local Discovery Service Implementation</description> - - <parent> - <groupId>org.apache.cxf.dosgi</groupId> - <artifactId>cxf-dosgi-ri-parent</artifactId> - <version>1.8-SNAPSHOT</version> - <relativePath>../../parent/pom.xml</relativePath> - </parent> - - <properties> - <topDirectoryLocation>../..</topDirectoryLocation> - </properties> - - <dependencies> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.core</artifactId> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.osgi</groupId> - <artifactId>org.osgi.compendium</artifactId> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </dependency> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>xmlunit</groupId> - <artifactId>xmlunit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.easymock</groupId> - <artifactId>easymockclassextension</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.jvnet.jaxb2.maven2</groupId> - <artifactId>maven-jaxb2-plugin</artifactId> - <version>0.9.0</version> - <executions> - <execution> - <goals> - <goal>generate</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <configuration> - <instructions> - <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> - <Bundle-Activator>org.apache.cxf.dosgi.discovery.local.internal.Activator</Bundle-Activator> - </instructions> - </configuration> - </plugin> - </plugins> - </build> -</project> http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/1425743f/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/Activator.java ---------------------------------------------------------------------- diff --git a/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/Activator.java b/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/Activator.java deleted file mode 100644 index 918f009..0000000 --- a/discovery/local/src/main/java/org/apache/cxf/dosgi/discovery/local/internal/Activator.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * 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.local.internal; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Activator implements BundleActivator { - - private static final Logger LOG = LoggerFactory.getLogger(Activator.class); - - LocalDiscovery localDiscovery; - - public synchronized void start(BundleContext context) { - localDiscovery = new LocalDiscovery(context); - LOG.info("Local D-OSGi service discovery started"); - } - - public synchronized void stop(BundleContext context) { - localDiscovery.shutDown(); - LOG.info("Local D-OSGi service discovery stopped"); - } -}
