/**
* Prepare runtime settings and start all manager instances.
*/
protected void configureContext(ServletContext context) {
ObjectGraph injector = getInjector(context);
// create the runtime settings object
IStoredSettings runtimeSettings = injector.get(IStoredSettings.class);
final File baseFolder;
if (goSettings != null) {
// Gitblit GO
baseFolder = configureGO(context, goSettings, goBaseFolder, runtimeSettings);
} else {
// servlet container
WebXmlSettings webxmlSettings = new WebXmlSettings(context);
String contextRealPath = context.getRealPath("/");
File contextFolder = (contextRealPath != null) ? new File(contextRealPath) : null;
// if the base folder dosen't match the default assume they don't want to use express,
// this allows for other containers to customise the basefolder per context.
String defaultBase = Constants.contextFolder$ + "/WEB-INF/data";
String base = lookupBaseFolderFromJndi();
if (!StringUtils.isEmpty(System.getenv("OPENSHIFT_DATA_DIR")) && defaultBase.equals(base)) {
// RedHat OpenShift
baseFolder = configureExpress(context, webxmlSettings, contextFolder, runtimeSettings);
} else {
// standard WAR
baseFolder = configureWAR(context, webxmlSettings, contextFolder, runtimeSettings);
}
// Test for Tomcat forward-slash/%2F issue and auto-adjust settings
ContainerUtils.CVE_2007_0450.test(runtimeSettings);
}
// Manually configure IRuntimeManager
logManager(IRuntimeManager.class);
IRuntimeManager runtime = injector.get(IRuntimeManager.class);
runtime.setBaseFolder(baseFolder);
runtime.getStatus().isGO = goSettings != null;
runtime.getStatus().servletContainer = context.getServerInfo();
runtime.start();
managers.add(runtime);