Announcement Announcement Module
No announcement yet.
Understanding spring beans Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Understanding spring beans

    Hello everyone,

    I am currently learning spring because I want to refactor an enterprise application with it.

    But after a short time a question came up to me.

    In our application we have an own connection pool implementation. Our application takes the use of different schemas. For each schema we are using a different connection pool instance.

    Imagine that I want to refactor this connection pool to be a spring bean.
    The problem is: How to instance the connection pool beans depending on an external xml configuration?
    How to get the appropriate bean instance for a given schema?

    (And there are many other examples with the same situation in our software)

    I do not know an exact answer, although I see several possibilities:

    - these classes should not be a spring bean
    - I should use a custom scope for each schema
    - I should use ApplicationContext.getBean(String, Object[]) to call a static factory method implementation
    - Something else?

    I'd very glad if you can enlight this situation to me and to help a beginner to understand how spring should be used.

    Best Regards,

  • #2
    It will help big time if you could tell more about the use-case for having multiple connection pools. I.e. what is the separation between the pools, when do you need to use a pool and how do you know what pool to use.

    I'm sure you can use Spring to load your connection pools - you can configure multiple connection pools as long as they are given different names - and inject those into other beans. I'm just not quite sure if this is what you need.