X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2Fmessages%2FRpcResponse.java;h=f141f09b3ccb42aa2f1adedb7c2299abba0e82da;hp=17766f15b9af7c22112852c16686c02684155924;hb=927bce5688e4b9d33d3e5e9b769d8a0dba5ccdd4;hpb=6d73d16b194435ea1ea783a37d1b51fc1f558a1f diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RpcResponse.java b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RpcResponse.java index 17766f15b9..f141f09b3c 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RpcResponse.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/messages/RpcResponse.java @@ -7,18 +7,53 @@ */ package org.opendaylight.controller.remote.rpc.messages; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import org.eclipse.jdt.annotation.Nullable; +import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils; +import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +public class RpcResponse extends AbstractResponse> { + private static final long serialVersionUID = -4211279498688989245L; -import java.io.Serializable; + public RpcResponse(final @Nullable NormalizedNode output) { + super(output); + } -public class RpcResponse implements Serializable { - private final String resultCompositeNode; + @Override + Object writeReplace() { + return new Proxy(this); + } - public RpcResponse(final String resultCompositeNode) { - this.resultCompositeNode = resultCompositeNode; - } + private static class Proxy implements Externalizable { + private static final long serialVersionUID = 1L; - public String getResultCompositeNode() { - return resultCompositeNode; - } + private RpcResponse rpcResponse; + + // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't + // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. + @SuppressWarnings("checkstyle:RedundantModifier") + public Proxy() { + } + + Proxy(final RpcResponse rpcResponse) { + this.rpcResponse = rpcResponse; + } + + @Override + public void writeExternal(final ObjectOutput out) throws IOException { + SerializationUtils.writeNormalizedNode(out, rpcResponse.getOutput()); + } + + @Override + public void readExternal(final ObjectInput in) throws IOException { + rpcResponse = new RpcResponse(SerializationUtils.readNormalizedNode(in).orElse(null)); + } + + private Object readResolve() { + return rpcResponse; + } + } }