Last active
November 8, 2018 13:27
-
-
Save mariomartinezricston/811a3f9df136f9e040e2316abf1c1872 to your computer and use it in GitHub Desktop.
Mule4 blog post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ee:transform doc:name="Transform Message"> | |
<ee:message > | |
<ee:set-payload ><![CDATA[%dw 2.0 | |
output application/json | |
--- | |
app.registry.defaultAnimal]]></ee:set-payload> | |
</ee:message> | |
</ee:transform> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ricston.test; | |
public class Animal implements java.io.Serializable { | |
private static final long serialVersionUID = 2828474494822L; | |
private String name; | |
public Animal(){ | |
name="maxMule"; | |
} | |
public Animal(String name){ | |
this.name=name; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String displayInfo(String info){ | |
return new StringBuilder(this.name).append(" : ").append(info).toString(); | |
} | |
@Override | |
public String toString() { | |
return "Animal [name=" + name + "]"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:context="http://www.springframework.org/schema/context" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd | |
http://www.springframework.org/schema/context | |
http://www.springframework.org/schema/context/spring-context-4.1.xsd"> | |
<bean id="defaultAnimal" class="com.ricston.test.Animal"> | |
<property name="name" value="sima" /> | |
</bean> | |
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<spring:config name="animalBean" doc:name="animalBean" files="AnimalBean.xml" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ee:transform doc:name="Transform Message"> | |
<ee:message > | |
<ee:set-payload ><![CDATA[%dw 2.0 | |
fun createAnimal(name) = | |
{ | |
name: name | |
} as Object {class: "com.ricston.test.Animal"} | |
output application/json | |
--- | |
do { | |
var localAnimal = createAnimal('treyu') | |
var info = Java::invoke( | |
"com.ricston.test.Animal", | |
"displayInfo(String)", | |
localAnimal, | |
{info: "is a dog"} ) | |
--- | |
{ | |
animalLocal: localAnimal, | |
info: info | |
} | |
}]]></ee:set-payload> | |
</ee:message> | |
</ee:transform> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<java:new doc:name="New Default Instance" doc:id="61265612-0824-47c6-ba46-4233d01cfe97" class="com.ricston.test.Animal" constructor="Animal()" target="animalInstance"/> | |
<java:invoke doc:name="Invoke" doc:id="15998db1-d486-4499-bf3a-5d166fd86cf1" instance="#[vars.animalInstance]" class="com.ricston.test.Animal" method="setName(String)"> | |
<java:args ><![CDATA[#[{name: attributes.uriParams.name}]]]></java:args> | |
</java:invoke> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ee:transform doc:name="Transform Message"> | |
<ee:message > | |
<ee:set-payload ><![CDATA[%dw 2.0 | |
import java!com::ricston::test::TestUtils | |
output application/json | |
--- | |
{message: TestUtils::returnTestMessage()}]]></ee:set-payload> | |
</ee:message> | |
</ee:transform> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<java:invoke-static doc:name="Invoke static" class="com.ricston.test.TestUtils" method="returnTestMessage()"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<java:new doc:name="New" class="com.ricston.test.Animal" constructor="Animal()"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<java:new doc:name="New" class="com.ricston.test.Animal" constructor="Animal(String)"> | |
<java:args ><![CDATA[#[{arg0: attributes.uriParams.name}]]]></java:args> | |
</java:new> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<java:new doc:name="New" class="com.ricston.test.Animal" constructor="Animal(String)"> | |
<java:args ><![CDATA[#[{name: attributes.uriParams.name}]]]></java:args> | |
</java:new> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.8.0</version> | |
<configuration> | |
<source>1.8</source> | |
<target>1.8</target> | |
<parameters>true</parameters> | |
</configuration> | |
</plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ricston.test; | |
public class TestUtils { | |
public static String returnTestMessage() { | |
return "I feel I am being tested"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment