Package com.tonbeller.tbutils.res

Access to key/value pairs and application home directory.

See:
          Description

Interface Summary
Dumper  
InitialProvider Base interface for the initial provider.
PersistentResourceProvider  
ResourceProvider Hides various ways of accessing name/value pairs.
 

Class Summary
BundleResourceProvider Adapter fuer ResourceBundle
CompositeResourceProvider Composite ResourceProvider.
JNDIInitialProvider initial provider. looks up variables in JNDI java:/comp/env context System.getProperty() user.properties in root classpath resfactory.properties in root classpath in that order.
JNDIResourceProvider Adapter for java naming
NullResourceProvider Dummy that does not know any key/values
PropertyResourceProvider Adapter for Properties
ReplacingResourceProvider  
Resources Facade to access key/value pairs and application home directory.
ResourcesFactory creates and caches Resources.
ResourcesFactoryContextListener sets the locale for JSTL tags
ServletContextResourceProvider Adapter for ServletContext initParameter
SimpleInitialProvider initial provider. looks up variables System.getProperty() user.properties in root classpath resfactory.properties in root classpath in that order.
StringDumper dumps into StringBuffer
SystemResourceProvider looksup keys via System.getProperty()
 

Exception Summary
 

Package com.tonbeller.tbutils.res Description

Access to key/value pairs and application home directory.

Resources is the facade to access Resources. ResourcesFactory contains a description how to configure the Resources.

ResourcesFactory looks for a resource bundle named resfactory in the classpath (root package). The resfactory may contain the following entries:

Initialization

tbeller.home Path of a directory in the filesystem where the application may want to store data or read property files. The default is ~/.tonbeller

Example: tbeller.home=c:\temp

Example: tbeller.home=${java.io.tmpdir}

tbeller.usejndi defaults to true. If set to false, properties will not looked up via JNDI. Example: tbeller.usejndi=false
tbeller.bundles Names of ResourceBundle's that will be looked up in the class path

Example: tbeller.bundles=com.tonbeller.jpivot.jpivot com.acme.messages

tbeller.resources Paths of property files, that will be looked up in the file system. If the path is relative, its releative to tbeller.home (see above), otherwise its taken absolute.

Example tbeller.resources=local.properties is identical to tbeller.resources=${tbeller.home}/local.properties

Example tbeller.resources=local.properties /etc/conf/conf.properties

These four variables are looked up

  1. in JNDI java:/comp/env context (depends on tbeller.usejndi)
  2. user.properties in root classpath
  3. resfactory.properties in root classpath
  4. System.getProperty()
in that order.

Runtime

After initialization using the four variables above, Properties are searched in the following order
  1. System Properties
  2. The tbeller.properties property files in the given order
  3. The tbeller.bundles Resource Bundles in the given order
The first match "wins".

Property references

Properties may be referenced from other properties. Example:
root.dir=/usr/local/myapp
dir1=${root.dir}/dir1
dir2=${java.io.tmpdir}/dir2
may expand to
root.dir=/usr/local/myapp
dir1=/usr/local/myapp/dir1
dir2=/tmp/dir2