Re: How to get instance of the given dependency using Container

2012-10-02 Thread Lukasz Lenart
2012/10/1 Aum Strut : > 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 provider) > { > this.provider = provider; > } > > So if at run time i want t

Re: How to get instance of the given dependency using Container

2012-10-01 Thread Aum Strut
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 provider) { this.provider = provider; } So if at run time i want to inject my provider, so i will be declari

Re: How to get instance of the given dependency using Container

2012-10-01 Thread Lukasz Lenart
2012/10/1 Aum Strut : > i was thinking about a way like Spring DI used to do something like > > > > > > It would be more convient to have injection like this way. Just annotate your setter with @Inject(name="a") and create constant in struts.xml. If "a" is a String value. Regards -- Łukas

Re: How to get instance of the given dependency using Container

2012-10-01 Thread Aum Strut
i was thinking about a way like Spring DI used to do something like It would be more convient to have injection like this way. On Mon, Oct 1, 2012 at 3:28 PM, Lukasz Lenart wrote: > 2012/10/1 Aum Strut : > > Only information i was having that all provider classes will have to > > extends

Re: How to get instance of the given dependency using Container

2012-10-01 Thread Lukasz Lenart
2012/10/1 Aum Strut : > 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

Re: How to get instance of the given dependency using Container

2012-10-01 Thread Aum Strut
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 informatio

Re: How to get instance of the given dependency using Container

2012-10-01 Thread Lukasz Lenart
2012/9/30 Aum Strut : > 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 wi

Re: How to get instance of the given dependency using Container

2012-09-30 Thread Aum Strut
Thanks Gabriel for the help, but i am a bit confused about it. Can you please help me to understand why we are using those two entries like one is a constant and other is a bean class? while my understanding was that all i need to define a constant and based on that i can get the actual class (ex

Re: How to get instance of the given dependency using Container

2012-09-30 Thread Gabriel Belingueres
This is a two step process: You can define a String property to hold the "name" of the required instance to inject, and then inject the appropiate instance with the given name. For example you can define a constant: @Inject(value="my.constant") public void setConstant(String value) {