Author: cschneider
Date: Wed Aug 28 10:02:54 2013
New Revision: 1518131
URL: http://svn.apache.org/r1518131
Log:
Switch discovery zookeeper to generics
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ZooKeeperDiscovery.java
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListener.java
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/util/Utils.java
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java
cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java
cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/util/Utils.java
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ZooKeeperDiscovery.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ZooKeeperDiscovery.java?rev=1518131&r1=1518130&r2=1518131&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ZooKeeperDiscovery.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/ZooKeeperDiscovery.java
Wed Aug 28 10:02:54 2013
@@ -22,7 +22,7 @@ import java.io.IOException;
import java.util.Dictionary;
import
org.apache.cxf.dosgi.discovery.zookeeper.publish.PublishingEndpointListenerFactory;
-import
org.apache.cxf.dosgi.discovery.zookeeper.subscribe.EndpointListenerTrackerCustomizer;
+import
org.apache.cxf.dosgi.discovery.zookeeper.subscribe.EndpointListenerTracker;
import
org.apache.cxf.dosgi.discovery.zookeeper.subscribe.InterfaceMonitorManager;
import org.apache.cxf.dosgi.discovery.zookeeper.util.Utils;
import org.apache.zookeeper.WatchedEvent;
@@ -45,21 +45,19 @@ public class ZooKeeperDiscovery implemen
private final BundleContext bctx;
private PublishingEndpointListenerFactory endpointListenerFactory;
- private ServiceTracker endpointListenerTracker;
+ private ServiceTracker<EndpointListener, EndpointListener>
endpointListenerTracker;
private InterfaceMonitorManager imManager;
private ZooKeeper zk;
private boolean closed;
- @SuppressWarnings("rawtypes")
- private Dictionary curConfiguration;
+ private Dictionary<String , ?> curConfiguration;
public ZooKeeperDiscovery(BundleContext bctx) {
this.bctx = bctx;
this.curConfiguration = null;
}
- @SuppressWarnings("rawtypes")
- public synchronized void updated(Dictionary configuration) throws
ConfigurationException {
+ public synchronized void updated(Dictionary<String, ?> configuration)
throws ConfigurationException {
LOG.debug("Received configuration update for Zookeeper Discovery: {}",
configuration);
stop(false);
@@ -79,8 +77,7 @@ public class ZooKeeperDiscovery implemen
endpointListenerFactory = new PublishingEndpointListenerFactory(zk,
bctx);
endpointListenerFactory.start();
imManager = new InterfaceMonitorManager(bctx, zk);
- EndpointListenerTrackerCustomizer customizer = new
EndpointListenerTrackerCustomizer(imManager);
- endpointListenerTracker = new ServiceTracker(bctx,
EndpointListener.class.getName(), customizer);
+ endpointListenerTracker = new EndpointListenerTracker(bctx,
imManager);
endpointListenerTracker.open();
}
@@ -105,8 +102,7 @@ public class ZooKeeperDiscovery implemen
}
}
- @SuppressWarnings("rawtypes")
- private synchronized void createZooKeeper(Dictionary props) {
+ private synchronized void createZooKeeper(Dictionary<String, ?> props) {
if (closed) {
return;
}
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListener.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListener.java?rev=1518131&r1=1518130&r2=1518131&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListener.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListener.java
Wed Aug 28 10:02:54 2013
@@ -54,7 +54,7 @@ public class PublishingEndpointListener
private static final Logger LOG =
LoggerFactory.getLogger(PublishingEndpointListener.class);
private final ZooKeeper zk;
- private final ServiceTracker discoveryPluginTracker;
+ private final ServiceTracker<DiscoveryPlugin, DiscoveryPlugin>
discoveryPluginTracker;
private final List<EndpointDescription> endpoints = new
ArrayList<EndpointDescription>();
private boolean closed;
@@ -62,7 +62,8 @@ public class PublishingEndpointListener
public PublishingEndpointListener(ZooKeeper zk, BundleContext bctx) {
this.zk = zk;
- discoveryPluginTracker = new ServiceTracker(bctx,
DiscoveryPlugin.class.getName(), null);
+ discoveryPluginTracker = new ServiceTracker<DiscoveryPlugin,
DiscoveryPlugin>(bctx,
+ DiscoveryPlugin.class, null);
discoveryPluginTracker.open();
endpointDescriptionParser = new EndpointDescriptionParser();
}
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java?rev=1518131&r1=1518130&r2=1518131&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactory.java
Wed Aug 28 10:02:54 2013
@@ -39,21 +39,20 @@ import org.slf4j.LoggerFactory;
/**
* Creates local EndpointListeners that publish to ZooKeeper.
*/
-public class PublishingEndpointListenerFactory implements ServiceFactory {
+public class PublishingEndpointListenerFactory implements
ServiceFactory<PublishingEndpointListener> {
private static final Logger LOG =
LoggerFactory.getLogger(PublishingEndpointListenerFactory.class);
private final BundleContext bctx;
private final ZooKeeper zk;
private final List<PublishingEndpointListener> listeners = new
ArrayList<PublishingEndpointListener>();
- private ServiceRegistration serviceRegistration;
public PublishingEndpointListenerFactory(ZooKeeper zk, BundleContext bctx)
{
this.bctx = bctx;
this.zk = zk;
}
- public Object getService(Bundle b, ServiceRegistration sr) {
+ public PublishingEndpointListener getService(Bundle b,
ServiceRegistration<PublishingEndpointListener> sr) {
LOG.debug("new EndpointListener from factory");
synchronized (listeners) {
PublishingEndpointListener epl = new
PublishingEndpointListener(zk, bctx);
@@ -62,7 +61,8 @@ public class PublishingEndpointListenerF
}
}
- public void ungetService(Bundle b, ServiceRegistration sr, Object service)
{
+ public void ungetService(Bundle b,
ServiceRegistration<PublishingEndpointListener> sr,
+ PublishingEndpointListener service) {
LOG.debug("remove EndpointListener");
synchronized (listeners) {
if (listeners.remove(service)) {
@@ -77,15 +77,10 @@ public class PublishingEndpointListenerF
"(&(" + Constants.OBJECTCLASS + "=*)(" +
RemoteConstants.ENDPOINT_FRAMEWORK_UUID
+ "=" + Utils.getUUID(bctx) + "))");
props.put(ZooKeeperDiscovery.DISCOVERY_ZOOKEEPER_ID, "true");
- serviceRegistration =
bctx.registerService(EndpointListener.class.getName(), this, props);
+ bctx.registerService(EndpointListener.class.getName(), this, props);
}
public synchronized void stop() {
- if (serviceRegistration != null) {
- serviceRegistration.unregister();
- serviceRegistration = null;
- }
-
synchronized (listeners) {
for (PublishingEndpointListener epl : listeners) {
epl.close();
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java?rev=1518131&r1=1518130&r2=1518131&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManager.java
Wed Aug 28 10:02:54 2013
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
+import org.apache.cxf.dosgi.discovery.zookeeper.ZooKeeperDiscovery;
import org.apache.cxf.dosgi.discovery.zookeeper.util.Utils;
import org.apache.zookeeper.ZooKeeper;
import org.osgi.framework.Bundle;
@@ -50,13 +51,14 @@ public class InterfaceMonitorManager {
private final BundleContext bctx;
private final ZooKeeper zk;
// map of EndpointListeners and the scopes they are interested in
- private final Map<ServiceReference, List<String>> endpointListenerScopes =
- new HashMap<ServiceReference, List<String>>();
+ private final Map<ServiceReference<EndpointListener>, List<String>>
endpointListenerScopes =
+ new HashMap<ServiceReference<EndpointListener>, List<String>>();
// map of scopes and their interest data
private final Map<String, Interest> interests = new HashMap<String,
Interest>();
protected static class Interest {
- List<ServiceReference> endpointListeners = new
CopyOnWriteArrayList<ServiceReference>();
+ List<ServiceReference<EndpointListener>> endpointListeners =
+ new CopyOnWriteArrayList<ServiceReference<EndpointListener>>();
InterfaceMonitor monitor;
}
@@ -65,7 +67,16 @@ public class InterfaceMonitorManager {
this.zk = zk;
}
- public void addInterest(ServiceReference endpointListener) {
+ public void addInterest(ServiceReference<EndpointListener>
endpointListener) {
+ if (isOurOwnEndpointListener(endpointListener)) {
+ LOG.debug("Skipping our own EndpointListener");
+ return;
+ }
+
+ LOG.info("updating EndpointListener interests: {}", endpointListener);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("updated EndpointListener properties: {}",
Utils.getProperties(endpointListener));
+ }
for (String scope : Utils.getScopes(endpointListener)) {
String objClass = Utils.getObjectClass(scope);
LOG.debug("Adding interest in scope {}, objectClass {}", scope,
objClass);
@@ -73,7 +84,14 @@ public class InterfaceMonitorManager {
}
}
- public synchronized void addInterest(ServiceReference endpointListener,
String scope, String objClass) {
+ private static boolean
isOurOwnEndpointListener(ServiceReference<EndpointListener> endpointListener) {
+ return Boolean.parseBoolean(String.valueOf(
+
endpointListener.getProperty(ZooKeeperDiscovery.DISCOVERY_ZOOKEEPER_ID)));
+ }
+
+ @SuppressWarnings("unchecked")
+ public synchronized void addInterest(ServiceReference<EndpointListener>
endpointListener,
+ String scope, String objClass) {
// get or create interest for given scope and add listener to it
Interest interest = interests.get(scope);
if (interest == null) {
@@ -106,7 +124,8 @@ public class InterfaceMonitorManager {
}
}
- public synchronized void removeInterest(ServiceReference endpointListener)
{
+ public synchronized void removeInterest(ServiceReference<EndpointListener>
endpointListener) {
+ LOG.info("removing EndpointListener interests: {}", endpointListener);
List<String> scopes = endpointListenerScopes.get(endpointListener);
if (scopes == null) {
return;
@@ -125,7 +144,7 @@ public class InterfaceMonitorManager {
endpointListenerScopes.remove(endpointListener);
}
- private InterfaceMonitor createInterfaceMonitor(final String scope, String
objClass, final Interest interest) {
+ protected InterfaceMonitor createInterfaceMonitor(final String scope,
String objClass, final Interest interest) {
// holding this object's lock in the callbacks can lead to a deadlock
with InterfaceMonitor
EndpointListener endpointListener = new EndpointListener() {
@@ -141,18 +160,16 @@ public class InterfaceMonitorManager {
}
private void notifyListeners(EndpointDescription endpoint, String
currentScope, boolean isAdded,
- List<ServiceReference> endpointListeners) {
- for (ServiceReference endpointListenerRef : endpointListeners) {
- Object service = bctx.getService(endpointListenerRef);
+ List<ServiceReference<EndpointListener>> endpointListeners) {
+ for (ServiceReference<EndpointListener> endpointListenerRef :
endpointListeners) {
+ EndpointListener service = bctx.getService(endpointListenerRef);
try {
- if (service instanceof EndpointListener) {
- EndpointListener endpointListener = (EndpointListener)
service;
- LOG.trace("matching {} against {}", endpoint,
currentScope);
- if (matchFilter(bctx, currentScope, endpoint)) {
- LOG.debug("Matched {} against {}", endpoint,
currentScope);
- notifyListener(endpoint, currentScope, isAdded,
- endpointListenerRef.getBundle(),
endpointListener);
- }
+ EndpointListener endpointListener = (EndpointListener)service;
+ LOG.trace("matching {} against {}", endpoint, currentScope);
+ if (matchFilter(bctx, currentScope, endpoint)) {
+ LOG.debug("Matched {} against {}", endpoint, currentScope);
+ notifyListener(endpoint, currentScope, isAdded,
endpointListenerRef.getBundle(),
+ endpointListener);
}
} finally {
if (service != null) {
@@ -195,7 +212,7 @@ public class InterfaceMonitorManager {
/**
* Only for test case!
*/
- protected synchronized Map<ServiceReference, List<String>>
getEndpointListenerScopes() {
+ protected synchronized Map<ServiceReference<EndpointListener>,
List<String>> getEndpointListenerScopes() {
return endpointListenerScopes;
}
}
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/util/Utils.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/util/Utils.java?rev=1518131&r1=1518130&r2=1518131&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/util/Utils.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/util/Utils.java
Wed Aug 28 10:02:54 2013
@@ -91,7 +91,7 @@ public final class Utils {
return copied == result.length ? result : Arrays.copyOf(result,
copied);
}
- public static String[] getScopes(ServiceReference sref) {
+ public static String[] getScopes(ServiceReference<?> sref) {
return
removeEmpty(getStringPlusProperty(sref.getProperty(EndpointListener.ENDPOINT_LISTENER_SCOPE)));
}
@@ -128,7 +128,7 @@ public final class Utils {
* @param serviceReference a service reference
* @return the service's properties as a map
*/
- public static Map<String, Object> getProperties(ServiceReference
serviceReference) {
+ public static Map<String, Object> getProperties(ServiceReference<?>
serviceReference) {
String[] keys = serviceReference.getPropertyKeys();
Map<String, Object> props = new HashMap<String, Object>(keys.length);
for (String key : keys) {
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java?rev=1518131&r1=1518130&r2=1518131&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerFactoryTest.java
Wed Aug 28 10:02:54 2013
@@ -32,11 +32,13 @@ import org.osgi.service.remoteserviceadm
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);
@@ -50,19 +52,15 @@ public class PublishingEndpointListenerF
eplf.start();
c.verify();
- c.reset();
- sreg.unregister();
- EasyMock.expectLastCall().once();
- c.replay();
- eplf.stop();
- 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);
@@ -79,7 +77,7 @@ public class PublishingEndpointListenerF
c.replay();
eplf.start();
- Object service = eplf.getService(null, null);
+ PublishingEndpointListener service = eplf.getService(null, null);
assertNotNull(service);
assertTrue(service instanceof EndpointListener);
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java?rev=1518131&r1=1518130&r2=1518131&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
Wed Aug 28 10:02:54 2013
@@ -91,7 +91,8 @@ public class PublishingEndpointListenerT
return endpointKey;
}
};
- ServiceReference sr1 = EasyMock.createMock(ServiceReference.class);
+ @SuppressWarnings("unchecked")
+ ServiceReference<DiscoveryPlugin> sr1 =
EasyMock.createMock(ServiceReference.class);
DiscoveryPlugin plugin2 = new DiscoveryPlugin() {
public String process(Map<String, Object> mutableProperties,
String endpointKey) {
@@ -99,7 +100,8 @@ public class PublishingEndpointListenerT
return endpointKey.replaceAll("localhost", "some.machine");
}
};
- ServiceReference sr2 = EasyMock.createMock(ServiceReference.class);
+ @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>() {
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java?rev=1518131&r1=1518130&r2=1518131&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/subscribe/InterfaceMonitorManagerTest.java
Wed Aug 28 10:02:54 2013
@@ -30,6 +30,7 @@ import org.easymock.classextension.IMock
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;
@@ -42,8 +43,10 @@ public class InterfaceMonitorManagerTest
BundleContext ctx = c.createMock(BundleContext.class);
ZooKeeper zk = c.createMock(ZooKeeper.class);
- ServiceReference sref = c.createMock(ServiceReference.class);
- ServiceReference sref2 = c.createMock(ServiceReference.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>();
@@ -75,19 +78,7 @@ public class InterfaceMonitorManagerTest
final List<IMocksControl> controls = new ArrayList<IMocksControl>();
- InterfaceMonitorManager eltc = new InterfaceMonitorManager(ctx, zk) {
- protected InterfaceMonitor createInterfaceMonitor(String scope,
String objClass, Interest interest) {
- IMocksControl lc = EasyMock.createNiceControl();
- InterfaceMonitor im = lc.createMock(InterfaceMonitor.class);
- im.start();
- EasyMock.expectLastCall().once();
- im.close();
- EasyMock.expectLastCall().once();
- lc.replay();
- controls.add(lc);
- return im;
- }
- };
+ InterfaceMonitorManager eltc = new InterfaceMonitorManager(ctx, zk);
c.replay();
Modified:
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java?rev=1518131&r1=1518130&r2=1518131&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/cxf-discovery/src/test/java/org/apache/cxf/dosgi/discovery/zookeeper/util/UtilsTest.java
Wed Aug 28 10:02:54 2013
@@ -94,7 +94,8 @@ public class UtilsTest extends TestCase
String[] scopes = new String[]{"myScope=test", ""};
- ServiceReference sref = c.createMock(ServiceReference.class);
+ @SuppressWarnings("unchecked")
+ ServiceReference<EndpointListener> sref =
c.createMock(ServiceReference.class);
EasyMock.expect(sref.getProperty(EasyMock.eq(EndpointListener.ENDPOINT_LISTENER_SCOPE)))
.andReturn(scopes).anyTimes();
Modified:
cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java?rev=1518131&r1=1518130&r2=1518131&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java
Wed Aug 28 10:02:54 2013
@@ -61,7 +61,7 @@ public class ZookeeperStarter implements
}
}
- private void setDefaults(Dictionary<String, Object> dict) throws
IOException {
+ 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");
@@ -70,14 +70,14 @@ public class ZookeeperStarter implements
Utils.setDefault(dict, "dataDir", new
File(bundleContext.getDataFile(""), "zkdata").getCanonicalPath());
}
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public synchronized void updated(Dictionary dict) throws
ConfigurationException {
+ @SuppressWarnings("unchecked")
+ public synchronized void updated(Dictionary<String, ?> dict) throws
ConfigurationException {
shutdown();
if (dict == null) {
return;
}
try {
- setDefaults(dict);
+ setDefaults((Dictionary<String, String>)dict);
QuorumPeerConfig config = parseConfig(dict);
startFromConfig(config);
LOG.info("Applied configuration update: " + dict);
@@ -86,8 +86,7 @@ public class ZookeeperStarter implements
}
}
- @SuppressWarnings("rawtypes")
- private QuorumPeerConfig parseConfig(Dictionary dict) throws IOException,
ConfigException {
+ private QuorumPeerConfig parseConfig(Dictionary<String, ?> dict) throws
IOException, ConfigException {
QuorumPeerConfig config = new QuorumPeerConfig();
config.parseProperties(Utils.toProperties(dict));
return config;
Modified:
cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/util/Utils.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/util/Utils.java?rev=1518131&r1=1518130&r2=1518131&view=diff
==============================================================================
---
cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/util/Utils.java
(original)
+++
cxf/dosgi/trunk/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/util/Utils.java
Wed Aug 28 10:02:54 2013
@@ -38,7 +38,7 @@ public final class Utils {
*
* @param dict a dictionary
*/
- public static void removeEmptyValues(Dictionary<String, Object> dict) {
+ public static void removeEmptyValues(Dictionary<String, ?> dict) {
List<String> keysToRemove = new ArrayList<String>();
Enumeration<String> keys = dict.keys();
while (keys.hasMoreElements()) {
@@ -61,7 +61,7 @@ public final class Utils {
* @param key the key
* @param value the default value to set
*/
- public static void setDefault(Dictionary<String, Object> dict, String key,
String value) {
+ public static void setDefault(Dictionary<String, String> dict, String key,
String value) {
if (dict.get(key) == null) {
dict.put(key, value);
}