一. Mule下载。 从Mule的官方网站(http://www.mulesoft.org/display/COMMUNITY/Home)上下在社区版。目前的最新版本是2.2. 下载下来的文件是mule-standalone-{version}.zip 二. 安装 1. 解压下载下来的zip文件。如图中所示 2. 将解压出来的mule文件夹拷贝到想要的地方,比如放在d:\soft目录下,然后将其重命名为mule
3. 鼠标右击我的电脑 —>属性—>高级—>环境变量—>系统变量。在系统变量新建MULE_HOME变量,值为Mule的路径。 4. 将MULE_HOME变量添加到Path路径 至此,Mule安装配置完成。 二 .Mule服务启动 点击开始菜单—>运行—>输入cmd—>进入控制台—>输入mule,出现启动信息。表明配置成功。 三 . Mule项目发布 1. 在MyEclipse工具中新建一个项目,名称为SayHello. 2. 新建一个package,名称为'com.mule.nick.test',在该package下,新建一个类,类名是SayHello 3. 在SayHello 类中。新增一个sayHello(),返回字符串。
1
package
com.mule.nick.test;
2 3 public class SayHello { 4 5 /** 6 * 7 * @param str 8 * @return 9 */ 10 public String sayHello(String str){ 11 return " Hello , " + str; 12 } 13 } 14
4. 在config目录下新增sayHello-mule-config.xml配置文件。
代码
1
<?
xml version="1.0" encoding="UTF-8"
?>
2 < mule xmlns ="http://www.mulesource.org/schema/mule/core/2.2" 3 xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" 4 xmlns:spring ="http://www.springframework.org/schema/beans" 5 xmlns:stdio ="http://www.mulesource.org/schema/mule/stdio/2.2" 6 xmlns:vm ="http://www.mulesource.org/schema/mule/vm/2.2" 7 xsi:schemaLocation =" 8 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 9 http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd 10 http://www.mulesource.org/schema/mule/stdio/2.2 http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd 11 http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd" > 12 13 < stdio:connector name ="SystemStreamConnector" 14 promptMessage ="Please enter yout name: " 15 messageDelayTime ="1000" /> 16 < model name ="SayHelloExample" > 17 < service name ="SayHelloUMO" > 18 < inbound > 19 < stdio:inbound-endpoint system ="IN" /> 20 </ inbound > 21 22 < component class ="com.mule.nick.test.SayHello" /> 23 24 < outbound > 25 < pass-through-router > 26 < stdio:outbound-endpoint system ="OUT" /> 27 </ pass-through-router > 28 </ outbound > 29 </ service > 30 </ model > 31 </ mule >
5. 利用MyEclipse工具提供的Export功能,将SayHello导出成jar包(SayHello.jar).
6. 将SayHello.jar拷贝到mule安装目录的lib\user目录下
7. 进入控制台,输入mule -config config/sayHello-mule-config.xml,启动刚才发布的SayHello项目。
8 .在出现的 Please enter yout name:的提示中输入参数值,在控制上显示 Hello,{param}.e.g Hello,Nick. 到此为止,mule的开发,部署圆满完成。 |
转载于:https://www.cnblogs.com/liyazhou/archive/2011/03/23/1993081.html