Is there some way of getting the base mule application name of a deployed mule application?
The only two options i have found so far is:
muleContext.getConfiguration().getId() //which gives me some not so humanly-readable id of some sort.
and
muleEvent.getFlowConstruct().getName() //gives me that flow name from where this was called.
Each application is in their own application directory when deployed, is it not possible to get a hold of this or some other similar distinguished name from within the muleContext?
kind regards
检索应用程序名称的最简单方法是使用${app.name}
spring 占位符将其注入到您的组件中
这对我有用:
String appName = ((org.mule.module.launcher.MuleApplicationClassLoader)this.getClass().getClassLoader()).getAppName();
For Mule 4.x there are predefined variables and one of those is app.name
to retrieve the application name in runtime. This is the link to the Mulesoft documentation to check all the predefined variables:
https://docs.mulesoft.com/mule-runtime/4.2/dataweave-variables-context
For MuleSoft 4.2.0 you can load application name with static Java function:
ClassLoader cl = Class.forName("full-name-holding-this").getClassLoader();
Method getArtifactDescriptor = cl.getClass().getMethod("getArtifactDescriptor");
Object artifactDescriptor = getArtifactDescriptor.invoke(cl);
Method getName = artifactDescriptor.getClass().getMethod("getName");
Object appName = getName.invoke(artifactDescriptor);
return appName.toString();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.