Re: [picocontainer-dev] Constructor Injection and Serialization Patterns
Paul Hammant <[email protected]>
| Newsgroups | gmane.comp.java.picocontainer.devel |
|---|---|
| Message-ID | <[email protected]> |
It could be that we leverage http://code.google.com/p/objenesis/ for a
variation of ConstructorInjection.
We would bring it in to the PicoContainer jar as per Paranamer with
'shade'
That way you can have your cake and eat it ? Or am I missing the
problem here ?
- Paul
On Feb 26, 2008, at 8:42 AM, Michael Rimov wrote:
> 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