[英]Adding settings to a POJO component in Mule
I have a POJO component which basically contains some Java classes. 我有一个POJO组件,该组件基本上包含一些Java类。 At this point I have some settings hardcoded (such as some credentials) that I would like to configure somehow in the flow via the Studio GUI. 此时,我已经通过Studio GUI在流程中以某种方式对一些设置进行了硬编码(例如某些凭据)。
Is is possible to store somehow in the flow some settings that can easily be read by my POJO component? 是否可以以某种方式在流程中存储一些可以由我的POJO组件轻松读取的设置?
I see two options: 我看到两个选择:
I ended up using this solution. 我最终使用了该解决方案。
<global-property name="mysystem.username" value="JSmith" doc:name="Global Property"/>
Using the @Lookup annotation in the POJO to read it: 在POJO中使用@Lookup批注读取它:
import org.mule.api.MuleContext; import org.mule.api.annotations.expressions.Lookup; public class MulePOJO { /* http://www.mulesoft.org/documentation/display/current/Lookup+Annotation*/ @Lookup private MuleContext muleContext; public String singleArgumentMethod(String x) { String value = muleContext.getRegistry().get("mysystem.username"); return x; } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.