Announcement Announcement Module
Collapse
No announcement yet.
Injecting into an HTTP session (Webwork not Spring MVC) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injecting into an HTTP session (Webwork not Spring MVC)

    I'm using Spring in combination with Webwork and the "external-ref" techique of integrating them together. This is working well.

    Webwork's built-in IoC (which I'm not using) allows one to inject a component into the session object. More specifically to inject into WebWork's session object which is a wrapper around HttpSession.

    My question is: how can I use spring to instantiate the object and inject it into the session? Ideally into WebWork's session wrapper, but I'd settle for injection into the HttpSession.

    Thanks!

    - Gary

  • #2
    Have you checked xwork-optional ? http://www.google.com/url?sa=U&start...va.net/&e=7629

    Comment


    • #3
      Look at the ServletContextAttributeExporter. It should do what you want. It's new in 1.1.4.

      Comment


      • #4
        Look at the ServletContextAttributeExporter. It should do what you want. It's new in 1.1.4.
        Thanks. Looked promising. *Almost* exactly what I need. But it injects objects into the ServletContext, not a session (as it starts up, say).

        Or am I missing something?

        - Gary

        Comment


        • #5
          You could use an HttpSessionListener to detect when a user's session begins and stuff a bean into it at that point.

          Matt

          Comment


          • #6
            You could use an HttpSessionListener to detect when a user's session begins and stuff a bean into it at that point.
            Right.

            But that's not really an improvement over the session-injection that WebWork offers with its own IoC system.

            What I'm looking for is a way to do this from a standard Spring applicationContext.xml.

            If I can't get Spring to do it, I guess I'll just fallback to using WebWork's IoC.

            - Gary

            Comment


            • #7
              I can't think of a way to do this without specifying something in the web.xml, since that's the only way to tell the servlet container about a SessionListener. What does WebWork do?

              However, I can think of a way to this with an entry in web.xml (to register the session listener), an entry in the applicationcontext.xml file, and the use of the ExternalSpringBean system I described in this thread:

              http://forum.springframework.org/showthread.php?t=12528

              (the code supplied needs a small fix for 1.1.4; if you are interested, I will post the fix)
              Last edited by robyn; May 19th, 2006, 06:04 AM.

              Comment


              • #8
                I can't think of a way to do this without specifying something in the web.xml, since that's the only way to tell the servlet container about a SessionListener. What does WebWork do?
                WebWork uses a listener. It's not that I want to do it without a listener, I just want to do it without a custom listener of my own. In other words, I want support from the framework for the injection.

                WebWork does do this with it's built-in injection feature. It sets up a general-purpose listener with which it's able to offer me the ability to inject into the session.

                I was just hoping for a similar facility from Spring.

                - Gary

                Comment


                • #9
                  Its gonna be ready probably in 2.0 M2. Alef Arendsen is working on it.

                  Its in JIRA:
                  http://opensource2.atlassian.com/pro...browse/SPR-437

                  its coming in a bit late considering the common nature of the prob, but hey, thats better than nothing =D

                  Comment

                  Working...
                  X