Integration Engine Solutions to Connect Anything to Anything

Log out?

eiConsole v.24R1
Tutorial & Working Directory

eiConsole Tutorial – Topology

Using OGNL

Note: The Quick Start and Foundation tutorials should be completed before proceeding with the Topology Tutorials.


Overview

This Interface and related tutorials demonstrate and explain the use of OGNL expressions in the eiConsole module configuration items, which allow for dynamically evaluated programmatic statements.

This tutorial covers using a standard Java class to create a “UUID.” In addition, we cover using OGNL expressions in configuration item values to allow for runtime evaluation of programmatic instructions. This tutorial expands on concepts covered in Expressions Using Environment Properties, so users are expected to be familiar with that content.


Before You Begin

Zip File IconUsing OGNL
Working Directory

Download the Using-OGNL-Working-Directory.zip file with the sample Working Directory and unzip it on your computer to a convenient place. In our case, it’s c:\Users\{USER _NAME}\PilotFish eiConsole Working Directories\Expressions Using OGNL where {USER_NAME} is the user’s name.

Open the eiConsole, browse to your Expressions – Using OGNL directory and open it. The fully configured Route (Expressions – Using OGNL) is included in the Working Directory. Your Route File Management screen will open as shown below.

Next, follow the tutorial and walk through it step-by-step.


Using OGNL Expressions

In a previous tutorial, “Expressions Using Environment Properties“, we walked through the use of Environment Properties in configuration items which allowed us to externalize the values. Other expression types are available to eiConsole users, the most notable of which is “OGNL.”

OGNL (Object Graph Navigation Language) can be roughly summarized as “scripted Java.” OGNL expressions evaluate within a Java Virtual Machine against some context and syntactically are very similar to Java statements. Within the eiConsole, OGNL expressions have access to the current transaction, its attributes, and any classes used by the eiConsole or its libraries.

You can find a reference guide for OGNL, as well as more information, at the Apache Commons site.


Click on Expressions – Using OGNL.


Defining a Directory/File Transport

We’ll start our example by defining a Directory/File Transport. Click on the Add Target and choose the Directory/File transport from the drop-down menu.

Set the Target Directory as ..\..\out and Target File Extension as txt.


Suppose we need a unique ID for our created file’s name. Because OGNL has access to the Java classes and libraries that the eiConsole uses, we can use standard Java classes, such as “UUID.” The “UUID” class is the package “java.util,” so its fully qualified name is “java.util.UUID.”

The UUID class has a static method called “randomUUID(),” which, as the name implies, generates a new “UUID” with a semi-random, unique value. We’ll use this method to create our file name. We indicate that our value is an OGNL expression by prefixing it with “{ognl:” and suffixing it with “}”:

{ognl:expression}

We’ll be using a static method, so we don’t need to instantiate a new UUID instance. We can statically reference a class by prefixing it with “@.” OGNL needs the fully qualified name of a class, so we’ll add that as well:

{ognl:@java.util.UUID}

Next, we’ll be accessing a static method, so once again, we’ll use the “@” character to indicate that. Then provide the method name and parameters:

{ognl:@java.util.UUID@randomUUID()}

That’s the entirety of our expression. Placed into the Directory/File Transport configuration, it looks like this:


Whenever this Transport executes now, we’ll get randomly named files, such as “264a5d08-55fe-44a9-9f7f-6121bee1fa50.txt”

One other concept we’ll briefly note is the OGNL context. The default context used by the eiConsole is the “TransactionAttributes” class, giving you access to transaction attributes. You can use this by specifying “#method” to access some method for the current transaction’s attributes. To fetch the attribute “com.pilotfish.FileName”, which is created by the Directory/File listener when files are picked up, we would provide:

{ognl:#getAttribute(“com.pilotfish.FileName”)}

To help make using OGNL as easy as possible, the eiConsole also includes a special OGNL tool pre-loaded with commonly used OGNL expressions. To start using this tool, first click on the Use Enhanced Properties button to the right of the text field, as shown below.


You’ll now see some new buttons on the screen. The middle one, with the concentric circles that almost looks like an eye, will open the OGNL tool. Click on it to open the dialog.


The OGNL Expression Constructor is automatically populated with the most commonly used Transaction Attributes you might want to access via OGNL expressions when building your Route. Select the “Insert” option next to one of them to add it to your expression.

In addition to adding these attributes, the text field at the bottom is also handy for building your OGNL expression, as you don’t need to worry about the full syntax. Any text put into the text field, including the Transaction Attributes above, will automatically be formatted to be {ognl:YOUR_TEXT_HERE}. This is a handy feature when you’re frequently working with OGNL, as it makes it easier to build complex expressions for your Route.


Go into the Testing Mode.


Then put the Sample.txt file found in c:\Users\{USER _NAME}\PilotFish eiConsole Working Directories\Expressions Using OGNL\data into the polling directory c:\Users\{USER _NAME}\PilotFish eiConsole Working Directories\Expressions Using OGNL\in

Then click the Execute Test icon.


The files, 3.txt and 31.txt, should then be in the directory c:\Users\{USER _NAME}\PilotFish eiConsole Working Directories\Expressions Using OGNL\out. One output file for each transport.


This concludes the tutorial. The next tutorial in the series is Configuration Using Transaction Attributes.

This is a unique website which will require a more modern browser to work! Please upgrade today!