Okay, so I figured this out... here's the scoop: I tried various incantations of contributeAlias and contributeAliasOverrides but the issue seemed to be with the injection of my service instance. If I commented out all the arguments to the service's constructor then I could get past the recursion error, but obviously that wouldn't allow my service to do what it needed to.
Looking at the nightly docs: http://tapestry.formos.com/nightly/tapestry5/ I noticed this line in the "new and of note" section: "A simpler method of overriding built-in services has been added." with a link to: http://tapestry.formos.com/nightly/tapestry5/apidocs/org/apache/tapestry5/ioc/services/ServiceOverride Which sounds like exactly what I want to do (Presents? ...and it's not even my birthday. ;) ). So I changed from trying to contribute an Alias (or AliasOverride) to ServiceOverride. My first attempts followed the (seemingly) standard pattern: public static void bind(ServiceBinder binder) { binder.bind(SiteLinkFactory.class).withId("SiteLinkFactory");; } public static void contributeServiceOverride( MappedConfiguration<Class, Object> configuration, @InjectService("SiteLinkFactory") SiteLinkFactory siteLinkFactory) { configuration.add(LinkFactory.class, siteLinkFactory); } But this got the same kind of recursion error I had been encountering before... seemingly that the ServiceOverride service was dependent on itself. Thanks to a post by Kris, I changed my code to this (note, no need for a binding): public static void contributeServiceOverride( MappedConfiguration<Class, Object> configuration, ObjectLocator locator) { configuration.add(LinkFactory.class, locator.proxy(LinkFactory.class, SiteLinkFactory.class)); } And, we make it past the recursion issue! <happy dance> Thanks for your help, people. Levi (on to the next exception... ;) ) xfile80303 wrote: > > Hi all, > > Short version: > > I need to override an existing binding so I can insert my own > implementation, but I get a RuntimeException from Tapestry when I try to > do so. > > How would I do this? > > Long Version: > > In my quest to do URL manipulation and insert "site" into the first > element of the URL, I have half the answer. The remaining issue is that > the generated links do not contain this site parameter, and need to so the > site will not always be the default site. It would appear (from reading > the Tapestry code) that I need to override the default functionality in > org.apache.tapestry5.internal.services.LinkFactoryImpl to insert the value > into the generated Link object's path. Again, this looks like I have to > completely copy the functionality of the LinkFactoryImpl, but that's no > biggie (thanks to open source... :) ). > > The issue is, how to use my implementation instead of the default > implementation? > > If, in my Module class, I try to bind to the LinkFactory interface, the > whole app fails to even deploy. > Even without my implementation in the way... I just try to replace the > existing binding with the same binding: > > public static void bind(ServiceBinder binder) > { > binder.bind(LinkFactory.class, LinkFactoryImpl.class); > } > > and I get a RuntimeException from Tapestry: > > java.lang.RuntimeException: Service id 'LinkFactory' has already been > defined by org.apache.tapestry5.internal.services.LinkFactoryImpl(Request, > Response, RequestSecurityManager, RequestPathOptimizer, PersistentLocale, > RequestPageCache, ContextValueEncoder, URLEncoder) (at > LinkFactoryImpl.java:53) via > org.apache.tapestry5.internal.services.InternalModule.bind(ServiceBinder) > (at InternalModule.java:59) and may not be redefined by > org.apache.tapestry5.internal.services.LinkFactoryImpl(Request, Response, > RequestSecurityManager, RequestPathOptimizer, PersistentLocale, > RequestPageCache, ContextValueEncoder, URLEncoder) (at > LinkFactoryImpl.java:53) via > com.java.dse.cwp.eos.services.EosModule.bind(ServiceBinder) (at > EosModule.java:50). You should rename one of the service builder methods. > > > So it would seem that I would need to do this in a different way. > > Thoughts? > > Thanks, > > Levi > -- View this message in context: http://n2.nabble.com/-T5.1--Overriding-a-binding--tp2344287p2348082.html Sent from the Tapestry Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org