Re: SpringComponentInjector and non null fields
ok, understood, thanks. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/SpringComponentInjector-and-non-null-fields-tp4386918p4387545.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: SpringComponentInjector and non null fields
that is there to give users a chance at test time to override injection partially, as in component c=new mycomponent(); c.service1=mock(service.class); injector.inject(c); injector will inject everything but service1. key here is to make sure service doesnt have to be defined in the test's spring context. -igor On Tue, Feb 14, 2012 at 8:08 AM, martin.dilger wrote: > Hi, > > thanks, this is true, but I dont think this is the Point I refer to, since I > call Injector.get().inject(this) in our Test, so I explicitely request > SpringBean-injection. > The Problem is this Line in Class Injector: > > if (field.get(object) == null) > { > > Object value = > factory.getFieldValue(field, object); > > if (value != null) > { > field.set(object, value); > } > } > > Injection only happens, if the Field is non-null. > I can not think of any use-case why this is? > > Any comments? > > Thanks in advance! > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/SpringComponentInjector-and-non-null-fields-tp4386918p4387511.html > Sent from the Users forum mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: SpringComponentInjector and non null fields
Hi, thanks, this is true, but I dont think this is the Point I refer to, since I call Injector.get().inject(this) in our Test, so I explicitely request SpringBean-injection. The Problem is this Line in Class Injector: if (field.get(object) == null) { Object value = factory.getFieldValue(field, object); if (value != null) { field.set(object, value); } } Injection only happens, if the Field is non-null. I can not think of any use-case why this is? Any comments? Thanks in advance! -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/SpringComponentInjector-and-non-null-fields-tp4386918p4387511.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: SpringComponentInjector and non null fields
There is a remark on this here: https://cwiki.apache.org/WICKET/spring.html "When doing this it is important to remember not to initialize dependencies, to null or any other value, e.g.private ContactDao dao=null;. Don't do this because the injector will run before the subclass initializes its fields, and so the dao=null will override the created proxy with null." Robert Am 14.02.2012 13:58, schrieb martin.dilger: > Hi, > > I just realized painfully, that SpringComponentInjector only injects Beans, > when the Fields are non-null. > Is there a reason for this Behavior? > The Reason I ask is, we "use" the SpringComponentInjector in all our Tests > to inject Mocks with Injector.get().inject(this). > This only works, if we set all Mocks to null in tearDown. > No problem so far, but this is surely not a typical use case, but > nonetheless, I would like to know if this is desired, and if we could > propably allow to configure this behavior (as a flag or whatever?). > Just for me to understand this better. > Thanks > > Martin > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/SpringComponentInjector-and-non-null-fields-tp4386918p4386918.html > Sent from the Users forum mailing list archive at Nabble.com. > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
SpringComponentInjector and non null fields
Hi, I just realized painfully, that SpringComponentInjector only injects Beans, when the Fields are non-null. Is there a reason for this Behavior? The Reason I ask is, we "use" the SpringComponentInjector in all our Tests to inject Mocks with Injector.get().inject(this). This only works, if we set all Mocks to null in tearDown. No problem so far, but this is surely not a typical use case, but nonetheless, I would like to know if this is desired, and if we could propably allow to configure this behavior (as a flag or whatever?). Just for me to understand this better. Thanks Martin -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/SpringComponentInjector-and-non-null-fields-tp4386918p4386918.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org