All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.objectify.util.DatastoreIntrospector Maven / Gradle / Ivy

Go to download

*** THIS VERSION UPLOADED FOR USE WITH CEDAR-COMMON, TO AVOID DEPENDENCIES ON GOOGLE CODE-BASED MAVEN REPOSITORIES. *** The simplest convenient interface to the Google App Engine datastore

The newest version!
/*
 */

package com.googlecode.objectify.util;

import com.google.appengine.api.datastore.DatastoreAttributes.DatastoreType;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.TransactionOptions;
import com.google.appengine.api.utils.SystemProperty;



/**
 * 

Lets us probe for certain datastore capabilities which may vary depending on dev/production/ms/hrd/etc

* * @author Jeff Schnitzer */ public class DatastoreIntrospector { /** true if XG transactions are supported */ public static final boolean SUPPORTS_XG; static { // This is convoluted. In production, we can check the DatastoreAttributes to see if we are on HRD. // But that doesn't work in development mode. So in that case, we actually try an XG transaction and // see if it fails. DatastoreService ds = DatastoreServiceFactory.getDatastoreService(); if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) { SUPPORTS_XG = ds.getDatastoreAttributes().getDatastoreType().equals(DatastoreType.HIGH_REPLICATION); } else { boolean supports = false; try { ds.beginTransaction(TransactionOptions.Builder.withXG(true)).rollback(); supports = true; } catch (Exception ex) { } finally { SUPPORTS_XG = supports; } } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy