[weld-dev] Injection into servlets, filters etc. for Jetty

Pete Muir pmuir at redhat.com
Thu Feb 18 12:17:21 EST 2010


Hi Matija,

I'll try to review the patch tomorrow :-)

On 18 Feb 2010, at 10:26, Matija Mazi wrote:

> Hi,
>  
> I've done some work on injection into servlets and filters for Jetty 6. Here's what I've come up with so far – the patch (to be applied to weld/servlet/trunk) is attached; I'll also attach it to the Jira issue (https://jira.jboss.org/jira/browse/WELDX-23).
>  
> This includes injection into Servlets and Filters, but not Listeners. It adds a sub-module weld-jetty-support to the weld-servlet module and changes some stuff in the weld-servlet-int module. To use it you need to:
> - add weld-jetty-support.jar to JETTY_HOME/lib
> - package the new weld-servlet.jar with your war/WEB-INF/lib (as normally)
> - deploy your web app into Jetty
> - change the attached myapp-context.xml to refer to your web app and deploy it into JETTY_HOME/contexts
>  
> Here are some open issues that remain and need some discussion. Which of these should I work on first?
>  
> 1.      Injection into Listeners. As far as I could see, this isn't yet supported even in Tomcat? I've done some work on this for Jetty 6 (not yet included in the attached patch) and I think it can be done (using javassist to add the injection code into the first lifecycle method called on the listener).

This *should* work on Tomcat IIRC, but perhaps not. Anyway, need a test for this :-)

> 2.      I don't like the fact that you need to deploy two files into Jetty, the war and the contexts/*.xml, but I don't think there's another way since the jetty example for using annotation injection does the same.

Agreed. In fact (not sure if it's in JIRA or not) but I want to try to remove the need to have a separate JAR which you put into the servers lib dir. This would be a good thing to have a play with :-)

> 3.      I haven't provided any tests for Jetty integration. There is a jboss-test-harness-tomcat but nothing similar for Jetty. Maybe I could create a jboss-test-harness-jetty and use it to create Weld-Jetty integration tests.

Yes, for now this is the best approach, until we have the Arquillian alpha done.

> 4.      This works for Jetty 6; I haven't tried Jetty 7.
> 5.      I didn't do for Jetty anything similar to JspInitialization (supposed to replace the el.ExpressionFactory) in tomcat-support; how is this used?

It replaces the ExpressionFactory that JSP uses so the wrapped one from Weld is used (so Weld gets the right callbacks to set up and destroy dependent object).

> 6.      Servlet injection doesn't work in Tomcat 7 (https://jira.jboss.org/jira/browse/WELDX-45); I think I should be able to fix this easily now.

Thaty would be great!

https://jira.jboss.org/jira/browse/WELDX-3 would also be a good one to look at...

Pete


More information about the weld-dev mailing list