On Thu, 14 Jun 2012 17:42:33 -0300, Muhammad Gelbana <m.gelb...@gmail.com> wrote:

*- Do you know you can use injection (no annotations needed) in build,
contribute and advise methods in Tapestry-IoC module classes? ;) *
You mean in the method signature ?

Yes.

It's of course different from injecting services in the module

No difference.

but how is it different tapestry-wise ?

Just two different ways to get access to services. No difference Tapestry-wise. If you're going to use a service in just one or two methods in your module class, I'd use injection in their parameters. Otherwise, field injection.

*- Another option is to contribute to the RegistryStartup configuration a
Runnable that invokes your service. Just calling it directly in
contributeRegistryStartup() makes the call to happen before the registry
was actually started up. *
Well that is what I'm actually doing.

The code you provided us tells that's *not* what you're doing.

Only that I'm injecting services in
the module, while it looks like injecting the service through the
contribute method signature is a better practice.

It isn't a better practice, just a different way of doing the same thing. Your module class, as posted here, had just one use of the service, so the most appropriate way of injecting it, IMHO, was in the method signature.

Also you are saying that the runnable will run *before* the registry starts up, isn't that a problem if I'm calling injected services ? I know it isn't as I'm already doing it.

The code you provided does *not* use a Runnable, so I what I wrote was based on it. If your code actually invokes the service inside a Runnable contributed to the RegistryStartup service configuration, then it was right but, again, that's not what you posted here.

--
Thiago H. de Paula Figueiredo

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

Reply via email to