*/
package org.opendaylight.netconf.sal.connect.netconf.sal;
-import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
*/
public final class NetconfDeviceRpc implements DOMRpcService {
- private final RemoteDeviceCommunicator<NetconfMessage> listener;
+ private final RemoteDeviceCommunicator<NetconfMessage> communicator;
private final MessageTransformer<NetconfMessage> transformer;
private final Collection<DOMRpcIdentifier> availableRpcs;
- public NetconfDeviceRpc(final SchemaContext schemaContext, final RemoteDeviceCommunicator<NetconfMessage> listener,
- final MessageTransformer<NetconfMessage> transformer) {
- this.listener = listener;
+ public NetconfDeviceRpc(final SchemaContext schemaContext,
+ final RemoteDeviceCommunicator<NetconfMessage> communicator,
+ final MessageTransformer<NetconfMessage> transformer) {
+ this.communicator = communicator;
this.transformer = transformer;
availableRpcs = Collections2.transform(schemaContext.getOperations(),
@Nullable final NormalizedNode<?, ?> input) {
final NetconfMessage message = transformer.toRpcRequest(type, input);
final ListenableFuture<RpcResult<NetconfMessage>> delegateFutureWithPureResult =
- listener.sendRequest(message, type.getLastComponent());
+ communicator.sendRequest(message, type.getLastComponent());
final ListenableFuture<DOMRpcResult> transformed =
Futures.transform(delegateFutureWithPureResult, input1 -> {
}
}, MoreExecutors.directExecutor());
- return Futures.makeChecked(transformed, new Function<Exception, DOMRpcException>() {
- @Nullable
- @Override
- public DOMRpcException apply(@Nullable final Exception exception) {
- return new DOMRpcImplementationNotAvailableException(exception, "Unable to invoke rpc %s", type);
- }
- });
+ return Futures.makeChecked(transformed, exception ->
+ new DOMRpcImplementationNotAvailableException(exception, "Unable to invoke rpc %s", type));
}
@Nonnull