You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Daniel Jomphe <af...@danieljomphe.name> on 2008/10/15 19:54:48 UTC

Is it a wrong idea to implement injection on Models?

Hi, I read a few other threads related to this issue, but saw only technical
means of freeing ourselves of the injection-is-only-for-Components
limitation.

Context
After refactoring my code to make it so that the Guice injection no more
happens on our Components but on our Models instead, I was surprised to find
out that Injection is only supported on Components. I thought it would make
more sense to inject the models, but I may be misunderstanding some Wicket
principle.

Questions
Was my approach of having injection on Models instead of Components sound?
And are there foreseeable issues with this approach?
Or would it be better that I only use injection on Components?
-- 
View this message in context: http://www.nabble.com/Is-it-a-wrong-idea-to-implement-injection-on-Models--tp19998823p19998823.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Is it a wrong idea to implement injection on Models?

Posted by Igor Vaynberg <ig...@gmail.com>.
there is no easy way for us to support this because imodel is an interface
and users implement their own implementations quiet frequently, so there is
no way for us to intercept its creation like there is with Component which
is a concrete class.

what is needed in java is a general mechanism for service lookup. they kind
of have that with serviceloader but that is on a much more coarse scope.
check out salve.googlecode.com, its a project i wrote that uses bytecode
instrumentation to allow dependency injection/service lookup hybrid on any
object no matter how it is instantiated.

-igor

On Wed, Oct 15, 2008 at 10:54 AM, Daniel Jomphe
<af...@danieljomphe.name>wrote:

>
> Hi, I read a few other threads related to this issue, but saw only
> technical
> means of freeing ourselves of the injection-is-only-for-Components
> limitation.
>
> Context
> After refactoring my code to make it so that the Guice injection no more
> happens on our Components but on our Models instead, I was surprised to
> find
> out that Injection is only supported on Components. I thought it would make
> more sense to inject the models, but I may be misunderstanding some Wicket
> principle.
>
> Questions
> Was my approach of having injection on Models instead of Components sound?
> And are there foreseeable issues with this approach?
> Or would it be better that I only use injection on Components?
> --
> View this message in context:
> http://www.nabble.com/Is-it-a-wrong-idea-to-implement-injection-on-Models--tp19998823p19998823.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>