hi all,
        sorry 2 bother, but while i was reading the post i was
curious of one thing.
First of all, sorry if i won't use the correct terminology, but
i hope that i cam make me understand anyway.

I am using JSP model 2 architecture, and i need to access some
classes from JSPs. I don't put them in the Session, since the
data stored in those classes (for example, list of buildings, cities
etc..) are not user specific.
I don't want to send it always as request attribute etc.. so i was thinking
of making those classes with static variables and static methods.
for example

public class Cities {
   static ArrayList cities = new ArrayList();

   static void addCity(String name) {
        cities.put(name);
   }

   static ArrayList getCityList() {
      return cities;
   }
   
   ....
   .....
   ....

}

So, if i am correct, those two methods will be available to all classes
of teh same JVM, correct?

This 'design' allows me to avoid to load the cities from the DB whenever a list
of cities/building is required.
I have fixed amount of users (the employees of my company), so whenever every user
of every possible nation and every possible city have used my app, the Cities.cities
is full with every possible city.

So, for every nation in my class i will have every possible city, 4 example

Luxembourg  
         Luxembourg City

Now, assume that an user from Luxebourg has logged in: if Luxembourg was not present
in my Cities class, i will load all the cities from the DB (it's only one), and i will
display it on the JSP.
At this point of time, all the cities of Luxembourg are loaded, so if a second user 
from
Luxembourg logs in, i don't need to call the DB to retreive all the cities, since they
are already in my Class.

But, the day after a new city is added, let's say  Luxemboug Area. 
If an user from Luxemboug logs in,  all the cities of Luxembourg are already stored, 
but
because the DB loading was done earlier, the new city won't be there.

Ideally, i can do something in my application that allows me to 'refresh' the 
data....but i
was curious if i could do it from another app, maybe running on a different JVM.

is that possible??? if so, how?

thanx and regards
        marco










































-----Original Message-----
From: ext Gene Chuang [mailto:[EMAIL PROTECTED]]
S
ent: 23. May 2002 9:15
To: [EMAIL PROTECTED]
Subject: Re: Off Topic : ClassLoaders


Please clarify: do you want an Instance singleton or a Class singleton across multiple
VM's?  These are two very distinct concepts.

An Instance singleton across multiple VMs is accomplishable in one of many ways, as
already described by previous posts.

A Class singleton across multiple VMs isn't difficult either;  simple overload the
classloading method to

1) check for a file lock
2) load class if no lock, or throw ClassNotFoundException if lock exists
3) place file lock if Class successfully loaded

Gene
--- Ramakrishna N <[EMAIL PROTECTED]> wrote:
> Hi,
>    This is an off topic suggestion that I am seeking but its urgent and so I
> am posting it here.
>     I want only one Instance of a particular Class to be running across
> multiple VMs. I mean if I am executing a class in one of the VMs then If I
> say run the same Class in another VM of the same machine it should not run.
> How do I achieve this behaviour ?
>     Currently we have a configuration xml file where in the Application
> registers when it has opened and registers again when it has successfully
> closed so that in between if I try to open the application in another VM the
> application first reads the configuration xml and understands that one
> istance of the application is running and so it exits.
>     I would like to achieve it through ClassLoaders. Say custom
> ClassLoaders. I am sure there should be a way to achieve this without doing
> any I/O operations like opening a socket when the application starts..
>     Any help on this would be of great help. Thanks in advance.
>
> Thanks & Regards,
> kris
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

==========================================================================To 
unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to