Mule
From Resin 3.0
(Difference between revisions)
m (→Mule and Resin) |
(hello-config.xml location) |
||
Line 10: | Line 10: | ||
<li>Create the Mule webapp directory structure: | <li>Create the Mule webapp directory structure: | ||
<pre>mkdir -p /usr/local/share/resin/webapps/mule/WEB-INF/lib/ | <pre>mkdir -p /usr/local/share/resin/webapps/mule/WEB-INF/lib/ | ||
− | mkdir -p /usr/local/share/resin/webapps/mule/WEB-INF/classes/example/</pre> | + | mkdir -p /usr/local/share/resin/webapps/mule/WEB-INF/classes/example/ |
+ | mkdir -p /usr/local/share/resin/webapps/mule/WEB-INF/classes/META-INF/ | ||
+ | </pre> | ||
</li> | </li> | ||
<li>Download Mule from http://mule.mulesource.org/display/MULE/Download</li> | <li>Download Mule from http://mule.mulesource.org/display/MULE/Download</li> | ||
Line 32: | Line 34: | ||
<bean class="com.caucho.mule.MuleConfig"> | <bean class="com.caucho.mule.MuleConfig"> | ||
<init> | <init> | ||
− | <mule-config> | + | <mule-config>META-INF/hello-config.xml</mule-config> |
</init> | </init> | ||
</bean> | </bean> | ||
Line 41: | Line 43: | ||
<li>Create the configuration file for Mule | <li>Create the configuration file for Mule | ||
− | <code>/usr/local/share/resin/webapps/mule/WEB-INF/hello-config.xml</code> | + | <code>/usr/local/share/resin/webapps/mule/WEB-INF/classes/META-INF/hello-config.xml</code> |
<pre><?xml version="1.0" encoding="UTF-8"?> | <pre><?xml version="1.0" encoding="UTF-8"?> | ||
Latest revision as of 00:49, 13 February 2008
Mule and Resin
Mule can be run within Resin and use objects created by it as components. This allows Mule to take advantage of Resin IoC. This simple example shows how to have Mule use Resin IoC-created objects. To see how to configure Mule with Resin using servlets and Amber JPA, see this example.
(The following has been tested with Resin 3.1.5 and Mule 1.4.3)
- Download Resin from http://www.caucho.com/download
- Unzip Resin into
/usr/local/share/resin
- Create the Mule webapp directory structure:
mkdir -p /usr/local/share/resin/webapps/mule/WEB-INF/lib/ mkdir -p /usr/local/share/resin/webapps/mule/WEB-INF/classes/example/ mkdir -p /usr/local/share/resin/webapps/mule/WEB-INF/classes/META-INF/
- Download Mule from http://mule.mulesource.org/display/MULE/Download
- Unzip Mule
- Copy all the jars included the Mule lib/ directory to
/usr/local/share/resin/webapps/mule/WEB-INF/lib/
- Create the configuration file
/usr/local/share/resin/webapps/mule/WEB-INF/resin-web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://caucho.com/ns/resin"> <!-- Create the bean reference for the Mule component --> <bean class="example.HelloBean"> <init> <message>Hello, World!</message> </init> </bean> <bean class="example.HelloComponent" name="helloComponent"/> <bean class="com.caucho.mule.MuleConfig"> <init> <mule-config>META-INF/hello-config.xml</mule-config> </init> </bean> </web-app>
- Create the configuration file for Mule
/usr/local/share/resin/webapps/mule/WEB-INF/classes/META-INF/hello-config.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mule-configuration PUBLIC "-//MuleSource //DTD mule-configuration XML V1.0//EN" "http://mule.mulesource.org/dtds/mule-configuration.dtd"> <mule-configuration id="Mule_Hello_Sample" version="1.0"> <model name="helloSample"> <mule-descriptor name="HelloUMO" implementation="helloComponent"> <inbound-router> <endpoint synchronous="true" address="http://localhost:8086"/> </inbound-router> </mule-descriptor> </model> </mule-configuration>
- Create a bean to inject into the Mule component
/usr/local/share/resin/webapps/mule/WEB-INF/classes/example/HelloBean.java
package example; import javax.webbeans.Component; @Component public class HelloBean { private String _msg = "Uninitialized"; public void setMessage(String msg) { _msg = msg; } public String getMessage() { return _msg; } public String toString() { return "HelloBean[" + _msg + "]"; } }
- Create the Mule component
/usr/local/share/resin/webapps/mule/WEB-INF/classes/example/HelloComponent.java
package example; import javax.webbeans.In; import org.mule.umo.lifecycle.Callable; import org.mule.umo.UMOEventContext; public class HelloComponent implements Callable { @In private HelloBean _hello; public Object onCall(UMOEventContext context) throws Exception { return _hello.getMessage(); } }
- Start Resin with
java -jar /usr/local/share/resin/lib/resin.jar
- Look at http://localhost:8086
It should showHello, World!