How to code tapestry ServiceOverride instead of Alias Contribution which is deprecated since Tapestry 5.3.8

175 views Asked by At

I have upgraded current java version from 1.7 to 1.8. since compatible tapestry version is 5.3.8 I have included same in my code. One of the class (Alias Contribution) is deprecated since tapstry 5.3.8 and they suggested to use ServiceOverride instead of it. Any one can me me out with this issue?

Current code with Alias Contribution(deprecated since tapestry 5.3.8):

public static void contributeAlias(
@InjectService("MyService") MyService myService,Configuration<AliasContribution> configuration)
{
    configuration.add(AliasContribution.create(MyService.class, myService));
}

Please suggest how can I use Service Override to make my code compatible with jdk 1.8

Thanks in advance.

1

There are 1 answers

0
Dmitry Gusev On

With ServiceOverride it would look like this:

@Contribute(ServiceOverride.class)
public static void overrideServices(
    MappedConfiguration<Class<?>, Object> configuration,
    @InjectService("MyService") MyService myService)
{
    configuration.add(MyService.class, myService);
}

More details here: https://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.html