/** * Add the content of a {@link ConfigurationMetadataRepository} defined by the * specified {@link InputStream} json document using the default charset. If this * metadata repository holds items that were loaded previously, these are ignored. * <p> * Leaves the stream open when done. * * @param inputStream the source input stream * @return this builder */ public CasConfigurationMetadataRepositoryJsonBuilder withJsonResource(final InputStream inputStream) { return withJsonResource(inputStream, this.defaultCharset); }
/** * Create a new builder instance using {@link StandardCharsets#UTF_8} as the default * charset and the specified json resource. * * @param inputStreams the source input streams * @return a new {@link ConfigurationMetadataRepositoryJsonBuilder} instance. * @throws IOException on error */ public static CasConfigurationMetadataRepositoryJsonBuilder create(final InputStream... inputStreams) throws IOException { var builder = create(); for (val inputStream : inputStreams) { builder = builder.withJsonResource(inputStream); } return builder; }
@SneakyThrows public CasConfigurationMetadataRepository(final Resource resource) { val builder = CasConfigurationMetadataRepositoryJsonBuilder.create(); try (val in = resource.getInputStream()) { builder.withJsonResource(in); } repository = builder.build(); }
/** * Instantiates a new Cas configuration metadata repository. * Scans the context looking for spring configuration metadata * resources and then loads them all into a repository instance. * * @param resource the resource */ @SneakyThrows public CasConfigurationMetadataRepository(final String resource) { val resources = new PathMatchingResourcePatternResolver().getResources(resource); val builder = CasConfigurationMetadataRepositoryJsonBuilder.create(); Arrays.stream(resources).forEach(Unchecked.consumer(r -> { try (val in = r.getInputStream()) { builder.withJsonResource(in); } })); repository = builder.build(); }