/**
* 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 = getBaseFolderPath(defaultBase);
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);
// create the plugin manager instance but do not start it
loadManager(injector, IPluginManager.class);
// start all other managers
startManager(injector, INotificationManager.class);
startManager(injector, IUserManager.class);
startManager(injector, IAuthenticationManager.class);
startManager(injector, IPublicKeyManager.class);
startManager(injector, IRepositoryManager.class);
startManager(injector, IProjectManager.class);
startManager(injector, IFederationManager.class);
startManager(injector, IGitblit.class);
// start the plugin manager last so that plugins can depend on
// deterministic access to all other managers in their start() methods
startManager(injector, IPluginManager.class);
logger.info("");
logger.info("All managers started.");
logger.info("");
IPluginManager pluginManager = injector.get(IPluginManager.class);
for (LifeCycleListener listener : pluginManager.getExtensions(LifeCycleListener.class)) {
try {
listener.onStartup();
} catch (Throwable t) {
logger.error(null, t);