On 8/20/07, Derek Broughton <[EMAIL PROTECTED]> wrote:
> Matt Raible wrote:
>
> > The test does use manual wiring:
> >
> > <quote>
> > action = new PersonAction();
> > GenericManager personManager = (GenericManager)
> > applicationContext.getBean("personManager");
> > action.setPersonManager(personManager);
> > </quote>
> >
> Ah. I see. Sorry, Matt, but that might mean "manual wiring" to you, but
> since the example page is specifically pointing out that you don't need to
> wire anything, I just assumed that applicationContext.getBean() returned
> the autowired bean. It's all magic, anyway. :-)
>
> How do you get a manager object, with autowiring, then? Is it just supposed
> to automatically exist in the Action's xxxxManager field (I guess that
> makes sense, given the note somewhere about it just needing a setter
> method)?
How autowiring works is that you initialize all your Spring objects
(managers, daos, etc.) with ContextLoaderListener (in your web.xml)
and then by adding setter methods to your Actions, they'll be resolved
at runtime. It might even work for constructor arguments, I'm not
sure.
>
> I really think that if autowiring doesn't work with the example, "zero
> configuration" shouldn't even be mentioned on that page; it's just
> misleading.
Autowiring doesn't work when doing tests, but it does at runtime, no?
The other way to do it is to declare a bean definition for your
action, then use setXXXAction in your test. However, sometimes it's
nice to not have to create the bean definition.
>
> I've never been a big fan of this sort of testing scenario, and you haven't
> made a convert of me yet :-)
It might just be the verbage in the tutorial. If you have suggestions
for making things clearer - we'd love to hear it.
Matt
> --
> derek
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
http://raibledesigns.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]