Thanks Lukasz for the inputs. I am using S2 DI because i am doing it for my plugin.
For Plugin to work with different implementations my intentions let user specify the provider class at configuration time and based on the user provider class i want to init the plugin mechanism. Only information i was having that all provider classes will have to extends MyClass and there are not any specific set of classes which implements MyClass. So i was trying to make the provider inside my plugin a more generic which should be capable enough to hook itself with any provider which satisfy the contact ( <? extends MyClass> ) is there any way to do this with S2 internals? Thanks On Mon, Oct 1, 2012 at 3:10 PM, Lukasz Lenart <lukaszlen...@apache.org>wrote: > 2012/9/30 Aum Strut <aum.str...@gmail.com>: > > How can i pass this information to the container to get the instance > > of the class passed at run time? > > First of all you shouldn't use Struts2 internal DI mechanism, use > Spring or Guice. But if you don't have any other option just declare > your bean in struts.xml and call with > > container.getInstance(MyClass.class) > > <bean type="com.foo.MyClass" /> > > or with interface > > container.getInstance(MyInterface.class) > > <bean type="com.foo.MyInterface" class="com.foo.MyImpl" /> > > or with two or more implementations > > container.getInstance(MyInterface.class, "impl1") > > <bean type="com.foo.MyInterface" class="com.foo.MyImpl1" name="impl1" /> > <bean type="com.foo.MyInterface" class="com.foo.MyImpl2" name="impl2" /> > > And there are scopes as well. > > > 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 > >