Properties Mule-创建用于流的自定义属性
我试图在我的流程中获得可用的操作系统名称,以便根据运行的操作系统调整变量。Properties Mule-创建用于流的自定义属性,properties,mule,spring-bean,Properties,Mule,Spring Bean,我试图在我的流程中获得可用的操作系统名称,以便根据运行的操作系统调整变量。 我不熟悉Springbeans,但到目前为止,下面的代码将调用set函数(我在日志中看到),但我需要能够从流内部访问osName java类: public class CustomVariables { public CustomVariables(){} public String osName; public String getOsName(){ System.out.
我不熟悉Springbeans,但到目前为止,下面的代码将调用set函数(我在日志中看到),但我需要能够从流内部访问osName java类:
public class CustomVariables {
public CustomVariables(){}
public String osName;
public String getOsName(){
System.out.println("got value: "+ osName);
return osName;
}
public void setOsName(String name){
osName = System.getProperty("os.name").toLowerCase();
System.out.println("set value: "+ osName); //this prints in console on startup
}
}
mule.xml:
<spring:beans>
<spring:bean class="netstockconnector.CustomVariables">
<spring:property name="osName" value="{os.name}"> </spring:property>
</spring:bean>
</spring:beans>
流动中:
<logger message="${osName}" level="INFO" doc:name="Logger"></logger>
例如,这只是打印到控制台“${osName}”,而不是“MacOSX”。
有什么想法吗?有一个更简单的解决方案
<logger message='#[System.getProperty("os.name")]' level="INFO" doc:name="Logger"></logger>
要触发Mule表达式语言,要计算的表达式应介于#[要计算的表达式]
之间。默认情况下,MEL导入一组java类,其中包括java.lang.System,因此在表达式中直接使用