I use a plugin (implements org.apache.struts.action.PlugIn) and put things
I need application-wide in the ServletContext.
[EMAIL PROTECTED]
x.com
To
02/04/2004 02:59 [EMAIL PROTECTED]
PM cc
Subject
Please respond to global data objects -- best
"Struts Users practices?
Mailing List"
<[EMAIL PROTECTED]
rta.apache.org>
hi,
I have a question regarding data objects that should be accessible from
the entire application and which must be created at container startup time.
I need to either create and load an existing index or load a serialized
index if one exists. This can be a time-consuming process, and I would
like to do it once when the servlet container starts, then keep the
index in memory thereafter and available to the entire web application.
I've seen a few different ways of doing this by searching the archives,
but there wasn't a definitive best practice solution that I came across,
and the struts API has also changed since many of the suggestions were
offered.
At present, I am extending the ActionServlet and taking care of the
initialization stuff in the subclass's init(). I place the generated
index in the ServletContext. This ensures that the index creation will
occur only once, at container startup, and that it will be available to
the action classes of that web application, but I'm not sure if this is
the best solution. Also, I have just come across plugins for the first
time, and it seems that they also provide a way of doing
application-specific initialization. Having the index creation code in
the ActionServlet, as it is at present, seems messy to me, so perhaps
that is not the best place for it.
In short, what is the best method for ensuring that a global index is
created exactly once, and at container startup time? At present, I am
subclassing ActionServlet, and doing it there, but is the plugin
mechanism an alternate (better?) solution? Is the ServletContext the
appropriate place for global data?
thanks in advance,
n.
---------------------------------------------------------------------
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]