/** * 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 ConfigurationMetadataRepositoryJsonBuilder create( InputStream... inputStreams) throws IOException { ConfigurationMetadataRepositoryJsonBuilder builder = create(); for (InputStream inputStream : inputStreams) { builder = builder.withJsonResource(inputStream); } return builder; }
Resource[] resources = new PathMatchingResourcePatternResolver() .getResources("classpath*:META-INF/spring-configuration-metadata.json"); ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder.create(); for (Resource resource : resources) { try (InputStream in = resource.getInputStream()) { builder.withJsonResource(in); } } ConfigurationMetadataRepository repository = builder.build();
/** * Create a new builder instance using the specified default {@link Charset}. * @param defaultCharset the default charset to use * @return a new {@link ConfigurationMetadataRepositoryJsonBuilder} instance. */ public static ConfigurationMetadataRepositoryJsonBuilder create( Charset defaultCharset) { return new ConfigurationMetadataRepositoryJsonBuilder(defaultCharset); }
for (FileObject fo : cfgMetaFiles) { try { ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder.create(); ConfigurationMetadataRepository currRepo; FileObject archiveFo = FileUtil.getArchiveFile(fo); if (!reposInJars.containsKey(archivePath)) { logger.log(INFO, "Unmarshalling configuration metadata from {0}", FileUtil.getFileDisplayName(fo)); ConfigurationMetadataRepository jarRepo = builder.withJsonResource(fo.getInputStream()).build(); reposInJars.put(archivePath, jarRepo); currRepo = builder.withJsonResource(fo.getInputStream()).build();
/** * 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 * @throws IOException in case of I/O errors */ public ConfigurationMetadataRepositoryJsonBuilder withJsonResource( InputStream inputStream) throws IOException { return withJsonResource(inputStream, this.defaultCharset); }
/** * Create a new builder instance using {@link StandardCharsets#UTF_8} as the default * charset. * @return a new {@link ConfigurationMetadataRepositoryJsonBuilder} instance. */ public static ConfigurationMetadataRepositoryJsonBuilder create() { return create(StandardCharsets.UTF_8); }
private SimpleConfigurationMetadataRepository create( RawConfigurationMetadata metadata) { SimpleConfigurationMetadataRepository repository = new SimpleConfigurationMetadataRepository(); repository.add(metadata.getSources()); for (ConfigurationMetadataItem item : metadata.getItems()) { ConfigurationMetadataSource source = getSource(metadata, item); repository.add(item, source); } Map<String, ConfigurationMetadataProperty> allProperties = repository .getAllProperties(); for (ConfigurationMetadataHint hint : metadata.getHints()) { ConfigurationMetadataProperty property = allProperties.get(hint.getId()); if (property != null) { addValueHints(property, hint); } else { String id = hint.resolveId(); property = allProperties.get(id); if (property != null) { if (hint.isMapKeyHints()) { addMapHints(property, hint); } else { addValueHints(property, hint); } } } } return repository; }
/** * Add the content of a {@link ConfigurationMetadataRepository} defined by the * specified {@link InputStream} json document using the specified {@link 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 * @param charset the charset of the input * @return this builder * @throws IOException in case of I/O errors */ public ConfigurationMetadataRepositoryJsonBuilder withJsonResource( InputStream inputStream, Charset charset) throws IOException { if (inputStream == null) { throw new IllegalArgumentException("InputStream must not be null."); } this.repositories.add(add(inputStream, charset)); return this; }
boolean include = (whitelistDescriptors.length == 0) || exhaustive; // when no descriptors, return everything loadWhiteLists(whitelistDescriptors, whiteListedClasses, whiteListedProperties); ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder.create(); for (Resource r : moduleResourceLoader.getResources(CONFIGURATION_METADATA_PATTERN)) { builder.withJsonResource(r.getInputStream()); for (ConfigurationMetadataGroup group : builder.build().getAllGroups().values()) { if (include || isWhiteListed(group, whiteListedClasses)) { result.addAll(group.getProperties().values());
private SimpleConfigurationMetadataRepository add(InputStream in, Charset charset) throws IOException { try { RawConfigurationMetadata metadata = this.reader.read(in, charset); return create(metadata); } catch (Exception ex) { throw new IllegalStateException("Failed to read configuration metadata", ex); } }
whiteListedProperties); ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder.create(); for (Resource r : moduleResourceLoader.getResources(CONFIGURATION_METADATA_PATTERN)) { builder.withJsonResource(r.getInputStream()); for (ConfigurationMetadataGroup group : builder.build().getAllGroups().values()) { if (exhaustive || isWhiteListed(group, whiteListedClasses)) { for (ConfigurationMetadataProperty property : group.getProperties().values()) {
Resource[] whitelistDescriptors = moduleResourceLoader.getResources(WHITELIST_PROPERTIES); loadWhiteLists(whitelistDescriptors, whiteListedClasses, whiteListedProperties); ConfigurationMetadataRepositoryJsonBuilder builder = ConfigurationMetadataRepositoryJsonBuilder.create(); for (Resource r : moduleResourceLoader.getResources(CONFIGURATION_METADATA_PATTERN)) { builder.withJsonResource(r.getInputStream()); for (ConfigurationMetadataGroup group : builder.build().getAllGroups().values()) { if (exhaustive || isWhiteListed(group, whiteListedClasses)) { for (ConfigurationMetadataProperty property : group.getProperties().values()) {