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 akka.actor.ActorRef;
12 public final class RequestEnvelope extends Envelope<Request<?, ?>> {
13 private static final long serialVersionUID = 1L;
15 public RequestEnvelope(final Request<?, ?> message, final long sequence, final long retry) {
16 super(message, sequence, retry);
20 RequestEnvelopeProxy createProxy() {
21 return new RequestEnvelopeProxy(this);
25 * Respond to this envelope with a {@link RequestFailure} caused by specified {@link RequestException}.
27 * @param cause Cause of this {@link RequestFailure}
28 * @throws NullPointerException if cause is null
30 public void sendFailure(final RequestException cause) {
31 sendResponse(new FailureEnvelope(getMessage().toRequestFailure(cause), getSequence(), getRetry()));
35 * Respond to this envelope with a {@link RequestSuccess}.
37 * @param success Successful response
38 * @throws NullPointerException if success is null
40 public void sendSuccess(final RequestSuccess<?, ?> success) {
41 sendResponse(new SuccessEnvelope(success, getSequence(), getRetry()));
44 private void sendResponse(final ResponseEnvelope<?> envelope) {
45 getMessage().getReplyTo().tell(envelope, ActorRef.noSender());