@Override public boolean isInGaeCloud() { try { return com.google.appengine.api.utils.SystemProperty.environment.value() == com.google.appengine.api.utils.SystemProperty.Environment.Value.Production; } catch (Throwable t) { // Nothing to do } return false; } }
@Override public T get() throws ExecutionException, InterruptedException { try { return super.get(); } catch (ExecutionException e) { return notFoundAsNull(e); } }
/** * Get the application id of the running application. When running in Development mode * (ie: in a local SDK environment) this simply returns the value "dev". When running * in Production mode, this returns the value of the application id. * * @return the application id. */ public static String applicationId() { return isProduction() ? SystemProperty.applicationId.get() : com.threewks.thundr.configuration.Environment.DEV; } }
@Override protected void doStart() throws Exception { this.helper = createHelper(); this.environment = ApiProxy.getCurrentEnvironment(); getServletContext().setAttribute(API_PROXY_LOCAL, ApiProxy.getDelegate()); getServletContext().setAttribute(APPENGINE_WEB_XML, readAppengineWebXml()); getServletContext().setAttribute(WEB_XML, readWebXml()); SystemProperty.environment.set(SystemProperty.Environment.Value.Development); configureUserRealmAppengineHelper(); super.doStart(); }
@Override public boolean isDevelopment() { return SystemProperty.environment.value() == SystemProperty.Environment.Value.Development; }
/** * @return The application version deployed to. In dev server, returns an empty string */ public static String applicationVersion() { // The version identifier for the current application version. // Result is of the form <major>.<minor> where <major> is the version name supplied at deploy time // and <minor> is a timestamp value maintained by App Engine String fullApplicationVersion = SystemProperty.applicationVersion.get(); return isProduction() ? StringUtils.substringBefore(fullApplicationVersion, ".") : StringPool.EMPTY; }
@Override public T get(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException, ExecutionException { try { return super.get(timeout, unit); } catch (ExecutionException e) { return notFoundAsNull(e); } }
@Override public boolean isInGaeCloud() { try { return com.google.appengine.api.utils.SystemProperty.environment.value() == com.google.appengine.api.utils.SystemProperty.Environment.Value.Production; } catch (Throwable t) { // Nothing to do } return false; } }
/** * Constructs a new {@code AppEngineDatastoreService} with the specified * {@code com.google.appengine.api.datastore.DatastoreService}. * * @param datastore com.google.appengine.api.datastore.DatastoreService. */ public AppEngineDatastoreService(DatastoreService datastore) { this.datastore = datastore; datastoreType = datastore.getDatastoreAttributes().getDatastoreType(); logger.fine("Application [" + SystemProperty.applicationId.get() + "] is using [" + datastoreType + "] datastore"); }
@Override public boolean isProduction() { return SystemProperty.environment.value() == SystemProperty.Environment.Value.Production; }
OauthRawGcsService(OAuthURLFetchService urlfetch, ImmutableSet<HTTPHeader> headers) { this.urlfetch = checkNotNull(urlfetch, "Null urlfetch"); this.headers = checkNotNull(headers, "Null headers"); AppIdentityCredential cred = new AppIdentityCredential(OAUTH_SCOPES); storage = new Storage.Builder(new UrlFetchTransport(), new JacksonFactory(), cred) .setApplicationName(SystemProperty.applicationId.get()).build(); }
public static boolean isDevServer(){ return SystemProperty.environment.value() == SystemProperty.Environment.Value.Development; } }
@Before public void setUp() { bucket = getTestSystemProperty("tck.gcs.bucket"); if (bucket == null) { bucket = SystemProperty.applicationId.get() + ".appspot.com"; } gcsService = GcsServiceFactory.createGcsService(); }
/** * Check if we are running on the Dev environment * @return */ public static boolean isDevelopment() { return (SystemProperty.environment.value() == SystemProperty.Environment.Value.Development); }
@Test public void testEntity() { for (String ns : namespaceDat) { NamespaceManager.set(ns); Query query = new Query(kindName); Entity readRec = service.prepare(query).asIterator().next(); assertEquals(ns, readRec.getNamespace()); String appId = readRec.getAppId(); appId = appId.substring(appId.indexOf("~") + 1); assertEquals(SystemProperty.applicationId.get(), appId); assertTrue(readRec.hasProperty("jobType")); } }
public static boolean isDev() { return SystemProperty.environment.value() == Value.Development; }
@Override public void configure(UpdatableInjectionContext injectionContext) { URLFetchService urlFetchService = URLFetchServiceFactory.getURLFetchService(); MemcacheService memcacheService = MemcacheServiceFactory.getMemcacheService(); com.google.appengine.api.search.SearchService searchService = SearchServiceFactory.getSearchService(); Cache cache = initialiseJCache(); injectionContext.inject(cache).as(Cache.class); injectionContext.inject(memcacheService).as(MemcacheService.class); injectionContext.inject(urlFetchService).as(URLFetchService.class); injectionContext.inject(HttpServiceImpl.class).as(HttpService.class); injectionContext.inject(searchService).as(com.google.appengine.api.search.SearchService.class); injectionContext.inject(QueueFactory.getDefaultQueue()).as(Queue.class); GlobalModel globalModel = injectionContext.get(GlobalModel.class); globalModel.put("applicationVersion", SystemProperty.applicationVersion.get()); globalModel.put("environment", GaeEnvironment.applicationId()); }
@Override protected final Injector getInjector() { if ( SystemProperty.environment.value() == SystemProperty.Environment.Value.Production ) { // The app is running on App Engine... return getProductionInjector(); } else { // The app is running on local development SDK... return getDevelopmentInjector(); } }
/** * Install our hook in the delegate system. This happens automatically when this class is * loaded, which is typically what you want when working with Objectify. It gets a lot * more complicated when you're working with the RemoteApiInstaller. */ public static synchronized void install() { // Already installed if (ApiProxy.getDelegate() instanceof TriggerFutureHook) return; @SuppressWarnings("unchecked") TriggerFutureHook hook = new TriggerFutureHook(ApiProxy.getDelegate()); if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) ApiProxy.setDelegate(hook); else ApiProxy.setDelegate(wrapPartially(ApiProxy.getDelegate(), hook)); }