// A few things that need to get set up before regular init().
  @Override
  protected void internalInit() {
    log.debug("Starting CWM Application Internal Init");
    log.debug("Application Class is " + getClass().getName());

    loadAppProperties();

    // If using Logback as the logger, and we have a logConfig property,
    // then read that configuration.
    File logConfig = configuration.getOptionalFile("cwm.logConfig");
    if (logConfig != null && LoggerFactory.getILoggerFactory() instanceof LoggerContext) {
      log.info("Log Configuration: {}", logConfig);
      LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

      try {
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(lc);
        // the context was probably already configured by default configuration rules
        lc.reset();
        configurator.doConfigure(logConfig);
      } catch (JoranException je) {
        je.printStackTrace();
      }
      StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
    }

    loadServices();

    getComponentInstantiationListeners()
        .add(new GuiceComponentInjector(this, getInjectionModuleArray()));

    super.internalInit();
  }
  @Override
  protected void init() {
    log.debug("Starting CWM Application Init");
    super.init();

    Injector.get().inject(this);

    mailHost = configuration.getProperty("cwm.mailHost");
    mailFromAddress = configuration.getProperty("cwm.mailFromAddress");

    getDebugSettings().setOutputMarkupContainerClassName(true);

    initResponseTypes();
    loadContent();
    runDatabaseInitializers();
    configureMountPaths();

    loginSessionCloser = new LoginSessionCloser(this);
    loginSessionCloser.start();

    log.debug("Finished CWM Application Init");
  }
  @Override
  protected void configureHibernate(Configuration c) {
    // We don't actually want the defaults that Databinder sets.
    // super.configureHibernate(ac);

    File configFile = configuration.getFile("cwm.hibernateConfig");
    if (configFile == null)
      throw new RuntimeException(
          "Hibernate config file must be specified with cwm.hibernateConfig property.");

    c.configure(configFile);

    addCwmHibernateClasses(c);
  }
 public void loadAppProperties() {
   configuration = AppConfiguration.loadFor(this);
   appInstanceId = configuration.getString("cwm.instanceId", "unknown");
   sessionTimeout = configuration.getInteger("cwm.sessionTimeout", DEFAULT_SESSION_TIMEOUT);
 }