CloudDatastoreRemoteServiceConfig (Google App Engine API for Java)

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.
Was this page helpful? Let us know how we did:

Send feedback about...

App Engine standard environment for Java