Hello!
I'm currently working on a project which is composed of a small bunch of
servlets, which are run inside the application server provided by the
WebTools parcel.
Some of the servlets need to perform some initialisation before they are
ready to run. In particular, I have one servlet which must initialise
when the application is brought up. As per the documentation, I've set
up my configuration file such that the "applicationStartup" event is
sent where I want it to. So at least in principle, I should be set.
However, this doesn't seem to work the way I expected. The
"applicationStartup" event never seems to be triggered, and hence my
class never gets sent the message, and does not initialise itself, and
everything else falls to pieces.
I've spent the better part of this morning tracing the application
server, to see whether I'm doing something wrong or not, and have now
found what seems to be the problem.
Basically, it seems that the config file (by default, webtools.ini) is
only read lazily. If I just start the runtime.im image from the examples
directory, at first it doesn't do much of anything besides reading my
parcels. Only after the first request, the configuration is read, the
various sites are initialised and so on, like this:
| WebSiteResolver>>resolverFor
| ...
| WebSiteConfiguration class>>configureServer
| ...
| WebSiteConfiguration>>configureFromFile:
| WebSiteConfiguration>>initializeFrom:
| WebSiteConfiguration>>configureSites:
| ...
| WebSite>>initializeApplication
The applicationSetup event is generated in that last method, but it
seems impossible to be handled at that moment.
| WebSiteConfiguration handleEvent: 'applicationStartup' with: application.
handleEvent: checks whether the "globalConfiguration" class instance
variable is set, and whether event handling is enabled. But that
variable is only set _after_ the whole stack of methods above is
terminated -- before that, the applicationStartup event is just
swallowed.
If I force an explicit reset of the configuration (e.g., by using the
builtin configure servlet) the event _is_ sent correctly, since the
globalConfiguration is now properly set up. But this seems just a
coincidence. The "normal" path through that code seems to twist into itself.
It looks to me as if I'd have to force _two_ manual server
reconfigurations: One to fill the globalConfiguration, the other one to
actually provoke the applicationStartup event. At the moment, this is
precicely what I'm doing, but this seems wrong on many levels.
So my question is: Is there a real bug in the code, or am I just trying
to use the application server in a very wrong way?
If needed, I can provide a minimal configuration of what I'm trying to
attempt (one mini-parcel + webtools.ini) with the runtime.im image.
Regards,
Stefan
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc