org.apache.commons.dbutils
public class QueryLoader extends java.lang.Object
QueryLoader
is a registry for sets of queries so
that multiple copies of the same queries aren't loaded into memory.
This implementation loads properties files filled with query name to
SQL mappings. This class is thread safe.Modifier and Type | Field and Description |
---|---|
private static QueryLoader |
instance
The Singleton instance of this class.
|
private java.util.Map |
queries
Maps query set names to Maps of their queries.
|
Modifier | Constructor and Description |
---|---|
protected |
QueryLoader()
QueryLoader constructor.
|
Modifier and Type | Method and Description |
---|---|
static QueryLoader |
instance()
Return an instance of this class.
|
java.util.Map |
load(java.lang.String path)
Loads a Map of query names to SQL values.
|
protected java.util.Map |
loadQueries(java.lang.String path)
Loads a set of named queries into a Map object.
|
void |
unload(java.lang.String path)
Removes the queries for the given path from the cache.
|
private static final QueryLoader instance
private java.util.Map queries
public static QueryLoader instance()
public java.util.Map load(java.lang.String path) throws java.io.IOException
path
- The path that the ClassLoader will use to find the file.
This is not a file system path. If you had a jarred
Queries.properties file in the com.yourcorp.app.jdbc package you would
pass "/com/yourcorp/app/jdbc/Queries.properties" to this method.java.io.IOException
- if a file access error occursjava.lang.IllegalArgumentException
- if the ClassLoader can't find a file at
the given path.protected java.util.Map loadQueries(java.lang.String path) throws java.io.IOException
path
- The path that the ClassLoader will use to find the file.java.io.IOException
- if a file access error occursjava.lang.IllegalArgumentException
- if the ClassLoader can't find a file at
the given path.public void unload(java.lang.String path)
path
- The path that the queries were loaded from.