023f906a67e90f495ae610ff0190687ecab54462
[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     override registerProvisionListener(MountProvisionListener listener) {
50         listeners.register(listener)
51     }
52     
53     
54     override createOrGetMountPoint(InstanceIdentifier path) {
55         val mount = mounts.get(path);
56         if(mount === null) {
57             return createMountPoint(path)
58         }
59         return mount;
60     }
61     
62     
63     override getMountPoint(InstanceIdentifier path) {
64         mounts.get(path);
65     }
66 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.