Posts

Showing posts with the label Script

Global Function that can be used in Mule DataWeave

You can write a Groovy custom function that can be used in Mule DataWeave (Transform Message). To do this, create a file with .mvel extension under src/main/resources, e.g. globalfunction.mvel. If you're familiar with Java, it is quite similar to Groovy, but with some differences such as type declaration is not required in Groovy and a statement doesn't have to be punctuated with a semi-colon as long as you write one statement per line. For example, we have the following Groovy function, which accepts a MongoDB ObjectId and converts it into a string value. This is useful when you just need to get the hexadecimal value and not the object itself, which gets serialized when transforming to JSON. def getObjectIdAsString(objectId) {     return ((org.bson.types.ObjectId) objectId).toString() }    In the Mule configuration file, add the below XML. You don't need to specify the complete path since src/main/resources automatically gets added to the classpat...

Building an EAR file from Command Prompt

You can use the buildear  utility to build an EAR. Using a command prompt, change directory to %TRA_HOME%\bin, and then issue the following command: buildear -x -v -o %location%\output.ear -p %designer_project_path% -x  Overwrites the existing file -v  Validates the project for errors -o  Full path of the EAR file -p  Path of the Designer project folder