
shoehorn.Shoehorn Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shoehorn Show documentation
Show all versions of shoehorn Show documentation
A Java Agent for mapping OS environment variables to Java system properties
The newest version!
package shoehorn;
import java.util.Map;
/**
* @author Ryan Brainard
*/
public class Shoehorn {
@SuppressWarnings("UnusedDeclaration")
public static void premain(String agentArgs) {
new Shoehorn(System.getenv(), new MappingLoader().load(System.getenv())).shoehorn();
}
private final Map environment;
private final Map mappings;
public Shoehorn(Map environment, Map mappings) {
this.environment = environment;
this.mappings = mappings;
}
void shoehorn() {
for (Map.Entry map : mappings.entrySet()) {
final String propName = map.getKey();
final String envName = map.getValue();
if (!environment.containsKey(envName)) {
continue;
}
System.setProperty(propName, environment.get(envName));
System.out.println("Shoehorned [" + envName + "] into [" + propName + "]");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy