Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-beta-5
    • Fix Version/s: 1.0-beta-4
    • Component/s: PicoContainer (Java)
    • Labels:
      None
    • Number of attachments :
      1

      Issue Links

        Activity

        Aslak Hellesøy made changes -
        Field Original Value New Value
        Attachment picopool-src.zip [ 10990 ]
        Hide
        Aslak Hellesøy added a comment -

        From Ross Mason:

        I have implemented a simple component pool which uses a PicoContainer for the pool and is itself picofiable. The pool supports exhausted policies ? Fail, Grow and Block.

        This is what it looks like ?

        //Creates a default pool of AnotherTouchable

        DefaultPicoPool pool = new DefaultPicoPool(AnotherTouchable.class);

        There is another constructor that accepts a PicoPoolConfiguration, i.e.

        MutablePicoContainer pico = new DefaultPicoContainer();

        PicoPoolConfiguration config = new PicoPoolConfiguration(AnotherTouchable.class, ...Other pool parameters);

        pico.registerComponentInstance(config);

        pico.registerComponentImplementation("myPool", DefaultPicoPool.class);

        DefaultPicoPool pool = (DefaultPicoPool) pico.getComponentInstance("myPool");

        To obtain objects call ?

        Object borrowed = pool.borrowComponent();

        And to return ?

        Pool.returnComponent(borrowed);

        I?ve included the source with test cases. I was also going to implement a keyed Pool version, but wanted to check I was on the right track.

        Also, I started playing with a PicoPoolComponentAdapter that would provide pooling transparently i.e.

        MutablePicoContainer pico = new DefaultPicoContainer(new PicoPoolComponentAdapterFactory());

        pico.registerComponentImplementation(AnotherTouchable.class);

        AnotherTouchable component = (AnotherTouchable)pico.getComponentInstance(AnotherTouchable.class);

        component.wasTouched();

        AnotherTouchable component2 = (AnotherTouchable)pico.getComponentInstance(AnotherTouchable.class);

        assertTrue(!component2.isTouched());

        I couldn?t think of a clean way of returning the object to the pool once it had been borrowed. Any ideas??

        Cheers,

        Ross

        Ps this uses Zohar?s NonCachingComponentAdapter, so you?ll need that code to run it.

        Show
        Aslak Hellesøy added a comment - From Ross Mason: I have implemented a simple component pool which uses a PicoContainer for the pool and is itself picofiable. The pool supports exhausted policies ? Fail, Grow and Block. This is what it looks like ? //Creates a default pool of AnotherTouchable DefaultPicoPool pool = new DefaultPicoPool(AnotherTouchable.class); There is another constructor that accepts a PicoPoolConfiguration, i.e. MutablePicoContainer pico = new DefaultPicoContainer(); PicoPoolConfiguration config = new PicoPoolConfiguration(AnotherTouchable.class, ...Other pool parameters); pico.registerComponentInstance(config); pico.registerComponentImplementation("myPool", DefaultPicoPool.class); DefaultPicoPool pool = (DefaultPicoPool) pico.getComponentInstance("myPool"); To obtain objects call ? Object borrowed = pool.borrowComponent(); And to return ? Pool.returnComponent(borrowed); I?ve included the source with test cases. I was also going to implement a keyed Pool version, but wanted to check I was on the right track. Also, I started playing with a PicoPoolComponentAdapter that would provide pooling transparently i.e. MutablePicoContainer pico = new DefaultPicoContainer(new PicoPoolComponentAdapterFactory()); pico.registerComponentImplementation(AnotherTouchable.class); AnotherTouchable component = (AnotherTouchable)pico.getComponentInstance(AnotherTouchable.class); component.wasTouched(); AnotherTouchable component2 = (AnotherTouchable)pico.getComponentInstance(AnotherTouchable.class); assertTrue(!component2.isTouched()); I couldn?t think of a clean way of returning the object to the pool once it had been borrowed. Any ideas?? Cheers, Ross Ps this uses Zohar?s NonCachingComponentAdapter, so you?ll need that code to run it.
        Aslak Hellesøy made changes -
        Link This issue depends upon PICO-55 [ PICO-55 ]
        Hide
        Zohar Melamed added a comment -

        >>this uses Zohar?s NonCachingComponentAdapter

        Note that in the last patch uploaded to PICO-55, NonCachingComponentAdapter has been renamed :
        BasicComponentAdapter.

        Show
        Zohar Melamed added a comment - >>this uses Zohar?s NonCachingComponentAdapter Note that in the last patch uploaded to PICO-55 , NonCachingComponentAdapter has been renamed : BasicComponentAdapter.
        Hide
        Jon Tirsen added a comment -

        Yes, and it's actually been renamed again. It's now "TransientComponentAdapter".

        Show
        Jon Tirsen added a comment - Yes, and it's actually been renamed again. It's now "TransientComponentAdapter".
        Hide
        Jon Tirsen added a comment -

        Is this more of a Pico-component than an actual part of the Pico-core? Move to PicoExtras?

        Show
        Jon Tirsen added a comment - Is this more of a Pico-component than an actual part of the Pico-core? Move to PicoExtras?
        Aslak Hellesøy made changes -
        Assignee Aslak Hellesoy [ rinkrank ]
        Hide
        rossmason rossmason added a comment -

        Agreed, pooling is definitely an extra.

        Show
        rossmason rossmason added a comment - Agreed, pooling is definitely an extra.
        Aslak Hellesøy made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Paul Hammant added a comment -

        Added to PicoExtras

        Show
        Paul Hammant added a comment - Added to PicoExtras
        Paul Hammant made changes -
        Resolution Fixed [ 1 ]
        Status In Progress [ 3 ] Closed [ 6 ]
        Hide
        Aslak Hellesøy added a comment -

        I have started to look at this.

        It looks very interesting, but also quite complicated with the threading stuff.

        Why are threads needed?

        Show
        Aslak Hellesøy added a comment - I have started to look at this. It looks very interesting, but also quite complicated with the threading stuff. Why are threads needed?
        Aslak Hellesøy made changes -
        Resolution Fixed [ 1 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        Aslak Hellesøy made changes -
        Fix Version/s 1.0-beta-4 [ 10412 ]
        Status Reopened [ 4 ] Closed [ 6 ]
        Fix Version/s 1.0 [ 10145 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Aslak Hellesøy
            Reporter:
            Aslak Hellesøy
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: