Add Guice injector to Application
This commit is contained in:
parent
d63dc601c0
commit
8c49d33731
@ -11,6 +11,8 @@ import net.sf.openrocket.logging.LogLevel;
|
||||
import net.sf.openrocket.logging.LogLevelBufferLogger;
|
||||
import net.sf.openrocket.logging.PrintStreamLogger;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* A class that provides singleton instances / beans for other classes to utilize.
|
||||
*
|
||||
@ -31,6 +33,8 @@ public final class Application {
|
||||
|
||||
private static ExceptionHandler exceptionHandler;
|
||||
|
||||
private static Injector injector;
|
||||
|
||||
// Initialize the logger to something sane for testing without executing Startup
|
||||
static {
|
||||
setLogOutputLevel(LogLevel.DEBUG);
|
||||
@ -172,5 +176,15 @@ public final class Application {
|
||||
Application.componentPresetDao = componentPresetDao;
|
||||
}
|
||||
|
||||
public static Injector getInjector() {
|
||||
return injector;
|
||||
}
|
||||
|
||||
public static void setInjector(Injector injector) {
|
||||
Application.injector = injector;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import net.sf.openrocket.logging.LogHelper;
|
||||
import net.sf.openrocket.util.BuildProperties;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* The second class in the OpenRocket startup sequence. This class can assume the
|
||||
@ -37,6 +38,8 @@ public class ApplicationStartup {
|
||||
|
||||
@Inject
|
||||
private LogHelper log;
|
||||
@Inject
|
||||
private Injector injector;
|
||||
|
||||
|
||||
private static final String THRUSTCURVE_DIRECTORY = "datafiles/thrustcurves/";
|
||||
@ -50,6 +53,10 @@ public class ApplicationStartup {
|
||||
|
||||
log.info("Starting up OpenRocket version " + BuildProperties.getVersion());
|
||||
|
||||
Application.setInjector(injector);
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
// Check that we're not running headless
|
||||
log.info("Checking for graphics head");
|
||||
checkHead();
|
||||
|
Loading…
x
Reference in New Issue
Block a user