Tapestry Users, I'd like to contribute an InjectionProvider2<http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/services/transform/InjectionProvider2.html> into the chain that processes @Inject annotations. The cookbook example that illustrates the chain of command pattern<http://tapestry.apache.org/ioc-cookbook-patterns.html> cites how Tapestry IOC's own injection provider is built. The example says, "And, of course, other contributions could be made in other modules ... if you wanted to add in your own form of injection." So, I tried copying a similar method into my AppModule:
public static void contributeInjectionProvider2( OrderedConfiguration<InjectionProvider2> configuration, MasterObjectProvider masterObjectProvider, ObjectLocator locator, SymbolSource symbolSource, AssetSource assetSource) { configuration.add("BeckonLogger", new InjectionProvider2() { public boolean provideInjection(PlasticField field, ObjectLocator locator1, MutableComponentModel componentModel) { if (field.getTypeName().equals("com.beckon.app.util.log.BeckonLogger")) { field.inject(BeckonLoggerImpl.getLogger(field.getPlasticClass().getClassName())); return true; } return false; } }); } But that gives me the following error: java.lang.IllegalArgumentException: Contribution com.beckon.app.services.AppModule.contributeInjectionProvider2(OrderedConfiguration, MasterObjectProvider, ObjectLocator, SymbolSource, AssetSource) (at AppModule.java:92) is for service 'InjectionProvider2', which does not exist. Is there a different way that I should contribute my InjectionProvider2? More generally, what is the best way to add a custom form of injection? More generally still, my overarching goal is to be able to instiate my own logger with the name of the owning class and to use @Inject to describe the dependency--is there a way to customize or otherwise use one of the existing InjectionProviders to do that? Thank you in advance, - Pavel