Download Java Transformation: Using External Objects

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Java Transformation: Using External Objects
© 2008 Informatica Corporation
Overview
The Java transformation provides a simple native programming interface to define transformation functionality with the
Java programming language. You can use the Java transformation to quickly define simple or moderately complex
transformation functionality without advanced knowledge of the Java programming language or an external Java
development environment.
You can use external objects within a Java transformation. To use external objects in the Java code of a Java
transformation, import packages, configure the CLASSPATH, and declare an instance of the external object in the
Java transformation.
Using External Objects
To use an external object in a Java transformation, complete the following steps:
1.
Import the Java package.
2.
Set the CLASSPATH.
3.
Declare an instance of the external object.
4.
Use the external object.
Step 1: Import the Java Package
Use the Import Package tab of the Java transformation to import third-party Java packages or custom Java packages
for active or passive Java transformations.
For example, you want to import a class named MyObject. MyPackage is the root package, MySubPackage is a
subfolder, and class MyObject is defined in the MySubPackage subfolder. Enter the following code in the Import
Packages tab:
import MyPackage.MySubPackage.MyObject
When you export or import metadata that contains a Java transformation in the PowerCenter Client, the JAR files or
classes that contain the third-party or custom packages required by the Java transformation are not included. If you
import metadata that contains a Java transformation, copy the JAR files or classes that contain the required third-party
or custom packages to the PowerCenter Client and Integration Service machines.
Step 2: Set the CLASSPATH
When you import third-party or custom Java packages on the Import Package tab, set the classpath for the
PowerCenter Client and the Integration Service to the location of the JAR files or class files for the Java package. The
JAR or class files must be accessible on the PowerCenter Client and the Integration Service machine.
Setting the CLASSPATH for the Integration Service
To set the classpath on the Integration Service machine, complete one of the following tasks:
y
Configure the Java Classpath session property. Set the classpath using the Java Classpath session property.
This classpath applies to the session.
y
Configure the Java SDK Classpath. Configure the Java SDK Classpath on the Processes tab of the Integration
Service properties in the Administration Console. This setting applies to all sessions run on the Integration
Service.
y
Set the CLASSPATH environment variable. Set the CLASSPATH environment variable on the Integration
Service machine. Restart the Integration Service after you set the environment variable. This applies to all
sessions run on the Integration Service.
2
To set the CLASSPATH environment variable on UNIX:
In a UNIX C shell environment, type:
setenv CLASSPATH <classpath>
-orIn a UNIX Bourne shell environment, type:
CLASSPATH = <classpath> export CLASSPATH
To set the CLASSPATH environment variable on Windows:
Enter the environment variable CLASSPATH, and set the value to the default classpath.
Configuring the Classpath for the PowerCenter Client
To set the classpath for the machine where the PowerCenter Client runs, complete one of the following tasks:
y
Set the CLASSPATH environment variable. Set the CLASSPATH environment variable on the PowerCenter
Client machine. This applies to all java processes run on the machine.
y
Configure the Java transformation settings. Set the classpath in the Java transformation settings. This applies
to sessions that include this Java transformation. The PowerCenter Client adds the required files to the classpath
when you compile the java code.
To set the classpath in the Java transformation settings:
1.
On the Java Code tab, click the Settings link.
The Settings dialog box appears.
2.
Click Browse under Add Classpath to select the JAR file or class file for the imported package. Click OK.
3.
Click Add.
The JAR or class file appears in the list of JAR and class files for the transformation.
4.
To remove a JAR file or class file, select the JAR or class file and click Remove.
Step 3: Declare an Instance of the Object
Use the Helper Code tab to declare the external object.
To declare an instance of an object:
1.
On the Java Code tab of the Java transformation, click the Helper Code tab.
2.
Perform one of the following options:
To create one instance of the object per partition, declare the object. For example, declare an object named
MyObject with the following code:
MyObject obj = new MyObject();
- or To create an instance of MyObject that is shared across partitions and reusable transformations, declare a static
instance. For example, declare a static object with the following code:
static MyObject obj = new MyObject();
Step 4: Use the External Object
After you declare an instance of an object on the Helper Code tab, you can use the object on any code entry tab
except the Import Packages tab.
3
Author
Padma Heid
Technical Writer
4