On Thu, Jun 17, 2021 at 8:29 AM Numa Schmeder <n...@dfacto.ch> wrote:
> Hi, Hi! > Thanks for your help, no it doesn’t seem to work. I found a solution > using decorate method, but I am not sure it’s really clean. I consider decoration really clean. Sometimes you cannot use service override because it causes a circular service dependency (it ends up depending on itself). > public static ComponentMessagesSource > decorateComponentMessagesSource(ComponentMessagesSource current, @Autobuild > CustomComponentMessagesSourceImpl custom, UpdateListenerHub > updateListenerHub) > { > updateListenerHub.addUpdateListener(custom); > return custom; > } > This looks good to me. > Just wondering if there is no cleaner way. I guess your problem in your original attempt was declaring your custom messages source as a service, something you don't need. That way, you end up with two services implementing the same service interface and Tapestry-IoC doesn't know which one to use. I'd try this: @Contribute(ServiceOverride.class) public static void setupApplicationServiceOverrides(MappedConfiguration<Class<?>,Object> configuration, @Autobuild YourCustomComponentMessagesSource messagesSource, UpdateListenerHub updateListenerHub) { // configuration.add(HibernateSessionSource.class, hibernateSessionSource); //overriding existing default component message source to add MessageFormat updateListenerHub.addUpdateListener(messagesSource); configuration.override(ComponentMessagesSource.class, messagesSource); } > I believe message formatter should be a service that should be overridable. Please create a Jira issue for this. -- Thiago