Announcement Announcement Module
Collapse
No announcement yet.
Re-Injecting dependencies after de-serialization Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Re-Injecting dependencies after de-serialization

    Hi you all,

    in short:

    what is the best practice for re-injecting my stateless and non serializable service beans into my web-beans?

    little less shorter:

    I have some myFluffyAppContext in the web layer storing user state in the http session. This Context gets some services injected by spring, business as usual, works great.

    Now, what if I would like to have this fluffy session state replicated on a failover setup? My services cannot be replicated (not serializable)... Having my fluffy bean locating its dependencies is not so nice.

    brgds,

    Papick

  • #2
    Never done this before, so this is just off the bat - make those non-serializable service references "transient" in your app context object, so the container won't try to replicate them. Then register a HttpSessionActivationListener which will reinject the references after a session gets activated.

    Comment


    • #3
      Originally posted by p.g.taboada View Post
      Now, what if I would like to have this fluffy session state replicated on a failover setup? My services cannot be replicated (not serializable)... Having my fluffy bean locating its dependencies is not so nice.
      One option will be to use field level injection or getter injection as proposed here. Also have a look at this thread, which discusses this issue. In case u r using @Configurable, there is a patch uploaded by Ramnivas that handles the injection on deserialization issue. I think it is available in the latest nightly build.

      HTH,
      - Debasish

      Comment

      Working...
      X