When you inject a service, Tapestry works primarily by the type (whether its
the type of a field in a component, or the type of a parameter to service
builder method or a constructor).

When resolving, based on type, Tapestry will search all the services defined
by any and all modules, looking for a single service that fits the bill.
That is, a single service whose service interface is assignable to the field
type.  This is often the case, a single interface, a single service.

When you contribute a new service that has the same interface as an existing
service, that creates an ambiguity.  Without additional disambiguating
information, Tapestry is unable to determine which of the two services to
inject.  This is considered an error.

One way to disambiguate is to use @InjectService("ServiceId")  (or the
corresponding @Service annotation on a field in a component). This removes
the ambiguity, but doesn't override the existing service.  Short of hacking
existing service implementation to use @InjectService, you can't get
Tapestry to use your service in the other services it defines.

Alias is used to disambiguate on type.  By making a contribution there, you
are saying "for type foo.bar.Baz, my implementation should be used.".  What
you contribute is usually a service, but can even be an object constructed
on the fly.

In your case, you are trying to override the default ComponentMessageSource,
and need to contribute an AliasContribution so that your CMS will be used
everywhere the built-in CMS is used in a typical Tapestry application.  Your
CMS implementation can even inject the default CMS, using @InjectService.

On 5/31/07, Martin Dietze <[EMAIL PROTECTED]> wrote:

On Thu, May 31, 2007, SergeEby wrote:

> You can provide your own implementation by contributing to
aliasOverrides:
>
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/alias.html

Thank you for your reply. I took a look at that page, but I do
not quite understand it. It seems like I lack some a-priori
knowledge on some of T5's concepts.

Could you give me a quick example and / or some hint on how I
could facilitate this mechanism for using my own localization
backend?

Cheers,

Martin

--
----------- / http://herbert.the-little-red-haired-girl.org /
-------------
=+=
In an organization, each person rises to the level of his own
incompetency.
           -- The Peter Principle

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

Reply via email to