cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dumping the BeanShell namespace in a rule

Dumping the BeanShell namespace in a rule

Many times, in a rule, you have no idea what are all the variables that are available to you. The following code snippet will dump all the variables available in the beanshell namespace for the currently executing rule:

 

UPDATE (1/14/2015): Added check for transient variable name which is a reserved word in Java. See red below.

 

<Rule name='Namespace'>

  <Source>

 

 

 

System.out.println("Beanshell namespace:");

 

for (int i=0; i&lt; this.variables.length; i++){

   String name = this.variables[i];

if ("transient".equals(name)) { continue; }

   Object value = eval(name);

 

   if (value == void)

       print(name + " = void");

   else if (value == null)

       print(name + " = null");

    else

       print (name + ":" + value.getClass().getSimpleName() + " = " + value);

}

 

  </Source>

</Rule>

 

 

As an example, when adding the code above to a buildmap rule, I see the following printed out:

 

Beanshell namespace:

state: HashMap = {}

context: InternalContext = sailpoint.server.InternalContext@ceb3c0

schema: Schema = sailpoint.object.Schema@630f2f[id=ff8080813fcad43c013fcad460590017,name=<null>]

log: Log4JLogger = org.apache.commons.logging.impl.Log4JLogger@1158f9e

record: ArrayList = [TEST01, 20080211, ADMINISTRATORS, DR System:YY-Function Control:YY-BackupControl:YY,  Administrators Group for PAM]

application: Application = sailpoint.object.Application@87d5ce[id=ff8080813fcad43c013fcad460550015,name=PAM]

cols: ArrayList = [Database Name, Report Date, Permission Group, Permission Rights, Description]

bsh: XThis = 'this' reference (XThis) to Bsh object: NameSpace: Bsh Object (bsh.NameSpace@1e43069)

bsf: BSFManager = org.apache.bsf.BSFManager@48702

Labels (3)
Version history
Revision #:
3 of 3
Last update:
‎May 17, 2026 01:47 AM
Updated by: