Reflection Entry Point Resolver是根据Mule Message的Payload参数类型匹配entry point的。配置代码如下
<reflection-entry-point-resolver acceptVoidMethods="true" />
如果存在多个符合条件的entry point,将会抛出异常信息
ReflectionEntryPointResolver: Found too many possible methods on object
"entrypointresolvertest.TestComponent" that accept parameters "{class java.lang.String}"
这是因为我们在TestComponent中配置了不止一个参数类型为String的方法,因此会出现匹配多个entry point的异常。
public void MethodEntryPointMethod1(String message)
{
logger.info("MethodEntryPointMethod1's message is:" + message);
}
public void MethodEntryPointMethod2(String message)
{
logger.info("MethodEntryPointMethod2's message is:" + message);
}
public void PropertyEntryPointMethod(String message)
{
logger.info("PropertyEntryPointMethod's message is:" + message);
}
如果我们只想匹配某一个方法时,可以把其他匹配的方法设置为排除方法
<reflection-entry-point-resolver acceptVoidMethods="true" >
<exclude-entry-point method="MethodEntryPointMethod1" />
<exclude-entry-point method="MethodEntryPointMethod2" />
</reflection-entry-point-resolver>
再运行程序,可以看到前两个方法在匹配entry point时被忽略了,只匹配了PropertyEntryPointMethod方法
Relection Entry Point Resolver还可以使用exclude-object-methods,这个子节点主要是用于排除自定义Component类继承的Object父类的toString(),notify()等方法。Mule ESB默认是使用这个子节点的,但是如果使用了exclude-entry-point子节点后,这个设定会失效,需要手动添加exclude-object-methods子节点
<reflection-entry-point-resolver acceptVoidMethods="true" >
<exclude-entry-point method="MethodEntryPointMethod1" />
<exclude-entry-point method="MethodEntryPointMethod2" />
<exclude-object-methods />
</reflection-entry-point-resolver>
来源:oschina
链接:https://my.oschina.net/u/237688/blog/733467