Well, designed or not, I suppose overriding the filter is not a modular solution. You can't add a third party library and expect it to work, instead the application developer needs to do additional work by modifying web.xml and on top of that, if you use your service without tapestry-core, it won't work. You really need to listen to the Registry shutdown if you want to write your service as a general solution.

Regarding that last thing, the code of shutdown in the Registry is as follows:

    public synchronized void shutdown()
    {
        lock.lock();

        registryShutdownHub.fireRegistryDidShutdown();

        SerializationSupport.clearProvider(this);
    }

Your idea would look like this:

    public synchronized void shutdown()
    {
        lock.check();

        registryShutdownHub.fireRegistryWillShutdown();

        lock.lock();

        registryShutdownHub.fireRegistryDidShutdown();

        SerializationSupport.clearProvider(this);
    }


I suppose that the reason the lock is locked is that you want to guarantee that somehow that services that are listening to registryDidShutdown aren't used anymore after receiving the shutdown event. However, you may need certain services to be instantiated at registry shutdown. In case of per-thread services, there is no way to do this pre-shutdown work, so a RegistryWillShutdown thing might be useful.

The actual implementation would require an additional service interface, RegistryWillShutdownListener (well, one could add a method to RegistryShutdownListener but then lots of code will break because not all methods are implemented). Perhaps a committer might be willing to look at it.



Op 29-11-2010 13:16, Javier Molina schreef:
Overriding the filter might look ugly, but it was designed for that; see the comments on destroy() and destroy(Registry registry).

You might find it less ugly to have a ServletContextListener and do the cleanup in contextDestroyed.

The real solution would be to have a registryIsShuttingDown() notification, fired before registryDidShutdown(). I haven't found it, though.


El 29/11/10 12:53, Tom van Dijk escribió:
Which service would that be? Could you provide a stack trace?

Perhaps you could make your service contribute to RegistryStartup as well,
to make sure the DbShutdownImpl service is realized and that the
sessionSource is realized. The "startupService" would then be the registry
startup method.

I agree that modifying TapestryFilter is an ugly solution and should be
avoided if possible.




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


Reply via email to