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.MountProvisionListener;
18 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
19 import org.opendaylight.yangtools.concepts.ListenerRegistration;
20 import org.opendaylight.yangtools.util.ListenerRegistry;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
24 public class MountPointManagerImpl implements MountProvisionService {
26 private final ListenerRegistry<MountProvisionListener> listeners =
27 ListenerRegistry.create();
28 private final ConcurrentMap<YangInstanceIdentifier, MountPointImpl> mounts =
29 new ConcurrentHashMap<>();
30 private DataProviderService dataBroker = null;
33 public MountProvisionInstance createMountPoint(final YangInstanceIdentifier path) {
34 checkState(!mounts.containsKey(path), "Mount already created");
35 final MountPointImpl mount = new MountPointImpl(path);
36 registerMountPoint(mount);
37 mounts.put(path, mount);
38 notifyMountCreated(path);
42 public void notifyMountCreated(final YangInstanceIdentifier identifier) {
43 for (final ListenerRegistration<MountProvisionListener> listener : listeners
45 listener.getInstance().onMountPointCreated(identifier);
49 public Object registerMountPoint(final MountPointImpl impl) {
50 // FIXME: Why is thie commented out? Either we need it or we don't
51 // dataBroker?.registerConfigurationReader(impl.mountPath,impl.readWrapper);
52 // dataBroker?.registerOperationalReader(impl.mountPath,impl.readWrapper);
57 public MountProvisionInstance createOrGetMountPoint(
58 final YangInstanceIdentifier path) {
59 final MountPointImpl mount = mounts.get(path);
61 return createMountPoint(path);
67 public MountProvisionInstance getMountPoint(final YangInstanceIdentifier path) {
68 return mounts.get(path);
72 * @return the dataBroker
74 public DataProviderService getDataBroker() {
80 * the dataBroker to set
82 public void setDataBroker(final DataProviderService dataBroker) {
83 this.dataBroker = dataBroker;
87 public ListenerRegistration<MountProvisionListener> registerProvisionListener(
88 final MountProvisionListener listener) {
89 return listeners.register(listener);