-
1. Re: Are transient dependencies re-injected after it awakes from passivation?
gavin.king Jan 11, 2010 6:12 PM (in response to cayhorstmann)According to the spec, all stateless session beans, resources (including EntityManagerFactory and DataSource), and the UserTransaction are passivation capable dependencies, so you do not need to declare the injected fields transient.
This is a bug. I believe it is a bug in Weld that has already been fixed.
-
2. Re: Are transient dependencies re-injected after it awakes from passivation?
cayhorstmann Jan 11, 2010 6:30 PM (in response to cayhorstmann)Thanks! Reading through 6.6.2, I now see that I am indeed assured that all SLSB and resources are going to be restored.
But I am still confused about transient. Since 6.6.1 says that my managed bean must be serializable, I must declare it so, and I can't very well lie about those dependencies. They aren't serializable, so it seems only proper to declare them as transient. I don't mind doing that--I just don't understand why you say it's not necessary. Does the app server not actually serialize the object when it passivates it?
-
3. Re: Are transient dependencies re-injected after it awakes from passivation?
gavin.king Jan 13, 2010 7:18 AM (in response to cayhorstmann)
They aren't serializable, so it seems only proper to declare them as transient.The actual underlying resource may not be serializable by the proxified reference to it is. You should not declare the field transient.
Does the app server not actually serialize the object when it passivates it?Exactly. It uses a proxy.
-
4. Re: Are transient dependencies re-injected after it awakes from passivation?
hirowla.ian.rowlands.three.com.au Jan 19, 2010 1:54 AM (in response to cayhorstmann)What about Conversation objects? Are they re-injected upon activation? Some static code analysis indicates that it is a non-serializable field. Or is my code analyser just annoying?
Thanks,
Ian
-
5. Re: Are transient dependencies re-injected after it awakes from passivation?
cayhorstmann Jan 19, 2010 3:28 AM (in response to cayhorstmann)The way I read the spec is that if CDI injects it, it owns the relationship and it will reinject it.
As for the static code analyzer, that's a good point. I see no harm in declaring the fields as
transient
to keep your static code analyzer happy. -
6. Re: Are transient dependencies re-injected after it awakes from passivation?
sknitelius Jun 10, 2016 9:44 AM (in response to cayhorstmann)There is no reinjection, after deseralization. What happens is CDI injects a serializable client proxy which is seralized along with the passivated object at least for normal scoped dependencies.
I have written a detailed blog post on their subject: https://www.knitelius.com/2016/05/18/cdi-passivation-uncovered/