Thanks.
The good old fashioned solution works. But I would like the .properties
to be loaded eagerly when application starts up ( to avoid the
Properties lazy-initialisation issue or the DCL bug, see
http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html)
Was just wondering whether if Tapestry has an flexible way of handling
this. By "flexible" I mean declarative and configurable, say, something
like spring's "PropertiesFactoryBean".
"org.apache.tapestry.property-source" extension (See the second question
I asked)seems promising. I implemented
org.apache.tapestry.engine.IPropertySource, this enables me to specify
the .properties file to load in my .application file. The only problem I
am having is figure out out a way to get tapestry to load the
.properties eagerly at application startup rather than performing a lazy
initialisation which can be problematic.
I might end up declaring a Properties instance using
PropertiesFactoryBean in spring and inject into tapestry.
Please advise.
Thanks
Sean
Patrick Casey wrote:
Couldn't you just use a physical properties file? Am I missing some
reason that you can't just drop the properties file in your classpath and
use the good old fashioned:
InputStream in =
this.class.getClassLoader().getResourceAsStream("application.properties");
if (in == null) {
Log.warn("We couldn't find your
application.properties file. Using all defaults.");
}
Properties foo = new Properties();
try {
foo.load(in);
} catch (IOException e) {
Log.error("Couldn't parse your
application.properties file");
Log.error("Proceeding with all default values, but
you should really fix the properties");
}
--- Pat
-----Original Message-----
From: sean gao [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 30, 2005 1:18 AM
To: [email protected]
Subject: global configuration and usage of org.apache.tapestry.property-
source
can anybody help me on these two questions please?
Thanks
Sean
<Question 1>
I would like load configurable global properties in my application
These are name/value pairs such as
tempfolder.path=/home/users/temp
default.color=white
stored in .properties files or in a database.
Ideally I would like to be able to set something like this in the
application specification file
<property name="org.apache.tapestry.global-config">
config.properties{,config2.properties,config3.properties}
</property>
But this seems to be impossible without patching tapestry3
Guess I could extend BaseEngine or define a custom version of Global .
Just wondering which is the common way of achieving this in tapestry?
<Question 2>
It is mentioned in the user guide
http://jakarta.apache.org/tapestry/3.0.3/doc/TapestryUsersGuide/configurat
ion.extensions.html
" org.apache.tapestry.property-source (IPropertySource
<../api/org/apache/tapestry/engine/IPropertySource.html>)
This extension is fit into the configuration property search path,
after the servlet context, but before JVM system properties.
A typical use would be to access some set of configuration properties
stored in a database.
"
Can anyone give an example?
Thanks
Sean
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]