源自 deltaspike 的 wildfly 11 部署中的拦截器警告

Nic*_*itz 3 cdi weld wildfly deltaspike

在Wildfly 11 中部署我的test.war期间,我看到了几个警告:

09:45:32,714 WARN  [org.jboss.weld.Validator] (MSC service thread 1-4) WELD-001478: Interceptor class org.apache.deltaspike.core.impl.throttling.ThrottledInterceptor is enabled for the application and for the bean archive test.war/WEB-INF/lib/deltaspike-core-impl-1.8.1.jar. It will only be invoked in the @Priority part of the chain.
09:45:32,714 WARN  [org.jboss.weld.Validator] (MSC service thread 1-4) WELD-001478: Interceptor class org.apache.deltaspike.core.impl.lock.LockedInterceptor is enabled for the application and for the bean archive test.war/WEB-INF/lib/deltaspike-core-impl-1.8.1.jar. It will only be invoked in the @Priority part of the chain.
09:45:32,715 WARN  [org.jboss.weld.Validator] (MSC service thread 1-4) WELD-001478: Interceptor class org.apache.deltaspike.core.impl.future.FutureableInterceptor is enabled for the application and for the bean archive test.war/WEB-INF/lib/deltaspike-core-impl-1.8.1.jar. It will only be invoked in the @Priority part of the chain.
09:45:32,722 WARN  [org.jboss.weld.Validator] (MSC service thread 1-4) WELD-001478: Interceptor class org.apache.deltaspike.jpa.impl.transaction.TransactionalInterceptor is enabled for the application and for the bean archive test.war/WEB-INF/lib/deltaspike-jpa-module-impl-1.8.1.jar. It will only be invoked in the @Priority part of the chain.
09:45:32,728 WARN  [org.jboss.weld.Validator] (MSC service thread 1-4) WELD-001478: Interceptor class org.apache.deltaspike.proxy.util.EnableInterceptorsInterceptor is enabled for the application and for the bean archive test.war/WEB-INF/lib/deltaspike-proxy-module-api-1.8.1.jar. It will only be invoked in the @Priority part of the 
Run Code Online (Sandbox Code Playgroud)

这似乎是因为在我的test.war现有 deltaspike jar中的每个beans.xml中都存在一些拦截器,例如对于deltaspike-core-impl-1.8.1.jar

<class>org.apache.deltaspike.core.impl.throttling.ThrottledInterceptor</class>
<class>org.apache.deltaspike.core.impl.lock.LockedInterceptor</class>
<class>org.apache.deltaspike.core.impl.future.FutureableInterceptor</class>
Run Code Online (Sandbox Code Playgroud)

是否可以从beans.xml 中删除拦截器而不会造成任何伤害?

在 Wildfly 11 中使用了 CDI 1.2,我认为不再需要在beans.xml 中明确列出拦截器。

至少似乎存在一些(次要)问题应该由 deltaspike 开发人员调查?

Sil*_*rus 6

这是 DeltaSpike 讨厌的黑魔法——他们试图保持 CDI 1.0 兼容,这意味着他们不能使用@Priority(稍后引入,CDI 1.1)作为全局启用拦截器/装饰器/替代品的手段。为了让它工作,他们必须在beans.xml他们的 JAR 中包含一个并在每个存档的基础上启用它

但这还不是全部,然后他们@Priority通过使用扩展来解决限制,该扩展将所有拦截器提升为全局启用拦截器(例如,好像他们有@Priority)。

现在,我不确定您是否可以删除它 - 您可以轻松尝试查看它们是否仍然有效。但我不会碰它,因为 DS 在这方面似乎很脆弱。

至于 Weld 警告 - 它是非常无害的,Weld 只是告诉您在处理所有拦截器时:

  • 它在beans.xml(每个 bean 存档启用)中找到的那些
  • 它通过扫描类路径识别的那些;寻找@Interceptor+ @Priority(全局启用)
  • 以及最终通过扩展启用的那些(全局启用)

它发现一些拦截器是双向启用的,尽管如此,它们只会被调用一次。

总而言之,您不需要做任何事情,它应该仍然适合您。