2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.sal.core.compat;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ForwardingObject;
13 import com.google.common.util.concurrent.CheckedFuture;
14 import com.google.common.util.concurrent.ListenableFuture;
15 import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener;
16 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
17 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
18 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
19 import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
20 import org.opendaylight.yangtools.concepts.ListenerRegistration;
21 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
22 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
24 @Deprecated(forRemoval = true)
25 public class LegacyDOMRpcServiceAdapter extends ForwardingObject implements DOMRpcService {
26 private final org.opendaylight.mdsal.dom.api.DOMRpcService delegate;
28 public LegacyDOMRpcServiceAdapter(final org.opendaylight.mdsal.dom.api.DOMRpcService delegate) {
29 this.delegate = requireNonNull(delegate);
33 public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type,
34 final NormalizedNode<?, ?> input) {
35 final ListenableFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> future = delegate().invokeRpc(type, input);
36 return future instanceof MdsalDOMRpcResultFutureAdapter ? ((MdsalDOMRpcResultFutureAdapter)future).delegate()
37 : new LegacyDOMRpcResultFutureAdapter(future);
41 public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(final T listener) {
42 final ListenerRegistration<org.opendaylight.mdsal.dom.api.DOMRpcAvailabilityListener> reg =
43 delegate().registerRpcListener(new RpcAvailabilityListenerAdapter<>(listener));
45 return new AbstractListenerRegistration<T>(listener) {
47 protected void removeRegistration() {
54 protected org.opendaylight.mdsal.dom.api.DOMRpcService delegate() {