* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.netconf.impl.osgi;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
-import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
-import com.google.common.collect.Sets;
-import io.netty.util.internal.ConcurrentSet;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.opendaylight.controller.config.util.capability.Capability;
+import java.util.concurrent.ConcurrentHashMap;
+import org.opendaylight.netconf.api.capability.Capability;
import org.opendaylight.netconf.api.monitoring.CapabilityListener;
import org.opendaylight.netconf.mapping.api.NetconfOperation;
import org.opendaylight.netconf.mapping.api.NetconfOperationService;
private static final Logger LOG = LoggerFactory.getLogger(AggregatedNetconfOperationServiceFactory.class);
- private final Set<NetconfOperationServiceFactory> factories = new ConcurrentSet<>();
+ private final Set<NetconfOperationServiceFactory> factories = ConcurrentHashMap.newKeySet();
private final Multimap<NetconfOperationServiceFactory, AutoCloseable> registrations =
Multimaps.synchronizedMultimap(HashMultimap.create());
- private final Set<CapabilityListener> listeners = new ConcurrentSet<>();
+ private final Set<CapabilityListener> listeners = ConcurrentHashMap.newKeySet();
public AggregatedNetconfOperationServiceFactory() {
}
@Override
public Set<Capability> getCapabilities() {
- final HashSet<Capability> capabilities = Sets.newHashSet();
+ final Set<Capability> capabilities = new HashSet<>();
for (final NetconfOperationServiceFactory factory : factories) {
capabilities.addAll(factory.getCapabilities());
}
@Override
public synchronized AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
- final Map<NetconfOperationServiceFactory, AutoCloseable> regs = Maps.newHashMap();
+ final Map<NetconfOperationServiceFactory, AutoCloseable> regs = new HashMap<>();
for (final NetconfOperationServiceFactory factory : factories) {
final AutoCloseable reg = factory.registerCapabilityListener(listener);
}
listeners.add(listener);
- return new AutoCloseable() {
- @Override
- public void close() throws Exception {
- synchronized (AggregatedNetconfOperationServiceFactory.this) {
- listeners.remove(listener);
- CloseableUtil.closeAll(regs.values());
- for (final Map.Entry<NetconfOperationServiceFactory, AutoCloseable> reg : regs.entrySet()) {
- registrations.remove(reg.getKey(), reg.getValue());
- }
+ return () -> {
+ synchronized (AggregatedNetconfOperationServiceFactory.this) {
+ listeners.remove(listener);
+ CloseableUtil.closeAll(regs.values());
+ for (final Map.Entry<NetconfOperationServiceFactory, AutoCloseable> reg : regs.entrySet()) {
+ registrations.remove(reg.getKey(), reg.getValue());
}
}
};
@Override
public Set<NetconfOperation> getNetconfOperations() {
- final HashSet<NetconfOperation> operations = Sets.newHashSet();
+ final Set<NetconfOperation> operations = new HashSet<>();
for (final NetconfOperationService service : services) {
operations.addAll(service.getNetconfOperations());
}