Skip to Content

Overview

Business Logic Services (Transaction Development)  editor provides the flexibility to develop the business logic for any application. It has enough action blocks to develop the logic, but some times we need some thing extra that is not provided by the Standard Action blocks and feel the need to having some thing new. The following exercise explains how to develop the custom action blocks to meet the business requirements.

Brief Explanation about the Action Blocks.

Before we start developing the custom action block, let me explain what these components really are and how they work.

Every Custom action block is a Java Program, which extends ActionReflectionBase class, which makes sure that the Action Block  is in compliance to lighthammer action block framework.

The Link properties in each custom action are private variables defined in the class, and for each of this property there must be getters and setters methods defined each property

For Example, if action block is expecting input variable strInput and output variable strOutput (both of String type) then we will behaving following properties defined in our code

    private String strInput;

    private String strOutput;

The getters and Setters defined for each property mentioned above will be

  • public String getstrInput()
  • public setstrInput(String strInput)

For strOutput there will be no setter method, since that is only the output of our ActionBlock. Here I have mentioned only the method signatures, actual implementations are shown in code below

In Each action Block, there is method with signature   

public void Invoke(Transaction transaction, ILog ilog),

The transaction object is the current transaction object and ILog is to Log any error if some exception is caught.
This method contains the actual business logic for the Action Block.

Prerequisites

  • 1. jdk 1.4.2_07 or above.

Things to do before the Development :

There are certain things to make sure on your system which are required to develop the action blocks. Please make sure the following things are done before we actaully start coding for the Block

  • 1. If the development is on the server machine , make sure the system classpath is <installation Directory>:\\ServletExec AS\\se-xMII\\webapps\\default\\Lighthammer\\WEB-INF\\lib;<installation Directory>:\\ServletExec AS\\se-xMII\\webapps\\default\\Lighthammer\\WEB-INF\\classes;
  • 2. If the development is any other machine, copy the Lighthammer.jar from the server machine from location <installation Directory>:\\ServletExec AS\\se-xMII\\webapps\\default\\Lighthammer\\CMSLogicEditor , keep some where on the development machine and make the system classpath compliant with that.

With this done, we are ready for the Development.

In this Example, I am considering simple Example which will take 2 input String Inputs and Output the two appended.

Please find the code below for the same.

————-Code Start————–

package com.wipro.action;
import com.lighthammer.xacute.actions.ActionReflectionBase;
import com.lighthammer.xacute.core.ILog;
import com.lighthammer.xacute.core.Transaction;

public class CustomAction extends ActionReflectionBase{
   
    /*
     * This will take the First Input in the Transaction
     */
    private String strFirstInput;
    /*
     * This will take the Second Input in the Transaction
     */
    private String strSecondInput;
   
    /*
     * This will give the result.
     */
    private String strOutString;
    /*
     * Constructor
     */
    public CustomAction() {
        // Initialise all attributes in the Cunstructor
        strFirstInput=””;
        strSecondInput=””;
        strOutString=””;
    }
   
   /**
     * This will take the Icon to display in the BLS
     */
    public String GetIconPath() {
        return “/com/wipro/action/resources/icons/CustomAction.png”;
    }

    /*
     * This method contains the actual business logic for the
     * Action Block
     */
    public void Invoke(Transaction trx, ILog ilog)
    {
       try{
           strOutString=strFirstInput+strSecondInput;

          /*

           // This varaible is defined in ActionReflectionBase class

            */
           _success=true;
       }catch (Exception e) {
        _success=false;// Set _success to false if any exception is cought

   }
}

// Getter for the Fisrt Input

    public String getFirstInput() {
        return strFirstInput;
    }

// Setter for the first Input

   public void setFirstInput(String strFirstInput) {
        this.strFirstInput = strFirstInput;
    }

//Getter for the Second Input
    public String getSecondInput() {
        return strSecondInput;
    }

// Setter for the Second Input

   public void setSecondInput(String strSecondInput) {
        this.strSecondInput = strSecondInput;
    }

// getter for the Output . Note there is no setter as this is output property

   public String getOutString() {
        return strOutString;
    }

/**
     * This is required to make the Configure Button Disabled
     * Note: If you want to have Custom ConfigureDialog, you need not put this method.

    */
    public boolean isConfigurable(){
        return false;
    }

   
}

———Code ends here————

Compile the Java Code

Now, we need to compile the code, use the following command on the command prompt 

<Working Dir>javac com\\wipro\\action\\CustomAction.java

Make sure there are no compilation errors.

Once done, we will get the class file (CustomAction.class) in the same directory.

Package the Class file and the Image file

Next step is to create the jar file(Jar files are used to package the different components of the application) . Along with the class file that we created, we need to package the image file that will shown on the Logic Editor. 

Choose a PNG picture object to be used for displaying the customized action block in BLS. Preferred dimension of the PNG picture should be 32 pixels X 32 pixels
keep the PNG file in the following folder structure
com\\wipro\\action\\resources\\icons and name that as CustomAction.PNG

create the Jar file with the following command on the CommandPrompt.

<Working Dir>jar -cf CustomAction.jar com\\wipro\\action\\CustomAction.class com\\wipro\\action\\resources\\icons\\CustomAction.PNG .

This will give you the jar file(which is similar to zip file) with the class file and image file in it.

Put this Jar file at the following 2 Locations on the server

  • <Install Dir>\\ServletExec AS\\se-xMII\\webapps\\default\\Lighthammer\\CMSLogicEditor.
  • <Install Dir>\\ServletExec AS\\se-xMII\\webapps\\default\\Lighthammer\\WEB-INF\\lib

With this we have completed the development part of our application.

Creating the XML configuration file

Create one XML file with the following Code

<ComponentCatalog>
    <Category Name=”Custom Action” Description=”This is the first Action”>
        <Component Type=”Action” Name=”CustomAction” Description=”” Label=”Custom Action” ClassName=”com.wipro.action.CustomAction” AssemblyName=”CustomAction.jar” HelpFileName=”” />
       
    </Category>
</ComponentCatalog>

Name this file and keep that at the following location on the server

<InstallationDir>:\\Lighthammer\\Xacute\\Components.

Clearing the Java Cache:

Clear the JavaCache on the Development and server machine. This can be done by starting the Javaconsole and deleting the temrary files, while doing so, make sure there are no java programs running.

Restart the ServletExec Service on the server.

Go to Control Pane->Adminstrative Tools-> Services and restart the Servlet Exec Service, refer to screen shot below.

Service.JPG

Now we are ready to use the Custom Action that we developed . Login to xMII portal and open the Business Logic Editor.

Here is how your Custom Action should Look Like

CustomAction1.JPG

Double click the Action block to put that into the sequence, and Configure, you can see the configure dialog box shows the configuration for First and Second variables mentioned in our code. See the following Screen

CustomAction2.JPG

You can also link the First and Second variables in the link editor as shown below.

CustomAction3.JPG

Test the action to see the result.

Hope this Little exercise was help ful to unserstand the Development of the Custom action blocks. This is simplest of the Actions for the illustration and could be used as a base to develop the complex and more use ful one.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

    1. Rupesh Bajaj Post author
      Naveen,
      I have uploaded the images.
      Initially I simply pasted the images and some how those were visible on my machine, My apologies for that.
      Regards
      Rupesh
      (0) 

Leave a Reply