I have a code snippet:
private static DatastoreService _db;
public static DatastoreService db() throws IOException
{
if(_db==null) _db = DatastoreServiceFactory.getDatastoreService();
return _db;
}
Is this safe approach? I cached the DatastoreService object statically and re-used over a single servlet execution. However, I have no sure about the servlet disposes after a request.