Hi Dean,

You have several options, which best suits your needs depends on what the 
listener does. ServletContextListeners usually initializes things that servlets 
and filters later depend on.

The most straightforward solution would be to simply copy the web.xml that 
Magnolia uses and add the listener to it. It comes from a war named 
magnolia-empty-webapp and is put in place by maven unless it already exists. So 
if you add your own in your webapp project it will be used. The downside here 
is that it's not future proof should any changes be made to the web.xml in 
magnolia-empty-webapp, although that happens _very_ rarely.

A better solution would be to use a module.

A module is installed into the system by executing its version handler. It can 
do any number of things, it can for instance add servlets and filters. These go 
into the Magnolia filter chain. After installation the module is started, and 
once all modules have been started the Magnolia filter chain is initialized.

If we think of this in terms of the Servlet API then the module is essentially 
a ServletContextListener.

By utilizing a module you're future proof regarding changes to the default 
web.xml and the functionality your developing is self contained in a module 
that does not require any extra installation steps other than adding its maven 
<dependency>.

Hope that helps, Tobias

-- 
Context is everything: 
http://forum.magnolia-cms.com/forum/thread.html?threadId=b4e5ec33-670a-456e-bcb1-604c88044c88


----------------------------------------------------------------
For list details, see: http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to