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
8 package org.opendaylight.controller.cluster.access.concepts;
10 import com.google.common.annotations.Beta;
11 import java.io.IOException;
12 import java.io.ObjectInput;
13 import java.io.ObjectOutput;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.yangtools.concepts.WritableIdentifier;
18 * Abstract Externalizable proxy for use with {@link RequestFailure} subclasses.
20 * @author Robert Varga
22 * @param <T> Target identifier type
25 public abstract class AbstractRequestFailureProxy<T extends WritableIdentifier, C extends RequestFailure<T, C>>
26 extends AbstractResponseProxy<T, C> {
27 private static final long serialVersionUID = 1L;
28 private RequestException cause;
30 protected AbstractRequestFailureProxy() {
34 protected AbstractRequestFailureProxy(final @NonNull C failure) {
36 this.cause = failure.getCause();
40 public void writeExternal(final ObjectOutput out) throws IOException {
41 super.writeExternal(out);
42 out.writeObject(cause);
46 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
47 super.readExternal(in);
48 cause = (RequestException) in.readObject();
52 final C createResponse(final T target, final long sequence) {
53 return createFailure(target, sequence, cause);
56 protected abstract @NonNull C createFailure(@NonNull T target, long sequence,
57 @NonNull RequestException failureCause);