Details
-
Type: New Feature
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.0-beta-5
-
Fix Version/s: None
-
Component/s: PicoContainer (Java)
-
Labels:None
-
Environment:Any Servlet Container
-
Number of attachments :
Description
The picoextras servlet stuff is very nice, and the ServletContainerListener makes the creation of containers for the context and session nice and automatic. For requests, however, one has to manually use the ServletRequestContainerLauncher to create request containers and remember to call startContainer() at the beginning of request handling and killContainer() at the end. Why not make this automatic as well? Servlet filters to the rescue!
I've create a filter to perform this magic as well so that the only thing a user ever needs to do is implement a ContainerComposer to register their components and then use those components. I will attach it right after this post. BTW, here is what the web.xml config might look like (btw, note the change in the context param name based on the patch I just attached to Pico Issue 116)...
<web-app>
<context-param>
<param-name>picoextras-container-composer</param-name>
<param-value>org.picoextras.servlet.sample.SampleContainerComposer</param-value>
</context-param>
<listener>
<listener-class>org.picoextras.servlet.ServletContainerListener</listener-class>
</listener>
<filter>
<filter-name>pico</filter-name>
<filter-class>org.picoextras.servlet.ServletRequestContainerFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>pico</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Activity
Field | Original Value | New Value |
---|---|---|
Attachment | ServletRequestContainerFilter.java [ 11360 ] |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
proposed ServletRequestContainerFilter.java to ease the burden of creating and killing request-scoped containers.
Jake