Customizing the Parameters DSL

To provide the best possible experience for the user, customize or limit some aspects of a component’s parameters. For example, you can hide irrelevant parameters for clarity.

Receiving Strings As Reference Or As Value

Let’s say we have an operation like the following:

public void send(@Connection MyConnection connection, Object value) {

Which will be invoked like this:

<demo:send value="requestPayload"/>

By default, Mule assumes that requestPayload is a reference to an object in the registry, like a global list or POJO. If instead we want the extension to actually receive the requestPayload string, we must modify the operation declaration, using the @ParameterDsl annotation:

public void send(@Connection MyConnection connection, @ParameterDsl(allowReferences = false) Object value) {

This change explicitly disables the use of references, so the operation will receive the string value.

Defining How Complex Types Can Be Used

Any Module is able to expose POJOs that conform to the Module API:

// This is the POJO declaration
public class Door {

  private boolean isLocked;

  private String color;


// This is the configuration
public class HouseConfig {

  private Door mainDoor;


When having this kind of parameters, the Module developer has the responsibility to configure how the Door can be used in the DSL. For this, we have the @TypeDsl annotation, that allows you to configure two important things:

  • allowInlineDefinition: Defines if the POJO (in the example, the Door) can be declared inline for the element that uses it as parameter. If this value is true, then the user can declare:

    <demo:config name="myConfig"> (1)
        <demo:door isLocked="true" color="red"/> (2)
    1 The config is declared as the container of the parameter
    2 A Door is declared inline (in the config)
  • allowTopLevelDefinition: Defines if the POJO (in the example, the Door) can be declared as a top-level element in the application. If this value is true, then the user can declare:

    <demo:door name="MyGlobalDoor" isLocked="true" color="red"/> (1)
    <demo:config name="myConfig" door-ref="MyGlobalDoor"/> (2)
    1 A Door is declared as a global element of the application
    2 The config is declared separately, referencing the global Door element by name with the door-ref attribute

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub