--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.api;
+
+import java.util.Collection;
+import java.util.EventListener;
+import javax.annotation.Nonnull;
+
+/**
+ * An {@link EventListener} used to track RPC implementations becoming (un)available
+ * to a {@link DOMRpcService}.
+ */
+public interface DOMRpcAvailabilityListener extends EventListener {
+ /**
+ * Method invoked whenever an RPC type becomes available.
+ *
+ * @param rpcs RPC types newly available
+ */
+ void onRpcAvailable(@Nonnull Collection<DOMRpcIdentifier> rpcs);
+
+ /**
+ * Method invoked whenever an RPC type becomes unavailable.
+ *
+ * @param rpcs RPC types which became unavailable
+ */
+ void onRpcUnavailable(@Nonnull Collection<DOMRpcIdentifier> rpcs);
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.api;
+
+/**
+ * Base class for failures that can occur during RPC invocation. This covers
+ * transport and protocol-level failures.
+ */
+public abstract class DOMRpcException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct an new instance with a message and an empty cause.
+ *
+ * @param message Exception message
+ */
+ protected DOMRpcException(final String message) {
+ super(message);
+ }
+
+ /**
+ * Construct an new instance with a message and a cause.
+ *
+ * @param message Exception message
+ * @param cause Chained cause
+ */
+ protected DOMRpcException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.api;
+
+import com.google.common.base.Preconditions;
+import java.util.Objects;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+/**
+ * Identifier of a RPC context. This is an extension of the YANG RPC, which
+ * always has global context. It allows an RPC to have a instance identifier
+ * attached, so that there can be multiple implementations bound to different
+ * contexts concurrently.
+ */
+public abstract class DOMRpcIdentifier {
+ private static final class Global extends DOMRpcIdentifier {
+ private Global(final @Nonnull SchemaPath type) {
+ super(type);
+ }
+
+ @Override
+ public YangInstanceIdentifier getContextReference() {
+ return null;
+ }
+ }
+
+ private static final class Local extends DOMRpcIdentifier {
+ private final YangInstanceIdentifier contextReference;
+
+ private Local(final @Nonnull SchemaPath type, final @Nonnull YangInstanceIdentifier contextReference) {
+ super(type);
+ this.contextReference = Preconditions.checkNotNull(contextReference);
+ }
+
+ @Override
+ public YangInstanceIdentifier getContextReference() {
+ return contextReference;
+ }
+ }
+
+ private final SchemaPath type;
+
+ private DOMRpcIdentifier(final SchemaPath type) {
+ this.type = Preconditions.checkNotNull(type);
+ }
+
+ /**
+ * Create a global RPC identifier.
+ *
+ * @param type RPC type, SchemaPath of its definition, may not be null
+ * @return A global RPC identifier, guaranteed to be non-null.
+ */
+ public static @Nonnull DOMRpcIdentifier create(final @Nonnull SchemaPath type) {
+ return new Global(type);
+ }
+
+ /**
+ * Create an RPC identifier with a particular context reference.
+ *
+ * @param type RPC type, SchemaPath of its definition, may not be null
+ * @param contextReference Context reference, null means a global RPC identifier.
+ * @return A global RPC identifier, guaranteed to be non-null.
+ */
+ public static @Nonnull DOMRpcIdentifier create(final @Nonnull SchemaPath type, final @Nullable YangInstanceIdentifier contextReference) {
+ if (contextReference == null) {
+ return new Global(type);
+ } else {
+ return new Local(type, contextReference);
+ }
+ }
+
+ /**
+ * Return the RPC type.
+ *
+ * @return RPC type.
+ */
+ public final @Nonnull SchemaPath getType() {
+ return type;
+ }
+
+ /**
+ * Return the RPC context reference. Null value indicates global context.
+ *
+ * @return RPC context reference.
+ */
+ public abstract @Nullable YangInstanceIdentifier getContextReference();
+
+ @Override
+ public final int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + type.hashCode();
+ result = prime * result + (getContextReference() == null ? 0 : getContextReference().hashCode());
+ return result;
+ }
+
+ @Override
+ public final boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof DOMRpcIdentifier)) {
+ return false;
+ }
+ DOMRpcIdentifier other = (DOMRpcIdentifier) obj;
+ if (!type.equals(other.type)) {
+ return false;
+ }
+ return Objects.equals(getContextReference(), other.getContextReference());
+ }
+
+ @Override
+ public final String toString() {
+ return com.google.common.base.Objects.toStringHelper(this).omitNullValues().add("type", type).add("contextReference", getContextReference()).toString();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.api;
+
+import com.google.common.util.concurrent.CheckedFuture;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * Interface implemented by an individual RPC implementation. This API allows for dispatch
+ * implementations, e.g. an individual object handling a multitude of RPCs.
+ */
+public interface DOMRpcImplementation {
+ /**
+ * Initiate invocation of the RPC. Implementations of this method are
+ * expected to not block on external resources.
+ *
+ * @param rpc RPC identifier which was invoked
+ * @param input Input arguments, null if the RPC does not take any.
+ * @return A {@link CheckedFuture} which will return either a result structure,
+ * or report a subclass of {@link DOMRpcException} reporting a transport
+ * error.
+ */
+ @Nonnull CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull DOMRpcIdentifier rpc, @Nullable NormalizedNode<?, ?> input);
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.api;
+
+import com.google.common.base.Preconditions;
+import javax.annotation.Nonnull;
+
+/**
+ * Exception indicating that no implementation of the requested RPC service is available.
+ */
+public class DOMRpcImplementationNotAvailableException extends DOMRpcException {
+ private static final long serialVersionUID = 1L;
+
+ public DOMRpcImplementationNotAvailableException(@Nonnull final String format, final Object... args) {
+ super(String.format(format, args));
+ }
+
+ public DOMRpcImplementationNotAvailableException(@Nonnull final Throwable cause, @Nonnull final String format, final Object... args) {
+ super(String.format(format, args), Preconditions.checkNotNull(cause));
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.api;
+
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+
+/**
+ * A registration of a {@link DOMRpcImplementation}. Used to track and revoke a registration
+ * with a {@link DOMRpcProviderService}.
+ *
+ * @param <T> RPC implementation type
+ */
+public interface DOMRpcImplementationRegistration<T extends DOMRpcImplementation> extends ObjectRegistration<T> {
+ @Override
+ void close();
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.api;
+
+import java.util.Set;
+import javax.annotation.Nonnull;
+
+/**
+ * A {@link DOMService} which allows registration of RPC implementations with a conceptual
+ * router. The client counterpart of this service is {@link DOMRpcService}.
+ */
+public interface DOMRpcProviderService extends DOMService {
+ /**
+ * Register an {@link DOMRpcImplementation} object with this service.
+ *
+ * @param implementation RPC implementation, must not be null
+ * @param rpcs Array of supported RPC identifiers. Must not be null, empty, or contain a null element.
+ * Each identifier is added exactly once, no matter how many times it occurs.
+ * @return A {@link DOMRpcImplementationRegistration} object, guaranteed to be non-null.
+ * @throws NullPointerException if implementation or types is null
+ * @throws IllegalArgumentException if types is empty or contains a null element.
+ */
+ @Nonnull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(@Nonnull T implementation, @Nonnull DOMRpcIdentifier... rpcs);
+
+ /**
+ * Register an {@link DOMRpcImplementation} object with this service.
+ *
+ * @param implementation RPC implementation, must not be null
+ * @param rpcs Set of supported RPC identifiers. Must not be null, empty, or contain a null element.
+ * @return A {@link DOMRpcImplementationRegistration} object, guaranteed to be non-null.
+ * @throws NullPointerException if implementation or types is null
+ * @throws IllegalArgumentException if types is empty or contains a null element.
+ */
+ @Nonnull <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(@Nonnull T implementation, @Nonnull Set<DOMRpcIdentifier> rpcs);
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.api;
+
+import java.util.Collection;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * Interface defining a result of an RPC call.
+ */
+public interface DOMRpcResult {
+ /**
+ * Returns a set of errors and warnings which occurred during processing
+ * the call.
+ *
+ * @return a Collection of {@link RpcError}, guaranteed to be non-null. In case
+ * no errors are reported, an empty collection is returned.
+ */
+ @Nonnull Collection<RpcError> getErrors();
+
+ /**
+ * Returns the value result of the call or null if no result is available.
+ *
+ * @return Invocation result, null if the operation has not produced a result. This might
+ * be the case if the operation does not produce a result, or if it failed.
+ */
+ @Nullable NormalizedNode<?, ?> getResult();
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.api;
+
+import com.google.common.util.concurrent.CheckedFuture;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+/**
+ * A {@link DOMService} which allows clients to invoke RPCs. The conceptual model of this
+ * service is that of a dynamic router, where the set of available RPC services can change
+ * dynamically. The service allows users to add a listener to track the process of
+ * RPCs becoming available.
+ */
+public interface DOMRpcService extends DOMService {
+ /**
+ * Initiate invocation of an RPC. This method is guaranteed to not block on any external
+ * resources.
+ *
+ * @param type SchemaPath of the RPC to be invoked
+ * @param input Input arguments, null if the RPC does not take any.
+ * @return A {@link CheckedFuture} which will return either a result structure,
+ * or report a subclass of {@link DOMRpcException} reporting a transport
+ * error.
+ */
+ @Nonnull CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull SchemaPath type, @Nullable NormalizedNode<?, ?> input);
+
+ /**
+ * Register a {@link DOMRpcAvailabilityListener} with this service to receive notifications
+ * about RPC implementations becoming (un)available. The listener will be invoked with the
+ * current implementations reported and will be kept uptodate as implementations come and go.
+ *
+ * Users should note that using a listener does not necessarily mean that {@link #invokeRpc(SchemaPath, NormalizedNode)}
+ * will not report a failure due to {@link DOMRpcImplementationNotAvailableException} and
+ * need to be ready to handle it. Implementations are encouraged to take reasonable precautions
+ * to prevent this scenario from occurring.
+ *
+ * @param listener {@link DOMRpcAvailabilityListener} instance to register
+ * @return A {@link DOMRpcAvailabilityListenerRegistration} representing this registration. Performing
+ * a {@link DOMRpcAvailabilityListenerRegistration#close()} will cancel it. Returned object
+ * is guaranteed to be non-null.
+ */
+ @Nonnull <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(@Nonnull T listener);
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.spi;
+
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
+import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
+
+/**
+ * Abstract base class for {@link DOMRpcImplementationRegistration} implementations.
+ */
+public abstract class AbstractDOMRpcImplementationRegistration<T extends DOMRpcImplementation> extends AbstractObjectRegistration<T> implements DOMRpcImplementationRegistration<T> {
+ protected AbstractDOMRpcImplementationRegistration(final T instance) {
+ super(instance);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.spi;
+
+import com.google.common.collect.ImmutableSet;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
+
+/**
+ * Convenience abstract base class for {@link DOMRpcProviderService} implementations.
+ */
+public abstract class AbstractDOMRpcProviderService implements DOMRpcProviderService {
+ @Override
+ public final <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(final T implementation, final DOMRpcIdentifier... types) {
+ return registerRpcImplementation(implementation, ImmutableSet.copyOf(types));
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.spi;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Preconditions;
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Objects;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * Utility class implementing {@link DefaultDOMRpcResult}.
+ */
+@Beta
+public final class DefaultDOMRpcResult implements DOMRpcResult, Immutable, Serializable {
+ private static final long serialVersionUID = 1L;
+ private final Collection<RpcError> errors;
+ private final NormalizedNode<?, ?> result;
+
+ private static Collection<RpcError> asCollection(final RpcError... errors) {
+ if (errors.length == 0) {
+ return Collections.emptyList();
+ } else {
+ return Arrays.asList(errors);
+ }
+ }
+
+ public DefaultDOMRpcResult(final NormalizedNode<?, ?> result, final RpcError... errors) {
+ this(result, asCollection(errors));
+ }
+
+ public DefaultDOMRpcResult(final RpcError... errors) {
+ this(null, asCollection(errors));
+ }
+
+ public DefaultDOMRpcResult(final NormalizedNode<?, ?> result) {
+ this(result, Collections.<RpcError>emptyList());
+ }
+
+ public DefaultDOMRpcResult(final NormalizedNode<?, ?> result, final @Nonnull Collection<RpcError> errors) {
+ this.result = result;
+ this.errors = Preconditions.checkNotNull(errors);
+ }
+
+ public DefaultDOMRpcResult(final @Nonnull Collection<RpcError> errors) {
+ this(null, errors);
+ }
+
+ @Override
+ public @Nonnull Collection<RpcError> getErrors() {
+ return errors;
+ }
+
+ @Override
+ public NormalizedNode<?, ?> getResult() {
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ int ret = errors.hashCode();
+ if (result != null) {
+ ret = 31 * ret + result.hashCode();
+ }
+ return ret;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof DefaultDOMRpcResult)) {
+ return false;
+ }
+
+ final DefaultDOMRpcResult other = (DefaultDOMRpcResult) obj;
+ if (!errors.equals(other.errors)) {
+ return false;
+ }
+ return Objects.equals(result, other.result);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.spi;
+
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.CheckedFuture;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * Utility implementation which implements {@link DOMRpcImplementation} by forwarding it to
+ * a backing delegate.
+ */
+public abstract class ForwardingDOMRpcImplementation extends ForwardingObject implements DOMRpcImplementation {
+ @Override
+ protected abstract @Nonnull DOMRpcImplementation delegate();
+
+ @Override
+ public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final DOMRpcIdentifier type, final NormalizedNode<?, ?> input) {
+ return delegate().invokeRpc(type, input);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.spi;
+
+import com.google.common.collect.ForwardingObject;
+import java.util.Set;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationRegistration;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
+
+/**
+ * Utility class which implements {@link DOMRpcProviderService} by forwarding
+ * requests to a backing instance.
+ */
+public abstract class ForwardingDOMRpcProviderService extends ForwardingObject implements DOMRpcProviderService {
+ @Override
+ protected abstract @Nonnull DOMRpcProviderService delegate();
+
+ @Override
+ public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(final T implementation, final DOMRpcIdentifier... types) {
+ return delegate().registerRpcImplementation(implementation, types);
+ }
+
+ @Override
+ public <T extends DOMRpcImplementation> DOMRpcImplementationRegistration<T> registerRpcImplementation(final T implementation, final Set<DOMRpcIdentifier> types) {
+ return delegate().registerRpcImplementation(implementation, types);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.spi;
+
+import com.google.common.collect.ForwardingObject;
+import java.util.Collection;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+
+/**
+ * Utility class which implements {@link DOMRpcResult} by forwarding all methods
+ * to a backing instance.
+ */
+public abstract class ForwardingDOMRpcResult extends ForwardingObject implements DOMRpcResult {
+ @Override
+ protected abstract @Nonnull DOMRpcResult delegate();
+
+ @Override
+ public Collection<RpcError> getErrors() {
+ return delegate().getErrors();
+ }
+
+ @Override
+ public NormalizedNode<?, ?> getResult() {
+ return delegate().getResult();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.md.sal.dom.spi;
+
+import com.google.common.collect.ForwardingObject;
+import com.google.common.util.concurrent.CheckedFuture;
+import javax.annotation.Nonnull;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+/**
+ * Utility {@link DOMRpcService} which forwards all requests to a backing delegate instance.
+ */
+public abstract class ForwardingDOMRpcService extends ForwardingObject implements DOMRpcService {
+ @Override
+ protected abstract @Nonnull DOMRpcService delegate();
+
+ @Override
+ public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
+ return delegate().invokeRpc(type, input);
+ }
+
+ @Override
+ public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(final T listener) {
+ return delegate().registerRpcListener(listener);
+ }
+}