+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.controller.sal.dom.broker;
-import java.util.List;
+import com.google.common.collect.Iterables;
+import com.google.common.util.concurrent.ListenableFuture;
import java.util.Set;
-import java.util.concurrent.Future;
-
+import org.opendaylight.controller.md.sal.common.api.RegistrationListener;
import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandlerRegistration;
import org.opendaylight.controller.md.sal.common.api.data.DataReader;
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
import org.opendaylight.controller.sal.common.DataStoreIdentifier;
import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.core.api.RpcImplementation;
import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration;
+import org.opendaylight.controller.sal.core.api.RoutedRpcDefaultImplementation;
+import org.opendaylight.controller.sal.core.api.RpcImplementation;
import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
+import org.opendaylight.controller.sal.core.api.RpcRoutingContext;
import org.opendaylight.controller.sal.core.api.data.DataChangeListener;
import org.opendaylight.controller.sal.core.api.data.DataModificationTransaction;
import org.opendaylight.controller.sal.core.api.data.DataValidator;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
import org.opendaylight.controller.sal.core.api.notify.NotificationListener;
-import org.opendaylight.controller.sal.dom.broker.impl.DataReaderRouter;
import org.opendaylight.controller.sal.dom.broker.impl.NotificationRouterImpl;
-import org.opendaylight.controller.sal.dom.broker.impl.RpcRouterImpl;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
import org.opendaylight.controller.sal.dom.broker.spi.NotificationRouter;
-import org.opendaylight.controller.sal.dom.broker.spi.RpcRouter;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.InstanceIdentifierBuilder;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-public class MountPointImpl implements MountProvisionInstance {
+@Deprecated
+public class MountPointImpl implements MountProvisionInstance, SchemaContextProvider {
- private final RpcRouter rpcs;
- private final DataReaderRouter dataReader;
+ private final SchemaAwareRpcBroker rpcs;
+ private final DataBrokerImpl dataReader;
private final NotificationRouter notificationRouter;
- private final DataReader<InstanceIdentifier,CompositeNode> readWrapper;
-
-
- private final InstanceIdentifier mountPath;
+ private final DataReader<YangInstanceIdentifier,CompositeNode> readWrapper;
+
+
+ private final YangInstanceIdentifier mountPath;
- public MountPointImpl(InstanceIdentifier path) {
+ private SchemaContext schemaContext;
+
+ public MountPointImpl(final YangInstanceIdentifier path) {
this.mountPath = path;
- rpcs = new RpcRouterImpl("");
- dataReader = new DataReaderRouter();
+ rpcs = new SchemaAwareRpcBroker(path.toString(),this);
+ dataReader = new DataBrokerImpl();
notificationRouter = new NotificationRouterImpl();
readWrapper = new ReadWrapper();
}
- public InstanceIdentifier getMountPath() {
+ public YangInstanceIdentifier getMountPath() {
return mountPath;
}
- public DataReader<InstanceIdentifier, CompositeNode> getReadWrapper() {
+ public DataReader<YangInstanceIdentifier, CompositeNode> getReadWrapper() {
return readWrapper;
}
@Override
- public void publish(CompositeNode notification) {
+ public void publish(final CompositeNode notification) {
notificationRouter.publish(notification);
}
@Override
- public Registration<NotificationListener> addNotificationListener(QName notification, NotificationListener listener) {
+ public ListenerRegistration<NotificationListener> addNotificationListener(final QName notification, final NotificationListener listener) {
return notificationRouter.addNotificationListener(notification, listener);
}
@Override
- public CompositeNode readConfigurationData(InstanceIdentifier path) {
+ public CompositeNode readConfigurationData(final YangInstanceIdentifier path) {
return dataReader.readConfigurationData(path);
}
@Override
- public CompositeNode readOperationalData(InstanceIdentifier path) {
+ public CompositeNode readOperationalData(final YangInstanceIdentifier path) {
return dataReader.readOperationalData(path);
}
- public Registration<DataReader<InstanceIdentifier, CompositeNode>> registerOperationalReader(
- InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader) {
+ @Override
+ public Registration registerOperationalReader(
+ final YangInstanceIdentifier path, final DataReader<YangInstanceIdentifier, CompositeNode> reader) {
return dataReader.registerOperationalReader(path, reader);
}
- public Registration<DataReader<InstanceIdentifier, CompositeNode>> registerConfigurationReader(
- InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader) {
+ @Override
+ public Registration registerConfigurationReader(
+ final YangInstanceIdentifier path, final DataReader<YangInstanceIdentifier, CompositeNode> reader) {
return dataReader.registerConfigurationReader(path, reader);
}
@Override
- public RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation) {
+ public RoutedRpcRegistration addRoutedRpcImplementation(final QName rpcType, final RpcImplementation implementation) {
return rpcs.addRoutedRpcImplementation(rpcType, implementation);
}
@Override
- public RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation)
+ public void setRoutedRpcDefaultDelegate(final RoutedRpcDefaultImplementation defaultImplementation) {
+ rpcs.setRoutedRpcDefaultDelegate(defaultImplementation);
+ }
+
+ @Override
+ public RpcRegistration addRpcImplementation(final QName rpcType, final RpcImplementation implementation)
throws IllegalArgumentException {
return rpcs.addRpcImplementation(rpcType, implementation);
}
+ @Override
public Set<QName> getSupportedRpcs() {
return rpcs.getSupportedRpcs();
}
-
- public RpcResult<CompositeNode> invokeRpc(QName rpc, CompositeNode input) {
+ @Override
+ public ListenableFuture<RpcResult<CompositeNode>> invokeRpc(final QName rpc, final CompositeNode input) {
return rpcs.invokeRpc(rpc, input);
}
- public ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(RpcRegistrationListener listener) {
+ @Override
+ public ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(final RpcRegistrationListener listener) {
return rpcs.addRpcRegistrationListener(listener);
}
-
@Override
- public Future<RpcResult<CompositeNode>> rpc(QName type, CompositeNode input) {
- // TODO Auto-generated method stub
- return null;
+ public ListenableFuture<RpcResult<CompositeNode>> rpc(final QName type, final CompositeNode input) {
+ return rpcs.invokeRpc( type, input );
}
@Override
public DataModificationTransaction beginTransaction() {
- // TODO Auto-generated method stub
- return null;
+ return dataReader.beginTransaction();
}
@Override
- public ListenerRegistration<DataChangeListener> registerDataChangeListener(InstanceIdentifier path,
- DataChangeListener listener) {
- // TODO Auto-generated method stub
- return null;
+ public ListenerRegistration<DataChangeListener> registerDataChangeListener(final YangInstanceIdentifier path,
+ final DataChangeListener listener) {
+ return dataReader.registerDataChangeListener(path, listener);
}
@Override
- public void sendNotification(CompositeNode notification) {
- publish(notification);
+ public Registration registerCommitHandler(
+ final YangInstanceIdentifier path, final DataCommitHandler<YangInstanceIdentifier, CompositeNode> commitHandler) {
+ return dataReader.registerCommitHandler(path, commitHandler);
+ }
+
+ @Override
+ public void removeRefresher(final DataStoreIdentifier store, final DataRefresher refresher) {
+ // NOOP
}
-
+
@Override
- public Registration<DataCommitHandler<InstanceIdentifier, CompositeNode>> registerCommitHandler(
- InstanceIdentifier path, DataCommitHandler<InstanceIdentifier, CompositeNode> commitHandler) {
- // TODO Auto-generated method stub
- return null;
+ public void addRefresher(final DataStoreIdentifier store, final DataRefresher refresher) {
+ // NOOP
}
-
+
@Override
- public void removeRefresher(DataStoreIdentifier store, DataRefresher refresher) {
- // NOOP
+ public void addValidator(final DataStoreIdentifier store, final DataValidator validator) {
+ // NOOP
}
-
@Override
- public void addRefresher(DataStoreIdentifier store, DataRefresher refresher) {
- // NOOP
+ public void removeValidator(final DataStoreIdentifier store, final DataValidator validator) {
+ // NOOP
}
-
+
@Override
- public void addValidator(DataStoreIdentifier store, DataValidator validator) {
- // NOOP
+ public SchemaContext getSchemaContext() {
+ return schemaContext;
}
+
@Override
- public void removeValidator(DataStoreIdentifier store, DataValidator validator) {
- // NOOP
+ public void setSchemaContext(final SchemaContext schemaContext) {
+ this.schemaContext = schemaContext;
}
-
- class ReadWrapper implements DataReader<InstanceIdentifier, CompositeNode> {
-
-
- private InstanceIdentifier shortenPath(InstanceIdentifier path) {
- InstanceIdentifier ret = null;
- if(mountPath.contains(path)) {
- List<PathArgument> newArgs = path.getPath().subList(mountPath.getPath().size(), path.getPath().size());
- ret = new InstanceIdentifier(newArgs);
+
+ class ReadWrapper implements DataReader<YangInstanceIdentifier, CompositeNode> {
+ private YangInstanceIdentifier shortenPath(final YangInstanceIdentifier path) {
+ if (!mountPath.contains(path)) {
+ return null;
}
- return ret;
+
+ return YangInstanceIdentifier.create(Iterables.skip(path.getPathArguments(), Iterables.size(mountPath.getPathArguments())));
}
-
+
@Override
- public CompositeNode readConfigurationData(InstanceIdentifier path) {
- InstanceIdentifier newPath = shortenPath(path);
+ public CompositeNode readConfigurationData(final YangInstanceIdentifier path) {
+ YangInstanceIdentifier newPath = shortenPath(path);
if(newPath == null) {
return null;
}
return MountPointImpl.this.readConfigurationData(newPath);
}
-
+
@Override
- public CompositeNode readOperationalData(InstanceIdentifier path) {
- InstanceIdentifier newPath = shortenPath(path);
+ public CompositeNode readOperationalData(final YangInstanceIdentifier path) {
+ YangInstanceIdentifier newPath = shortenPath(path);
if(newPath == null) {
return null;
}
return MountPointImpl.this.readOperationalData(newPath);
}
}
+
+ @Override
+ public ListenerRegistration<RegistrationListener<DataCommitHandlerRegistration<YangInstanceIdentifier, CompositeNode>>> registerCommitHandlerListener(
+ final RegistrationListener<DataCommitHandlerRegistration<YangInstanceIdentifier, CompositeNode>> commitHandlerListener) {
+ return dataReader.registerCommitHandlerListener(commitHandlerListener);
+ }
+
+ @Override
+ public <L extends RouteChangeListener<RpcRoutingContext, YangInstanceIdentifier>> ListenerRegistration<L> registerRouteChangeListener(
+ final L listener) {
+ return rpcs.registerRouteChangeListener(listener);
+ }
}