|
From: Bob L. <cra...@cr...> - 2006-06-24 02:31:57
|
I'm injecting an object which will be stored in the HTTP session which means it needs to be serializable. I want to inject a non-serializable singleton into the session object. Option A: Keep a transient reference to the singleton. What to I do when the object deserializes? Do I re-inject it from the readObject() method? How? How do I re-inject only transient references? Option B: Inject a static reference. Does Spring support this? What is the "Spring Way" here? Bob |
|
From: Dmitry S. <ds...@ch...> - 2006-06-24 14:10:47
|
What if you wrap a non-serializable singleton in a proxy that has a reference to the application context (BeanFactoryAware) and knows how to pull that object out of the context when it is null? Dmitry > I'm injecting an object which will be stored in the HTTP session which > means it needs to be serializable. I want to inject a non-serializable > singleton into the session object. > > Option A: Keep a transient reference to the singleton. What to I do > when the object deserializes? Do I re-inject it from the readObject() > method? How? How do I re-inject only transient references? > > Option B: Inject a static reference. Does Spring support this? > > What is the "Spring Way" here? > > Bob > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |
|
From: Colin Y. <col...@gm...> - 2006-06-24 14:14:59
|
Just thinking aloud here, but another more less intrusive, but more complicated way would to to intercept the serialise/deserialise methods using AOP and have the dehydration/rehydration done via an aspect. On 6/24/06, Dmitry Sklyut <ds...@ch...> wrote: > > What if you wrap a non-serializable singleton in a proxy that has a > reference to the application context (BeanFactoryAware) and knows how to > pull that object out of the context when it is null? > > Dmitry > > > I'm injecting an object which will be stored in the HTTP session which > > means it needs to be serializable. I want to inject a non-serializable > > singleton into the session object. > > > > Option A: Keep a transient reference to the singleton. What to I do > > when the object deserializes? Do I re-inject it from the readObject() > > method? How? How do I re-inject only transient references? > > > > Option B: Inject a static reference. Does Spring support this? > > > > What is the "Spring Way" here? > > > > Bob > > > > Using Tomcat but need to do more? Need to support web services, > security? > > Get stuff done quickly with pre-integrated technology to make your job > > easier > > Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > > _______________________________________________ > > Springframework-developer mailing list > > Spr...@li... > > https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > > > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |
|
From: Eugene K. <eu...@pl...> - 2006-06-24 14:21:10
|
Bob, You probably won't want to use something like that. But with Terracotta for Sessions product you can put non-serializable objects into session. Version for Tomcat is free for up to 4 nodes. See http://www.terracottatech.com/ Otherwise, using AOP to inject dependencies on deserialization. This will be quite similar to @Configurable added in Spring 2.0. Would require an AspectJ though... regards, Eugene Bob Lee wrote: > I'm injecting an object which will be stored in the HTTP session which > means it needs to be serializable. I want to inject a non-serializable > singleton into the session object. > > Option A: Keep a transient reference to the singleton. What to I do > when the object deserializes? Do I re-inject it from the readObject() > method? How? How do I re-inject only transient references? > > Option B: Inject a static reference. Does Spring support this? > > What is the "Spring Way" here? > > Bob |
|
From: Bob L. <cra...@cr...> - 2006-06-24 17:27:39
|
Injecting statics is simpler and more straightforward. Does Spring support this? Bob On 6/24/06, Eugene Kuleshov <eu...@pl...> wrote: > Bob, > > You probably won't want to use something like that. But with > Terracotta for Sessions product you can put non-serializable objects > into session. Version for Tomcat is free for up to 4 nodes. See > http://www.terracottatech.com/ > > Otherwise, using AOP to inject dependencies on deserialization. This > will be quite similar to @Configurable added in Spring 2.0. Would > require an AspectJ though... > > regards, > Eugene > > > Bob Lee wrote: > > I'm injecting an object which will be stored in the HTTP session which > > means it needs to be serializable. I want to inject a non-serializable > > singleton into the session object. > > > > Option A: Keep a transient reference to the singleton. What to I do > > when the object deserializes? Do I re-inject it from the readObject() > > method? How? How do I re-inject only transient references? > > > > Option B: Inject a static reference. Does Spring support this? > > > > What is the "Spring Way" here? > > > > Bob > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |