2 * Copyright (c) 2014 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
8 package org.opendaylight.controller.sal.dom.broker;
10 import static com.google.common.base.Preconditions.checkState;
12 import java.util.concurrent.ConcurrentHashMap;
13 import java.util.concurrent.ConcurrentMap;
15 import org.opendaylight.controller.sal.core.api.data.DataProviderService;
16 import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
17 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
18 import org.opendaylight.yangtools.concepts.ListenerRegistration;
19 import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
20 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
22 public class MountPointManagerImpl implements MountProvisionService {
24 private final ListenerRegistry<MountProvisionListener> listeners =
25 ListenerRegistry.create();
26 private final ConcurrentMap<InstanceIdentifier, MountPointImpl> mounts =
27 new ConcurrentHashMap<>();
28 private DataProviderService dataBroker = null;
31 public MountProvisionInstance createMountPoint(final InstanceIdentifier path) {
32 checkState(!mounts.containsKey(path), "Mount already created");
33 final MountPointImpl mount = new MountPointImpl(path);
34 registerMountPoint(mount);
35 mounts.put(path, mount);
36 notifyMountCreated(path);
40 public void notifyMountCreated(final InstanceIdentifier identifier) {
41 for (final ListenerRegistration<MountProvisionListener> listener : listeners
43 listener.getInstance().onMountPointCreated(identifier);
47 public Object registerMountPoint(final MountPointImpl impl) {
48 // FIXME: Why is thie commented out? Either we need it or we don't
49 // dataBroker?.registerConfigurationReader(impl.mountPath,impl.readWrapper);
50 // dataBroker?.registerOperationalReader(impl.mountPath,impl.readWrapper);
55 public MountProvisionInstance createOrGetMountPoint(
56 final InstanceIdentifier path) {
57 final MountPointImpl mount = mounts.get(path);
59 return createMountPoint(path);
65 public MountProvisionInstance getMountPoint(final InstanceIdentifier path) {
66 return mounts.get(path);
70 * @return the dataBroker
72 public DataProviderService getDataBroker() {
78 * the dataBroker to set
80 public void setDataBroker(final DataProviderService dataBroker) {
81 this.dataBroker = dataBroker;
85 public ListenerRegistration<MountProvisionListener> registerProvisionListener(
86 final MountProvisionListener listener) {
87 return listeners.register(listener);