Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products.

CloudDatastoreRemoteServiceConfig (Google App Engine API for Java)

Stay organized with collections Save and categorize content based on your preferences.
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 from com.google.appengine.api. For example:

     public 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();
       ...
     }
     
    Outside of tests, the config should not be cleared once it has been set. In tests, the config can be cleared by calling clear():
      @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();
     }
     
    By default, this configuration uses application-default credentials.