/** * Convert a standard properties class into a configuration class. * <p> * NOTE: From Commons Collections 3.2 this method will pick up * any default parent Properties of the specified input object. * * @param props the properties object to convert * @return new ExtendedProperties created from props */ public static ExtendedProperties convertProperties(Properties props) { ExtendedProperties c = new ExtendedProperties(); for (Enumeration e = props.propertyNames(); e.hasMoreElements();) { String s = (String) e.nextElement(); c.setProperty(s, props.getProperty(s)); } return c; }
/** * Convert a standard properties class into a configuration class. * <p> * NOTE: From Commons Collections 3.2 this method will pick up * any default parent Properties of the specified input object. * * @param props the properties object to convert * @return new ExtendedProperties created from props */ public static ExtendedProperties convertProperties(Properties props) { ExtendedProperties c = new ExtendedProperties(); for (Enumeration e = props.propertyNames(); e.hasMoreElements();) { String s = (String) e.nextElement(); c.setProperty(s, props.getProperty(s)); } return c; }
/** * Combines an existing Hashtable with this Hashtable. * <p> * Warning: It will overwrite previous entries without warning. * * @param props the properties to combine */ public void combine(ExtendedProperties props) { for (Iterator it = props.getKeys(); it.hasNext();) { String key = (String) it.next(); setProperty(key, props.get(key)); } }
/** * Combines an existing Hashtable with this Hashtable. * <p> * Warning: It will overwrite previous entries without warning. * * @param props the properties to combine */ public void combine(ExtendedProperties props) { for (Iterator it = props.getKeys(); it.hasNext();) { String key = (String) it.next(); setProperty(key, props.get(key)); } }
public void testInterpolation() { eprop.setProperty("applicationRoot", "/home/applicationRoot"); eprop.setProperty("db", "${applicationRoot}/db/hypersonic"); String dbProp = "/home/applicationRoot/db/hypersonic"; assertTrue("Checking interpolated variable", eprop.getString("db").equals(dbProp)); }
/** 设置高级配置。 */ public void setAdvancedProperties(Map<String, Object> configuration) { this.properties.clear(); for (Map.Entry<String, Object> entry : configuration.entrySet()) { this.properties.setProperty(entry.getKey(), entry.getValue()); } }
properties.setProperty(RESOURCE_LOADER, "spring"); properties.setProperty(prefix + "description", "Spring Resource Loader Adapter"); properties.setProperty(prefix + "class", SpringResourceLoaderAdapter.class.getName()); properties.setProperty(prefix + "path", path); properties.setProperty(prefix + "cache", String.valueOf(cacheEnabled)); properties.setProperty(prefix + "modificationCheckInterval", String.valueOf(modificationCheckInterval)); properties.setProperty(prefix + "description", "Preloaded Resource Loader"); properties.setProperty(prefix + "class", PreloadedResourceLoader.class.getName()); properties.setProperty(prefix + "cache", String.valueOf(cacheEnabled)); properties.setProperty(prefix + "modificationCheckInterval", String.valueOf(modificationCheckInterval)); properties.setProperty(prefix + PRELOADED_RESOURCES_KEY, preloadedResources);
/** 设置默认值。如果值已存在,则不覆盖。 */ private void setDefaultProperty(String key, Object value) { if (!properties.containsKey(key)) { properties.setProperty(key, value); } }
properties.setProperty(RESOURCE_LOADER, "spring"); properties.setProperty(prefix + "description", "Spring Resource Loader Adapter"); properties.setProperty(prefix + "class", SpringResourceLoaderAdapter.class.getName()); properties.setProperty(prefix + "path", path); properties.setProperty(prefix + "cache", String.valueOf(cacheEnabled)); properties.setProperty(prefix + "modificationCheckInterval", String.valueOf(modificationCheckInterval)); properties.setProperty(prefix + "description", "Preloaded Resource Loader"); properties.setProperty(prefix + "class", PreloadedResourceLoader.class.getName()); properties.setProperty(prefix + "cache", String.valueOf(cacheEnabled)); properties.setProperty(prefix + "modificationCheckInterval", String.valueOf(modificationCheckInterval)); properties.setProperty(prefix + PRELOADED_RESOURCES_KEY, preloadedResources);
/** 设置高级配置。 */ public void setAdvancedProperties(Map<String, Object> configuration) { this.properties.clear(); for (Map.Entry<String, Object> entry : configuration.entrySet()) { this.properties.setProperty(entry.getKey(), entry.getValue()); } }
/** 设置默认值。如果值已存在,则不覆盖。 */ private void setDefaultProperty(String key, Object value) { if (!properties.containsKey(key)) { properties.setProperty(key, value); } }
public void setRuntimeServices(RuntimeServices rs) { rs.getConfiguration().setProperty(RUNTIME_SERVICES_KEY, rs); } }
/** 初始化日志系统。 */ private void initLogger() { properties.setProperty(RUNTIME_LOG_LOGSYSTEM, new Slf4jLogChute(log)); }
/** 初始化日志系统。 */ private void initLogger() { properties.setProperty(RUNTIME_LOG_LOGSYSTEM, new Slf4jLogChute(log)); }
public void setRuntimeServices(RuntimeServices rs) { rs.getConfiguration().setProperty(RUNTIME_SERVICES_KEY, rs); } }
eprop.setProperty("number", "1"); assertEquals("This returns '1'", eprop.getProperty("number"), "1"); assertEquals("This returns '1'", eprop.getString("number"), "1"); eprop.setProperty("prop.string", prop); assertTrue("This returns vector", (eprop.getVector("prop.string") instanceof java.util.Vector)); assertTrue("This returns list", (eprop.getList("prop.string") instanceof java.util.List)); eprop.setProperty("prop.string", prop2); assertTrue("This returns array", (eprop.getString("prop.string") instanceof java.lang.String));
/** 初始化杂项。 */ private void initMiscs() { if (charset == null) { charset = DEFAULT_CHARSET; } setDefaultProperty(RESOURCE_MANAGER_LOGWHENFOUND, "false"); setDefaultProperty(INPUT_ENCODING, charset); setDefaultProperty(OUTPUT_ENCODING, DEFAULT_CHARSET); setDefaultProperty(PARSER_POOL_SIZE, "50"); setDefaultProperty(UBERSPECT_CLASSNAME, CustomizedUberspectImpl.class.getName()); setDefaultProperty(VM_ARGUMENTS_STRICT, "true"); setDefaultProperty(VM_PERM_INLINE_LOCAL, "true"); setDefaultProperty(SET_NULL_ALLOWED, "true"); // auto-reload macros if (productionMode) { properties.setProperty(VM_LIBRARY_AUTORELOAD, "false"); } else { properties.setProperty(VM_LIBRARY_AUTORELOAD, "true"); } // strict ref properties.setProperty(RUNTIME_REFERENCES_STRICT, String.valueOf(strictReference)); }
/** 初始化杂项。 */ private void initMiscs() { if (charset == null) { charset = DEFAULT_CHARSET; } setDefaultProperty(RESOURCE_MANAGER_LOGWHENFOUND, "false"); setDefaultProperty(INPUT_ENCODING, charset); setDefaultProperty(OUTPUT_ENCODING, DEFAULT_CHARSET); setDefaultProperty(PARSER_POOL_SIZE, "50"); setDefaultProperty(UBERSPECT_CLASSNAME, CustomizedUberspectImpl.class.getName()); setDefaultProperty(VM_ARGUMENTS_STRICT, "true"); setDefaultProperty(VM_PERM_INLINE_LOCAL, "true"); setDefaultProperty(SET_NULL_ALLOWED, "true"); // auto-reload macros if (productionMode) { properties.setProperty(VM_LIBRARY_AUTORELOAD, "false"); } else { properties.setProperty(VM_LIBRARY_AUTORELOAD, "true"); } // strict ref properties.setProperty(RUNTIME_REFERENCES_STRICT, String.valueOf(strictReference)); }
/** 查找所有全局macros。 */ private void initMacros() throws Exception { ResourcePatternResolver resolver; if (loader instanceof ResourcePatternResolver) { resolver = (ResourcePatternResolver) loader; } else { resolver = new PathMatchingResourcePatternResolver(loader); } if (macros != null) { for (String macro : macros) { resolveMacro(resolver, macro); } } // Velocity default: VM_global_library.vm resolveMacro(resolver, VM_LIBRARY_DEFAULT); // Plugin macros if (plugins != null) { for (Object plugin : plugins) { if (plugin instanceof VelocityPlugin) { addMacroResources(null, ((VelocityPlugin) plugin).getMacros()); } } } if (!properties.containsKey(VM_LIBRARY)) { properties.setProperty(VM_LIBRARY, EMPTY_STRING); } }
/** 查找所有全局macros。 */ private void initMacros() throws Exception { ResourcePatternResolver resolver; if (loader instanceof ResourcePatternResolver) { resolver = (ResourcePatternResolver) loader; } else { resolver = new PathMatchingResourcePatternResolver(loader); } if (macros != null) { for (String macro : macros) { resolveMacro(resolver, macro); } } // Velocity default: VM_global_library.vm resolveMacro(resolver, VM_LIBRARY_DEFAULT); // Plugin macros if (plugins != null) { for (Object plugin : plugins) { if (plugin instanceof VelocityPlugin) { addMacroResources(null, ((VelocityPlugin) plugin).getMacros()); } } } if (!properties.containsKey(VM_LIBRARY)) { properties.setProperty(VM_LIBRARY, EMPTY_STRING); } }