[morphia] feat.-req: DI container support

12 views
Skip to first unread message

Uwe Schäfer

unread,
May 9, 2010, 2:34:22 PM5/9/10
to mor...@googlegroups.com
hi

>> - DI container support (guice here)
> What support would you want? Just a module to map all the entities in
> some way? Some people use the DAO<Entity,String> per entity type
> pattern and this is helpful there I think.

i´d like to see DI into entities as well as DAOs and Listeners.
in fact, even the creation of entities should be delegateable to the DI
container.

this way, the user can apply any crazy kind of tweak to his entities
(aspectj for instance) and DAOs.

i´m a complete ignorant when it comes to spring, but i can provide
something for guice.

objections?

cu uwe

Scott Hernandez

unread,
May 9, 2010, 4:43:23 PM5/9/10
to mor...@googlegroups.com
This sounds like you just want some kind of factory to create all
objects (entities, converters, listeners, etc.). Then you can override
them however you want for some DI, or custom creation system.

BTW. The DAO stuff is up to the user so you can already, and in fact
have to, manage the dao instances yourself.

2010/5/9 Uwe Schäfer <u...@thomas-daily.de>:

Ólafur Gauti Guðmundsson

unread,
May 10, 2010, 5:52:22 AM5/10/10
to Morphia
Hi Uwe,
Thanks for your feature requests and input. Really good stuff.

I agree that this feature would be quite good. At the moment we're
really just doing Class.forName().newInstance(), but as you suggest it
would be great to leave the creation up to a DI container (I use Guice
myself).

As Scott suggests, this would probably be best implemented by creating
an ObjectFactory interface, with a default implementation that uses
Class.forName().newInstance(). Then people can implement their own,
for example a GuiceObjectFactory, and do something like
morphia.setObjectFactory(myObjectFactory).

Regards,
OGG

Uwe Schäfer

unread,
May 10, 2010, 11:49:57 AM5/10/10
to mor...@googlegroups.com
Ólafur Gauti Guðmundsson schrieb:

hi Ólafur

> As Scott suggests, this would probably be best implemented by creating
> an ObjectFactory interface, with a default implementation that uses
> Class.forName().newInstance(). Then people can implement their own,
> for example a GuiceObjectFactory, and do something like
> morphia.setObjectFactory(myObjectFactory).

Fully agreed.
i´ll suggest one a few days from now.

cu uwe



Reply all
Reply to author
Forward
0 new messages