CREATE JAVA ACTION
Synopsis
CREATE JAVA ACTION module.Name ( parameters )
RETURNS type
[ EXPOSED AS 'caption' IN 'category' ]
AS $$ java_code $$
DROP JAVA ACTION module.Name
Description
Creates a Java action with inline Java code. Java actions allow custom server-side logic written in Java to be called from microflows.
The action parameters, return type, and Java body are all specified inline. When the action is created, the corresponding Java source file is generated with the parameter boilerplate and the provided code body.
Type Parameters
Java actions support generic entity handling through type parameters. A parameter declared as ENTITY <pEntity> creates a type parameter selector – the caller chooses which entity type to use. Other parameters declared as bare pEntity (without ENTITY) receive instances of the selected entity type.
Exposed Actions
The optional EXPOSED AS clause makes the action visible in the Studio Pro toolbox under the specified category, allowing modelers to use it directly in microflows.
Parameters
module.Name- The qualified name of the Java action.
parameters- Comma-separated parameter declarations. Each parameter has a name, colon, and type. Supported types:
- Primitives:
String,Integer,Long,Decimal,Boolean,DateTime - Entity:
Module.EntityName - List:
List of Module.EntityName - Enumeration:
ENUM Module.EnumNameorEnumeration(Module.EnumName) - String template:
StringTemplate(Sql),StringTemplate(Oql) - Type parameter declaration:
ENTITY <pEntity>(declares the type parameter) - Type parameter reference: bare
pEntity(uses the declared type parameter) - Add
NOT NULLafter the type to mark a parameter as required.
- Primitives:
RETURNS type- The return type. Same type options as parameters.
EXPOSED AS 'caption' IN 'category'- Optional. Makes the action visible in the toolbox with the given caption and category.
AS $$ java_code $$- The Java code body, enclosed in
$$delimiters.
Examples
Simple Java action returning a string:
CREATE JAVA ACTION MyModule.JA_FormatCurrency (
Amount: Decimal NOT NULL,
CurrencyCode: String NOT NULL
) RETURNS String
AS $$
java.text.NumberFormat formatter = java.text.NumberFormat.getCurrencyInstance();
formatter.setCurrency(java.util.Currency.getInstance(CurrencyCode));
return formatter.format(Amount);
$$;
Java action with type parameters for generic entity handling:
CREATE JAVA ACTION MyModule.JA_Validate (
EntityType: ENTITY <pEntity> NOT NULL,
InputObject: pEntity NOT NULL
) RETURNS Boolean
EXPOSED AS 'Validate Entity' IN 'Validation'
AS $$
return InputObject != null;
$$;
Java action with a list parameter:
CREATE JAVA ACTION MyModule.JA_ExportToCsv (
Records: List of MyModule.Customer NOT NULL,
FilePath: String NOT NULL
) RETURNS Boolean
AS $$
// Export logic here
return true;
$$;
Drop a Java action:
DROP JAVA ACTION MyModule.JA_FormatCurrency;