Created
January 11, 2011 12:42
-
-
Save adamrabung/774359 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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