2012/10/1 Aum Strut <aum.str...@gmail.com>:
> I am still confused the way Struts2 internal DI and container.getInstance()
> working
> since i have this inside my class
>
> private Class provider;
> public void setProvider( Class<? extends Provider> provider)
>     {
>         this.provider = provider;
>     }
>
> So if at run time i want to inject my provider, so i will be declaring a
> constant for my plugin say
>
> <constant name="provider.name' value="com.abc.MyCustomProvider">
>
> so i believe now i have to do the following steps
>
> 1. Get an instance of the provider based on the constant name
> 2. Init my provider with the instance i got from Struts2 DI
>
> so i guess i need to do this either in init method or my bean constructor
>
>  init(){
>
>     setProvider(container.getInstance(Provider.class,"provider.name"));
> }
>
> but above will not work ,since as per the getInstance() method
> signature <T>T getInstance
> (Class<T> type, String name)
> i will getting instance of Provider class and which means either i have to
> change the signature of  public void setProvider( Class<? extends Provider>
> provider)
>
> which means loosing the generics capability as my intentions are to inject
> any class which extends Provider.

Yeah, but the Container's job is to inject instances of classes not
the classes itself. It isn't doable. I don't know why do you want to
inject just a class. If you want to just have a class name use
constant, no need for <bean/>


Regards
-- 
Ɓukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to