Exemple #1
0
  // Option : standalone without webserver
  private void applyOptionWithoutWebServer() {
    // ApplicationContext initiliazed by DispatcherServlet otherwise
    applicationContext = new ClassPathXmlApplicationContext();
    if (cmd.hasOption(OPTION_BACKEND)) {
      if (cmd.getOptionValue(OPTION_BACKEND).equalsIgnoreCase(Backend.MONGODB.toString()))
        applicationContext.getEnvironment().setActiveProfiles("standalone", "chart-mongodb");
      else if (cmd.getOptionValue(OPTION_BACKEND).equalsIgnoreCase(Backend.RRD.toString()))
        applicationContext.getEnvironment().setActiveProfiles("standalone", "chart-rrd");
      else {
        logger.info(
            "Unknown backend "
                + cmd.getOptionValue(OPTION_BACKEND)
                + ". You can choose between "
                + getBackends()
                + ".");
        System.exit(-1);
      }

    } else applicationContext.getEnvironment().setActiveProfiles("standalone", "chart-jpa");
    // Init Spring controller
    applicationContext.setConfigLocations(
        new String[] {
          "classpath:applicationContext.xml",
          "classpath:applicationContext-jmx.xml",
          "classpath:applicationContext-jmx-standalone.xml",
          "classpath:applicationContext-jpa.xml",
          "classpath:applicationContext-mongodb.xml",
          "classpath:applicationContext-rrd.xml"
        });
    ((ConfigurableApplicationContext) applicationContext).registerShutdownHook();

    applicationContext.refresh();
  }
 @Override
 public void start() {
   this.context =
       new ClassPathXmlApplicationContext(new String[] {CORE_CONFIG, PLUGIN_CONFIGS}, false);
   context.setId(this.id);
   updateLoggerFilename();
   Assert.notNull(launcherContext, "no Container launcher ApplicationContext has been set");
   ApplicationContext globalContext = launcherContext.getParent();
   Assert.notNull(globalContext, "no global context has been set");
   context.setParent(globalContext);
   context.registerShutdownHook();
   context.refresh();
   this.containerRunning = true;
   context.publishEvent(new ContainerStartedEvent(this));
   if (logger.isInfoEnabled()) {
     logger.info("started container: " + context.getId());
   }
 }