Java class fields, object use in Beanshell

Viewed 1535

I am using Java with JSF and Beanshell script. I want to use fields and object of java class in beanshell. I have tried my best to get help from google but couldn't find any helpful information. For example

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import bsh.EvalError;
import bsh.Interpreter;

public class C {

static Map<String,Object> map = new HashMap<String,Object>();
static List<String> list = new ArrayList<String>();
static Map<String,Integer> integerMap = new HashMap<String,Integer>();

public static void main(String[] arg) throws EvalError{
    list.add("Hello");
    list.add("World");
    Interpreter i = new Interpreter();  // Construct an interpreter
    map.put("stringList", list);//in java
    i.eval("map.put(\"stringList\", list)");// gives error
    List list = (List) map.get("stringList");
    for(String str:(List<String>)list){
        System.out.println(str);
    }
  }
}

I want to perform all the operation which is available for collection in java to same object in beanshell.

Jmeter provide such facilities where user can update the variable in beanshell and based on the details given on link, it seems Jmeter is using string map and I want to do same things but it is with objects.

I would appreciate your inputs, if any technology in or framework which can be used to achieve my requirement would be good either java, beanshell, JSF or other available option in java.

1 Answers
Related