NormalizedNode Mount APIs.
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / sal / dom / broker / MountPointManagerImpl.java
1 /**
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.dom.broker;
9
10 import static com.google.common.base.Preconditions.checkState;
11
12 import java.util.concurrent.ConcurrentHashMap;
13 import java.util.concurrent.ConcurrentMap;
14
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;
21
22 @Deprecated
23 public class MountPointManagerImpl implements MountProvisionService {
24
25     private final ListenerRegistry<MountProvisionListener> listeners =
26             ListenerRegistry.create();
27     private final ConcurrentMap<InstanceIdentifier, MountPointImpl> mounts =
28             new ConcurrentHashMap<>();
29     private DataProviderService dataBroker = null;
30
31     @Override
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);
38         return mount;
39     }
40
41     public void notifyMountCreated(final InstanceIdentifier identifier) {
42         for (final ListenerRegistration<MountProvisionListener> listener : listeners
43                 .getListeners()) {
44             listener.getInstance().onMountPointCreated(identifier);
45         }
46     }
47
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);
52         return null;
53     }
54
55     @Override
56     public MountProvisionInstance createOrGetMountPoint(
57             final InstanceIdentifier path) {
58         final MountPointImpl mount = mounts.get(path);
59         if (mount == null) {
60             return createMountPoint(path);
61         }
62         return mount;
63     }
64
65     @Override
66     public MountProvisionInstance getMountPoint(final InstanceIdentifier path) {
67         return mounts.get(path);
68     }
69
70     /**
71      * @return the dataBroker
72      */
73     public DataProviderService getDataBroker() {
74         return dataBroker;
75     }
76
77     /**
78      * @param dataBroker
79      *            the dataBroker to set
80      */
81     public void setDataBroker(final DataProviderService dataBroker) {
82         this.dataBroker = dataBroker;
83     }
84
85     @Override
86     public ListenerRegistration<MountProvisionListener> registerProvisionListener(
87             final MountProvisionListener listener) {
88         return listeners.register(listener);
89     }
90 }