Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / datastore / DatastoreServiceFactory.java
blobe0f0e64287cb0307e2bf06ea8222868e425c1bf1
1 // Copyright 2008 Google Inc. All rights reserved.
3 package com.google.appengine.api.datastore;
5 import static com.google.appengine.api.datastore.DatastoreServiceConfig.Builder.withDefaults;
6 import static com.google.appengine.api.datastore.DatastoreServiceConfig.Builder.withImplicitTransactionManagementPolicy;
8 /**
9 * Creates DatastoreService implementations.
12 public final class DatastoreServiceFactory {
14 /**
15 * @deprecated Exposed by accident, do not instantiate.
17 @Deprecated
18 public DatastoreServiceFactory() { }
20 /**
21 * Creates a {@code DatastoreService} using the default config
22 * ({@link DatastoreServiceConfig.Builder#withDefaults()}).
24 public static DatastoreService getDatastoreService() {
25 return getDatastoreService(withDefaults());
28 /**
29 * Creates a {@code AsyncDatastoreService} using the default config
30 * ({@link DatastoreServiceConfig.Builder#withDefaults()}).
32 public static AsyncDatastoreService getAsyncDatastoreService() {
33 return getAsyncDatastoreService(withDefaults());
36 /**
37 * Creates a {@code DatastoreService} using the provided config.
38 * @deprecated Use {@link #getDatastoreService(DatastoreServiceConfig)}
39 * instead.
41 @Deprecated
42 public static DatastoreService getDatastoreService(DatastoreConfig oldConfig) {
43 DatastoreServiceConfig newConfig =
44 withImplicitTransactionManagementPolicy(oldConfig.getImplicitTransactionManagementPolicy());
45 return getDatastoreService(newConfig);
48 /**
49 * Creates a {@code DatastoreService} using the provided config.
51 public static DatastoreService getDatastoreService(DatastoreServiceConfig config) {
52 return new DatastoreServiceImpl(config, new TransactionStackImpl());
55 /**
56 * Creates a {@code AsyncDatastoreService} using the provided config. The
57 * async datastore service does not support implicit transaction management
58 * policy {@link ImplicitTransactionManagementPolicy#AUTO}.
60 * @throws IllegalArgumentException If the provided {@link
61 * DatastoreServiceConfig} has an implicit transaction management policy of
62 * {@link ImplicitTransactionManagementPolicy#AUTO}.
64 public static AsyncDatastoreService getAsyncDatastoreService(DatastoreServiceConfig config) {
65 return new AsyncDatastoreServiceImpl(config, new TransactionStackImpl());
68 /**
69 * @deprecated Use {@link DatastoreServiceConfig.Builder#withDefaults()}
70 * instead.
72 @Deprecated
73 public static DatastoreConfig getDefaultDatastoreConfig() {
74 return DatastoreConfig.DEFAULT;