[英]Class inheritance in Mule Java / POJO Component
I am trying to use a base class with common methods and to extend it other more specific classes. 我试图将基类与常用方法一起使用,并将其扩展为其他更具体的类。
public class myClass extends myBaseClass {}
The extended class I am using as a Java component in a flow: 我在流程中用作Java组件的扩展类:
<component class="org.example.MyClass" doc:name="Java"/>
When I am not calling methods from the parent class, everything works well. 当我不从父类调用方法时,一切工作正常。 But each time I try calling one Mule is throwing an exception: 但是每次我尝试调用一个Mule都会引发异常:
DefaultJavaComponent{vtigersapFlow1.component.9760166}. Message payload is of type: String
In my base class I am using: 在我的基类中,我正在使用:
@Lookup
private MuleContext muleContext;
and and a NullPointerExcception
is thrown when I am doing: 并且在执行操作时抛出NullPointerExcception
:
muleContext.getRegistry().get("system.uri");
It's possible that the @Lookup
annotation is not honoured correctly in a class hierarchy. 在类层次结构中, @Lookup
批注可能未正确使用。
Instead of looking values in the registry, you should receive them by injection, ie get system.uri
by injection. 与其在注册表中查找值, system.uri
通过注入来接收它们,即通过注入来获取system.uri
。
You may find that switching to Spring beans will help a lot in doing so. 您可能会发现,切换到Spring Bean将在此方面大有帮助。 component class=
is really for basic stuff. component class=
确实是基本的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.