NanoContainer
  1. NanoContainer
  2. NANO-115

Ability to CDI vanilla javax.servlet.Filter

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: nanowar
    • Labels:
      None
    • Number of attachments :
      2

      Description

      This PicoFilterProxy is a javax.servlet.Filter which can proxy to another Filter which is pico-ified.

      The tests are not fully reliougiously perfect, I'm still not really at ease with mock objects. I think it still covers the situations pretty much.

      Sample usage can be found here: https://swaf.dev.java.net/source/browse/swaf/swaf-skeleton/src/webapp/WEB-INF/web.xml

      Same approach could be used to do IOC with plain servlets or listener.

      1. nanowar-servlet.tgz
        4 kB
        Grégory Joseph (old account)
      2. nanowar-servlet-20050116.tgz
        4 kB
        Grégory Joseph (old account)

        Activity

        Hide
        Grégory Joseph (old account) added a comment -

        PicoFilterProxy

        Show
        Grégory Joseph (old account) added a comment - PicoFilterProxy
        Grégory Joseph (old account) made changes -
        Field Original Value New Value
        Attachment nanowar-servlet.tgz [ 13778 ]
        Hide
        Grégory Joseph (old account) added a comment -

        Improved version: added a "lookup-only-once" init param. By default the proxy filter is going to lookup the delegate from pico at every call; if this param is set to true, then it only looks it up the first time it's called.

        Show
        Grégory Joseph (old account) added a comment - Improved version: added a "lookup-only-once" init param. By default the proxy filter is going to lookup the delegate from pico at every call; if this param is set to true, then it only looks it up the first time it's called.
        Grégory Joseph (old account) made changes -
        Attachment nanowar-servlet-20050116.tgz [ 13822 ]
        Hide
        Mauro Talevi added a comment -

        Added to trunk after some minor clean-up of code.

        A comment: I'm not sure what the purpose of the contextTypes Map is.
        Is it really necessary or it could be refactored away?

        Cheers

        Show
        Mauro Talevi added a comment - Added to trunk after some minor clean-up of code. A comment: I'm not sure what the purpose of the contextTypes Map is. Is it really necessary or it could be refactored away? Cheers
        Hide
        Grégory Joseph added a comment -

        Err, I'm confused, but yes it seems it's totally useless; instead of figuring out what to do with initType as an int, just make initType a String.
        Maybe that was inherited from an earlier version where I used a switch or some other construct to determine how to init the delegate Filter. Can't really remember :/ Feel free to clean that out !

        Show
        Grégory Joseph added a comment - Err, I'm confused, but yes it seems it's totally useless; instead of figuring out what to do with initType as an int, just make initType a String. Maybe that was inherited from an earlier version where I used a switch or some other construct to determine how to init the delegate Filter. Can't really remember :/ Feel free to clean that out !
        Hide
        Mauro Talevi added a comment -

        Removed unnecessary contextTypes map.
        Also moved filter to
        org.nanocontainer.nanowar.ServletContainerProxyFilter
        for consistency with other filters.
        A separate package can be used for a more complex component, eg chain.

        Show
        Mauro Talevi added a comment - Removed unnecessary contextTypes map. Also moved filter to org.nanocontainer.nanowar.ServletContainerProxyFilter for consistency with other filters. A separate package can be used for a more complex component, eg chain.
        Mauro Talevi made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Grégory Joseph (old account)
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: