4208ca9f3d30786d5a864b65a41ea47cc75ab6c9
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / rpc / AbstractRequestContext.java
1 /**
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.impl.rpc;
9
10 import com.google.common.util.concurrent.SettableFuture;
11 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
12 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
13 import org.opendaylight.yangtools.yang.common.RpcResult;
14
15 public abstract class AbstractRequestContext<T> implements RequestContext<T> {
16     private SettableFuture<RpcResult<T>> rpcResultFuture;
17     private long waitTimeout;
18     private Xid xid;
19
20     protected AbstractRequestContext() {
21
22     }
23
24     @Override
25     public SettableFuture<RpcResult<T>> getFuture() {
26         if (null == rpcResultFuture) {
27             rpcResultFuture = SettableFuture.create();
28         }
29         return rpcResultFuture;
30     }
31
32     @Override
33     public Xid getXid() {
34         return xid;
35     }
36
37     @Override
38     public void setXid(final Xid xid) {
39         this.xid = xid;
40     }
41
42     @Override
43     public long getWaitTimeout() {
44         return waitTimeout;
45     }
46
47     @Override
48     public void setWaitTimeout(final long waitTimeout) {
49         this.waitTimeout = waitTimeout;
50     }
51 }