您好,欢迎访问三七文档
Mule学习笔记作者:郑先全msn:zhengxianquan@hotmail.com1.原理请参考《UsingJBIforService-OrientedIntegration(SOI)》2.Mule介绍2.1.架构2.2.核心概念请参考《ArchitectureGuid》2.3.repository如果想保持新鲜,访问他们的CVS是最好的办法。cvs-d:pserver:anonymous@cvs.mule.codehaus.org:/scm/mulelogin(nopassword)cvs-d:pserver:anonymous@cvs.mule.codehaus.org:/scm/mulecomule注意:从2006年4月14日开始,不再使用cvs,而采用svn,路径如下:有自己的IDE:Download::使用3.1.Mule的安装我的JDK为1.4.2_05。下载后,解压缩,并设置MULE_HOME为解压缩目录测试:提供的echo例子程序是个比较好的测试工具,放在%MULE_HOME%\samples\echo下,cmd并切换到改目录的bin下,执行mule-echo.bat,即可看到如下窗口:恭喜,说明安装成功。Tip:事实上,在我的环境中会提示一个关于缺少一个sax文件的错误,郁闷,通过到sax王张并下载sax2r3.zip后,把里面的xml-apis.jar解压缩到%MULE_HOME%\lib下,可以解决该问题。3.2.echo例子分析参考这个地址()的介绍,应该会有一个比较好的开始。3.2.1.过程图示描述为:1、通过两种方式接入(红色标识):一为System.in,另一为Soap(http)方式;2、每种接入都可以通过接入器(Connector)经过NMR路由转发后,进行输出,目前通过两种方式输出:一为System.out,另一为Soap(http)方式可以通过Mule提供的工具生成配置图,如下:3.2.2.相关代码(TheEchoService)TheechoServiceisaPOJOthatimplementsanEchoServiceinterface-publicinterfaceEchoService{publicStringecho(Stringecho);}Theimplementation(i.ethePOJOtobemanagedbyMule)lookslike-packageorg.mule.components.simple;publicclassEchoComponentextendsLogComponentimplementsEchoService{publicStringecho(Stringecho){returnecho;}}3.2.3.配置和说明?xmlversion=1.0encoding=UTF-8?!DOCTYPEmule-configurationPUBLIC-//SymphonySoft//DTDmule-configurationXMLV1.0//EN!--整体配置--mule-configurationid=Mule_Echo_Sampleversion=1.0!--配置描述--description描述/description!--连接器配置--connectorname=SystemStreamConnectorclassName=org.mule.providers.stream.SystemStreamConnectorpropertiespropertyname=promptMessagevalue=Pleaseentersomething:/propertyname=messageDelayTimevalue=1000//properties/connector!--模型配置--modelname=echoSamplemule-descriptorname=EchoUMOimplementation=org.mule.components.simple.EchoComponent!—接入点设置,目前为stream和axis两种类型--inbound-routerendpointaddress=stream://System.in/endpointaddress=axis:!—输出点设置,目前为stream类型--outbound-routerrouterclassName=org.mule.routing.outbound.OutboundPassThroughRouterendpointaddress=stream://System.out//router/outbound-router/mule-descriptor/model/mule-configuration3.3.Webapp例子分析这个例子其实是对原有几个例子在webapp的集成,通过使用MuleClient进行基于编码的调用。Tips:1、可以通过干预web.xml,逐个加载需要揣摩的例子,便于分析;2、开始时,使用默认的加载方式。3.3.1.echo例子略3.3.2.Hello例子3.3.2.1.介绍本例子主要用于演示两个transformer、两个UMO之间的信息转换和事件交互。3.3.2.2.代码分析几个java文件,说明如下:POJO/javabean:NameString.javaChatString.javaTransformer:StringToNameStringTransformer:NameStringToChatStringGreeterUMOChitChatUMOSERVICE:Greeter.javaChitChatter.javaTransformer:HttpRequestToString.javaNameStringToChatString.javaStringToNameString.javaChatStringToString.java3.3.2.3.配置Web.xmlparam-value/WEB-INF/mule-config.xml,/WEB-INF/mule-echo-config.xml,/WEB-INF/mule-hello-config.xml/param-valueMule-hello-config.xml!--转换器transformerstransformername=StringToNameStringclassName=org.mule.samples.hello.StringToNameStringreturnClass=org.mule.samples.hello.NameString/transformername=NameStringToChatStringclassName=org.mule.samples.hello.NameStringToChatStringreturnClass=org.mule.samples.hello.ChatString//transformers!--AMuledescriptordefinesallthenecessaryinformationabouthowyourcomponentswillinteractwiththeframework,othercomponentsinthesystemandexternalsources.PleaserefertotheConfigurationGuideforafulldescriptionofalltheparameters.--mule-descriptorname=GreeterUMOimplementation=org.mule.samples.hello.Greeterinbound-routerendpointaddress=vm://greetertransformers=StringToNameString/endpointaddress=servlet://greetertransformers=StringToNameString//inbound-routeroutbound-routerrouterclassName=org.mule.routing.outbound.OutboundPassThroughRouterendpointaddress=vm://chitchatter//router/outbound-router/mule-descriptormule-descriptorname=ChitChatUMOimplementation=org.mule.samples.hello.ChitChatterinbound-routerendpointaddress=vm://chitchattertransformers=NameStringToChatString//inbound-router/mule-descriptorTips:1、endpoint的address并没有实际的意义,但由于在整个Mule实例里面必须唯一,故可以理解为命名空间2、Transformer必须继承AbstractTransformer,主要实现doTransform接口方法3.3.3.loanbroker3.3.3.1.介绍异步实现:同步实现:3.3.3.2.配置图请参考:类图3.3.3.4.配置文件详细分析mule-configurationid=Loan_broker_Syncversion=1.0!—定义EndPointendpoint-identifiersendpoint-identifiername=LoanBrokerRequestsvalue=vm://LoanBrokerRequests/endpoint-identifiername=LoanBrokerQuotesvalue=vm://LoanQuotes/endpoint-identifiername=CreditAgencyvalue=axis:=getCreditProfile/endpoint-identifiername=CreditAgencyReceivervalue=axis:=LenderServicevalue=vm://localhost/LenderService?method=setLenderList/!--Themethodparameterforthebankendpointsisaddedprogrammitcallywhenthebankobjects
本文标题:MULE的学习总结
链接地址:https://www.777doc.com/doc-6133123 .html