/** * Create a new builder instance using {@link StandardCharsets#UTF_8} as the default * charset. * * @return a new {@link ConfigurationMetadataRepositoryJsonBuilder} instance. */ public static CasConfigurationMetadataRepositoryJsonBuilder create() { return create(StandardCharsets.UTF_8); }
private SimpleConfigurationMetadataRepository add(final InputStream in, final Charset charset) { try { val metadata = this.reader.read(in, charset); return create(metadata); } catch (final Exception ex) { throw new IllegalStateException("Failed to read configuration metadata", ex); } }
/** * 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(); }