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