correct -igor
On Feb 7, 2008 4:43 AM, Sebastiaan van Erk <[EMAIL PROTECTED]> wrote: > dfernandez wrote: > > Hello everyone, > > > > I have a question regarding the relation between the @SpringBean annotation > > and the serialization of objects being referenced in a Page. If I have: > > > > @SpringBean(name="myBean") > > protected MyService myService; > > > > May I suppose that the proxy object that @SpringBean will create for > > "myService" will handle serialization properly? (this is, forgetting about > > the reference to the Spring object when serializing, and retrieving it again > > when de-serializing...) > > > If this is so, I also suppose that it would be *incorrect* to mark this > > property as "transient", right? like, > > > > @SpringBean(name="myBean") > > protected transient MyService myService; > > > > ...and if this is incorrect as I suppose, we are on a little "formal issue" > > here, as we are using a neither-serializable-nor-transient object (the > > service) inside a serializable object (the page), which is formally > > incorrect, but which we know will work because we are relying on the proxy > > implementation (and thus binding to it)... > > > > Could anyone please confirm that this works this way? > > As far as I know, that is exactly how it works. The myService field is > filled with a proxy to the service which is serializable and can look up > the service again if it is lost (due to a serialize/deserialize cycle of > the component). The proxy is injected on instantiation of the component > and NOT on deserialization (see also IComponentInstantiationListener). > > Marking it transient will not work because after deserialize the > myService field will be null, calling all subsequent calls to the > service to fail with a NullPointerException. > > > Many thanks, > > Daniel. > > Regards, > Sebastiaan > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]