Universal Cache User Guide : IBM InfoSphere CDC for solidDB® reference : User exits for IBM InfoSphere CDC : Sample user exits for IBM InfoSphere CDC
  
Sample user exits for IBM InfoSphere CDC
IBM InfoSphere CDC provides sample user exits that you can extend or modify to suit your environment. The samples are found in samples.jar which is located in the samples directory in your IBM InfoSphere CDC installation directory. The Java file contains the following samples:
ArchiveLogPathUserExitSample.java: Returns the fully qualified path (including file name and extension) to the archive log file. This sample is located in com.datamirror.ts.target.publication.userexit.sample.
CRUserExitSample.java: A conflict resolution user exit that can be used with tables having a primary key column of any data type or a numeric column with any data type. This sample is located in com.datamirror.ts.target.publication.userexit.cdr.
DEUserExitSample.java: Used in expressions using the %USERFUNC column function. It calculates the sum of the user-supplied parameters (in the expression) and returns the sum incremented by 1. This sample is located in com.datamirror.ts.derivedexpressionmanager.
SPUserExitSample.java: Calls a stored procedure with the image coming from the source. This sample is located in
com.datamirror.ts.target.publication.userexit.sample
UserExitSample.java: Subscribes to replication events to retrieve the details of the events which took place. This sample is located in
com.datamirror.ts.target.publication.userexit.sample.
UserExitSample1.java: Records new rows inserted into a table on the target and stores them in a text file. The user specifies the name of the text file as a parameter. This sample is located in
com.datamirror.ts.target.publication.userexit.sample
Note the following:
To run the sample user exits without modifying them, you must specify the fully qualified path to the compiled user exit in Management Console. For example:
com.datamirror.ts.target.publication.userexit.sample.
   UserExitSample
Compiled sample user exits are located in the ts.jar file which is found in the lib directory in your IBM InfoSphere CDC installation directory. Note that the compiled user exits in the ts.jar file have a *.class extension.
If you want to modify the sample user exits, you must compile the user exit after you make changes to the source code.
The user exit class must also be in your classpath.
For more information about how to specify Java class or Stored Procedure user exits in Management Console, see your Management Console documentation.
To compile the sample user exits (Windows)
1 Stop IBM InfoSphere CDC.
2 Unzip the samples.jar file into the lib folder in your IBM InfoSphere CDC installation folder. Make sure you maintain the folder structure when unzipping the jar file.
3 After unzipping the jar file, you will have a folder structure like the following:
<IBM InfoSphere CDC installation folder>\lib\com\datamirror\ts\target \publication\userexit\sample
4 Make your changes to the sample user exit.
5 Compile the modified user exit. For example, if you want to compile UserExitSample.java, open a command window, navigate to the lib folder and issue the following command:
javac -classpath ts.jar;. com\datamirror\ts\target\publication\userexit\sample \UserExitSample.java
If this command runs successfully, there will be no output on your screen.
Note Your system must have the Java JDK to run this command.
6 After running the command successfully, navigate to the following directory and confirm that you have created a UserExitSample.class file:
<IBM InfoSphere CDC installation directory>\lib\com\datamirror\ts\target \publication\userexit\sample
7 Start IBM InfoSphere CDC.
8 The final step to configure the user exit is to specify the fully qualified path to UserExitSample in Management Console. For example:
com.datamirror.ts.target.publication.userexit.sample.UserExitSample
Note Do not specify the .class extension.
What to do next
For more information about how to specify Java class user exits in Management Console, see your Management Console documentation.
If you plan to use the sample user exits in production environments, you must test the samples before they are deployed. UNICOM Systems, Inc. does not assume responsibility for adverse results caused by modified or customized user exit classes.
To compile the sample user exits (UNIX and Linux)
1 Stop IBM InfoSphere CDC.
2 Unzip the samples.jar file into the lib directory in your IBM InfoSphere CDC installation directory. Make sure you maintain the directory structure when unzipping the jar file.
3 After unzipping the jar file, you will have a directory structure like the following:
<IBM InfoSphere CDC installation directory>
   /lib/com/datamirror/ts/target /publication/userexit/sample
4 Make your changes to the sample user exit.
5 Compile the modified user exit. For example, if you want to compile UserExitSample.java, open a command window, navigate to the lib directory and issue the following command:
javac -classpath ts.jar:. com/datamirror/ts/target/publication/userexit/sample /UserExitSample.java
If this command runs successfully, there will be no output on your screen.
Your system must have the Java JDK to run this command.
6 After running the command successfully, navigate to the following directoryand confirm that you have created a UserExitSample.class file:
<IBM InfoSphere CDC installation directory>
   /lib/com/datamirror/ts/target /publication/userexit/sample
7 Start IBM InfoSphere CDC.
8 The final step to configure the user exit is to specify the fully qualified path to UserExitSample in Management Console. For example:
com.datamirror.ts.target.publication.userexit.sample.
   UserExitSample
Do not specify the .class extension.
What to do next
For more information about how to specify Java class user exits in Management Console, see your Management Console documentation.
Note If you plan to use the sample user exits in production environments, you will have to test the samples before they are deployed. IBM does not assume responsibility for adverse results caused by modified or customized user exit classes.
See also
User exits for IBM InfoSphere CDC