com.googlecode.objectify.util.Closeable Java Examples
The following examples show how to use
com.googlecode.objectify.util.Closeable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RemoteApiClient.java From teammates with GNU General Public License v2.0 | 5 votes |
protected void doOperationRemotely() throws IOException { String appUrl = ClientProperties.TARGET_URL.replaceAll("^https?://", ""); String appDomain = appUrl.split(":")[0]; int appPort = appUrl.contains(":") ? Integer.parseInt(appUrl.split(":")[1]) : 443; System.out.println("--- Starting remote operation ---"); System.out.println("Going to connect to:" + appDomain + ":" + appPort); RemoteApiOptions options = new RemoteApiOptions().server(appDomain, appPort); if (ClientProperties.isTargetUrlDevServer()) { // Dev Server doesn't require credential. options.useDevelopmentServerCredential(); } else { // Your Google Cloud SDK needs to be authenticated for Application Default Credentials // in order to run any script in production server. // Refer to https://developers.google.com/identity/protocols/application-default-credentials. options.useApplicationDefaultCredential(); } RemoteApiInstaller installer = new RemoteApiInstaller(); installer.install(options); OfyHelper.registerEntityClasses(); Closeable objectifySession = ObjectifyService.begin(); try { doOperation(); } finally { objectifySession.close(); installer.uninstall(); } System.out.println("--- Remote operation completed ---"); }