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:
- The API for the AbstractColumnHandler abstract class.
- The API for the ColumnHandler interface.
Task info
To create a custom column handler, extend the abstract class AbstractColumnHandler, which is the default implementation of the ColumnHandler interface.
Procedure
- Open WebSphere Commerce Developer.
- Switch to the Java EE perspective.
- In the Enterprise Explorer view, double-click WebSphereCommerceServerExtensionsLogic to open this project.
- 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.
- Optional: Override the init() or close() methods to achieve the functionality of your handler.
- 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.
- 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.
- Save and close the file.
- Repeat step 6 for each of your business object configuration files.
What to do next
Deploy our customized code:
- Package our custom column handler class in the WebSphereCommerceServerExtensionsLogic project to a JAR file.
- 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.
- 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).
- Run the Data Load utility to load data with our custom data load configuration files to the database.