Refactor TransactonContext
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / AbstractRead.java
1 /*
2  * Copyright (c) 2015 Huawei, 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
9 package org.opendaylight.controller.cluster.datastore.messages;
10
11 import com.google.common.util.concurrent.CheckedFuture;
12 import com.google.common.util.concurrent.SettableFuture;
13 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
14 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16
17 /**
18  * Abstract base class for ReadData and DataExists messages.
19  *
20  * @author gwu
21  *
22  */
23 public abstract class AbstractRead<T> implements SerializableMessage {
24     private final YangInstanceIdentifier path;
25
26     public AbstractRead(final YangInstanceIdentifier path) {
27         this.path = path;
28     }
29
30     public YangInstanceIdentifier getPath() {
31         return path;
32     }
33
34     public abstract CheckedFuture<T, ReadFailedException> apply(DOMStoreReadTransaction readDelegate);
35
36     public abstract void processResponse(Object reponse, SettableFuture<T> promise);
37
38 }