context.getContextType().addResolver(new VariableResolver());
/** * Creates a new context with system variables as context parameters. * @param classLoader current class loader * @return the created context object * @throws IllegalArgumentException if some parameters were {@code null} */ public static ProfileContext system(ClassLoader classLoader) { return new ProfileContext(classLoader, new VariableResolver(System.getenv())); }
/** * Creates a new instance from environment variables and system properties. * If both have same entry, the system properties takes precedence over the environment variables. * @return the created instance */ public static VariableResolver system() { Map<String, String> entries = new HashMap<>(); entries.putAll(System.getenv()); for (Map.Entry<Object, Object> entry : System.getProperties().entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); if (key instanceof String && value instanceof String) { entries.put((String) key, (String) value); } } return new VariableResolver(entries); }
env.putAll(System.getenv()); env.putAll(toMap(variables)); result.context = new ProfileContext(loader, new VariableResolver(env)); Properties properties = CommandLineUtil.loadProperties(file); result.profile = YaessProfile.load(properties, result.context);