Announcement Announcement Module
Collapse
No announcement yet.
Calling a method on every pooled object Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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!

      Comment


      • #4
        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.

        Comment

        Working...
        X