Esempio n. 1
0
 private static ClassPathXmlApplicationContext setup() {
   ClassPathXmlApplicationContext applicationContext =
       new ClassPathXmlApplicationContext("classpath:spring-configs/config.xml");
   applicationContext.registerShutdownHook();
   applicationContext.start();
   return applicationContext;
 }
Esempio n. 2
0
  public static void main(String[] args) throws Throwable {
    // you can setup $GRIDGAIN_HOME as an environmental variable
    File whereImKeepingGridgain =
        new File(new File(SystemUtils.getUserHome(), "Desktop"), "gridgain-2.1.1");
    System.setProperty("GRIDGAIN_HOME", whereImKeepingGridgain.getAbsolutePath());

    ClassPathXmlApplicationContext applicationContext =
        new ClassPathXmlApplicationContext("gridservice.xml");
    applicationContext.registerShutdownHook();
    applicationContext.start();

    SalutationService salutationServiceImpl =
        (SalutationService) applicationContext.getBean("salutationService");

    String[] names =
        ("Alan,Arin,Clark,Craig,Drew,Gary,Gordon,Fumiko,"
                + "Hicham,Jordon,Kathy,Ken,Makani,Mario, "
                + "Mark,Mia,Mike,Nick,Richard,Richelle, "
                + "Rod,Ron,Scott,Shaun,Srinivas,Valerie,Venkatesh")
            .split(",");

    System.out.println(StringUtils.repeat("=", 100));

    for (String name : names) {
      System.out.println("Result: " + salutationServiceImpl.saluteSomeoneInForeignLanguage(name));
    }

    System.out.println(StringUtils.repeat("=", 100));
    System.out.println(
        "Results:"
            + StringUtils.join(
                salutationServiceImpl.saluteManyPeopleInRandomForeignLanguage(names), ","));
  }
Esempio n. 3
0
 public static void main(String[] args) {
   ClassPathXmlApplicationContext applicationContext =
       new ClassPathXmlApplicationContext("classpath:array-property.xml");
   // Без этого событие destroy для бинов не будет вызвано
   applicationContext.registerShutdownHook();
   ArrayProperty manager = applicationContext.getBean("prop0", ArrayProperty.class);
   System.out.print(manager);
 }
  @Override
  public void start(Stage stage) throws Exception {
    String[] configLocations = new String[] {"applicationContext.xml", "datasource.xml"};

    @SuppressWarnings("resource")
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(configLocations);
    context.registerShutdownHook();

    StageController stageController = context.getBean(StageController.class);
    stageController.setStage(stage);
    stageController.showMainMenuScreen();
    stage.show();
  }
  /**
   * Creates a new instance of ContainerLauncher.
   *
   * @param options The options that select transport, analytics, and other infrastructure options.
   * @param parentContext an optional parent context to set on the XDContainer's ApplicationContext.
   * @return a new ContainerLauncher instance
   */
  @SuppressWarnings("resource")
  public ContainerLauncher createContainerLauncher(
      ContainerOptions options, ApplicationContext parentContext) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext();
    context.setConfigLocation(LAUNCHER_CONFIG_LOCATION);

    OptionUtils.configureRuntime(options, context.getEnvironment());

    if (parentContext == null) {
      parentContext = createParentContext();
    }

    context.setParent(parentContext);
    context.refresh();
    context.registerShutdownHook();

    ContainerLauncher launcher = context.getBean(ContainerLauncher.class);
    return launcher;
  }