I've read the section below about contributing a service override. This method 
is exactly what I need to resolve an issue I'm having getting a conditional 
override implemented, but it doesn't appear to work if the service 
implementations' constructor has any other T5 service dependencies in the 
signature. (T5 complains that ServiceOverride depends on itself.

Is this true, because that doesn't seem to be what's implied below by "handle 
dependency resolution", and makes addInstance of limited usefulness. I'm hoping 
I'm just missing something here.



>From http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.html :

"In this case, it is very easy to supply your own alternate implementation of a 
service.
AppModule.java (partial)

  @Contribute(ServiceOverride.class)

  public static void 
setupApplicationServiceOverrides(MappedConfiguration<Class,Object> 
configuration)

  {

    configuration.addInstance(SomeServiceType.class, 
SomeServiceTypeOverrideImpl.class);

  }

The name of the method is not important, as long as the 
@Contribute<http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/annotations/Contribute.html>
 annotation is present on the method.

In this example, we are using addInstance() which will instantiate the 
indicated class and handle dependency resolution. (Be careful with this, 
because in some cases, resolving dependencies of the override class can require 
checking against the ServiceOverrides service, and you'll get a runtime 
exception about ServiceOverrides requiring itself!)"

Reply via email to