public class ConfigurationUtils extends Object
Type | Property and Description |
---|---|
static FactoryConfiguration |
findFromSystem
Returns a
FactoryConfiguration loaded from the path specified
in the "org.apache.velocity.tools" system property (if any). |
Modifier and Type | Field and Description |
---|---|
static String |
AUTOLOADED_PROPS_PATH |
static String |
AUTOLOADED_XML_PATH |
static String |
CONFIG_FACTORY_METHOD |
static String |
GENERIC_DEFAULTS_PATH |
static ConfigurationUtils |
INSTANCE |
static String |
SYSTEM_PROPERTY_KEY |
static String |
VIEW_DEFAULTS_PATH |
Modifier and Type | Method and Description |
---|---|
static void |
clean(Configuration config)
Convenience method that automatically creates a new
ConfigurationCleaner and applies it to the specified
Configuration . |
static ToolboxFactory |
createFactory()
Returns a new, standard
ToolboxFactory configured
with the results of findFromSystemProperty() . |
static FactoryConfiguration |
find(String path)
Searches for a configuration file at the specified path and returns
it in the form of a
FactoryConfiguration . |
static FactoryConfiguration |
findFromSystemProperty()
Returns a
FactoryConfiguration loaded from the path specified
in the "org.apache.velocity.tools" system property (if any). |
static FactoryConfiguration |
findInClasspath(String path) |
static FactoryConfiguration |
findInClasspath(String path,
Object caller)
Searches the classpath for a configuration file matching the
specified path.
|
static FactoryConfiguration |
findInFileSystem(String path)
Searches the file system for a configuration file matching the
specified path.
|
static FactoryConfiguration |
getDefaultTools()
Returns the "default"
FactoryConfiguration . |
static FactoryConfiguration |
getFromClass(Class factory) |
static FactoryConfiguration |
getFromClass(String classname)
Get a specific
FactoryConfiguration class |
static FactoryConfiguration |
getGenericTools()
Returns a
FactoryConfiguration including all default
"GenericTools" available and no others. |
ConfigurationUtils |
getInstance() |
static org.slf4j.Logger |
getLog(org.apache.velocity.app.VelocityEngine engine,
String childNamespace) |
static FactoryConfiguration |
getVelocityView()
Returns a
FactoryConfiguration including all default
"velocity-tools-view" tools available as well as the default "GenericTools". |
static FactoryConfiguration |
load(String path)
Returns a
FactoryConfiguration loaded from a configuration file
at the specified path. |
static FactoryConfiguration |
read(URL url)
Returns a
FactoryConfiguration read from a known configuration
file type at the specified URL . |
public static FactoryConfiguration findFromSystemProperty
FactoryConfiguration
loaded from the path specified
in the "org.apache.velocity.tools" system property (if any).
If no such property has been set null
will be returned.public static final String GENERIC_DEFAULTS_PATH
public static final String VIEW_DEFAULTS_PATH
public static final String AUTOLOADED_XML_PATH
public static final String AUTOLOADED_PROPS_PATH
public static final String SYSTEM_PROPERTY_KEY
public static final ConfigurationUtils INSTANCE
public static final String CONFIG_FACTORY_METHOD
public ConfigurationUtils getInstance()
public static FactoryConfiguration getDefaultTools()
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.FactoryConfiguration
public static FactoryConfiguration getGenericTools()
FactoryConfiguration
including all default
"GenericTools" available and no others.FactoryConfiguration
public static FactoryConfiguration getVelocityView()
Returns a FactoryConfiguration
including all default
"velocity-tools-view" tools available as well as the default "GenericTools".
FactoryConfiguration
ConfigurationException
- if a tools.xml is not found at the VIEW_DEFAULTS_PATH
.public static FactoryConfiguration findFromSystemProperty()
FactoryConfiguration
loaded from the path specified
in the "org.apache.velocity.tools" system property (if any).
If no such property has been set null
will be returned.public static ToolboxFactory createFactory()
ToolboxFactory
configured
with the results of findFromSystemProperty()
.ToolboxFactory
public static void clean(Configuration config)
ConfigurationCleaner
and applies it to the specified
Configuration
.config
- Configuration
public static FactoryConfiguration load(String path)
FactoryConfiguration
loaded from a configuration file
at the specified path. If no such file is found at that path, this
will throw a ResourceNotFoundException
.path
- configuration pathFactoryConfiguration
find(String path)
public static FactoryConfiguration find(String path)
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 null
.path
- configuration classpath or filesystem pathFactoryConfiguration
for the given pathpublic static FactoryConfiguration findInFileSystem(String path)
FactoryConfiguration
. If not found, this will return
null
.path
- filesystem pathFactoryConfiguration
for the given pathIllegalStateException
- if the file exists, but its path could not be converted to a URL for reading.public static FactoryConfiguration findInClasspath(String path)
path
- configuration classpathFactoryConfiguration
for the given classpathfindInClasspath(String path, Object caller)
public static FactoryConfiguration findInClasspath(String path, Object caller)
FactoryConfiguration
. If not found, this will return
null
. If there are multiple matching resources in the
classpath, then they will be added together in the order found
(i.e. the last one will have precedence).path
- configuration classpathcaller
- classloader contextFactoryConfiguration
for the given classpathClassUtils.getResources(String path, Object caller)
public static FactoryConfiguration read(URL url)
FactoryConfiguration
read from a known configuration
file type at the specified URL
. If the file is missing or unreadable,
this will simply return null
(i.e. if an IOException is thrown).url
- configuration URLFactoryConfiguration
for the given URLUnsupportedOperationException
- if the file type (identified via suffix)
is neither ".xml" or ".properties"public static FactoryConfiguration getFromClass(String classname)
FactoryConfiguration
classclassname
- FacotyConfiguration classpublic static FactoryConfiguration getFromClass(Class factory)
public static org.slf4j.Logger getLog(org.apache.velocity.app.VelocityEngine engine, String childNamespace)
Copyright © 2002–2021 The Apache Software Foundation. All rights reserved.