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;
23 public class MountPointManagerImpl implements MountProvisionService {
25 private final ListenerRegistry<MountProvisionListener> listeners =
26 ListenerRegistry.create();
27 private final ConcurrentMap<InstanceIdentifier, MountPointImpl> mounts =
28 new ConcurrentHashMap<>();
29 private DataProviderService dataBroker = null;
32 public MountProvisionInstance createMountPoint(final InstanceIdentifier path) {
33 checkState(!mounts.containsKey(path), "Mount already created");
34 final MountPointImpl mount = new MountPointImpl(path);
35 registerMountPoint(mount);
36 mounts.put(path, mount);
37 notifyMountCreated(path);
41 public void notifyMountCreated(final InstanceIdentifier identifier) {
42 for (final ListenerRegistration<MountProvisionListener> listener : listeners
44 listener.getInstance().onMountPointCreated(identifier);
48 public Object registerMountPoint(final MountPointImpl impl) {
49 // FIXME: Why is thie commented out? Either we need it or we don't
50 // dataBroker?.registerConfigurationReader(impl.mountPath,impl.readWrapper);
51 // dataBroker?.registerOperationalReader(impl.mountPath,impl.readWrapper);
56 public MountProvisionInstance createOrGetMountPoint(
57 final InstanceIdentifier path) {
58 final MountPointImpl mount = mounts.get(path);
60 return createMountPoint(path);
66 public MountProvisionInstance getMountPoint(final InstanceIdentifier path) {
67 return mounts.get(path);
71 * @return the dataBroker
73 public DataProviderService getDataBroker() {
79 * the dataBroker to set
81 public void setDataBroker(final DataProviderService dataBroker) {
82 this.dataBroker = dataBroker;
86 public ListenerRegistration<MountProvisionListener> registerProvisionListener(
87 final MountProvisionListener listener) {
88 return listeners.register(listener);