All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opendaylight.ocpplugin.impl.rpc.AbstractRequestContext Maven / Gradle / Ivy

/*
 * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.ocpplugin.impl.rpc;

import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import org.opendaylight.ocpplugin.api.ocp.device.RequestContext;
import org.opendaylight.ocpplugin.api.ocp.device.Xid;
import org.opendaylight.yangtools.yang.common.RpcResult;

public abstract class AbstractRequestContext implements RequestContext {
    private final SettableFuture> rpcResultFuture = SettableFuture.create();
    private final Xid xid;
    private long waitTimeout;

    protected AbstractRequestContext(final Long xid) {
        this.xid = xid == null ? null : new Xid(xid);
    }

    @Override
    public final ListenableFuture> getFuture() {
        return rpcResultFuture;
    }

    @Override
    public final void setResult(final RpcResult result) {
        rpcResultFuture.set(result);
    }

    @Override
    public final Xid getXid() {
        return xid;
    }

    @Override
    public final long getWaitTimeout() {
        return waitTimeout;
    }

    @Override
    public final void setWaitTimeout(final long waitTimeout) {
        this.waitTimeout = waitTimeout;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy