|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.resources.impl.ResourcesBase org.apache.commons.resources.impl.CollectionResourcesBase org.apache.commons.resources.impl.JDBCResources
public class JDBCResources
Concrete implementation of
Resources
that retrieves message
key value pairs using JDBC. For this specific implementation, database
connection properties and Locale
for which the document's
messages apply are specified via property files. Resources are looked up in
a hierarchy of database values in a manner identical to that
performed by java.util.ResourceBundle.getBundle().
.
The base URL passed to our constructor must contain the base name of a properties file that holds the JDBC datasource configuration.
The expected format of the required properties file might look like this:
jdbc.connect.driver = org.gjt.mm.mysql.Driver
jdbc.connect.url = jdbc:mysql://localhost/resources
jdbc.connect.login = resourcesTest
jdbc.connect.password = resourcesTest
jdbc.sql.db = resources
jdbc.sql.table = resources
jdbc.sql.locale.column = locale
jdbc.sql.key.column = msgKey
jdbc.sql.val.column = val
org.apache.commons.resource.CACHE = true
Constructor Summary | |
---|---|
JDBCResources(String name,
String base)
Create a new Resources instance with the specified
logical name and base resource URL. |
Method Summary | |
---|---|
protected Map |
getLocaleMap(String baseUrl,
Locale locale)
Return a Map containing the name-value mappings for
the specified base URL and requested Locale , if there
are any. |
Methods inherited from class org.apache.commons.resources.impl.CollectionResourcesBase |
---|
destroy, getDefaultLocale, getKeys, getLocaleList, getLocaleMap, getLocaleSuffix, getObject, setDefaultLocale |
Methods inherited from class org.apache.commons.resources.impl.ResourcesBase |
---|
getBufferSize, getBytes, getInputStream, getName, getReader, getString, init, isReturnNull, setBufferSize, setReturnNull |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JDBCResources(String name, String base)
Create a new
Resources
instance with the specified
logical name and base resource URL.
name
- Logical name of the new instancebase
- Base URL of the JDBC configuration properties.Method Detail |
---|
protected Map getLocaleMap(String baseUrl, Locale locale)
Return a Map
containing the name-value mappings for
the specified base URL and requested Locale
, if there
are any. If there are no defined mappings for the specified
Locale
, return an empty Map
instead.
Concrete subclasses must override this method to perform the
appropriate lookup. A typical implementation will construct an
absolute URL based on the specified base URL and Locale
,
retrieve the specified resource file (if any), and parse it into
a Map
structure.
Caching of previously retrieved Map
s (if any) should
be performed by callers of this method. Therefore, this method should
always attempt to retrieve the specified resource and load it
appropriately.
getLocaleMap
in class CollectionResourcesBase
baseUrl
- Base URL of the resource files for this
Resources
instancelocale
- Locale
for which name-value mappings
are requested
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |