2 * Copyright (c) 2016 Cisco Systems, Inc. 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
9 package org.opendaylight.netconf.topology.singleton.messages.rpc;
11 import java.io.Externalizable;
12 import java.io.IOException;
13 import java.io.ObjectInput;
14 import java.io.ObjectOutput;
15 import java.io.Serializable;
16 import org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage;
17 import org.opendaylight.netconf.topology.singleton.messages.SchemaPathMessage;
18 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
20 public class InvokeRpcMessage implements Serializable {
21 private static final long serialVersionUID = 1L;
23 private final SchemaPathMessage schemaPathMessage;
24 private final NormalizedNodeMessage normalizedNodeMessage;
26 public InvokeRpcMessage(final SchemaPathMessage schemaPathMessage,
27 final NormalizedNodeMessage normalizedNodeMessage) {
28 this.schemaPathMessage = schemaPathMessage;
29 this.normalizedNodeMessage = normalizedNodeMessage;
31 private SchemaPathMessage getSchemaPathMessage() {
32 return schemaPathMessage;
35 public SchemaPath getSchemaPath() {
36 return schemaPathMessage.getSchemaPath();
39 public NormalizedNodeMessage getNormalizedNodeMessage() {
40 return normalizedNodeMessage;
43 private Object writeReplace() {
44 return new Proxy(this);
47 private static class Proxy implements Externalizable {
48 private static final long serialVersionUID = 2L;
50 private InvokeRpcMessage invokeRpcMessage;
53 //due to Externalizable
56 Proxy(final InvokeRpcMessage invokeRpcMessage) {
57 this.invokeRpcMessage = invokeRpcMessage;
61 public void writeExternal(final ObjectOutput out) throws IOException {
62 out.writeObject(invokeRpcMessage.getSchemaPathMessage());
63 out.writeObject(invokeRpcMessage.getNormalizedNodeMessage());
67 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
68 invokeRpcMessage = new InvokeRpcMessage((SchemaPathMessage) in.readObject(),
69 (NormalizedNodeMessage) in.readObject());
72 private Object readResolve() {
73 return invokeRpcMessage;