如何获取mule应用程序名称
是否有某种方法可以获取已部署mule应用程序的基本mule应用程序名称 到目前为止,我找到的唯一两个选择是:如何获取mule应用程序名称,mule,Mule,是否有某种方法可以获取已部署mule应用程序的基本mule应用程序名称 到目前为止,我找到的唯一两个选择是: muleContext.getConfiguration().getId() //which gives me some not so humanly-readable id of some sort. 及 部署时,每个应用程序都位于其自己的应用程序目录中,是否不可能从muleContext中获取此或其他类似的可分辨名称 善良的问候检索应用程序名称的最简单方法是使用${app.name
muleContext.getConfiguration().getId() //which gives me some not so humanly-readable id of some sort.
及
部署时,每个应用程序都位于其自己的应用程序目录中,是否不可能从muleContext中获取此或其他类似的可分辨名称
善良的问候检索应用程序名称的最简单方法是使用
${app.name}
spring占位符将其注入组件中这对我很有效:
String appName = ((org.mule.module.launcher.MuleApplicationClassLoader)this.getClass().getClassLoader()).getAppName();
对于MuleSoft 4.2.0,您可以使用静态Java函数加载应用程序名称:
ClassLoader cl=Class.forName(“保存此文件的全名”).getClassLoader();
方法getArtifactDescriptor=cl.getClass().getMethod(“getArtifactDescriptor”);
objectartifactdescriptor=getArtifactDescriptor.invoke(cl);
方法getName=artifactDescriptor.getClass().getMethod(“getName”);
对象appName=getName.invoke(artifactDescriptor);
返回appName.toString();
对于Mule 4.x有预定义的变量,其中一个是app.name
,用于在运行时检索应用程序名称。这是指向Mulesoft文档的链接,用于检查所有预定义变量:
String appName = ((org.mule.module.launcher.MuleApplicationClassLoader)this.getClass().getClassLoader()).getAppName();