/** * 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; } }
/** * @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; }
/** * 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"); }
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(); }
@Before public void setUp() { bucket = getTestSystemProperty("tck.gcs.bucket"); if (bucket == null) { bucket = SystemProperty.applicationId.get() + ".appspot.com"; } gcsService = GcsServiceFactory.createGcsService(); }
@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")); } }
@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()); }
/** * These could return different values from the implementations so just assert the basics. */ @Test @InSequence(20) public void testMiscProperties() throws Exception { RequestLogs logs = getRequestLogs1(); assertNotNull("App Engine Release, e.g. 1.8.0, or empty string.", logs.getAppEngineRelease()); assertTrue("Estimated cost of this request, in dollars.", logs.getCost() >= 0.0); assertTrue("Time required to process this request in microseconds.", logs.getLatencyUsec() >= 0); assertTrue("Microseconds request spent in pending request queue, if was pending at all.", logs.getPendingTimeUsec() >= 0); assertFalse("This should never be a loading request: " + logs.toString(), logs.isLoadingRequest()); String appId = SystemProperty.applicationId.get(); // appIds have a prefix according to datacenter. assertTrue("The application ID that handled this request.", logs.getAppId().endsWith(appId)); long cycles = logs.getMcycles(); assertTrue("Number of machine cycles used to process this request: " + cycles, cycles >= 0); String getOffsetMsg = "Base64-encoded offset used with subsequent LogQuery to continue reading logs at the point in time immediately following this request."; assertNotNull(getOffsetMsg, logs.getOffset()); assertTrue("Should be Base64: " + logs.getOffset(), Base64.isBase64(logs.getOffset().getBytes())); String mapEntryMsg = "File or class within the URL mapping used for this request: " + logs.getUrlMapEntry(); assertNotNull(mapEntryMsg, logs.getUrlMapEntry()); }
appId = appId.substring(appId.indexOf('~') + 1); assertEquals(SystemProperty.applicationId.get(), appId);