Hi, Thanks for you help! So the ServiceOverride solution doesn’t work, you get a recursive exception! Construction of service 'ServiceOverride' has failed due to recursion: the service depends on itself in some way.
But the decorate works, it’s fine for me that way. I will add a Jira issue. 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 > Le 21 juin 2021 à 14:13, Thiago H. de Paula Figueiredo <thiag...@gmail.com> a > écrit : > > 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