IoC cookbook - overridePage added by Ulrich StärkOverriding ServicesTapestry is designed to be easy to customize, and the IoC container is key to that customizability. Part of Tapestry's core functionality is resolving injected objects; that is, when Tapestry is building an object or service and sees a constructor parameter or a field, what value does it plug in? Most of the time, the injected object is a service defined elsewhere within the container (and, in fact, that actual instance will be a proxy to the service, which may not have been fully realized yet). However, there are cases where you might want to override how Tapestry operates in some specific way. The strategy used to determine what object gets injected where is [defined inside Tapestry IoC itself|../injection.html]; thus we can take advantage of several features of the IoC container in order to take control over specific injections. Overriding ServicesIn most cases, services are injected by matching just type; there no @InjectService annotation, just a method or constructor parameter whose type matches the service's interface. In this case, it is very easy to supply your own alternate implementation of a service. AppModule.java (partial) public static void contributeServiceOverride(MappedConfiguration<Class,Object> configuration)
{
configuration.add(SomeServiceType.class, new SomeServiceType() { . . . });
}
Change Notification Preferences
View Online
|
- [CONF] Apache Tapestry > IoC cookbook - override confluence
- [CONF] Apache Tapestry > IoC cookbook - override confluence
- [CONF] Apache Tapestry > IoC cookbook - override confluence
- [CONF] Apache Tapestry > IoC cookbook - override confluence
- [CONF] Apache Tapestry > IoC cookbook - override confluence
- [CONF] Apache Tapestry > IoC cookbook - override confluence
- [CONF] Apache Tapestry > IoC cookbook - override confluence
- [CONF] Apache Tapestry > IoC cookbook - override confluence
- [CONF] Apache Tapestry > IoC cookbook - override confluence
