initLogging();
boolean restarting = restartRequested;
restartRequested = false;
Weld weld = new ModularWeld();
BeanManager manager = null;
// FIXME this plugin loading scheme causes classloading issues w/weld because weld cannot load classes
// from its own classloaders before plugins are loaded and pollute the classpath.
// We can work around it by loading weld before we load plugins, then restarting weld, but this is SLOW.
try
{
WeldContainer container = weld.initialize();
manager = container.getBeanManager();
weld.shutdown();
}
catch (Exception e)
{
}
try
{
// TODO verify plugin API versions. only activate compatible plugins.
loadPlugins();
WeldContainer container = weld.initialize();
manager = container.getBeanManager();
}
catch (Throwable e)
{
// Boot up with external plugins disabled.
System.out
.println("Plugin system disabled due to failure while loading one or more plugins; try removing offending plugins with \"forge remove-plugin <TAB>\".");
e.printStackTrace();
Thread.currentThread().setContextClassLoader(mainClassLoader);
initLogging();
WeldContainer container = weld.initialize();
manager = container.getBeanManager();
}
try
{
manager.fireEvent(new PreStartup());
}
catch (Throwable t)
{
System.out.println("Error during PreStartup event");
t.printStackTrace();
}
try
{
manager.fireEvent(new Startup(workingDir, restarting));
}
catch (Throwable t)
{
System.out.println("Error during Startup event");
t.printStackTrace();
}
try
{
manager.fireEvent(new PostStartup());
}
catch (Throwable t)
{
System.out.println("Error during PostStartup event");
t.printStackTrace();
}
try
{
manager.fireEvent(new AcceptUserInput());
}
catch (Throwable t)
{
System.out.println("Error during AcceptUserInput event");
t.printStackTrace();
}
weld.shutdown();
}
});
currentShell.start();
try