import static java.util.Objects.requireNonNull;
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import javax.inject.Singleton;
-import org.opendaylight.mdsal.dom.api.DOMActionResult;
import org.opendaylight.mdsal.dom.api.DOMActionService;
-import org.opendaylight.mdsal.dom.api.DOMActionServiceExtension;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.sal.connect.api.DeviceActionFactory;
import org.opendaylight.netconf.sal.connect.api.MessageTransformer;
import org.opendaylight.netconf.sal.connect.api.RemoteDeviceCommunicator;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
public DOMActionService createDeviceAction(final MessageTransformer<NetconfMessage> messageTransformer,
final RemoteDeviceCommunicator<NetconfMessage> listener, final SchemaContext schemaContext) {
-
- return new DOMActionService() {
- @Override
- public ListenableFuture<? extends DOMActionResult> invokeAction(final Absolute schemaPath,
- final DOMDataTreeIdentifier dataTreeIdentifier, final ContainerNode input) {
- requireNonNull(schemaPath);
- requireNonNull(dataTreeIdentifier);
- requireNonNull(input);
-
- final ListenableFuture<RpcResult<NetconfMessage>> actionResultFuture = listener.sendRequest(
- messageTransformer.toActionRequest(schemaPath, dataTreeIdentifier, input), input.getNodeType());
-
- return Futures.transform(actionResultFuture, netconfMessageRpcResult -> {
- if (netconfMessageRpcResult != null) {
- return messageTransformer.toActionResult(schemaPath, netconfMessageRpcResult.getResult());
- } else {
- final String message = "Missing action result of action on schema path: " + schemaPath;
- LOG.error(message);
- throw new IllegalStateException(message);
- }
- }, MoreExecutors.directExecutor());
- }
-
- @Override
- public ClassToInstanceMap<DOMActionServiceExtension> getExtensions() {
- return ImmutableClassToInstanceMap.of();
- }
+ return (schemaPath, dataTreeIdentifier, input) -> {
+ requireNonNull(schemaPath);
+ requireNonNull(dataTreeIdentifier);
+ requireNonNull(input);
+
+ final ListenableFuture<RpcResult<NetconfMessage>> actionResultFuture = listener.sendRequest(
+ messageTransformer.toActionRequest(schemaPath, dataTreeIdentifier, input),
+ input.getIdentifier().getNodeType());
+
+ return Futures.transform(actionResultFuture, netconfMessageRpcResult -> {
+ if (netconfMessageRpcResult != null) {
+ return messageTransformer.toActionResult(schemaPath, netconfMessageRpcResult.getResult());
+ }
+
+ final String message = "Missing action result of action on schema path: " + schemaPath;
+ LOG.error(message);
+ throw new IllegalStateException(message);
+ }, MoreExecutors.directExecutor());
};
}
-}
\ No newline at end of file
+}