google-code-export / morphia

Automatically exported from code.google.com/p/morphia
1 stars 0 forks source link

Separate actual instanciation from ObjectCreator #249

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
provide a patch for that

Original issue reported on code.google.com by google-a...@codesmell.de on 20 Mar 2011 at 2:35

GoogleCodeExporter commented 9 years ago
created branch factory_prototype for this.

see http://groups.google.com/group/morphia/browse_thread/thread/e2f643e668613526

Original comment by google-a...@codesmell.de on 20 Mar 2011 at 8:54

GoogleCodeExporter commented 9 years ago
committed a prototype, please verify the change.

We might want to changes some names, but basically, the idea is rerouting 
newInstance to objenesis and provide a simple hook for DI to step in.

for instance a guice impl would be as easy as extending DefaultInstanceFactory, 
trying a 

injector.getInstance(clazz) 

and, if that fails use onInstantiation to do 

injector.injectMembers(instance)

so that injector-defined scope is adhered to, as well as dependencies are 
injected.

Original comment by google-a...@codesmell.de on 20 Mar 2011 at 10:49