[weld-dev] Ordering of servlet listeners

Remy Maucherat rmaucher at redhat.com
Wed Mar 24 18:38:04 EDT 2010


On Wed, 2010-03-24 at 22:42 +0200, Nicklas Karlsson wrote:
> You seem to know that you are doing so I'll leave the ball with
> you ;-)
> 
> 
> The situation we're aming for is that when people throw in web.xml:s
> and web-fragment.xmls and @WebListener:s, the order (of course)
> follows that of the Servlet specification but we have sneaked in the
> WeldListener before that. Now how to guarantee portability, that this
> has also been done when throwing the same application in another
> appserver is another thing...

You can use a web-fragment.xml in your JAR with an
<ordering><before><others/></before></ordering>. It is a weak guarantee,
but that's the only thing portable you can do without user
configuration. Your listeners will then be right after the listeners
from the main web.xml, the @WebListener from /WEB-INF/classes, and other
fragments ordered before others could compete with you.

For JBoss, probably a regular deployer would be something more robust.

-- 
Remy Maucherat <rmaucher at redhat.com>
Red Hat Inc



More information about the weld-dev mailing list