Announcement Announcement Module
No announcement yet.
a protoype inside a singleton? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • a protoype inside a singleton?

    i have class called command, which accepts in it setter CommandType class

    this CommandType class accepts in it's constuctor a Resource class

    all of this is configured in spring, the user can get the resource class via a getter method and fiddle with it (it saves state), so natrually it can't be shared through the entire application

    does it make sense to turn ONLY the resource class to a prototype, or do i have to turn the whole tree into a prototype? becouse if spring depsenses the same root class with diferent Resorouces i'm afriad from this:

    user 1 gets the tree, and changes data inside Resource class
    while user 1 fiddles with it, user 2 gets the tree, but now the changes user1 made are lost becouse user 2 caused spring to create a new instance of the resource class.

  • #2
    Although this article talks about session-scoped beans it might be useful. In the "even more advanced work" section it discusses a singleton which has a sesion scoped bean. In your case a singleton which has a prototype. Hope this helps.


    • #3
      thanks but it this work in spring 1.2.8? is there such a tag for prototype?


      • #4
        For managing a prototype within a singleton, two very useful techniques offered by Spring are lookup-method-injection and field level injection. Adrian Coyler explains field level injection in For lookup-method injection you can refer to the Spring Reference.

        - Debasish