Have a look at AssistedInject:
http://stackoverflow.com/questions/8976250/how-to-use-guices-assistedinject

On 11/01/2015 12:21 AM, Petar Aleksic wrote:
> I am extending a class from a library. This class from a library has a
> constructor and some parameters that are *not* injected:
>
> |
> //Constructor
> publicexternalClass(SomeParamA,SomeOtherParamB){
>    ...
> }
> |
>
> The subclass's constructor looks something like this:
>
> |
> //Constructor of class that exteds externalClass
> publicsubClass(SomeParamA,SomeOtherParamB,ParamToBeInjectedC){
>     super(SomeParamA,SomeOtherParamB);
>     this.paramToBeInjected =C;
>     ...
> }
> |
>
> Now, the problem is that only dependency I want to inject in subClass
> is the third parameter, ParamToBeInjected C . The first two are
> handled by the externalClass i.e. the parent class of  subClass.
> If I annote the constructor with @Inject, it  wont't work since an
> attempt to inject all the constructor arguments will be made. If, on
> the other hand, the constructor is not annoted, the error "Could not
> find a suitable constructor..." occurs. Any ideas, suggestions?
>
> Thanks.
> Regards
>
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "google-guice" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/google-guice.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-guice/d6e0d047-a605-4a46-9fca-2243cd16b725%40googlegroups.com
> <https://groups.google.com/d/msgid/google-guice/d6e0d047-a605-4a46-9fca-2243cd16b725%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/563552A3.3000907%40googlemail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to