use of com.google.appengine.tools.remoteapi.RemoteApiInstaller in project pratilipi by Pratilipi.
the class DataStoreUtil method main.
public static void main(String... args) throws IOException, UnexpectedServerException, InterruptedException, ParseException {
RemoteApiOptions options = new RemoteApiOptions().server("m.gamma.pratilipi.com", 80).useServiceAccountCredential("prod-pratilipi@appspot.gserviceaccount.com", "PrivateKey.p12").remoteApiPath("/remote_api");
RemoteApiInstaller installer = new RemoteApiInstaller();
installer.install(options);
ObjectifyService.begin();
Memcache memcache = DataAccessorFactory.getL2CacheAccessor();
GcsService gcsService = GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance());
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
SearchAccessor searchAccessor = DataAccessorFactory.getSearchAccessor();
BlobAccessor blobAccessor = DataAccessorFactory.getBlobAccessor();
DocAccessor docAccessor = DataAccessorFactory.getDocAccessor();
// START
// END
installer.uninstall();
}
use of com.google.appengine.tools.remoteapi.RemoteApiInstaller in project java-docs-samples by GoogleCloudPlatform.
the class RemoteApiExample method main.
public static void main(String[] args) throws IOException {
String serverString = args[0];
RemoteApiOptions options;
if (serverString.equals("localhost")) {
options = new RemoteApiOptions().server(serverString, 8080).useDevelopmentServerCredential();
} else {
options = new RemoteApiOptions().server(serverString, 443).useApplicationDefaultCredential();
}
RemoteApiInstaller installer = new RemoteApiInstaller();
installer.install(options);
try {
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
System.out.println("Key of new entity is " + ds.put(new Entity("Hello Remote API!")));
} finally {
installer.uninstall();
}
}
use of com.google.appengine.tools.remoteapi.RemoteApiInstaller in project teammates by TEAMMATES.
the class RemoteApiClient method doOperationRemotely.
protected void doOperationRemotely() throws IOException {
String appUrl = TestProperties.TEAMMATES_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 (TestProperties.isDevServer()) {
// 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 ---");
}
use of com.google.appengine.tools.remoteapi.RemoteApiInstaller in project Cached-Datastore by Emperorlou.
the class CachedDatastoreService method getMC.
public MemcacheService getMC() {
if (mc != null)
return mc;
if (isUsingRemoteAPI()) {
try {
// Properties p = new Properties();
// InputStream in = new FileInputStream("C:\\Universe (Non Repo)\\MySpacewarConfig\\db.properties");
// p.load(in);
// in.close();
RemoteApiInstaller installer = new RemoteApiInstaller();
installer.install(options);
} catch (IllegalStateException ise) {
// Ignore. Remote API is probably already installed
} catch (Exception e) {
// Ok fine, no remote API
disableRemoteAPI = true;
Logger.getLogger(getClass().toString()).log(Level.WARNING, "Failed to connect to remote API", e);
}
}
mc = MemcacheServiceFactory.getMemcacheService();
return mc;
}
Aggregations