Mule
From Resin 3.0
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/
- 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>/WEB-INF/hello-config.xml</mule-config> </init> </bean> </web-app>
- Create the configuration file for Mule
/usr/local/share/resin/webapps/mule/WEB-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!