Skip to main content

User defined Java Class

Description

User defined Java Class is a step in the Scripting Plugin for Process Studio Workflows. This step allows you to enter User Defined Java Class to drive the functionality of a complete step. In essence, this step allows you to program your own step.

Note: The goal is to allow users to define methods and logic with as little as code as possible, executed as fast as possible. For this the Janino project libraries that compile Java code in the form of classes at runtime are used. Not 100% Java. The first thing to know is that Janino and as a consequence this step doesn't need the complete Java class, only the class body: the imports, constructors and methods needed. So to drive the point home, the step doesn't need the full class declaration.

The developers of this step selected this approach over the definition of the full class since it was possible to hide a lot of technical details and methods from the user this way. If you need to do a lot of Java development it is advised to do this in a Java IDE like Eclipse, not inside this step. You can always expose your Java code to this step by throwing it in a jar file and by placing that library in the classpath of Process Studio (libext/ folder).

Configurations

No.SectionDescription
1Classes & Code Fragments*It is a navigator from where you can choose Classes & Code Fragments such as code snippets, Web Driver, Logging, Input/Output/Info fields.
2Class CodeIt contains the body of the class.
3Fields TabYou can define all the new fields you want in the output of the step in the "Fields" tab.
4Parameters TabSuppose you have a nice piece of code, and you’d like it to become more generic. Step parameters may be a useful tool in this context. As an example I’d like to provide a regular expression and a field name as parameters. The step should check whether the specified field matches the regex and output a 1 or 0 to a result field.
5Info Steps TabSometimes it’s necessary to combine the input of multiple steps. Possibly assigning roles to them. A stream lookup step is a classic example. This is where info steps come into play: they are input steps that are explicitly read from. Their rows are not returned by calls to getRow(). It’s easy to utilize info steps on a user defined java class step. Just attach them to the step and define them as info steps in the UDJC step UI. Reading rows from the info steps is as easy as calling getRowsFrom().
6Target Steps TabIt is possible to direct rows to different target steps using the user defined java class step. In a regular case a call to putRow() takes care of passing on a row to the next step(s). Process takes care of the rest. Now if you’d like to direct rows to specific steps, you’d define all possible target steps and call putRowTo(), specifying the output row set explicitly instead.

*Classes & Code Fragments

No.Tree StructureDescription
Code Snippets:
1Common UseIt provides the common methods such as main method.
2Step StatusIt provides methods for getting/setting and incrementing input and output lines of the step
3Step LoggingIt provides methods for logging at different level of details at step level.
4Step/Row ListenerIt provides methods for row level and step level listeners.
5Row ManipulationIt provides methods for getting metadata of input and output rows and row manipulation.
6Uncommon UseThis package contains the uncommon classes needed to define and execute workflows.
Web Driver:
1Get Web DriverThis method is used to specify the Web Driver
Logging:Logging option is used to log some extra information in the agent log file.
1InfoIt provides methods for ‘Info’ level logging at workflow level.

The log can be specified , WithIdentifier:

Double clicking this option allows you to specify log message and its relevant identifier through which information can be searched in agent log file. Or WithWorkflowInstanceId:

This option also allows info level logging but uses WorkflowRequestId instead of custom identifier.

2ErrorIt provides methods for ‘Error’ level logging at workflow level. The error log can be specified WithIdentifier or WithWorkflowInstanceId
3ExceptionIt provides methods for ‘Exception’ level logging at workflow level. It allows to log exceptions at, Info or Error
4Input fields:Most of the time, working with input and output fields is the most important thing you'll be doing in your UDJC code. As such, there are a number of ways to handle the manipulation of fields provided by ‘row manipulation’ code snippets.
5Output fields:These are the step output fields
6Info fields:These are fields from the stream