2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.impl.device;
11 import java.util.Collections;
13 import java.util.concurrent.ConcurrentHashMap;
14 import org.opendaylight.openflowplugin.api.openflow.registry.ItemLifeCycleRegistry;
15 import org.opendaylight.openflowplugin.api.openflow.rpc.ItemLifeCycleSource;
16 import org.opendaylight.yangtools.concepts.Registration;
19 * Default implementation.
21 public class ItemLifeCycleRegistryImpl implements ItemLifeCycleRegistry {
23 private final Set<ItemLifeCycleSource> registry;
25 public ItemLifeCycleRegistryImpl() {
26 registry = Collections.newSetFromMap(new ConcurrentHashMap<ItemLifeCycleSource, Boolean>());
32 public Registration registerLifeCycleSource(final ItemLifeCycleSource lifeCycleSource) {
33 registry.add(lifeCycleSource);
34 return () -> registry.remove(lifeCycleSource);
43 public Iterable<ItemLifeCycleSource> getLifeCycleSources() {
44 return Collections.unmodifiableCollection(registry);