Re: Static fields in java classes from DB record
Re: Static fields in java classes from DB record
- Subject: Re: Static fields in java classes from DB record
- From: Wolfram Stebel <email@hidden>
- Date: Mon, 22 Aug 2005 11:23:19 +0200
Title: Re: Static fields in java classes from DB record
Am 20.08.2005 16:55 Uhr schrieb "Florijan Stamenkovic" unter <email@hidden>:
> You could put your paths into the Properties file, like this
>
> myapp.path.files=/var/xyx/abc
>
> and in code, put
>
> protected final static String MY_PATH = System.getProperty(
> "myapp.path.files" );
Yup, that might be a better solution then keeping those properties in
the database.
>
>
> OR better use lazy initialization......
I prefer to have it done at startup, just to disable anybody using the
app if the "globals" are not set. For the time being the Application
constructor seems like a good idea.
>
> protected static String _myPath;
>
> public static String myPath() {
> if ( _myPath == null ) {
> _myPath = System.getProperty( "myapp.path.files" );
>
> // Check the path here to make sure it is valid, exists, etc
> }
>
> return _myPath;
> }
>
> static vars get created the first time a class is loaded
Yeah, I was more confused as to how WO handles this. What if all
instances are killed and restarted, does that re-load the classes?
Well, it is not such a significant problem, as those paths should not
be changed frequently... Might as well reboot after a change.
>
> HTH, Kieran
It does, as far as there is no major drawbacks of this, it is great.
And thanks for the properties tip, it didn't occur to me to do it that
way.
Flor
You should have a look on my “PropDemo.zip” at “www.bugs-and-errors.de”.
This is a demo to use my class PropertiesUpdater for updateing properties at runtime
and allowing a different setting in development and deployment.
Wolfram
Wolfram Stebel
Flutgrabenstr. 19, 35576 Wetzlar
Tel. 06441/47633
Mailto: email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden