You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Spencer Crissman <sp...@gmail.com> on 2005/11/03 23:01:15 UTC

Re: How to initialize object/service properly?

No one has any best practices or suggestions regarding this?

-------------------

When my application starts up, I want it to do some configuration from
.properties files, then setup an in memory hsqldb. When it is shutdown, I

need to perform some shutdown/cleanup, and at some point might want to flush
the db contents to disk.

I'm am unsure of the proper method of doing this within the whole
Hivemind/Tapestry world. It seems like I could do this several ways, and I

don't know what is best, and why:

1) Create a new java class that performs the startup logic, and then create
a service point for it in the hivemodule.xml file. I can't figure out how I
could make sure this happens prior to the app starting up, and it doesn't

seem like there is any way of handling the shutdown. I believe access to the
object could then be injected to the page.

2) Define an application object with the scope of "application" which would

then get constructed via hivemind, in the application specification file.
What is the difference between this and 1? I don't see any.

3) Create classes to act as web context listeners, and make the appropriate

entries in the web.xml file. If I do this, I'm not sure how to access the
objects within the tapestry pages, as this doesn't go through hivemind.

4) Other methods?

Can someone offer insights between the differences of these methods? I am

leaning toward 1 or 2, so that if I ever create an application form of the
webapp, I can leverage hivemind to do the setup/teardown of that and
basically keep all that code.

Thanks for the feedback,


Spencer