1 package org.opendaylight.controller.sal.dom.broker;
5 import java.util.concurrent.Future;
7 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
8 import org.opendaylight.controller.md.sal.common.api.data.DataReader;
9 import org.opendaylight.controller.sal.common.DataStoreIdentifier;
10 import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration;
11 import org.opendaylight.controller.sal.core.api.RpcImplementation;
12 import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration;
13 import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
14 import org.opendaylight.controller.sal.core.api.data.DataChangeListener;
15 import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction;
16 import org.opendaylight.controller.sal.core.api.data.DataValidator;
17 import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
18 import org.opendaylight.controller.sal.core.api.notify.NotificationListener;
19 import org.opendaylight.controller.sal.dom.broker.impl.DataReaderRouter;
20 import org.opendaylight.controller.sal.dom.broker.impl.NotificationRouterImpl;
21 import org.opendaylight.controller.sal.dom.broker.impl.RpcRouterImpl;
22 import org.opendaylight.controller.sal.dom.broker.spi.NotificationRouter;
23 import org.opendaylight.controller.sal.dom.broker.spi.RpcRouter;
24 import org.opendaylight.yangtools.concepts.ListenerRegistration;
25 import org.opendaylight.yangtools.concepts.Registration;
26 import org.opendaylight.yangtools.yang.common.QName;
27 import org.opendaylight.yangtools.yang.common.RpcResult;
28 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
29 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
30 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdentifierBuilder;
31 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
33 public class MountPointImpl implements MountProvisionInstance {
35 private final RpcRouter rpcs;
36 private final DataReaderRouter dataReader;
37 private final NotificationRouter notificationRouter;
38 private final DataReader<InstanceIdentifier,CompositeNode> readWrapper;
41 private final InstanceIdentifier mountPath;
43 public MountPointImpl(InstanceIdentifier path) {
44 this.mountPath = path;
45 rpcs = new RpcRouterImpl("");
46 dataReader = new DataReaderRouter();
47 notificationRouter = new NotificationRouterImpl();
48 readWrapper = new ReadWrapper();
51 public InstanceIdentifier getMountPath() {
55 public DataReader<InstanceIdentifier, CompositeNode> getReadWrapper() {
60 public void publish(CompositeNode notification) {
61 notificationRouter.publish(notification);
65 public Registration<NotificationListener> addNotificationListener(QName notification, NotificationListener listener) {
66 return notificationRouter.addNotificationListener(notification, listener);
70 public CompositeNode readConfigurationData(InstanceIdentifier path) {
71 return dataReader.readConfigurationData(path);
75 public CompositeNode readOperationalData(InstanceIdentifier path) {
76 return dataReader.readOperationalData(path);
79 public Registration<DataReader<InstanceIdentifier, CompositeNode>> registerOperationalReader(
80 InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader) {
81 return dataReader.registerOperationalReader(path, reader);
84 public Registration<DataReader<InstanceIdentifier, CompositeNode>> registerConfigurationReader(
85 InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader) {
86 return dataReader.registerConfigurationReader(path, reader);
90 public RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation) {
91 return rpcs.addRoutedRpcImplementation(rpcType, implementation);
95 public RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation)
96 throws IllegalArgumentException {
97 return rpcs.addRpcImplementation(rpcType, implementation);
100 public Set<QName> getSupportedRpcs() {
101 return rpcs.getSupportedRpcs();
105 public RpcResult<CompositeNode> invokeRpc(QName rpc, CompositeNode input) {
106 return rpcs.invokeRpc(rpc, input);
109 public ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(RpcRegistrationListener listener) {
110 return rpcs.addRpcRegistrationListener(listener);
115 public Future<RpcResult<CompositeNode>> rpc(QName type, CompositeNode input) {
116 // TODO Auto-generated method stub
121 public DataModificationTransaction beginTransaction() {
122 // TODO Auto-generated method stub
127 public ListenerRegistration<DataChangeListener> registerDataChangeListener(InstanceIdentifier path,
128 DataChangeListener listener) {
129 // TODO Auto-generated method stub
134 public void sendNotification(CompositeNode notification) {
135 publish(notification);
139 public Registration<DataCommitHandler<InstanceIdentifier, CompositeNode>> registerCommitHandler(
140 InstanceIdentifier path, DataCommitHandler<InstanceIdentifier, CompositeNode> commitHandler) {
141 // TODO Auto-generated method stub
146 public void removeRefresher(DataStoreIdentifier store, DataRefresher refresher) {
151 public void addRefresher(DataStoreIdentifier store, DataRefresher refresher) {
156 public void addValidator(DataStoreIdentifier store, DataValidator validator) {
160 public void removeValidator(DataStoreIdentifier store, DataValidator validator) {
164 class ReadWrapper implements DataReader<InstanceIdentifier, CompositeNode> {
167 private InstanceIdentifier shortenPath(InstanceIdentifier path) {
168 InstanceIdentifier ret = null;
169 if(mountPath.contains(path)) {
170 List<PathArgument> newArgs = path.getPath().subList(mountPath.getPath().size(), path.getPath().size());
171 ret = new InstanceIdentifier(newArgs);
177 public CompositeNode readConfigurationData(InstanceIdentifier path) {
178 InstanceIdentifier newPath = shortenPath(path);
179 if(newPath == null) {
182 return MountPointImpl.this.readConfigurationData(newPath);
186 public CompositeNode readOperationalData(InstanceIdentifier path) {
187 InstanceIdentifier newPath = shortenPath(path);
188 if(newPath == null) {
191 return MountPointImpl.this.readOperationalData(newPath);