In my application I use the singleton pattern to cache information which is
globally accessible. You can invoke the singleton in the init method of a
servlet which is loaded on startup. This way you have one instance of the
object in the JVM

Regards,
   MAX

----- Original Message -----
From: "Sri Sankaran" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Saturday, November 02, 2002 11:39 AM
Subject: RE: [OT] static vs. application scope


Sure, good point.  What I was trying to establish was the difference in
*availability*.  In the proper context, both a static property and an
attribute in application scope will be both *available*.

However, as David Graham pointed out, business objects can not (sic)
(interpret -- should not) have access to the application context.  *That*
probably should suggest which technique to use to cache constant data.

Sri

-----Original Message-----
From: Galbreath, Mark [mailto:Galbreath@;tessco.com]
Sent: Saturday, November 02, 2002 10:31 AM
To: 'Struts Users Mailing List'
Subject: RE: [OT] static vs. application scope


It's not going to be available to anything outside its class with the stated
signature, static or not.

Mark

-----Original Message-----
From: Sri Sankaran [mailto:Sri.Sankaran@;sas.com]
Sent: Friday, November 01, 2002 4:45 PM
To: Struts-User
Subject: [OT] static vs. application scope


What is the difference between making a property available in application
scope as opposed to making it static to a class?  As a simple (contrived)
example, I want to maintain a mapping of car model and manufacturer.  This
being, un-changing I could implement it as a static property of some class.

public class SomeClass {
  private static Map carInfo;
}

This will be available to *all* sessions -- since all sessions are "hosted"
by the same VM (isn't that true -- or is that dependent on the container?).

I could, alternatively, maintain such information in the servlet application
context.

What is the difference?

Sri

--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@;jakarta.apache.org>


--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@;jakarta.apache.org>

-




--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>

Reply via email to