thread.stop() -> thread.interrupt(), and updated KickStart args to correctly point to the GAE SDK and logging.properties locations

This commit is contained in:
Andrew Phillips 2011-05-29 19:48:24 +01:00
parent 36beb90de0
commit 6524390f4b
2 changed files with 50 additions and 26 deletions

View File

@ -18,12 +18,17 @@
*/
package org.jclouds.demo.tweetstore.integration;
import com.google.appengine.tools.KickStart;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.String.format;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.File;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import com.google.appengine.tools.KickStart;
import com.google.appengine.tools.info.SdkInfo;
/**
* Basic functionality to start a local google app engine instance.
@ -44,22 +49,29 @@ public class GoogleDevServer {
assert new File(filename).exists();
this.server = new Thread(new Runnable() {
public void run() {
KickStart
.main(new String[]{
"com.google.appengine.tools.development.DevAppServerMain",
"--disable_update_check", "-a", address, "-p",
port, warfile});
String sdkRoot = checkNotNull(System.getProperty(SdkInfo.SDK_ROOT_PROPERTY), SdkInfo.SDK_ROOT_PROPERTY);
KickStart.main(new String[] {
KickStarter.systemProperty("java.util.logging.config.file",
format("%s/WEB-INF/logging.properties", warfile)),
KickStarter.systemProperty(SdkInfo.SDK_ROOT_PROPERTY, sdkRoot),
"com.google.appengine.tools.development.DevAppServerMain",
"--disable_update_check",
format("--sdk_root=%s", sdkRoot),
"-a", address, "-p", port, warfile });
}
});
server.start();
Thread.sleep(30 * 1000);
TimeUnit.SECONDS.sleep(30);
}
@SuppressWarnings("deprecation")
public void stop() throws Exception {
server.stop();
// KickStart.main opens a process and calls process.waitFor(), which is interruptable
server.interrupt();
}
private static class KickStarter {
private static String systemProperty(String key, String value) {
return format("--jvm_flag=-D%s=%s", key, value);
}
}
}

View File

@ -18,12 +18,17 @@
*/
package org.jclouds.demo.tweetstore.integration;
import com.google.appengine.tools.KickStart;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.String.format;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.File;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import com.google.appengine.tools.KickStart;
import com.google.appengine.tools.info.SdkInfo;
/**
* Basic functionality to start a local google app engine instance.
@ -44,22 +49,29 @@ public class GoogleDevServer {
assert new File(filename).exists();
this.server = new Thread(new Runnable() {
public void run() {
KickStart
.main(new String[]{
"com.google.appengine.tools.development.DevAppServerMain",
"--disable_update_check", "-a", address, "-p",
port, warfile});
String sdkRoot = checkNotNull(System.getProperty(SdkInfo.SDK_ROOT_PROPERTY), SdkInfo.SDK_ROOT_PROPERTY);
KickStart.main(new String[] {
KickStarter.systemProperty("java.util.logging.config.file",
format("%s/WEB-INF/logging.properties", warfile)),
KickStarter.systemProperty(SdkInfo.SDK_ROOT_PROPERTY, sdkRoot),
"com.google.appengine.tools.development.DevAppServerMain",
"--disable_update_check",
format("--sdk_root=%s", sdkRoot),
"-a", address, "-p", port, warfile });
}
});
server.start();
Thread.sleep(30 * 1000);
TimeUnit.SECONDS.sleep(30);
}
@SuppressWarnings("deprecation")
public void stop() throws Exception {
server.stop();
// KickStart.main opens a process and calls process.waitFor(), which is interruptable
server.interrupt();
}
private static class KickStarter {
private static String systemProperty(String key, String value) {
return format("--jvm_flag=-D%s=%s", key, value);
}
}
}