2 * Copyright (c) 2015 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.openflowplugin.impl.rpc;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import com.google.common.util.concurrent.SettableFuture;
12 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
13 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
14 import org.opendaylight.yangtools.yang.common.RpcResult;
16 public abstract class AbstractRequestContext<T> implements RequestContext<T> {
17 private final SettableFuture<RpcResult<T>> rpcResultFuture = SettableFuture.create();
18 private final Xid xid;
19 private long waitTimeout;
21 protected AbstractRequestContext(final Long xid) {
22 this.xid = xid == null ? null : new Xid(xid);
26 public final ListenableFuture<RpcResult<T>> getFuture() {
27 return rpcResultFuture;
31 public final void setResult(final RpcResult<T> result) {
32 rpcResultFuture.set(result);
36 public final Xid getXid() {
41 public final long getWaitTimeout() {
46 public final void setWaitTimeout(final long waitTimeout) {
47 this.waitTimeout = waitTimeout;