You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Howard Lewis Ship <hl...@gmail.com> on 2008/03/19 00:32:24 UTC

Use of @InjectService

Just a heads up; I'm seeing lots of informed and useful postings of
code to the list.  Bravo!

One thing I do keep seeing is code such as:

public class MyServiceImpl implements MyService
{
   public MyServiceImpl(@InjectService("Session") Session session) { ...


Several preview releases back, I went to some trouble to ensure that
in nearly all cases, you can omit the @InjectService annotation and
Tapestry would still be able to inject the dependency in to the
constructor. This works in all cases where only a single service
implements the service interface deduced from the parameter type
(Session in the above example).

I can see why there's some confusion, because the quickstart archetype
uses an explicit @InjectService ... and that's because it's injecting
a service type, RequestFilter, that already has multiple
implementations inside Tapestry.

Even then, there are ways to reference services without resorting to
service id:  through the use of marker annotations.

In any case, for the maximum agilty and refactorablilty in your code,
see if you can get by without the @InjectService.

-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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