Hello,

I am trying to override the ComponentMessageSource service with a custom 
ComponentMessageSourceImpl. The main reason to override the service is to be 
able to use a custom implementation of MapMessages in MessageFormatterImpl.
Currently it uses only String Formatter, which is very good for some time of 
formatting but less practical for i18n formatting as it doesn’t handle plurals 
at all. I would like to revert to classic MessageFormat.

This is what I have done in my module:
@Contribute(ServiceOverride.class)
public static void 
setupApplicationServiceOverrides(MappedConfiguration<Class<?>,Object> 
configuration, @Local ComponentMessagesSource messagesSource)
{
    //  configuration.add(HibernateSessionSource.class, hibernateSessionSource);
    //overriding existing default component message source to add MessageFormat
    configuration.override(ComponentMessagesSource.class, messagesSource);

}

public static ComponentMessagesSource 
buildCustomComponentMessagesSource(UpdateListenerHub updateListenerHub, 
@Autobuild ComponentMessagesSourceImpl service)
{
    updateListenerHub.addUpdateListener(service);
    return service;
}

If anyone has a clue on how to override this service this would be very 
helpful. I always end up with 2 conflicting service, and configuration.override 
doesn’t work. 
It tapestry module ComponentMessageSource is built using a builder method and 
then injected
public static ComponentMessagesSource 
buildComponentMessagesSource(UpdateListenerHub updateListenerHub, @Autobuild 
ComponentMessagesSourceImpl service)
{
    updateListenerHub.addUpdateListener(service);
    return service;
}

Thank you for your help :)

Best regards, 

  <http://www.dfacto.ch/>       Numa Schmeder    www.dfacto.ch  
<http://www.dfacto.ch/>
n...@dfacto.ch <mailto:n...@dfacto.ch>   |   M +41 79 538 30 01 

DIGITAL STRATEGY   |   DESIGN   |   DEVELOPMENT


 

Reply via email to