]
Dan Allen commented on WELD-718:
--------------------------------
Please name the web fragment WeldServlet, if that approach is taken. We can then reference
this name for relative ordering of web components in Seam.
register Weld Servlet listener in web fragment
----------------------------------------------
Key: WELD-718
URL:
https://issues.jboss.org/browse/WELD-718
Project: Weld
Issue Type: Feature Request
Components: Servlet Container Support
Affects Versions: 1.1.0.Beta1
Reporter: Dan Allen
Priority: Minor
Fix For: 1.2.0.Beta1
Instead of making the developer add the Weld Servle listener in their web.xml when using
weld-servlet, might we consider registering it for them automatically but including it in
a web.xml fragment or TLD that's bundled in weld-servlet.jar? The benefit of using the
TLD is that it would work in pre-Servlet 3.0 environments.
META-INF/web-fragment.xml
<web-fragment
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd"
version="3.0">
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
</web-fragment>
META-INF/weld.tld
<taglib
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<description>
An empty tag library that registers a listener to bootstrap Weld in a Servlet
container.
</description>
<tlib-version>1.0</tlib-version>
<short-name>w</short-name>
<
uri>http://jboss.org/weld</uri>
<!--
This ServletContextListener initializes the runtime environment of the CDI
Reference Implementation (Weld) when a web application including it is
initialized by the container.
-->
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
</taglib>
Btw, we are already including other automatic configurations, such as a JSF phase
listener and view handler (META-INF/faces-config.xml).
If we require ordering, that leans more to web-fragment.xml as a solution, since it's
possible to have ordering control. There is no guarantee as to when a listener will load
that's defined in a TLD (the advantage is only for non-Servlet 3.0 containers). Given
that Weld is a new programming model and likely to be used with newer containers, then
I'd say we should go with web-fragment.xml.
(Worse case scenario is we introduce a classifier for weld-servlet that will be for
pre-Servlet 3.0 environments. Something like
org.jboss.weld.servlet:weld-servlet:1.1:pre-servlet-3)
--
This message is automatically generated by JIRA.
For more information on JIRA, see: