• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Static fields in java classes from DB record
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Static fields in java classes from DB record


  • Subject: Re: Static fields in java classes from DB record
  • From: Florijan Stamenkovic <email@hidden>
  • Date: Sat, 20 Aug 2005 16:55:05 +0200

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

_______________________________________________
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


  • Follow-Ups:
    • Re: Static fields in java classes from DB record
      • From: Wolfram Stebel <email@hidden>
References: 
 >Static fields in java classes from DB record (From: Florijan Stamenkovic <email@hidden>)
 >Re: Static fields in java classes from DB record (From: Kieran Kelleher <email@hidden>)

  • Prev by Date: Re: Static fields in java classes from DB record
  • Next by Date: How to find out users browser?
  • Previous by thread: Re: Static fields in java classes from DB record
  • Next by thread: Re: Static fields in java classes from DB record
  • Index(es):
    • Date
    • Thread