Configuring magicMethod

magicMethod is used in the integration plugin to dynamically update the values at runtime. It is a useful functionality to manipulate the value of mapping attributes. magicMethod converts value to the desired size-format before transferring to the target side. Based on requirements, you can customize the magic method.

To configure magicMethod, complete the following procedure.

  1. Create a Java function for your requirement, and define an appropriate method name. Following example shows a basic code:
    public static <returntype> methodName(String origValue){ 
    return <manipulatedValue>; 
  2. Open the <Integration Plugin>/resources/config/magicMethod/MagicMethod.txt file.
  3. Copy the Java code that you have created and paste it in the MagicMethod.txt file.
  4. In the <CI>.xml file, do the following:
    1. Replace the magicMetod element value with the method name of the Java code. The following example shows a few lines from the <CI>.Xml file:
      <srcAttribute name="MemorySize" type="Long"> 
    2. Make sure that the data type in the [type] attributes is the same as the data type defined in the Java code.
    3. Fix Pack
9If you need to pass the complete CI Object in the magic method, pass “this” keyword in the name attribute as follows:
      <srcAttribute name="this" type="Object">
  5. Open the <Integration Plugin>/resources/config/ file, and configure the following properties:

    useMagicMethod = true

    By default the value is false, but the code executes only if the value is set to true.

    Javahome= < Enter the same ibm Java path where the plugin is running/jre >

    The following example shows a path: /opt/IBM/taddm/dist/tools/IntegrationPlugin/IntegrationPlugin/external/jdk-Linux-x86_64/jre

  6. Open the <IntegrationPlugin>/lib folder and locate the magic-method.jar file.
  7. Make a backup of the magic-method.jar file, and then delete the magic-method.jar from the lib directory.
  8. Restart the plugin.

    The following example shows a Java code that converts the memory value from megabyte to gigabyte:

    “public static float convertMBToGB(Long value){
    return value/1024;

    In this code, the value parameter denotes the original value received from the source. In the backend, a magic-method.jar file is created; this jar file converts the value while transferring the data to the target.

To test the plugin, do the following:
  • Check the console.log for successful compilation.
  • Check the plugin.log to ensure that magic method has started.
  • Check the transform.log to confirm if values are changed according to magicMethod.
Important: Once the execution is complete, set the magicMethod property to false. If you keep the value as true, each time you start the plugin, the magicMethod compilation starts automatically in the backend.