FactoryConfiguration factoryConfig = new FactoryConfiguration(); factoryConfig.addToolbox(toolbox); velocityToolManager.configure(factoryConfig); toolContext = velocityToolManager.createContext();
public void addToolbox(ToolboxConfiguration toolbox) { addChild(toolbox); }
public void setData(Collection<Data> data) { for (Data datum : data) { addData(datum); } }
public void addConfiguration(FactoryConfiguration config) { // add config's Data to our own setData(config.getData()); // add config's sources to our own for (String source : config.getSources()) { addSource(source); } // pass to CompoundConfiguration's to add properties super.addConfiguration(config); }
/** * Load {@link FactoryConfiguration} if present * * @param toolboxConfigLocations * @return FactoryConfiguration */ public FactoryConfiguration load(String... toolboxConfigLocations) { FactoryConfiguration allFactoryConfiguration = new FactoryConfiguration(); for (String toolboxConfigLocation : toolboxConfigLocations) { FactoryConfiguration factoryConfiguration = load(toolboxConfigLocation); if (factoryConfiguration != null) { allFactoryConfiguration.addConfiguration(factoryConfiguration); } } return allFactoryConfiguration; }
if (includeSources) out.append(getSources().size()); out.append(" sources "); appendProperties(out); if (hasData()) out.append(" data"); if (getToolboxes().isEmpty()) appendChildren(out, "toolboxes: \n ", "\n "); if (hasData()) for (String source : getSources())
/** * Searches for a configuration file at the specified path and returns * it in the form of a {@link FactoryConfiguration}. This method will * look for a matching file in both the classpath and the file system. * If perchance a match is found in both, then both are loaded and the * configuration loaded from the file system is given precedence (i.e. * it is added onto the other). If no match is found in either, then * this will return {@code null}. * @param path configuration classpath or filesystem path * @return new {@link FactoryConfiguration} for the given path */ public static FactoryConfiguration find(String path) { FactoryConfiguration cp = findInClasspath(path); FactoryConfiguration fs = findInFileSystem(path); if (cp != null) { if (fs != null) { cp.addConfiguration(fs); } return cp; } else { return fs; } }
public Collection<ToolboxConfiguration> getToolboxes() { return getChildren(); }
/** * Allows subclasses to construct an instance that uses their classname. * @param clazz FactoryConfiguration class name * @param source configuration source name */ protected FactoryConfiguration(Class clazz, String source) { addSource(clazz.getName()+"("+source+")"); }
/** * Load {@link FactoryConfiguration} if present * * @param toolboxConfigLocations * @return FactoryConfiguration */ public FactoryConfiguration load(String... toolboxConfigLocations) { FactoryConfiguration allFactoryConfiguration = new FactoryConfiguration(); for (String toolboxConfigLocation : toolboxConfigLocations) { FactoryConfiguration factoryConfiguration = load(toolboxConfigLocation); if (factoryConfiguration != null) { allFactoryConfiguration.addConfiguration(factoryConfiguration); } } return allFactoryConfiguration; }
new FactoryConfiguration("ConfigurationUtils.findInClassPath("+path+","+caller+")"); boolean readAConfig = false; for (URL resource : found) config.addConfiguration(c);