Merge "Add missing headers to config, netconf subsystems"
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / sal / dom / broker / MountPointManagerImpl.xtend
1 package org.opendaylight.controller.sal.dom.broker
2
3
4 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService
5 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
6 import java.util.concurrent.ConcurrentMap
7 import java.util.concurrent.ConcurrentHashMap
8 import static com.google.common.base.Preconditions.*;
9 import org.opendaylight.controller.sal.core.api.data.DataProviderService
10 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService.MountProvisionListener
11 import org.opendaylight.yangtools.concepts.util.ListenerRegistry
12
13 class MountPointManagerImpl implements MountProvisionService {
14     
15     @Property
16     DataProviderService dataBroker;
17     
18     val ListenerRegistry<MountProvisionListener> listeners = ListenerRegistry.create()
19     
20     ConcurrentMap<InstanceIdentifier,MountPointImpl> mounts = new ConcurrentHashMap();
21     
22     override createMountPoint(InstanceIdentifier path) {
23         checkState(!mounts.containsKey(path),"Mount already created");
24         val mount = new MountPointImpl(path);
25         registerMountPoint(mount);
26         mounts.put(path,mount);
27         notifyMountCreated(path);
28         return mount;
29     }
30     
31     def notifyMountCreated(InstanceIdentifier identifier) {
32         for(listener : listeners) {
33             listener.instance.onMountPointCreated(identifier);
34         }
35     }
36     
37     def registerMountPoint(MountPointImpl impl) {
38         dataBroker?.registerConfigurationReader(impl.mountPath,impl.readWrapper);
39         dataBroker?.registerOperationalReader(impl.mountPath,impl.readWrapper);
40         
41     }
42     
43     override registerProvisionListener(MountProvisionListener listener) {
44         listeners.register(listener)
45     }
46     
47     
48     override createOrGetMountPoint(InstanceIdentifier path) {
49         val mount = mounts.get(path);
50         if(mount === null) {
51             return createMountPoint(path)
52         }
53         return mount;
54     }
55     
56     
57     override getMountPoint(InstanceIdentifier path) {
58         mounts.get(path);
59     }
60 }