Revision created by MOE tool push_codebase.
[gae.git] / java / src / main / com / google / appengine / api / datastore / DatastoreServiceFactory.java
blob8a9c3266292f20b5b6e67cec1d6eaaa77aabb937
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;
10 /**
11 * Creates DatastoreService implementations.
14 public final class DatastoreServiceFactory {
16 /**
17 * Creates a {@code DatastoreService} using the provided config.
19 public static DatastoreService getDatastoreService(DatastoreServiceConfig config) {
20 return getFactory().getDatastoreService(config);
23 /**
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);
35 /**
36 * Creates a {@code DatastoreService} using the default config (
37 * {@link DatastoreServiceConfig.Builder#withDefaults()}).
39 public static DatastoreService getDatastoreService() {
40 return getDatastoreService(withDefaults());
43 /**
44 * Creates an {@code AsyncDatastoreService} using the default config (
45 * {@link DatastoreServiceConfig.Builder#withDefaults()}).
47 public static AsyncDatastoreService getAsyncDatastoreService() {
48 return getAsyncDatastoreService(withDefaults());
51 /**
52 * Creates a {@code DatastoreService} using the provided config.
54 * @deprecated Use {@link #getDatastoreService(DatastoreServiceConfig)} instead.
56 @Deprecated
57 public static DatastoreService getDatastoreService(DatastoreConfig oldConfig) {
58 ImplicitTransactionManagementPolicy policy = oldConfig.getImplicitTransactionManagementPolicy();
59 DatastoreServiceConfig newConfig = withImplicitTransactionManagementPolicy(policy);
60 return getDatastoreService(newConfig);
63 /**
64 * @deprecated Use {@link DatastoreServiceConfig.Builder#withDefaults()} instead.
66 @Deprecated
67 public static DatastoreConfig getDefaultDatastoreConfig() {
68 return DatastoreConfig.DEFAULT;
71 /**
72 * @deprecated Exposed by accident, do not instantiate.
74 @Deprecated
75 public DatastoreServiceFactory() {}
77 private static IDatastoreServiceFactory getFactory() {
78 return ServiceFactoryFactory.getFactory(IDatastoreServiceFactory.class);