Mule ESB中entry-point-resolver的使用(9) Entry Point Resolver Set和 Legacy Entry Point Resolver Set

   前面的系列介绍了Mule ESB提供和用户自定义的Entry Point Resolver,若是咱们在实际使用中须要用到多个Entry Point Resolver进行Entry Point 匹配时,咱们须要使用Entry Point Resolver Set。java

   Mule ESB提供的Entry Point Resolver Set包含两种,一种是系统默认的Entry Point Resolver Set:.net

Legacy Entry Point Resolver Set,它包含了实现标准逻辑的Entry Point Resolver,这些Resolver包括code

  •  Annotation Entry Point Resolver 

      这个Entry Point Resolver前面没有提到,它主要是用于解析带有@Service标签的Component类的方法,匹配的方法全部的参数都须要有Mule Expression Language注解,例如如下的方法     xml

public Object method1(@XPath ("/foo/bar")String bar, 
  @Payload Document doc, @InboundHeaders("name")String name)
{
  ........
}

      这个方法的全部参数就包含了MEL注解@XPath, @Payload, @InboundHeader。第一个注解表示从Document类型的Payload中根据XPath “/foo/bar"获取的节点文本。第二个注解表示将Mule Message的Payload赋给参数doc,第三个注解表示从Mule inbound property中读取name属性,赋给参数name。get

      若是Component中符合注解要求的方法多于一个,须要在Mule inbound property中设置"method" property,指定匹配的方法名。io

  • Property Entry Point Resolver 
  • Callable Entry Point Resolver
  • Reflection Entry Point Resolver

     Legacy Entry Point Resolver Set默认包含这些Entry Point Resolver,若是须要添加其余的entry point resolver,能够使用legacy-entry-point-resolver-set标签    class

<legacy-entry-point-resolver-set>
   <xxx-entry-point-resolver />
</legacy-entry-point-resolver-set>

   另外一种Entry Point Resolver Set是Entry Point Resolver Set,是为用户自定义指定Resolver指定的Set,用户能够像如下方式使用 方法

<legacy-entry-point-resolver-set>
   <xxx-entry-point-resolver />
   <xxxx-entry-point-resolver />
</legacy-entry-point-resolver-set>

   不管是Legacy Entry Point Resolver Set,仍是Entry Point Resolver Set,匹配Entry Point时逐一使用Set中定义的Resolver进行匹配,若是匹配失败,记入异常信息,继续使用下一个Resolver进行匹配,直到找到第一个匹配的Entry Point执行,或者全部的Entry Point Resolver都匹配完毕,没有找到匹配的Entry Point。im

具体实现代码以下异常

相关文章
相关标签/搜索