使用Wicket从超级/抽象类调用方法时焊接注入失败 [英] Weld injection failing when calling a method from an super/abstract class with Wicket
问题描述
但是,如果我从具体的类调用一个方法,它的工作是完美的。我可以覆盖方法并调用它们,我可以将一个重写的方法委托给抽象类(覆盖的方法调用super.method()),并且它的工作原理。抽象类有什么样的配置吗?
谢谢。
这是一个基于我的经验的猜测与Seam。 Weld注入一个包装你的bean的代理。代理只拦截公共方法并将它们委托给底层bean(在您的情况下为EJB)。当您在代理上调用受保护的方法时,或者在同一个包中的类中使用package-private方法,该方法不会被拦截,并直接在代理上调用,从而导致错误。为了使故事简短,只需调用公共方法或通过接口返回所有的依赖项并注入。
I am having a problem with weld-wicket. When @Inject-ing an EJB that inherits from an abstract class, if I attempt to call a method from the abstract class I get an ejb-ref error. However if I call a method from the concrete class it works perfectly. I can override methods and call them, and I can delegate an overridden method to the abstract class (having the overridden method call super.method()) and that works. Is there some sort of configuration I have to do to the abstract class?
Thanks.
This is a guess based on my experience with Seam. Weld injects a proxy that wraps your bean. The proxy only intercepts public methods and delegates those to the underlying bean (EJB in your case). When you call a protected method on the proxy or a package-private method from a class in the same package that method is not intercepted and is invoked directly on the proxy which causes your error. To make the story short, only call public methods or back all your dependencies by an interface and inject that.
这篇关于使用Wicket从超级/抽象类调用方法时焊接注入失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!