BW6 Access all Module Properties

BW6 Access all Module Properties

book

Article ID: KB0083929

calendar_today

Updated On:

Products Versions
TIBCO ActiveMatrix BusinessWorks 6.x

Description

Accessing module level properties from java code by using @ModuleProperties results in nullpointer exception. It happens due to misconfiguration. Please follow the steps as mentioned in the resolution to overcome configuration issue.

Issue/Introduction

This article is based on https://docs.tibco.com/pub/activematrix_businessworks/6.4.0/doc/html/GUID-0789354B-8A60-4E70-B492-5E155FE18D6F.html

Environment

BW 6.X

Resolution


1. Create a Simple project and define some module level properties 

User-added image

2. Convert the project into a java project 
User-added image
3. Create a java class.
User-added image
4. Open the module dependencies 
User-added image
5. Add the following class in the dependency
com.tibco.bw.palette.shared.java
User-added image
6. After selecting it, save the project.
7. Open up the class "AccessModuleProperties" and copy paste the following content.

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.tibco.bw.palette.shared.java.ModuleProperties;
public class AccessModuleProperties {
HashMap map=null;
public AccessModuleProperties()
{
    ;
}
@ModuleProperties
public void setProperties(HashMap maptmp)
{
    System.out.println("called");
    System.out.println(maptmp.size());
    map=maptmp;
}
public void printProperties()
{
    Iterator it = map.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pair = (Map.Entry)it.next();
        System.out.println(pair.getKey() + " = " + pair.getValue());
    }
    
}
}
User-added image
8. Create a java global instance 
User-added image
9. Choose the class and the constructor as follows
User-added image
10. Create a simple process with timer to test the configuration. Add java invoke and configure it as follows 
User-added image
11. Run the project and it will print all the module level properties as follows 
User-added image

Additional Information

https://docs.tibco.com/pub/activematrix_businessworks/6.4.0/doc/html/GUID-0789354B-8A60-4E70-B492-5E155FE18D6F.html