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 import com
.google
.appengine
.spi
.ServiceFactoryFactory
;
11 * Creates DatastoreService implementations.
14 public final class DatastoreServiceFactory
{
17 * Creates a {@code DatastoreService} using the provided config.
19 public static DatastoreService
getDatastoreService(DatastoreServiceConfig config
) {
20 return getFactory().getDatastoreService(config
);
24 * Creates an {@code AsyncDatastoreService} using the provided config. The async datastore service
25 * does not support implicit transaction management policy
26 * {@link ImplicitTransactionManagementPolicy#AUTO}.
28 * @throws IllegalArgumentException If the provided {@link DatastoreServiceConfig} has an implicit
29 * transaction management policy of {@link ImplicitTransactionManagementPolicy#AUTO}.
31 public static AsyncDatastoreService
getAsyncDatastoreService(DatastoreServiceConfig config
) {
32 return getFactory().getAsyncDatastoreService(config
);
36 * Creates a {@code DatastoreService} using the default config (
37 * {@link DatastoreServiceConfig.Builder#withDefaults()}).
39 public static DatastoreService
getDatastoreService() {
40 return getDatastoreService(withDefaults());
44 * Creates an {@code AsyncDatastoreService} using the default config (
45 * {@link DatastoreServiceConfig.Builder#withDefaults()}).
47 public static AsyncDatastoreService
getAsyncDatastoreService() {
48 return getAsyncDatastoreService(withDefaults());
52 * Creates a {@code DatastoreService} using the provided config.
54 * @deprecated Use {@link #getDatastoreService(DatastoreServiceConfig)} instead.
57 public static DatastoreService
getDatastoreService(DatastoreConfig oldConfig
) {
58 ImplicitTransactionManagementPolicy policy
= oldConfig
.getImplicitTransactionManagementPolicy();
59 DatastoreServiceConfig newConfig
= withImplicitTransactionManagementPolicy(policy
);
60 return getDatastoreService(newConfig
);
64 * @deprecated Use {@link DatastoreServiceConfig.Builder#withDefaults()} instead.
67 public static DatastoreConfig
getDefaultDatastoreConfig() {
68 return DatastoreConfig
.DEFAULT
;
72 * @deprecated Exposed by accident, do not instantiate.
75 public DatastoreServiceFactory() {}
77 private static IDatastoreServiceFactory
getFactory() {
78 return ServiceFactoryFactory
.getFactory(IDatastoreServiceFactory
.class);