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
;
9 * Creates DatastoreService implementations.
12 public final class DatastoreServiceFactory
{
15 * @deprecated Exposed by accident, do not instantiate.
18 public DatastoreServiceFactory() { }
21 * Creates a {@code DatastoreService} using the default config
22 * ({@link DatastoreServiceConfig.Builder#withDefaults()}).
24 public static DatastoreService
getDatastoreService() {
25 return getDatastoreService(withDefaults());
29 * Creates a {@code AsyncDatastoreService} using the default config
30 * ({@link DatastoreServiceConfig.Builder#withDefaults()}).
32 public static AsyncDatastoreService
getAsyncDatastoreService() {
33 return getAsyncDatastoreService(withDefaults());
37 * Creates a {@code DatastoreService} using the provided config.
38 * @deprecated Use {@link #getDatastoreService(DatastoreServiceConfig)}
42 public static DatastoreService
getDatastoreService(DatastoreConfig oldConfig
) {
43 DatastoreServiceConfig newConfig
=
44 withImplicitTransactionManagementPolicy(oldConfig
.getImplicitTransactionManagementPolicy());
45 return getDatastoreService(newConfig
);
49 * Creates a {@code DatastoreService} using the provided config.
51 public static DatastoreService
getDatastoreService(DatastoreServiceConfig config
) {
52 return new DatastoreServiceImpl(config
, new TransactionStackImpl());
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());
69 * @deprecated Use {@link DatastoreServiceConfig.Builder#withDefaults()}
73 public static DatastoreConfig
getDefaultDatastoreConfig() {
74 return DatastoreConfig
.DEFAULT
;