1 Using Oracle Data Integrator Open Tools
This appendix includes the following sections:
1.1 Using Oracle Data Integrator Tools
Oracle Data Integrator tools (also called Oracle Data Integrator commands) are commands provided for performing specific tasks at runtime. These tasks can be as simple as waiting for a certain time or producing a sound, or as sophisticated as executing Ant scripts or reading e-mail from a server.
Oracle Data Integrator tools are used in Packages, Procedure Commands, Knowledge Modules Commands, or directly from a command line.
Note:
Previous versions of Oracle Data Integrator supported calling built-in tools from Jython or Java scripts using their internal Java classes (such as SnpsSendMail
and SendMai
l). This approach is no longer supported.
Note:
Carriage returns in commands are not permitted.
1.1.1 Using a Tool in a Package
Adding and using an Oracle Data Integrator tool in a Package is described in Adding Oracle Data Integrator Tool Steps in Developing Integration Projects with Oracle Data Integrator.
You can sequence the tool steps within the package and organize them according to their success and failure. For more information about sequencing, see Arranging the Steps Layout and Defining the Sequence of Steps in Developing Integration Projects with Oracle Data Integrator.
You can use variable values, sequences, or Oracle Data Integrator substitution method calls directly in tool parameters.
1.1.2 Using a Tool in a Knowledge Module or Procedure Command
Using an Oracle Data Integrator tool in a Knowledge Module or Procedure is described in Working with Procedures section in Developing Integration Projects with Oracle Data Integrator Guide.
You can use variable values, sequences, Oracle Data Integrator substitution method calls, or the results from a SELECT
statement directly in tool parameters.
1.1.3 Using a Tool From a Command Line
Command line scripts for Oracle Data Integrator tools are run from the DOMAIN_HOME/bin
directory. To run a tool from a command line, you must first create an ODI Physical Agent instance in the ODI Topology and configure an ODI Standalone Agent instance in a Domain. For more information about performing these tasks, see Installing and Configuring Oracle Data Integrator.
When you run a tool from a command line, you must specify the -INSTANCE
parameter, where <agent_name>
is the name of the physical agent you configured (for example, OracleDIAgent1
).
To use an Oracle Data Integrator tool from a command line:
Command names and command parameters are case-sensitive.
Example 1-1 Important Notes
Note the following:
-
On Windows platforms, command arguments that contain equal (
=
) signs or spaces must be surrounded with double quotation marks. This differs from the UNIX command call. For example:startcmd.cmd OdiSleep "-INSTANCE=OracleDIAgent1" "-DELAY=5000" ./startcmd.sh OdiSleep -INSTANCE=OracleDIAgent1 -DELAY=5000
-
The following tools do not support direct invocation through a command line:
-
OdiRetrieveJournalData
-
OdiRefreshJournalCount
-
1.2 Using Open Tools
The Open Tools feature provides an extensible platform for developing custom third-party tools that you can use in Packages and Procedures. As with the standard tools delivered with Oracle Data Integrator, Open Tools can interact with the operating system and manipulate data.
Open Tools are written in Java. Writing your own Open Tools is described in Developing Open Tools.
Open Tools are delivered as a Java package (.zip
or .jar
) that contains several files:
-
A compiled Java
.class
file -
Other resources, such as icon files
1.2.1 Installing and Declaring an Open Tool
Before you can use an Open Tool, you must install and add it.
1.2.1.1 Installing an Open Tool
To install an Open Tool, you must add the Open Tool JAR into the classpath or the component using the tool.
Open Tool JARs must be added to the DOMAIN_HOME/lib
directory. Drivers are added to the same location.
To deploy an Open Tool JAR with a Java EE agent, generate a server template for this agent. The Open Tool is displayed in the Libraries and Drivers list in the Template Generation Wizard. See Creating a Server Template for the Java EE Agent in Administering Oracle Data Integrator for more information.
Note:
This operation must be performed for each Oracle Data Integrator Studio from which the tool is being used, and for each agent that will run sessions using this tool.
1.2.1.2 Declaring a New Open Tool
This operation declares an Open Tool in a master repository and enables the tool to be displayed in Oracle Data Integrator Studio.
To declare an Open Tool, a JAR must be added in <ide.user.dir>/oracledi/userlib
.
To declare a new tool:
-
In Oracle Data Integrator Studio, select the ODI menu and then select Add Remove/Open Tools. The Add Open Tools dialog is displayed.
-
Enter the name of the class in the Open Tool Class Name field.
or:
1.3 Developing Open Tools
An Open Tool is a Java package that contains a compiled Java class that implements the interface oracle.odi.sdk.opentools.IOpenTool
. For a complete description of classes and methods, see the Oracle Data Integrator Open Tools Java API Reference (JavaDoc).
An Open Tool package typically should also contain two icons, which are used to represent the Open Tool in the Oracle Data Integrator graphical interface.
1.3.1 Classes
The following table lists and describes Open Tool classes and interfaces.
Class or Interface | Description |
---|---|
|
Interface that every Open Tool must implement. |
|
Abstraction of the interface with some helper methods. Preferably extend this class rather than implementing the interface directly. |
|
Interface that parameters used by Open Tools must implement. In most cases, |
|
Complete implementation of |
|
Exception class that should be thrown if necessary by Open Tool methods. |
|
A simple example of an Open Tool, which can be used as a starting point. |
1.3.2 Developing a New Open Tool
The following steps describe the development of a basic Open Tool, SimpleMessageBox. The source code for this class is available in the demo/plugins/src
directory.
1.3.2.1 Implementing the Class
Implementing the class consists of the following steps:
1.3.2.1.1 Declaration
Before you declare the class, you must name the package.
Naming the Package
Put the class in a package named appropriately. The package name is used to identify the Open Tool when installing it.
package com.myCompany.OpenTools;
Declaring the Class
There are two basic approaches to developing an Open Tool:
-
Extend an existing class that you want to convert into an Open Tool. In this case, simply implement the interface
IOpenTool
directly on the existing class. -
Develop a new class. In this case, it is easiest to extend the abstract class
OpenToolAbstract
. This abstract class also contains additional helper methods for working with parameters.public class SimpleMessageBox extends OpenToolAbstract {
1.3.2.1.2 Importing Packages
Almost every Open Tool must import the following Open Tool SDK packages:
import oracle.odi.sdk.opentools.IOpenTool; /* All Open Tool classes need these three classes */ import oracle.odi.sdk.opentools.IOpenToolParameter; import oracle.odi.sdk.opentools.OpenToolExecutionException; import oracle.odi.sdk.opentools.OpenToolAbstract; /* The abstract extended for the Open Tool */ import oracle.odi.sdk.opentools.OpenToolParameter; /* The class used for parameters */
In this particular example, a package to create the message box is also needed:
import javax.swing.JOptionPane; /* Needed for the message box used in this example */
1.3.2.1.3 Defining the Parameters
Add a property to store the OpenToolParameter
objects. This is used to both define them for the syntax, and to retrieve the values of the parameters from the eventual user. It is easiest to define the parameters of the Open Tool with a static array as follows. This array should be private, as it will be accessed through an accessor function.
private static final IOpenToolParameter[] mParameters = new IOpenToolParameter[] { new OpenToolParameter("-TEXT", "Message text", "Text to show in the messagebox (Mandatory).", true), new OpenToolParameter("-TITLE", "Messagebox title", "Title of the messagebox.", false) };
The four parameters passed to the OpenToolParameter()
constructor are as follows:
-
The code of the parameter, including the initial hyphen. This code must correspond to the syntax returned by
getSyntax()
. -
The user-friendly name, which is used if the user is using the graphical interface to set parameters.
-
A descriptive help text.
-
Whether the parameter is mandatory. This is an indication to the user.
Note:
Oracle Data Integrator does not enforce the mandatory flag on parameters. Your class must be able to handle any combination of parameters being provided.
You must implement the accessor function getParameters()
to retrieve the parameters:
public IOpenToolParameter[] getParameters() { return mParameters; }
1.3.2.1.4 Implementing Informational Functions
Implement functions to return information about your Open Tool: getDescription()
, getVersion()
, getProvider()
.
public String getDescription() { return "This Open Tool displays a message box when executed."; } public String getVersion() { return "v1.0"; } public String getProvider() { return "My Company, Inc."; }
The getSyntax()
function determines the name of the Open Tool as it is displayed in the Oracle Data Integrator graphical interface, and also the initial values of the parameter. Make sure the names of the parameters here match the names of the parameters returned by getParameters()
.
public String getSyntax() { return "SimpleMessageBox \"-TEXT=<text message>\" \"-TITLE=<window title>\""; }
The getIcon()
method should then return paths to two appropriately sized images. It should look something like this:
public String getIcon(int pIconType) { switch (pIconType) { case IOpenTool.SMALL_ICON: return "/com/myCompany/OpenTools/images/SimpleMessageBox_16.gif"; case IOpenTool.BIG_ICON: return "/com/myCompany/OpenTools/images/SimpleMessageBox_32.gif"; default: return ""; } }
1.3.2.1.5 Execution
Finally, the execute()
method, which carries out the functionality provided by the Open Tool. In this case, a message box is shown. If you are extending the OpenToolAbstract
class, use the getParameterValue()
method to easily retrieve the values of parameters, as they are set at runtime.
Note:
You must catch all exceptions and only raise an OpenToolExecutionException
.
public void execute() throws OpenToolExecutionException { try { if (getParameterValue("-TITLE") == null || getParameterValue("-TITLE").equals("")) /* title was not filled in by user */ { JOptionPane.showMessageDialog(null, (String) getParameterValue("-TEXT"), (String) "Message", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, (String) getParameterValue("-TEXT"), (String) getParameterValue("-TITLE"), JOptionPane.INFORMATION_MESSAGE); } } /* Traps any exception and throw them as OpenToolExecutionException */ catch (IllegalArgumentException e) { throw new OpenToolExecutionException(e); } }
1.3.3 Open Tools at Runtime
In general, your Open Tool class is instantiated only very briefly, and is used in the following ways.
Installation
When the user chooses to install an Open Tool, Oracle Data Integrator instantiates the class and calls the methods getDescription()
, getProvider()
, getIcon()
, and getVersion()
to retrieve information about the class.
Use in a Package
When the Open Tool is used in a package, the class is instantiated briefly to call the methods getDescription()
, getProvider()
, getIcon()
, and getVersion()
. Additionally, getSyntax()
is called to retrieve the code name of the Open Tool and its default arguments. The method getParameters()
is called to display the list of arguments to the user.
Execution
Each time the Open Tool is executed in a package or procedure, the class is instantiated again; it has no persistence after its execution. The execute()
method is called just once.
Tip:
See also Using Open Tools and Open Tools SDK documentation (JavaDoc).