Results 1 to 1 of 1

Thread: Problem with scripting bean "scope" in Spring 2.0.3

  1. #1

    Default 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 11th, 2007 at 11:35 PM. Reason: mistake

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •