Example #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();
  }
Example #2
0
  // Option : standalone with webserver. Active profiles
  private void applyOptionWithWebServer() {
    String springProfiles = "standalone";
    if (cmd.hasOption(OPTION_BACKEND)) {
      if (cmd.getOptionValue(OPTION_BACKEND).equalsIgnoreCase(Backend.MONGODB.toString()))
        springProfiles += ",chart-mongodb";
      else if (cmd.getOptionValue(OPTION_BACKEND).equalsIgnoreCase(Backend.RRD.toString()))
        springProfiles += ",chart-rrd";
      else {
        logger.info(
            "Unknown backend "
                + cmd.getOptionValue(OPTION_BACKEND)
                + ". You can choose between "
                + getBackends()
                + ".");
        System.exit(-1);
      }
    } else {
      springProfiles += ",chart-jpa";
    }

    System.setProperty("spring.profiles.active", springProfiles);
  }