public void read(URL url, boolean required) { read(url, required, null); }
protected void read(URL url, boolean required, Logger log) { try { readImpl(url); // only add the sources which can be read addSource(" .read("+url.toString()+")"); } catch (IOException ioe) { String msg = "Could not open stream from: "+url; if (log != null) { log.debug(msg, ioe); } if (required) { throw new RuntimeException(msg, ioe); } } } }
public void read(String path, boolean required, Logger log) { if (path == null) { throw new NullPointerException("Path value cannot be null"); } if (log != null && log.isTraceEnabled()) { log.trace("Attempting to read configuration file at: {}", path); } URL url = findURL(path); if (url != null) { read(url, required, log); } else { String msg = "Could not find configuration file at: "+path; if (log != null) { log.debug(msg); } if (required) { throw new ResourceNotFoundException(msg); } } }
/** * <p>Reads a configuration file from the specified file path * and sets up the configuration from that. If the file does not * exist, a {@link ResourceNotFoundException} will be thrown.</p> * * @param path the path to the file to be read from */ public void read(String path) { read(path, true); }
public void read(URL url) { read(url, true); }
public void read(String path, boolean required) { read(path, required, null); }
/** * <p>Returns a {@link FactoryConfiguration} including all default * "VelocityView" tools available as well as the default "GenericTools".</p> * @return all default tools {@link FactoryConfiguration} * @throws ConfigurationException if a tools.xml is not found at the {@link #VIEW_DEFAULTS_PATH}. */ public static FactoryConfiguration getVelocityView() { FileFactoryConfiguration config = new XmlFactoryConfiguration("ConfigurationUtils.getVelocityView()"); config.read(GENERIC_DEFAULTS_PATH); config.read(VIEW_DEFAULTS_PATH); // defaults should *always* be clean! clean(config); return config; }
/** * Returns the "default" {@link FactoryConfiguration}. This includes * all the standard tools developed by this project and available in * the jar being used. In other words, if the velocity-tools-generic-2.x.jar * is being used, then only the generic tools will be included. If * the velocity-tools-struts-2.x.jar is being used, then all VelocityTools * will be available. This also means that subclasses in the larger jars * will override their superclasses. So, if you are using the VelocityStruts * jar, then your $link reference will be a StrutsLinkTool. If you are using * the VelocityView jar, it will be a standard LinkTool. * @return the default {@link FactoryConfiguration} */ public static FactoryConfiguration getDefaultTools() { FileFactoryConfiguration config = new XmlFactoryConfiguration("ConfigurationUtils.getDefaultTools()"); config.read(GENERIC_DEFAULTS_PATH); // view tools may not be available config.read(VIEW_DEFAULTS_PATH, false); // defaults should *always* be clean! clean(config); return config; }
/** * Returns a {@link FactoryConfiguration} including all default * "GenericTools" available and no others. * @return the generic tools default {@link FactoryConfiguration} */ public static FactoryConfiguration getGenericTools() { FileFactoryConfiguration config = new XmlFactoryConfiguration("ConfigurationUtils.getGenericTools()"); config.read(GENERIC_DEFAULTS_PATH); // defaults should *always* be clean! clean(config); return config; }