Hi :-) I have a question about how to use SingleTon with Servlet as a
helping class
I suppose the name of my SingleTon class is MySingleTon.class, and it
has a public
method getMe to return the Only-One instance:
IMO, when we first use MySingleTon.class by the following line:
MySingleTon mst = MySingleTon.getMe();
- MySingleTon.class is loaded by one ClassLoader, so now we have a
Class object->its name is CO.
- then a instance object of the above Class object is created->its
name is IO
- and a field mst is refrencing the above instance object
So my question is: how to keep this instance object as long as possible
before
we close the Servlet container?
- if the field mst is a local field in doGet/doPost/service, then
after
all client-accessings end( for example, in the evening of
Dec.31:-) ), there
is not any field which is refrencing IO, so in theory, IO will
be GCed->
garbage-collected.
- if the field mst is a static field or a instance field, IO will
be there for a
longer time, but I think it is still possible to be GCed before
we close the
Servlet container.:
* in one Servlet defination, the instance of my Servlet
class is destroyed/re-made(?)
* the Class object of my Servlet class is
unloaded/reloaded(?)
so is there a way to keep the IO there forever before we close the
Servlet container?
- without any field to refrence IO?
- with a field to refrence IO:
* this field is inside my Servlet class
* this field is outside my Servlet class
Could anybody give me some directions? Thanks in advance!
Happy new year right now!:-)
Bo
Dec.27, 2000
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html