Create custom column handlers

Create a custom column handler so that the Data Load utility can resolve data and load the data into database columns. Create a custom column handler to resolve the data that cannot be mapped to a column value through the data load configuration. For example, if you input data to populate the password column in the database with a clear text password. If the password column expects an encrypted value, create a custom column handler to encrypt the clear text password. The handled can then return an encrypted password from the resolveColumnValue() method.


Before beginning

Ensure that you understand the following information:


Task info

To create a custom column handler, extend the abstract class AbstractColumnHandler, which is the default implementation of the ColumnHandler interface.


Procedure

  1. Open WebSphere Commerce Developer.

  2. Switch to the Java EE perspective.

  3. In the Enterprise Explorer view, double-click WebSphereCommerceServerExtensionsLogic to open this project.

  4. In the WebSphereCommerceServerExtensionsLogic project, create a new custom column handler class that extends from the AbstractColumnHandler class. Implement the resolveColumnValue() abstract method within the custom column handler class.

  5. Optional: Override the init() or close() methods to achieve the functionality of your handler.

  6. Open your sample business object configuration file that uses TableObjectBuilder. For an example of a business object configuration file, see the wc-loader-member-group-condition.xml sample file in the WCDE_installdir\samples\DataLoad\Member directory.

    1. If the <_config:ColumnHandler> element does not exist in this file, add this element and specify the class name of our customized column handler. If the <_config:ColumnHandler> element exists in your file, update the className attribute within this element with the class name of our customized column handler.

    2. Save and close the file.

  7. Repeat step 6 for each of your business object configuration files.


What to do next

Deploy our customized code:

  1. Package our custom column handler class in the WebSphereCommerceServerExtensionsLogic project to a JAR file.

  2. Create the utilities_root\ext\lib directory if it does not exist, and copy the JAR file to the utilities_root\ext\lib directory. We must place our custom JAR files in this directory.

  3. Copy all of the custom data load configuration files from WCDE_installdir\samples\DataLoad (WebSphere Commerce development environment) to utilities_root\samples\DataLoad(WebSphere Commerce server environment).

  4. Run the Data Load utility to load data with our custom data load configuration files to the database.