Skip to content

Instantly share code, notes, and snippets.

@adamrabung
Created January 11, 2011 12:42
Show Gist options
  • Save adamrabung/774359 to your computer and use it in GitHub Desktop.
Save adamrabung/774359 to your computer and use it in GitHub Desktop.
public static void bootPlay(String projectName, File projectsHome) {
try {
System.setProperty("play.id", projectName);
File projectHome = new File(projectsHome, projectName);
System.setProperty("application.path", projectHome.getAbsolutePath());
Play.init(projectHome, projectName);
Play.start();
Thread.currentThread().setContextClassLoader(Play.classloader);
for (PlayPlugin plugin : Play.plugins) {
System.out.println("PlayMain.main: loaded plugin " + plugin);
plugin.beforeInvocation();
}
Future<?> mainInvocation = Invoker.invoke(new Invocation() {
@Override
public void execute() throws Exception {
System.out.println("PlayMain.main: all sessions: " + Session.all());
}
});
//block the main thread
mainInvocation.get();
for (PlayPlugin plugin : Play.plugins) {
plugin.afterInvocation();
}
Play.stop();
}
catch (Throwable e) {
throw new RuntimeException("Failed to boot " + projectName + " from " + projectsHome, e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment