存储对象并从 Mule Registry 中检索它们
Storing Objects and retrieving them from Mule Registry
我在以下位置添加了一对 key/value:
src/main/resources/META-INF/services/org/mule/config/registry-bootstrap.属性。 Mule 文档指出,那是它们应该放置的地方,以便在启动时加载它们。
文件中的条目如下所示:
myObject=org.sys.jks.DataConstants
class DataConstants{
public static final String GGS="FST";
}
class 有一个静态最终变量列表。但是,当我尝试访问流程中的常量时,我没有获得任何值。以下是我的尝试。
#[app.registry.myObject.GGS]
#[app.registry.'myObject'.GGS]
不幸的是,两者都不起作用。如何访问常量作为负载中映射的键?
例如#[payload['app.registry.myObject.GGS'] 不起作用。
请帮忙!!
根据文档,您可以尝试#[app.registry.get('nameOfBean').nameOfConstant]
.get() 文档:
Returns the value to which the specified key is
mapped, or null if this map contains no mapping for the
key.
More formally, if this map contains a mapping from a
key k to a value v such that (key==null ? k==null :
key.equals(k)), then this method returns v; otherwise it
returns null. (There can be at most one such mapping.)
If this map permits null values, then a return value of
null does not necessarily indicate that the map
contains no mapping for the key; it's also possible that
the map explicitly maps the key to null. The
containsKey operation may be used to distinguish
these two cases.
Parameters:
key the key whose associated value is to be
returned
Returns:
the value to which the specified key is mapped, or
null if this map contains no mapping for the key
Throws:
ClassCastException if the key is of an
inappropriate type for this map (optional)
NullPointerException if the specified key is null
and this map does not permit null keys (optional)
在我的例子中,我在我的 global.xml mule 配置文件中添加内存中的 bean:
<spring:beans>
<spring:bean id="beanUtils" name="beanUtils"
class="somepackage.NameOfClass"
scope="singleton" />
</spring:beans>
我在以下位置添加了一对 key/value: src/main/resources/META-INF/services/org/mule/config/registry-bootstrap.属性。 Mule 文档指出,那是它们应该放置的地方,以便在启动时加载它们。 文件中的条目如下所示:
myObject=org.sys.jks.DataConstants
class DataConstants{
public static final String GGS="FST";
}
class 有一个静态最终变量列表。但是,当我尝试访问流程中的常量时,我没有获得任何值。以下是我的尝试。
#[app.registry.myObject.GGS]
#[app.registry.'myObject'.GGS]
不幸的是,两者都不起作用。如何访问常量作为负载中映射的键?
例如#[payload['app.registry.myObject.GGS'] 不起作用。 请帮忙!!
根据文档,您可以尝试#[app.registry.get('nameOfBean').nameOfConstant]
.get() 文档:
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. More formally, if this map contains a mapping from a key k to a value v such that (key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.) If this map permits null values, then a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases. Parameters: key the key whose associated value is to be returned Returns: the value to which the specified key is mapped, or null if this map contains no mapping for the key Throws: ClassCastException if the key is of an inappropriate type for this map (optional) NullPointerException if the specified key is null and this map does not permit null keys (optional)
在我的例子中,我在我的 global.xml mule 配置文件中添加内存中的 bean:
<spring:beans>
<spring:bean id="beanUtils" name="beanUtils"
class="somepackage.NameOfClass"
scope="singleton" />
</spring:beans>