Exemplo n.º 1
0
  public void initialise() throws InitialisationException {
    if (configFile == null) {
      if (configuration != null) {
        try {
          configure(configuration);
          return;
        } catch (ContainerException e) {
          throw new InitialisationException(e, this);
        }
      } else {
        return;
      }
    }

    try {
      if (ClassUtils.getResource(configFile, getClass()) == null) {
        logger.warn(
            "Spring config resource: "
                + configFile
                + " not found on class path, attempting to load it from local file");
        setExternalBeanFactory(new FileSystemXmlApplicationContext(configFile));
      } else {
        logger.info("Loading Spring config from classpath, resource is: " + configFile);
        setExternalBeanFactory(new ClassPathXmlApplicationContext(configFile));
      }
    } catch (BeansException e) {
      throw new InitialisationException(
          new ConfigurationException(
              new Message(Messages.FAILED_LOAD_X, "Application Context: " + configFile), e),
          this);
    }
  }