Results 1 to 4 of 4

Thread: Calling a method on every pooled object

  1. #1
    Join Date
    Nov 2009
    Posts
    4

    Default Calling a method on every pooled object

    Hi,

    I'm developing a system where we have a number of POJOs holding stateful connections to a third-party system. These POJOs are pooled using the Target Source technique.

    This all works as we want, except for one thing.

    We need to be able to call a reconfigure() method on each of those from time-to-time.

    Is there a recommended approach on how to access all of the members in the pool?

    Bonus point: we'd also like to be able to expose reconfigure() via JMX, so that the sys admins can trigger that when they need to via a JMX admin tool in JBoss. We are using JMX successfully with singletons, but is there any easy way of doing this for a bunch of pooled POJOs? I suppose the answer may depend on the solution to the earlier question.

    I'm sure I must be missing something obvious because I can't believe this is an incredibly unusual use case. We've got a couple of other ideas in mind on how we might solve this, but none of them feel very nice (or performant).

    Regards,

    Camden

  2. #2
    Join Date
    May 2007
    Posts
    157

    Default

    Haven't used yet POJO pooling support in Spring, but by looking at the docs it should be possible to apply same technique as in commons-dbcp, validating target (as efficient as possible) before returning it to the caller, and if it's invalid, destroying it and asking for next target instance from the pool. This would remove the need for JMX & reconfiguring.

    IMO this is more question for AOP forum.
    Stevo Slavic

  3. #3
    Join Date
    Nov 2009
    Posts
    4

    Default

    Quote Originally Posted by sslavic View Post
    Haven't used yet POJO pooling support in Spring, but by looking at the docs it should be possible to apply same technique as in commons-dbcp, validating target (as efficient as possible) before returning it to the caller, and if it's invalid, destroying it and asking for next target instance from the pool. This would remove the need for JMX & reconfiguring.

    IMO this is more question for AOP forum.
    You are probably right, I'll ask over there also.

    We don't really want to destroy those objects though, and triggering a 're-configuration' through JMX is actually a requirement we have from the business.

    Thanks for the suggestion though!

  4. #4
    Join Date
    May 2007
    Posts
    157

    Default

    Maybe you can combine two targetsource-s, one for the pool of prototypes, and other one for hotswappable configuration. Pooled prototypes would reference hotswappable configuration so you could substitute configuration easilly.
    Stevo Slavic

Tags for this Thread

Posting Permissions

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