To expand on this:
A decorator is passed the service to delegate to, with the intention
that it will, at some point, invoke methods on the delegate. However,
this doesn't have to be the case. A decorator is free to completely
replace the original service if it so wishes. The advantage of that
is that there's no naming ambiguity ... there's just the single
service. The disadvantage is that the decorator has to really
understand the implementation of the service it replaces. For
example, the ComponentMessagesSource service has some extra
implementation:
public ComponentMessagesSource buildComponentMessagesSource(
@ContextProvider
AssetFactory contextAssetFactory,
@Inject
@Value("WEB-INF/${tapestry.app-name}.properties")
String appCatalog)
{
ComponentMessagesSourceImpl service = new
ComponentMessagesSourceImpl(contextAssetFactory
.getRootResource(), appCatalog);
updateListenerHub.addUpdateListener(service);
return service;
}
The alternative is to define a new service, say
"CustomizedComponentMessagesSource". However, you will then start
seeing errors becuase there will be two services that use the same
service interface, and injections (that use just the service interface
and no additional annotations) will be ambiguous. This is where you
can disambiguate, using the Alias service. A contribution there
influences the injection process (Tapestry IoC is partrially
implemented in itself, which can be alternatly sublimely powerful and
hair raising) ... in any case, the contribution removes the ambiguity
on service type.
On Tue, Jun 10, 2008 at 4:14 AM, Davor Hrg <[EMAIL PROTECTED]> wrote:
> to change a service you can also use service decorators,
> http://tapestry.apache.org/tapestry5/tapestry-ioc/decorator.html
>
> and for config just add a SymbolSource
> http://tapestry.apache.org/tapestry5/tapestry-ioc/symbols.html
>
>
> Davor Hrg
>
>
> On Tue, Jun 10, 2008 at 12:33 PM, Cordenier Christophe <
> [EMAIL PROTECTED]> wrote:
>
>> Hello
>>
>> Take a look at the service 'Alias'.
>>
>> There is also a thread about this :
>> http://markmail.org/search/?q=tapestry+type%3Ausers+list%3Aorg.apache.tapestry.users+Can+you+try+with+something+like+this%2C+Override+and+alias#query:tapestry%20type%3Ausers%20list%3Aorg.apache.tapestry.users%20Can%20you%20try%20with%20something%20like%20this%2C%20Override%20and%20alias+page:1+mid:bd4xfcmup7cdlbes+state:results
>>
>> Christophe.
>>
>> -----Message d'origine-----
>> De : news [mailto:[EMAIL PROTECTED] De la part de Neeme Praks
>> Envoyé : mardi 10 juin 2008 10:45
>> À : [email protected]
>> Objet : [T5] overriding application-wide message catalog location?
>>
>> Hi all,
>>
>> Tapestry5 is shaping up quite nicely, great work!
>> As a result, I have chosen Tapestry 5 as the framework to build a new
>> project on :-)
>>
>> Inevitably, there will be questions and here is mine:
>> Is there some way to override application-wide message catalog
>> location? The default is WEB-INF/<appname>.properties
>>
>> Why would I want to do that? Well, historically we have used Spring
>> Web-MVC for our applications and there we stored the application message
>> catalog in WEB-INF/messages/messages.properties and I would like to keep
>> that location unchanged. Easier for our translators.
>>
>> As far as I can see in the source code, this location is pretty much
>> hardcoded? org.apache.tapestry.services.TapestryModule has:
>>
>> public ComponentMessagesSource buildComponentMessagesSource(
>> @ContextProvider
>> AssetFactory contextAssetFactory,
>>
>> @Inject
>> @Value("WEB-INF/${tapestry.app-name}.properties")
>> String appCatalog)
>> {
>> ComponentMessagesSourceImpl service = new
>> ComponentMessagesSourceImpl(contextAssetFactory
>> .getRootResource(), appCatalog);
>>
>> updateListenerHub.addUpdateListener(service);
>>
>> return service;
>> }
>>
>> As this location is hardcoded, I guess I have two options:
>> * patch Tapestry to make it configurable
>> * override the definition of ComponentMessagesSource with my own
>> implementation (or just my own configuration)
>>
>> I guess the first option is a long-term solution and second is a
>> short-term solution?
>>
>> I'm willing to investigate the possibility for patching Tapestry (any
>> pointers are very welcome), but at the same time, I would also like to
>> implement the short-term solution to solve the issue at hand.
>>
>> While investigating the possibility to override, I came across the
>> following.
>> On page http://tapestry.apache.org/tapestry5/tapestry-ioc/module.html
>> it is written that:
>> "Service ids must be unique; if another module contributes a service
>> with the id "Indexer" (or any case variation thereof) a runtime
>> exception will occur when the Registry is created."
>>
>> Does this mean that I cannot override the default
>> ComponentMessagesSource service implementation?
>>
>> I hope I misunderstood something :-)
>>
>> And, while I'm already consuming airtime here: how can I override the
>> default tapestry configuration mechanism with my own? So instead of
>> taking parameters from web.xml, I can implement my own way of loading
>> them (e.g. from properties file, from DB, etc).
>>
>> Rgds,
>> Neeme
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>
>> Ce message et les pièces jointes sont confidentiels et réservés à l'usage
>> exclusif de ses destinataires. Il peut également être protégé par le secret
>> professionnel. Si vous recevez ce message par erreur, merci d'en avertir
>> immédiatement l'expéditeur et de le détruire. L'intégrité du message ne
>> pouvant être assurée sur Internet, la responsabilité du groupe Atos Origin
>> ne pourra être recherchée quant au contenu de ce message. Bien que les
>> meilleurs efforts soient faits pour maintenir cette transmission exempte de
>> tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa
>> responsabilité ne saurait être recherchée pour tout dommage résultant d'un
>> virus transmis.
>>
>> This e-mail and the documents attached are confidential and intended solely
>> for the addressee; it may also be privileged. If you receive this e-mail in
>> error, please notify the sender immediately and destroy it. As its integrity
>> cannot be secured on the Internet, the Atos Origin group liability cannot be
>> triggered for the message content. Although the sender endeavours to
>> maintain a computer virus-free network, the sender does not warrant that
>> this transmission is virus-free and will not be liable for any damages
>> resulting from any virus transmitted.
>>
>
--
Howard M. Lewis Ship
Creator Apache Tapestry and Apache HiveMind
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]