Introduced in Feature Pack 3

Creating 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 you begin

Ensure that you understand the following information:
  • The API for the com.ibm.commerce.foundation.dataload.config.AbstractColumnHandler abstract class.
  • The API for the com.ibm.commerce.foundation.dataload.config.ColumnHandler interface.

About this task

To create a custom column handler, extend the abstract class AbstractColumnHandler, which is the default implementation of the ColumnHandler interface. For an example of creating and using a column handler, see Extending the generic table loader to encrypt user passwords.

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 required functionality of your handler.
  6. Open your sample business object configuration file that uses com.ibm.commerce.foundation.dataload.businessobjectbuilder.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 your customized column handler. If the <_config:ColumnHandler> element exists in your file, update the className attribute within this element with the class name of your 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 your customized code:
  1. Package your custom column handler class in the WebSphereCommerceServerExtensionsLogic project to a JAR file.
  2. Create the WC_installdir\ext\lib directory if it does not exist, and copy the JAR file to the WC_installdir\ext\lib directory. You must place your 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 WC_installdir\samples\DataLoad (WebSphere Commerce server environment).
  4. Run the Data Load utility to load data with your custom data load configuration files to the WebSphere Commerce database.