1 package org.opendaylight.controller.sal.dom.broker;
5 import java.util.concurrent.Future;
7 import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
8 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
9 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration;
10 import org.opendaylight.controller.md.sal.common.api.data.DataReader;
11 import org.opendaylight.controller.sal.common.DataStoreIdentifier;
12 import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration;
13 import org.opendaylight.controller.sal.core.api.RpcImplementation;
14 import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration;
15 import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
16 import org.opendaylight.controller.sal.core.api.data.DataChangeListener;
17 import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction;
18 import org.opendaylight.controller.sal.core.api.data.DataValidator;
19 import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
20 import org.opendaylight.controller.sal.core.api.notify.NotificationListener;
21 import org.opendaylight.controller.sal.dom.broker.impl.DataReaderRouter;
22 import org.opendaylight.controller.sal.dom.broker.impl.NotificationRouterImpl;
23 import org.opendaylight.controller.sal.dom.broker.impl.RpcRouterImpl;
24 import org.opendaylight.controller.sal.dom.broker.spi.NotificationRouter;
25 import org.opendaylight.controller.sal.dom.broker.spi.RpcRouter;
26 import org.opendaylight.yangtools.concepts.ListenerRegistration;
27 import org.opendaylight.yangtools.concepts.Registration;
28 import org.opendaylight.yangtools.yang.common.QName;
29 import org.opendaylight.yangtools.yang.common.RpcResult;
30 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
31 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
32 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdentifierBuilder;
33 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
34 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
36 public class MountPointImpl implements MountProvisionInstance {
38 private final RpcRouter rpcs;
39 private final DataBrokerImpl dataReader;
40 private final NotificationRouter notificationRouter;
41 private final DataReader<InstanceIdentifier,CompositeNode> readWrapper;
44 private final InstanceIdentifier mountPath;
46 private SchemaContext schemaContext;
48 public MountPointImpl(InstanceIdentifier path) {
49 this.mountPath = path;
50 rpcs = new RpcRouterImpl("");
51 dataReader = new DataBrokerImpl();
52 notificationRouter = new NotificationRouterImpl();
53 readWrapper = new ReadWrapper();
56 public InstanceIdentifier getMountPath() {
60 public DataReader<InstanceIdentifier, CompositeNode> getReadWrapper() {
65 public void publish(CompositeNode notification) {
66 notificationRouter.publish(notification);
70 public Registration<NotificationListener> addNotificationListener(QName notification, NotificationListener listener) {
71 return notificationRouter.addNotificationListener(notification, listener);
75 public CompositeNode readConfigurationData(InstanceIdentifier path) {
76 return dataReader.readConfigurationData(path);
80 public CompositeNode readOperationalData(InstanceIdentifier path) {
81 return dataReader.readOperationalData(path);
84 public Registration<DataReader<InstanceIdentifier, CompositeNode>> registerOperationalReader(
85 InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader) {
86 return dataReader.registerOperationalReader(path, reader);
89 public Registration<DataReader<InstanceIdentifier, CompositeNode>> registerConfigurationReader(
90 InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader) {
91 return dataReader.registerConfigurationReader(path, reader);
95 public RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation) {
96 return rpcs.addRoutedRpcImplementation(rpcType, implementation);
100 public RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation)
101 throws IllegalArgumentException {
102 return rpcs.addRpcImplementation(rpcType, implementation);
105 public Set<QName> getSupportedRpcs() {
106 return rpcs.getSupportedRpcs();
110 public RpcResult<CompositeNode> invokeRpc(QName rpc, CompositeNode input) {
111 return rpcs.invokeRpc(rpc, input);
114 public ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(RpcRegistrationListener listener) {
115 return rpcs.addRpcRegistrationListener(listener);
120 public Future<RpcResult<CompositeNode>> rpc(QName type, CompositeNode input) {
121 // TODO Auto-generated method stub
126 public DataModificationTransaction beginTransaction() {
127 return dataReader.beginTransaction();
131 public ListenerRegistration<DataChangeListener> registerDataChangeListener(InstanceIdentifier path,
132 DataChangeListener listener) {
133 return dataReader.registerDataChangeListener(path, listener);
137 public void sendNotification(CompositeNode notification) {
138 publish(notification);
142 public Registration<DataCommitHandler<InstanceIdentifier, CompositeNode>> registerCommitHandler(
143 InstanceIdentifier path, DataCommitHandler<InstanceIdentifier, CompositeNode> commitHandler) {
144 return dataReader.registerCommitHandler(path, commitHandler);
148 public void removeRefresher(DataStoreIdentifier store, DataRefresher refresher) {
153 public void addRefresher(DataStoreIdentifier store, DataRefresher refresher) {
158 public void addValidator(DataStoreIdentifier store, DataValidator validator) {
162 public void removeValidator(DataStoreIdentifier store, DataValidator validator) {
166 public SchemaContext getSchemaContext() {
167 return schemaContext;
170 public void setSchemaContext(SchemaContext schemaContext) {
171 this.schemaContext = schemaContext;
174 class ReadWrapper implements DataReader<InstanceIdentifier, CompositeNode> {
177 private InstanceIdentifier shortenPath(InstanceIdentifier path) {
178 InstanceIdentifier ret = null;
179 if(mountPath.contains(path)) {
180 List<PathArgument> newArgs = path.getPath().subList(mountPath.getPath().size(), path.getPath().size());
181 ret = new InstanceIdentifier(newArgs);
187 public CompositeNode readConfigurationData(InstanceIdentifier path) {
188 InstanceIdentifier newPath = shortenPath(path);
189 if(newPath == null) {
192 return MountPointImpl.this.readConfigurationData(newPath);
196 public CompositeNode readOperationalData(InstanceIdentifier path) {
197 InstanceIdentifier newPath = shortenPath(path);
198 if(newPath == null) {
201 return MountPointImpl.this.readOperationalData(newPath);
206 public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier, CompositeNode>>> registerCommitHandlerListener(
207 RegistrationListener<DataCommitHandlerRegistration<InstanceIdentifier, CompositeNode>> commitHandlerListener) {
208 return dataReader.registerCommitHandlerListener(commitHandlerListener);