سؤال

I want to have some kind of an initialization in 1 particular beanshell script , which is later used in 2 other bsh scripts. Now , the initialization thus takes place twice.

Is there some way to share variables/namespace between beanshell scripts so that the initialization takes place only once ?

هل كانت مفيدة؟

المحلول

Look at the object "bsh.shared".

if(bsh.shared.myList == void)
  bsh.shared.myList = new java.util.ArrayList();

// Do stuff to the List anywhere as follows:
//
bsh.shared.myList.add("foo");

نصائح أخرى

Can you create a BeanShell script that performs the initialisation and load it into your other scripts via source ?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top