I agree, application context is a good answer to this question, and its
what I use today for most shared data of any type.

But, don't forget one simpler answer: static!

For a while, I was in the habit of having an AppConfig object that was
just a typical bean with private fields, accessors and mutators, but
everything was static.  It would usually include a configureApp() method
that knew how to read in the relevant configuration file and populate the
bean.

I would usually call configureApp() from a Struts plug-in or session
listener.  Many times I would have the code that actually read the
configuration outside the AppConfig class, so AppConfig was actually
nothing but static fields and static accessors and mutators.

This works just fine if you won't be changing the values after the initial
load.  If you have that requirement though, you will have to deal with the
data integrity issues yourself.  So, it might not be a good idea in every
case... but, synchronization isn't the performance-killer it used to be,
so synchronizing all the methods of this class shouldn't automatically be
considered a bad idea, but that's a decision for you to make :)

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: [EMAIL PROTECTED]

On Wed, January 18, 2006 7:39 am, Vidya \(Suvarna\) Mahavadi said:
> Putting variables in application context should work for you. You can
> get/set those values as long as the application is active.
>
> Vidya
>
> -----Original Message-----
> From: Martin Ravell [mailto:[EMAIL PROTECTED]
> Sent: Wednesday 18 January 2006 14:19
> To: 'Struts Users Mailing List'
> Subject: RE: Globally available variables
>
>>-----Original Message-----
>>From: ALEX HYDE [mailto:[EMAIL PROTECTED]
>>Sent: Wednesday, 18 January 2006 10:47 PM
>>To: Struts Users Mailing List
>>Subject: Re: Globally available variables
>>
>>Can't you put it in the application context instead of all the
> sessions?
>>
>
> I don't know. Will look into this but is it possible to have a session
> write
> an object to this app context and have another session see the result?
>
> I had a suspicion that stuff in the application context was setup during
> the
> app being deployed and could not be changed?
>
>
> Regards
> Marty
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> This message and any attachments are confidential and intended solely for
> the addressee. If you have received this message in error, please notify
> Discovery immediately, telephone number +27 11 529 2888. Any unauthorised
> use; alteration or dissemination of the contents of this email is strictly
> prohibited. In no event will Discovery or the sender be liable in any
> manner whatsoever to any person for any loss or any direct, indirect,
> special or consequential damages arising from use of this email or any
> linked website, including, without limitation, from any lost profits,
> business interruption, loss of programmes or other data that may be stored
> on any information handling system or otherwise from any assurance that
> this email is virus free even if Discovery is expressly advised of the
> possibility of such damages. Discovery is an Authorised Financial Services
> Provider.
>
> ---------------------------------------------------------------------
> 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]

Reply via email to