Results 1 to 9 of 9

Thread: Injecting into an HTTP session (Webwork not Spring MVC)

  1. #1

    Default 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. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Have you checked xwork-optional ? http://www.google.com/url?sa=U&start...va.net/&e=7629
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Jan 2005
    Location
    DC Metro Area
    Posts
    18

    Default

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

  4. #4

    Default

    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

  5. #5
    Join Date
    Aug 2004
    Location
    Denver
    Posts
    249

    Default

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

    Matt

  6. #6

    Default

    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

  7. #7
    Join Date
    Jan 2005
    Location
    DC Metro Area
    Posts
    18

    Default

    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 at 06:04 AM.

  8. #8

    Default

    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

  9. #9

    Default

    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

Similar Threads

  1. OpenSessionInView and portlet support
    By garpinc2 in forum Web Flow
    Replies: 31
    Last Post: Apr 9th, 2010, 11:12 AM
  2. Replies: 0
    Last Post: Aug 25th, 2005, 05:11 AM
  3. Replies: 1
    Last Post: Mar 12th, 2005, 04:33 AM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •