title: how to reattach singleton Spring beans upon deserialization
body: <p>I want to reinject singleton-scoped dependencies into prototype Spring beans, after they have been deserialized.  </p>
  
  <p>Say I've got a Process bean, which depends on a Repository bean.  The Repository bean is a scoped as a singleton, but the Process bean is prototype-scoped.  Periodically I serialize the Process, and then later deserialize it.  </p>
  
  <pre><code>class Process {
     private Repository repository;
     // getters, setters, etc.
  }
  </code></pre>
  
  <p>I don't want to serialize and deserialize the Repository.  Nor do I want to put "transient" on the member variable that holds a reference to it in Process, nor a reference to some kind of proxy, or anything other than a plain old member variable declared as a Repository.</p>
  
  <p>What I think I want is for the Process to have its dependency filled with a serializable proxy that points (with a transient reference) to the Repository, and, upon deserialization, can find the Repository again.  How could I customize Spring to do that?  </p>
  
  <p>I figure I could use a proxy to hold the dependency references, much like .  I wish I could use that exact technique.  But the proxy I've seen Spring generate isn't serializable, and the docs say that if I use it with a singleton bean, I'll get an exception.</p>
  
  <p>I could use a custom scope, perhaps, on the singleton beans, that would always supply a proxy when asked for a custom-scoped bean.  Is that a good idea?  Other ideas?</p>