Announcement Announcement Module
Collapse
No announcement yet.
Problem with scripting bean "scope" in Spring 2.0.3 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with scripting bean "scope" in Spring 2.0.3

    In Spring 2.0.3 dynamic language support, we can create scripting bean with beanshell, groovy or jruby but the scope of the scripting bean is always singleton. I have checked the ScriptBeanDefinitionParser class and find that there is no way to set the scripting bean scope. Singleton scope creates a problem in the following example code:
    ...
    // suppose person is a scripting bean in bsh or groovy or jruby
    List personList = new LinkedList() ;
    for (int i=0 ; i < 3 ; i++) {
    Person person = (Person)applicationContext.getBean("ScriptPerson") ;
    // do something like setting person property
    person.setName("name"+String.valueOf(i)) ;
    ...
    personList.add(person) ;
    }
    // do something with the list later
    ...
    The above example code does not work because "ScriptPerson" bean is singleton and the person name is always "name2".
    Is there anyway to workaround this problem? Also is there any special reason that scripting bean scope must be singleton. Thanks a lot for any comment or answer.

    I am very sorry to post twice.

    Cheers
    chris tam
    xenium
    Last edited by cltam96; Feb 12th, 2007, 12:35 AM. Reason: mistake
Working...
X