Free MuleSoft CONNECT Keynote & Expo Pass Available!

Register now+
Nav

Java Module Documentation Reference

JavaModule MuleSoft Extension, used to invoke Java code.

Configurations


Config

Default configuration

Parameters

Name Type Description Default Value Required

Name

String

The name for this configuration. Connectors reference the configuration with this name.

x 

Operations

Invoke

<java:invoke>

Operation that allows the user to invoke methods with the provided args on the given instance. The identifier of the Method to be invoked includes the class and method names, being the method a full description of its signature including the types of each parameter.

For example, if we want to invoke the method echo with signature public String echo(String msg) which belongs to Class org.bar.Foo, then the identifier of the method will be "echo(String)"

Parameters

Name Type Description Default Value Required

Instance

Any

the instance on which the method will be invoked

x 

Args

Object

the arguments used to invoke the given Method

 

Class

String

Represents the fully qualified name of the Class containing the referenced Method.

x 

Method

String

Represents the Method signature containing the method name and it's argument types.

For example, for the method with signature public String log(String msg, boolean verbose) then the identifier of the method will be "log(String, boolean)"

x 

Target Variable

String

The name of a variable on which the operation's output will be placed

 

Target Value

String

An expression that will be evaluated against the operation's output and the outcome of that expression will be stored in the target variable

#[payload]

 

Output

Type

Any

Throws

  • JAVA:CLASS_NOT_FOUND  

  • JAVA:ARGUMENTS_MISMATCH  

  • JAVA:INVOCATION  

  • JAVA:WRONG_INSTANCE_CLASS  

  • JAVA:NO_SUCH_METHOD  

Invoke Static

<java:invoke-static>

Operation that allows the user to invoke static methods with the provided arguments. The identifier of the Method to be invoked includes the class and method names, being the method a full description of its signature including the types of each parameter.

For example, if we want to invoke the static method echo with signature public static String echo(String msg) which belongs to Class org.bar.Foo, then the identifier of the method will be "echo(String)"

Parameters

Name Type Description Default Value Required

Args

Object

the arguments used to invoke the given Method

 

Class

String

Represents the fully qualified name of the Class containing the referenced Method.

x 

Method

String

Represents the Method signature containing the method name and it's argument types.

For example, for the method with signature public static String log(String msg, boolean verbose) then the identifier of the method will be "log(String, boolean)"

x 

Target Variable

String

The name of a variable on which the operation's output will be placed

 

Target Value

String

An expression that will be evaluated against the operation's output and the outcome of that expression will be stored in the target variable

#[payload]

 

Output

Type

Any

Throws

  • JAVA:CLASS_NOT_FOUND  

  • JAVA:ARGUMENTS_MISMATCH  

  • JAVA:INVOCATION  

  • JAVA:WRONG_INSTANCE_CLASS  

  • JAVA:NO_SUCH_METHOD  

New

<java:new>

Operation that allows the user to create a new instance of the given class The identifier of the Constructor to be used includes the class and constructor names, being the constructor a full description of its signature including the types of each parameter.

For example, if we want to invoke the constructor Foo(String name, int age) which belongs to Class org.bar.Foo, then the identifier of the method will be "Foo(String,int)"

Parameters

Name Type Description Default Value Required

Args

Object

the arguments used to invoke the given Constructor

 

Class

String

Represents the fully qualified name of the Class containing the referenced Method.

x 

Constructor

String

Represents the Constructor signature containing the name and it's argument types.

For example, for the Constructor with signature public Foo(String name, Integer age) then the identifier of the method will be "Foo(String, Integer)"

x 

Target Variable

String

The name of a variable on which the operation's output will be placed

 

Target Value

String

An expression that will be evaluated against the operation's output and the outcome of that expression will be stored in the target variable

#[payload]

 

Output

Type

Any

Throws

  • JAVA:CLASS_NOT_FOUND  

  • JAVA:ARGUMENTS_MISMATCH  

  • JAVA:NOT_INSTANTIABLE_TYPE  

  • JAVA:NO_SUCH_CONSTRUCTOR  

Validate Type

<java:validate-type>

Operation that allows the user to validate that a given instance is an instanceof the specified class.

Parameters

Name Type Description Default Value Required

Class

String

 

Instance

Any

the object whose type is expected to be an instanceof of the given class

x 

Accept Subtypes

Boolean

whether or not to accept sub types of the given class or if the instance has to be of the exact same class

true

 

Throws

  • JAVA:CLASS_NOT_FOUND  

  • JAVA:WRONG_INSTANCE_CLASS  

In this topic: