PropertiesMergingResourceTransformer Class — spring-boot Architecture
Architecture documentation for the PropertiesMergingResourceTransformer class in PropertiesMergingResourceTransformer.java from the spring-boot codebase.
Entity Profile
Source Code
build-plugin/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java lines 41–110
public class PropertiesMergingResourceTransformer implements ReproducibleResourceTransformer {
// Set this in pom configuration with <resource>...</resource>
private @Nullable String resource;
private final Properties data = new Properties();
private long time;
/**
* Return the data the properties being merged.
* @return the data
*/
public Properties getData() {
return this.data;
}
@Override
public boolean canTransformResource(String resource) {
return this.resource != null && this.resource.equalsIgnoreCase(resource);
}
@Override
@Deprecated(since = "2.4.0", forRemoval = false)
public void processResource(String resource, InputStream inputStream, List<Relocator> relocators)
throws IOException {
processResource(resource, inputStream, relocators, 0);
}
@Override
public void processResource(String resource, InputStream inputStream, List<Relocator> relocators, long time)
throws IOException {
Properties properties = new Properties();
properties.load(inputStream);
properties.forEach((name, value) -> process((String) name, (String) value));
if (time > this.time) {
this.time = time;
}
}
private void process(String name, String value) {
String existing = this.data.getProperty(name);
this.data.setProperty(name, (existing != null) ? existing + "," + value : value);
}
@Override
public boolean hasTransformedResource() {
return !this.data.isEmpty();
}
@Override
public void modifyOutputStream(JarOutputStream os) throws IOException {
Assert.state(this.resource != null, "'resource' must not be null");
JarEntry jarEntry = new JarEntry(this.resource);
jarEntry.setTime(this.time);
os.putNextEntry(jarEntry);
this.data.store(os, "Merged by PropertiesMergingResourceTransformer");
os.flush();
this.data.clear();
}
public @Nullable String getResource() {
return this.resource;
}
public void setResource(@Nullable String resource) {
this.resource = resource;
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free