aspose file tools*
The moose likes Tomcat and the fly likes Singleton class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Singleton class" Watch "Singleton class" New topic
Author

Singleton class

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5599
    
  15

Hi,

I have a class that's reading a file and it has to happen once, so i made a singleton. I have 2 web-apps, both using same file. Now the file is read twice (one time with webappA and once with webappB)

So i am looking to create a singleton on server-level instead of application-level

Anyone knows how to do this or is it mission impossible?


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
asirob civokviz
Greenhorn

Joined: Jun 12, 2004
Posts: 24
it is possible but problem is that you run two different applications and
every in it's own JVM instance!!! So classical singleto pattern wouldnot
work. You should try to find some pattern which is "network aware". Think
I saw some article on this a month ago at http://www.theserverside.com

search
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
You should be managed in Concurrent User to write file.


Concurrent Programming with java
http://www.mcs.drexel.edu/~shartley/ConcProgJava/

Concurrent Pattern
http://www.cs.wustl.edu/~schmidt/patterns-ace.html


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
is possible but problem is that you run two different applications and every in it's own JVM instance!!!

No - there is only one JVM per Tomcat server. Perhaps you meant each has its own class loader. See the tomcat class loader how-to installed in tomcat-docs with a typical tomcat installation.
Bill
asirob civokviz
Greenhorn

Joined: Jun 12, 2004
Posts: 24
sorry,
just saw what I said... My mistake
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Singleton class