Results 1 to 7 of 7

Thread: reinject transient properties

  1. #1
    Join Date
    Aug 2004
    Location
    Seattle
    Posts
    30

    Default reinject transient properties

    Is it possible to inject dependencies into a bean that that has been deserialized based on what I configured in the spring xml config file?

    I have a bean which contains references to services. Those references I've made transient so that they are not serialized. When I deserialize the bean's, I would like to reinject all the services that were injected to begin with.

    Cameron

  2. #2
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    You would need to intercept the deserialisation. How are you serialising/deserialising it, or what *causes* the serialisation?

  3. #3
    Join Date
    Aug 2004
    Location
    Germany
    Posts
    24

    Default

    I would like to see an elegant answer to this problem too.

    Some of my beans will be serialized when the HttpSession is serialized (on server restart / clustering maybe later).

    And that's the problem, there is no way to listen to serialization/deserialization. Only "readResolve" in the serialized bean itself.
    But since the bean should not know Spring this is not a real solution.

    Currently I'm helping myself with a Pseudo-Singleton-Registry, but some kind of real listener-mechanism would be nice.

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    I agree with yatesco - intercepting the deserialization (with after return) would allow spring to get a valid object and then reinject everything in there.
    It's the cleanest and most decoupled alternative in my opinion.

    As for doing this outside the Spring context - I think it's a contradiction in terms - Spring should inject the properties but outside the Spring context?
    If you will not have dependecies on the Spring API, you'll have then on your pseudo-singleton-registry that will act as the bridge between the Spring context and container.
    It's simply a dependecy that has to be satisfied one way or another.
    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

  5. #5
    Join Date
    Aug 2004
    Location
    Germany
    Posts
    24

    Default

    Uhm, maybe I did not make things as clear as I should have ;-)

    Of course I want to do the injection of transient properties inside a spring-environment.
    It's okay for me, if an Advice depends on the Spring API to lookup dependencies and rewire the serialized/deserialized bean.

    Only the bean itself should not depend on the Spring API (and also not on my pseudo-singleton-registry, of course).

    Now I'm thinking about, how to intercept deserialization. Any hints, how such a joinpoint-definition could look like?

    thx

  6. #6
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Take a look in the reference manual - just make a standard interceptor which will wrap your bean and that's it.
    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

  7. #7
    Join Date
    Oct 2005
    Posts
    8

    Default

    I face the same problem and I've described my case in a different thread :
    http://forum.springframework.org/showthread.php?t=18753

    If anyone succeeded in solving this problem, please post your solution.

    Thanks
    Last edited by robyn; May 14th, 2006 at 06:15 PM.

Similar Threads

  1. FlowExecutionStorage in a DB
    By cacho in forum Web Flow
    Replies: 7
    Last Post: Oct 19th, 2009, 03:36 PM
  2. Hibernate Properties as JMX
    By FelderR in forum Container
    Replies: 1
    Last Post: Jul 4th, 2005, 04:59 AM
  3. Replies: 0
    Last Post: May 8th, 2005, 02:15 AM
  4. Shared properties within application context
    By milosh in forum Architecture
    Replies: 5
    Last Post: Nov 16th, 2004, 08:29 AM
  5. Replies: 19
    Last Post: Oct 20th, 2004, 11:24 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
  •