Property Files in Mule 4

Main Points:

  • Property files allow the centralization of properties.
  • Property placeholders used instead of hard coding.
  • Property file location must be configured in global elements.
  • Property files can be constructed in Java or YAML format.

Centralization of Application Properties

It is best practice to centralize the management of properties rather than hard code values at the location of use. This allows for the reuse of values and better maintenance. Instead of changing the property in multiple places (if the value has been hardcoded), you change the value once in the property file and every location where that property placeholder is used gets to use the new value at runtime.

Setting up A Property File

There are three parts to set up when you want to use property files:

Access Mule Application Properties With DataWeave

Main Points

  • DataWeave script can reference application properties.
  • DataWeave expressions can reference properties in the configuration.

Configure a Property File

Firstly, you will need to configure a property file in which application properties are defined. There are steps parts to follow:

  1. Create the property file in which the application properties are defined.
  2. Create a Configuration Property to reference the location of the file.
  3. Use property placeholders in the application configuration.

You can find more about this in my blog post How to configure Property Files in Mule 4.

DataWeave: The map Function Explained

Main Points:

  • The map function transforms data
  • If iterates over the elements in an array 
  • It applies a transformation to each element
  • Applies only to array input
  • It can only output an array

What Is the map Function Used For?

The map function is used to transform the data contained in an array. It does this by iterating over the elements in the array and applying a transformation to each element. The result of the transformation is collected together and output as an array of transformed elements. If you are familiar with Java 8 functional programming approach, a comparison can be made with the the map() method of the Stream class, find out more in my article Contrast DataWeave and Java mapping operations.

How Is the Transformation Described?

The transformation that is applied to each element is described with DataWeave. For example, to change a text value in the source array use the upper() built in function.

Supercharge Your Java Career With Digital Transformation

If you are an experienced Java developer and you want to know how to get ahead in these unprecedented times, then adding digital transformation skills to your resume will give you the boost you want. 

In this article, I will define digital transformation and discuss how to leverage your Java expertise to gain an advantage in this high demand area. To know more join the Mule Integration for Java professionals meetup (also in Spanish) where I discuss this exciting topic together with a chance to receive free professional training and certification. 

Jakarta EE: A Clean Slate

The announcement that Jakarta EE cannot use the javax.* namespace is great news and provides Jakarta EE with a clean slate on which to build and innovate the future of Enterprise Java.

The Original Proposal

It had been envisioned that the javax.* and jakarta.* namespaces would coexist after Java EE 8 and, as it evolved, the jakarta.* namespace would be used for new features of exiting APIs and the innovation of new APIs. This would have ensured backward compatibility from the start. And overtime the use of jarkata.* would eclipse the old namespace, but never actually replacing javax.* namespace. So, forever more Enterprise Java developers would have to explain why there are two namespaces. A constent reminder of Enterprise Java’s past (something we are trying to move on from).