com.google.appengine.api.datastore
Class CloudDatastoreRemoteServiceConfig
- java.lang.Object
-
- com.google.appengine.api.datastore.CloudDatastoreRemoteServiceConfig
-
public abstract class CloudDatastoreRemoteServiceConfig extends java.lang.Object
User-configurable global properties of Cloud Datastore.Code not running in App Engine Standard can use the Cloud Datastore API by making a single call to
setConfig(com.google.appengine.api.datastore.CloudDatastoreRemoteServiceConfig)
before accessing any other classes fromcom.google.appengine.api
. For example: Outside of tests, the config should not be cleared once it has been set. In tests, the config can be cleared by callingpublic static void main(Strings[] args) { CloudDatastoreRemoteServiceConfig config = CloudDatastoreRemoteServiceConfig.builder() .appId(AppId.create(Location.US_CENTRAL, "my-project-id")) .build(); CloudDatastoreRemoteServiceConfig.setConfig(config); DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); ... }
clear()
: By default, this configuration uses application-default credentials.@Before public void before() { CloudDatastoreRemoteServiceConfig config = CloudDatastoreRemoteServiceConfig.builder() .appId(AppId.create(Location.US_CENTRAL, "my-project-id")) .emulatorHost(...) .build(); CloudDatastoreRemoteServiceConfig.setConfig(config); } @After public void after() { CloudDatastoreRemoteServiceConfig.clear(); }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
CloudDatastoreRemoteServiceConfig.AppId
An App Engine application ID.static class
CloudDatastoreRemoteServiceConfig.Builder
Builder forCloudDatastoreRemoteServiceConfig
.
-
Constructor Summary
Constructors Constructor and Description CloudDatastoreRemoteServiceConfig()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static CloudDatastoreRemoteServiceConfig.Builder
builder()
Returns aCloudDatastoreRemoteServiceConfig.Builder
.static void
clear()
Clears theCloudDatastoreRemoteServiceConfig
instance (if one has been set) as well as theApiProxy
'sApiProxy.EnvironmentFactory
and theApiProxy.Environment
for the current thread.static void
setConfig(CloudDatastoreRemoteServiceConfig config)
Sets theCloudDatastoreRemoteServiceConfig
instance.
-
-
-
Method Detail
-
setConfig
public static void setConfig(CloudDatastoreRemoteServiceConfig config)
Sets theCloudDatastoreRemoteServiceConfig
instance.- Throws:
java.lang.IllegalStateException
- if theCloudDatastoreRemoteServiceConfig
instance has already been set andclear()
has not been calledjava.lang.IllegalStateException
- if the providedCloudDatastoreRemoteServiceConfig
is not supported in this environment
-
clear
public static void clear()
Clears theCloudDatastoreRemoteServiceConfig
instance (if one has been set) as well as theApiProxy
'sApiProxy.EnvironmentFactory
and theApiProxy.Environment
for the current thread.This method should only be called in tests.
-
builder
public static CloudDatastoreRemoteServiceConfig.Builder builder()
Returns aCloudDatastoreRemoteServiceConfig.Builder
.
-
-