Getting Started with the Utility Bundles
Author:
Holger Lierse
Changed on:
25 Aug 2025
Key Points
- Dependencies: To get started, add the
`util-core`
,`util-dynamic`
, and`util-test`
artifacts as Maven dependencies to your project's`pom.xml`
. - Simple Usage: Utility classes can be called directly from within your Rules. The most common helpers are static methods that take the
`Context`
object as a parameter. - Build Integration: Once the dependencies are added,
`mvn clean install`
will automatically download the libraries and make them available to your project. - Explore the Docs: This guide is the first step. For detailed information on every class and method, explore the other documentation articles and refer to the JavaDocs in your IDE.
Prerequisites
Steps
Adding Dependencies
To get started, you need to add the utility bundles as dependencies in your project's `pom.xml`
file. It's recommended to add all three bundles to take full advantage of the platform's capabilities.
1<dependencies>
2
3 <!-- Core Utilities: Essential helpers for all rules -->
4 <dependency>
5 <groupId>com.fluentcommerce</groupId>
6 <artifactId>util-core</artifactId>
7 <version>2.2.0</version>
8 </dependency>
9
10 <!-- Dynamic Utilities: For building queries and mutations at runtime -->
11 <dependency>
12 <groupId>com.fluentcommerce</groupId>
13 <artifactId>util-dynamic</artifactId>
14 <version>2.2.0</version>
15 </dependency>
16
17 <!-- Test Utilities: For writing unit and integration tests -->
18 <dependency>
19 <groupId>com.fluentcommerce</groupId>
20 <artifactId>util-test</artifactId>
21 <version>2.2.0</version>
22 <scope>test</scope>
23 </dependency>
24
25 <!-- Other dependencies -->
26
27</dependencies>
Using a Utility in a Rule
Let's create a simple Rule that uses `EventUtils`
from the `util-core`
bundle to clone and forward an event.
Create a new Java class for your Rule:
1package com.mycompany.rules;
2
3import com.fluentcommerce.util.core.EventUtils;
4import com.fluentretail.rubix.rule.meta.RuleInfo;
5import com.fluentretail.rubix.v2.context.Context;
6import com.fluentretail.rubix.v2.rule.Rule;
7
8@RuleInfo(
9 name = "CloneAndForwardEvent",
10 description = "Clones the incoming event and forwards it with a new name."
11)
12public class CloneAndForwardEvent implements Rule {
13
14 @Override
15 public void run(Context context) {
16 // Use the utility to create a clone of the current event
17 // with a new name. This automatically handles attribute
18 // copying and schedule management.
19 EventUtils.forwardInboundEventWithNewName(context, "NEW_EVENT");
20
21 context.action().log("Event was successfully forwarded!");
22 }
23}
Building Your Project
After creating your rule, build the project by running the following command in your terminal at the root of your project:
`mvn clean install`
This command will download the utility libraries, compile your code, and package it into a deployable JAR file.
Next Steps
You are now ready to use the full power of the utility bundles. Explore the other documentation articles to learn about the specific features of each utility. For detailed information on every class and method, the JavaDocs are your most valuable resource. You can typically view them in your IDE by hovering over a utility class or method.