Contact Us 1-800-664-9073

On Saturday April 1, 2023, from 9 AM to 2 PM (PDT), content will be unavailable due to scheduled maintenance.

This product has reached End of Life.

Complex Data Types Attributes

DevKit is compatible only with Studio 6 and Mule 3. To build Mule 4 connectors, see the Mule SDK documentation.

One integration point between Mule and your connector is the data passing between the connector and Mule ESB, such as when configuring a component. Primitive data types are straightforward; however enumerated types, arrays, and complex types require special handling.

Enumerated Types

Anypoint DevKit provides an easy way for handling enumerated types. Methods annotated with @Processor or @Source can receive enums as parameters and these can be passed as strings from Mule. It’s also possible to use enumerated types along with java.lang.Collection and java.lang.Map.

Consider the following extension:

public class MyConnector {

    private Map<Property, String> properties;

    private Property myProperty;

    public void setProperties(Map<Property, String> properties) { = properties;

    public String getPropertyValue(Property property) {
        return properties.get(property);

With this enum class:

public enum Property {

Then the following enums types and flows are valid:

<my-connector:config myProperty="FIRST_NAME"/>
<flow name="setProperties">
            <my-connector:property key="FIRST_NAME">Muley</enums:property>
            <my-connector:property key="LAST_NAME">The Mule</enums:property>
<flow name="getPropertyValue">
    <my-connector:get-property-value property="LAST_NAME"/>

How It Works

Under the hood, Anypoint DevKit generates a Transformer for all the enumerated types that appear as parameters of @Processor and @Source methods, or any instance field annotated with @Configurable. So when a string is entered in the XML for an enumerated type, the enum constant with the specified name is passed to the method or assigned to the field.

The generated schema file also adds restrictions so that only matching enumerated values can be used in the xml. For example, since the possible values for the Property enum are FIRST_NAME, LAST_NAME, and ADDRESS then the following is not valid and the validation of the schema fails:

<flow name="getPropertyValue">
    <my-connector:get-property-value property="COUNTRY"/>


Anypoint DevKit provides a simple way to handle java.util.Collection and java.util.Map types, whether they appear in @Configurable fields, or as parameters of @Processor or @Source methods. DevKit also allows more complex scenarios where types are nested such as Map<String, List<String>> or List<Map<String, Object>>.

There are two ways to handle these types from Mule.

  • Declare the elements explicitly.

  • Pass a reference to the elements.

All examples and explanations on this page are valid for @Connector classes.

Collection Examples

Consider the following custom Mule Connector:

import org.mule.api.annotations.Configurable;
import org.mule.api.annotations.Connector;
import org.mule.api.annotations.Processor;
import org.mule.api.annotations.param.Optional;

import java.util.List;
import java.util.Map;

@Connector(name = "collection")
public class CollectionConnector {

    private List<String> strings;

    private Map<String, String> mapStrings;

And these Spring beans:

<spring:bean id="objectA" class="java.lang.String">
    <spring:constructor-arg value="ObjectA"/>

<spring:bean id="objectB" class="java.lang.String">
    <spring:constructor-arg value="ObjectB"/>

<spring:bean id="list" class="org.springframework.beans.factory.config.ListFactoryBean">
    <spring:property name="sourceList">
            <spring:ref bean="objectA"/>
            <spring:ref bean="objectB"/>

You can configure the Connector any of the following ways.

  • Declare the list elements explicitly.

  • Declare the map elements explicitly.

            <collection:map-string key="a">MuleSoft</collection:map-string>
            <collection:map-string key="b">FTW</collection:map-string>
  • Like the previous map, use the tag names (a and b) as keys.

    <collection:count-map-of-strings config-ref="configC">
  • Declare one element explicitly and use a reference for the other element.

            <collection:string value-ref="objectA"/>
  • Instead of declaring the elements of the list, pass a reference to a bean of the same type.

    <collection:config name="configA">
        <collection:strings ref="list" />

Nested Collections

Now consider the following @Processor method.

public void mapOfLists(Map<String, List<String>> map) {

The generated message processor can be invoked as follows.

        <collection:map key="key1" value-ref="list" />
        <collection:map key="key2" value-ref="#[map-payload:anotherList]" />

Instead of passing the values of the map by reference, the map itself can also be a reference:

    <collection:map ref="#[map-payload:myMap]" />

Supported Complex Types

Anypoint DevKit supports the following types:

  • int

  • float

  • long

  • byte

  • short

  • double

  • boolean

  • char

  • java.lang.Integer

  • java.lang.Float

  • java.lang.Long

  • java.lang.Byte

  • java.lang.Short

  • java.lang.Double

  • java.lang.Boolean

  • java.lang.Character

  • java.lang.String

  • java.math.BigDecimal

  • java.math.BigInteger

  • java.util.Date

  • java.lang.Class



You can pass other types by reference.

public void receiveAComplexType(MyComplexType myComplexType) { ... }

Anypoint DevKit enables you to use such processors, especially when Anypoint DataMapper uses the module. DataMapper-friendly modules pass information in beans, since DataMapper can extract metadata from both a Java bean and the XML. DevKit also standardizes the way Mule passes references.

Complex Type Construction

When an @Processor method receives a complex type, Anypoint DevKit deconstructs the object then constructs a schema that can be used to reconstruct that object. This lets you represent complex type objects with concise, intuitive XML. For example:

    <ns:my-complex-type color="red"/>

You can use the following annotations inside the complex type definition to control schema generation:

  • @Optional

  • @Default

Further, a complex type can have inner lists or maps of other complex types.

Ignoring Fields in a Complex Type

The @Ignore annotation tells DevKit to ignore a field inside a complex object.

public class MyComplexType
    private String color;

    private String description;

public void receiveAComplexType(MyComplexType myComplexType) { ... }

Anypoint DevKit omits the description field from the generated schema. For example, the snippet below is invalid, because the @Ignored description attribute is not part of the generated schema. For DevKit’s purposes, at the XML level this element does not have a description attribute.

    <ns:my-complex-type color="red" description=""/>

Passing List and Map Objects by Reference

Anypoint DevKit standardizes the way to pass objects by reference. List and Map objects can be passed by reference in a ref attribute in a child element, as in the following examples.

public void receiveAList(List<String> strings) { ... }
  <ns:strings ref="#[payload]"/>

In Anypoint DevKit, passing a complex object also uses a ref attribute in a child element.

    <ns:my-complex-type ref="#[payload]"/>

See Also

View on GitHub