Hello, Mule!

Prerequisites

准备

  • You must have the JDK 5 or later installed on the computer where you will install Mule.
  • 你的电脑上必须安装了JDK5 或者更高版本的JDK。

Download and Install Mule

下载和安装Mule

  1. In your browser, go to the Mule download page.
  2. 打开浏览器,跳转至 Mule download page.
  3. Use the .zip button for Windows and the .tar.gz button for Linux/UNIX. On Linux/UNIX, if wget ships by default on your distribution, or if you have installed wget, you can also enter the following command in a terminal window to download Mule:
    wget http://dist.codehaus.org/mule/distributions/mule-standalone-3.2.0.tar.gz).
  4.  windows下载 .zip Linux/UNIX 下载 .tar.gz,如果安装了wget 也可以再命令行输入下面的命令安装Mule;
    wget http://dist.codehaus.org/mule/distributions/mule-standalone-3.2.0.tar.gz).
  5. Extract the files from it into the directory you want to use as your Mule home directory.
    Do not install Mule in a directory path that contains spaces!

    On Linux/UNIX, in a terminal window switch to your installation directory, and enter the following command:

    tar -xvzf mule-standalone-3.2.0.tar.gz
  6. 注意安装目录中不能出现空格 。在Linux/UNIX中 打开命令行输入下面的命令安装
    tar -xvzf mule-standalone-3.2.0.tar.gz
If you're upgrading from Mule ESB 2.2, read this: Previous versions of Mule ESB required setting an environment variable called MULE_HOME to run Mule. As of Mule 3.1, the MULE_HOME variable is no longer required. Make sure to remove this setting from your environment before running Mule 3.2. This is also true of a previously set MULE_BASE variable.
如果是从Mule ESB 2.2升级的,注意这段:3.x之前版本的Mule ESB需要设置环境变量MULE_HOME去运行Mule。但从3.1开始MULE_HOME已经不再需要了。在运行3.2版本的Mule前确认已经移除了MULE_HOME的环境变量

Install Eclipse and Mule IDE

To begin developing a Mule application, install the Mule IDE.

  1. If you do not have Eclipse version 3.4 or later, download the latest version of Eclipse fromhttp://www.eclipse.org/downloads/ and install it. MuleSoft recommends the Eclipse Java EE Developers package, but you can also install the Java Developers package.
  2. Start Eclipse, and set up a workspace for your installation of Mule. (Important: Make sure your workspace does not have a space in the directory path or the Mule application you develop will not run.)

For Eclipse version 3.5/3.6/3.7 (Galileo/Helios/Indigo) follow these steps to install Mule IDE:

  1. In the workbench view, click Help > Install New Software.
  2. Click the Add button next to the Work with text box, enter http://dist.muleforge.org/mule-ide/updates-2.1.x/ for the location, and pressEnter. The Mule IDE now appears in your list of available software.
  3. Select the Mule IDE check box and click Next. Eclipse will process for a moment. When Eclipse is finished processing, clickNext again.
  4. Review the Mule IDE license, select the option to accept the license, and then clickFinish.
  5. Click Yes to restart Eclipse.

If you are using Eclipse version 3.4 (Ganymede), read this:

  1. In the workbench view, choose Help > Software Updates.
  2. On the Available Software tab, click Add Site.
  3. Specify http://dist.muleforge.org/mule-ide/updates-2.1.x/ for the location and clickOK. It now appears in your list of available software.
  4. Expand the list until you see the Mule IDE. Choose Mule IDE and clickInstall.
  5. Click Next, read and accept the license agreement terms, and clickFinish.
  6. Choose to run the installation in the background.
  7. When prompted, restart Eclipse.

Configure the Mule Distribution

To execute Mule properly, you must specify in the IDE the location of your Mule distribution.

  1. In the Eclipse workbench, choose Window > Preferences. (On Mac OS X, chooseEclipse > Preferences.)
  2. Choose Mule, and then click Add
  3. Specify your Mule home directory. Then click OK.
  4. Select the Mule distribution's check box, click Apply, then clickOK.

Create a Mule Application

  1. Choose File > New > Project, expand the Mule folder and selectMule Project, and then click Next.
  2. Enter a name for the project, ensuring that there is no space in the project name. If you want to put the project in a location other than the default workspace, clear theUse default location check box and specify a new file location.
  3. Click Finish so the Mule IDE will generate your project. The project just created is added to the Package Explorer pane. The Mule libraries from the distribution you selected are contained in the project.
  4. Create a conf directory in your Mule project.
  5. Create a new file in the conf directory called "mule-config.xml."
  6. Add the following configuration to mule-config.xml:
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:script="http://www.mulesoft.org/schema/mule/scripting"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
      http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.2/mule-scripting.xsd
      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd" >

    <simple-service name="hello" address="http://localhost:8080/hello">
        <script:component>
            <script:script engine="groovy">
                <script:text>return "Hello World"</script:text>
            </script:script>
        </script:component>
    </simple-service>
</mule>


Note that what you have just done is create a Mule application, which is XML-driven. When you create a configuration, you are creating an application.

Run the Application

  1. In the Package Explorer, expand the conf directory, and right-click themule-config.xml configuration file.
  2. Choose Run As > Mule Server.

A new run configuration is created automatically and the server is started. To trigger the Hello service, connect tohttp://localhost:8080/hello in your browser. The server should respond back with the text "Hello World."

That's it! You have a complete Mule development environment up and running and have created your first application.

Next Steps

  • Run the example launcher for the included examples to learn more about how to program Mule.
  • You can now modify the configuration file, or create a new configuration file as described in theMule IDE User Guide.
  • If you want to use Maven for a task such as using the Maven archetypes for creating transports and modules, seeSetting Up Eclipse for Use with Maven for complete instructions.

你可能感兴趣的:(eclipse,application,ide,download,Terminal,archetypes)