Reputation: 35276
Because of the nature of my application, I need to "namespace" the datastore.
This is the code I see in the docs:
// Set the namepace temporarily to "abc"
String oldNamespace = NamespaceManager.get();
NamespaceManager.set("abc");
try {
... perform operation using current namespace ...
} finally {
NamespaceManager.set(oldNamespace);
}
However, I'm not sure where the namespace must be set to the XML before you can use it or you can create namespace dynamically in code?
Also I see with the MemcacheService
there is a setNamespace
method (although deprecated already); how about the DatastoreService
is there a way to namespace a given service instance we get from the DatastoreServiceFactory
factory, so we don't have to set namespace back-and-forth with our code?
Upvotes: 1
Views: 1577
Reputation: 584
You don't have to declare namespaces to use them. If you want to make a multi-tenant application then namespaces are a perfect fit. Basically, you just have to set the namespace once at the beginning of your request. That namespace setting automatically applies to all your API calls during that request. Switching back and forth as shown in the docs will only be necessary for accessing data that's shared by all tenants.
Upvotes: 1