Hi,

I need to override the original HibernateSessionSourceImpl service with a modification of mine - MyHibernateSessionSourceImpl. It is 5.3.8 version.

I followed the instructions in http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.html
and replace the example code:

@Contribute(ServiceOverride.class)
public static void setupApplicationServiceOverrides(MappedConfiguration<Class,Object> configuration)
{
configuration.addInstance(SomeServiceType.class, SomeServiceTypeOverrideImpl.class);
}

with mine:

    @Contribute(ServiceOverride.class)
public static void setupApplicationServiceOverrides(MappedConfiguration<Class<?>, Object> configuration) { configuration.addInstance(HibernateSessionSource.class, MyHibernateSessionSourceImpl.class);
    }

But it throws:

java.lang.RuntimeException: Error invoking service contribution method com.mypack.services.AppModule.setupApplicationServiceOverrides(MappedConfiguration): Error invoking service contribution method org.apache.tapestry5.services.TapestryModule.productionModeOverrides(MappedConfiguration, boolean): Service 'ServiceOverride' is configured using org.apache.tapestry5.ioc.OrderedConfiguration, not org.apache.tapestry5.ioc.MappedConfiguration.


So I changed MappedConfiguration to OrderedConfiguration:

    @Contribute(ServiceOverride.class)
public static void setupApplicationServiceOverrides(OrderedConfiguration<HibernateSessionSource> configuration) { configuration.addInstance("Default", MyHibernateSessionSourceImpl.class);
    }

But it throws:

java.lang.RuntimeException: Error invoking service contribution method com.mypack.services.AppModule.setupApplicationServiceOverrides(OrderedConfiguration): Service 'ServiceOverride' is configured using org.apache.tapestry5.ioc.MappedConfiguration, not org.apache.tapestry5.ioc.OrderedConfiguration.

It looks like Catch-22.

So, what is the proper way to override a service implementation?

--
Best regards,
Aleksandar

Reply via email to