如何编写Tapestry ServiceOverride而不是自Tapestry 5.3.8以来不推荐使用的Alias Contribution

时间:2016-12-23 06:29:34

标签: tapestry

我已将当前的java版本从1.7升级到1.8。因为兼容的tapestry版本是5.3.8我在我的代码中包含了相同的内容。其中一个类(别名贡献)自tapstry 5.3.8以来已被弃用,他们建议使用ServiceOverride而不是它。任何人都可以解决这个问题吗?

Alias Contribution的当前代码(自tapestry 5.3.8起不推荐使用):

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

请建议我如何使用服务覆盖使我的代码与jdk 1.8

兼容

提前致谢。

1 个答案:

答案 0 :(得分:0)

使用ServiceOverride,它看起来像这样:

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

此处有更多详情: https://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.html