我有一个Quarkus应用程序,它使用当前版本的Vaadin和Quarkus (23.2.4和2.13.1.Final)。我希望有一个VaadinServiceInitListener来检查视图上的访问注释(@RolesAllowed(...))使用AccessAnnotationChecker )。我认为用@VaadinServiceEnabled注释实现应该可以修复这个问题,但是我需要在META-INF/services/com.vaadin.flow.server.VaadinServiceInitListener中注册它才能激活它。这就是在不使用依赖注入框架时如何做到这一点。然后一切按预期工作,我可以使用AccessAnnotationChecker查看用户在BeforeEnterEvent上是否有访问该视图的权限。
我还注意到启动时的消息Can't find any @VaadinServiceScoped bean implementing 'I18NProvider'. Cannot use CDI beans for I18N, falling back to the default behavior.。奇怪的是,在类中实现I18NProvided并使用@VaadinServiceEnabled和@VaadinServiceScoped注释它会使消息消失,例如。它得到了CDI的认可。
为什么我的VaadinServiceInitListener实现没有被重新签名?当前,它被注释为
@VaadinServiceEnabled
@VaadinServiceScoped
@Unremovable我的pom.xml包括
vaadin-quarkus-extension,
quarkus-oidc,
quarkus-keycloak-authorization,
vaadin-jandex发布于 2022-10-12 17:00:13
您可以使用CDI事件,而不是使用侦听器。Quarkus的依赖注入解决方案基于CDI,因此您可以使用相同的事件。下面是一个例子
public class BootstrapCustomizer {
private void onServiceInit(@Observes
ServiceInitEvent serviceInitEvent) {
serviceInitEvent.addIndexHtmlRequestListener(
this::modifyBootstrapPage);
}
private void modifyBootstrapPage(
IndexHtmlResponse response) {
response.getDocument().body().append(
"<p>By CDI add-on</p>");
}
}更多信息,在这里https://vaadin.com/docs/latest/integrations/cdi/events
https://stackoverflow.com/questions/74044789
复制相似问题