Package com.google.appengine.api (2.0.0)

Provides facilities for server lifecycle management, threading and namespaces/multitenancy. These facilities, along with the services defined in subpackages, make up the Google App Engine API. See Also: Multitenancy and the Namespaces Java API in the Google App Engine Developer's Guide.

Classes

LifecycleManager

NamespaceManager

Provides functions for manipulating the current namespace used for App Engine APIs.

The "current namespace" is the string that is returned by #get() and used by a number of APIs including Datatore, Memcache and Task Queue.

When a namespace aware class (e.g., com.google.appengine.api.datastore.Key, com.google.appengine.api.datastore.Query and com.google.appengine.api.memcache.MemcacheService) is constructed, it determines which namespace will be used by calling NamespaceManager#get() if it is otherwise unspecified. If NamespaceManager#get() returns null, the current namespace is unset and these APIs will use the empty ("") namespace in its place.

Example:

 NamespaceManager.#set("a-namespace");
 MemcacheService memcache = MemcacheServiceFactory.getMemcacheService();
 // Store record in namespace "a-namespace"
 memcache.put("key1", "value1");

NamespaceManager.#set("other-namespace"); // Store record in namespace "other-namespace" memcache.put("key2", "value2");

MemcacheService boundMemcache = MemcacheServiceFactory.getMemcacheService("specific-namespace"); NamespaceManager.#set("whatever-namespace"); // The record is still stored in namespace "specific-namespace". boundMemcache.put("key3", "value3");

MemcacheService memcache (in the above example) uses the current namespace and key1 will be stored in namespace "a-namespace", while key2 is stored in namespace "other-namespace". It is possible to override the current namespace and store data in specific namespace. In the above example key3 is stored in namespace "specific-namespace".

The Task Queue com.google.appengine.api.taskqueue.Queue#add methods will forward the NamespaceManager settings into the task being added causing the added task to be executed with the same current namespace as the task creator. The exception is that an unset current namespace (i.e. NamespaceManager#get() returns null) will be forwarded as an empty ("") namespace to the created task's requests. See Also: Multitenancy and the Namespaces Java API. In Google App Engine Developer's Guide.

ThreadManager

ThreadManager exposes a ThreadFactory that allows App Engine applications to spawn new threads.

Refer to this discussion of threads for drawbacks of thread usage and possible alternatives.

Interfaces

LifecycleManager.ShutdownHook