Exemplo n.º 1
0
 private static ResourceStreamSourceChainOfResponsibility createComposite(
     final List<ResourceStreamSource> resourceStreamSources) {
   final ResourceStreamSourceChainOfResponsibility composite =
       new ResourceStreamSourceChainOfResponsibility();
   for (final ResourceStreamSource rss : resourceStreamSources) {
     if (rss == null) {
       continue;
     }
     composite.addResourceStreamSource(rss);
   }
   return composite;
 }
Exemplo n.º 2
0
  /**
   * Loads the configuration resource (usually, a file) with the specified name from the first
   * {@link ResourceStreamSource} available.
   *
   * <p>If the configuration resource cannot be found then the provided {@link NotFoundPolicy}
   * determines whether an exception is thrown or not.
   */
  private void loadConfigurationResource(
      final String configurationResource,
      final NotFoundPolicy notFoundPolicy,
      final IsisConfigurationDefault.ContainsPolicy containsPolicy) {

    try {
      final PropertiesReader propertiesReader =
          loadConfigurationResource(resourceStreamSourceChain, configurationResource);
      LOG.info("loading properties from " + configurationResource);
      configuration.add(propertiesReader.getProperties(), containsPolicy);
      configurationResourcesFound.add(configurationResource);
      return;
    } catch (final IOException ignore) {
      // ignore
    }
    if (notFoundPolicy == NotFoundPolicy.FAIL_FAST) {
      throw new IsisException(
          String.format(
              "failed to load '%s'; tried using: %s",
              configurationResource, resourceStreamSourceChain.getName()));
    }
    configurationResourcesNotFound.add(configurationResource);
    if (LOG.isDebugEnabled()) {
      LOG.debug(String.format("'%s' not found, but not needed", configurationResource));
    }
  }