Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / datastore / InternalTransactionCloudDatastore.java
blob1cf168698223851e0434d4e672596614a18f0a46
1 package com.google.appengine.api.datastore;
3 import com.google.apphosting.datastore.DatastoreV4.BeginTransactionResponse;
4 import com.google.apphosting.datastore.DatastoreV4.CommitRequest;
5 import com.google.apphosting.datastore.DatastoreV4.Mutation;
7 import java.util.Collection;
8 import java.util.concurrent.Future;
10 /**
11 * Stores transaction state as java proto objects, with the expectation that the
12 * {@link DatastoreV4Proxy} will need to inspect a deserialized version of the commit.
14 class InternalTransactionCloudDatastore extends BaseInternalTransactionV4<Mutation> {
15 /**
16 * Objects should be created with {@link #create(DatastoreV4Proxy, Future)} due
17 * to post-construction manipulation.
19 private InternalTransactionCloudDatastore(DatastoreV4Proxy dsApiProxy,
20 Future<BeginTransactionResponse> beginTxnFuture) {
21 super(dsApiProxy, beginTxnFuture);
24 static TransactionImpl.InternalTransaction create(DatastoreV4Proxy dsApiProxy,
25 Future<BeginTransactionResponse> future) {
26 return registerTxn(new InternalTransactionCloudDatastore(dsApiProxy, future));
29 @Override
30 Mutation serializeMutation(Mutation mutation) {
31 return mutation;
34 @Override
35 Future<?> sendCommit(Collection<Mutation> mutations) {
36 return dsApiProxy.commit(CommitRequest.newBuilder()
37 .setTransaction(getHandle())
38 .addAllMutation(mutations)
39 .build());