[picocontainer-dev] Constructor Injection and Serialization Patterns
"Michael Rimov" <[email protected]>
| Newsgroups | gmane.comp.java.picocontainer.devel |
|---|---|
| Organization | Centerline Computers, Inc |
| Message-ID | <01af01c87896$8d979c10$a8c6d430$@com> |
Hi All,
Pico was my first initiation into constructor injection and I've been an avid
fan after finding it. However, I'm lacking a solution to a problem that I keep
encountering.
Given the sample class:
public class Sample implements Serializable {
private ClassLoader cl;
public Sample(ClassLoader classLoader) {
cl = classLoader;
}
}
The problem that I have is that since ClassLoader is not serializable, neither
is Sample. If I make the classloader transient, then I deserialize a useless
object.
So far, the only solution I can see is to downgrade to setter injection.
(yuck!).
Has anybody come up with some sort of externalization pattern that they use in
practice that I can add to the "Best Practices" section for the Pico Docs?
Anything, especially in mind of usage in XStream, would be great :D
Thanks in advance!
-Mike