Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: JDBC-based bean definitions

  1. #1
    Join Date
    Aug 2004
    Location
    Germany
    Posts
    24

    Default JDBC-based bean definitions

    Just wanted to verify my understanding of the following issue at
    http://opensource.atlassian.com/proj.../browse/SPR-95
    Addresses this a new feature where I can store my bean definitions in a DB table instead of an XML file?
    is this correct?
    Because this would come quite nice to play with the Timer functionality in Spring. I could specify the timertasks in a DB table then which I need for a project.
    Is there any possibility to work on this and contribute it?
    cheers.

  2. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    Karsten,

    Yes, the existing JdbcBeanDefinitionReader can read bean definitions from a database, but it's not incredibly flexible. Additionally, there is the question of dynamic reconfiguration. One of the main reasons why somebody would put some data in a db (at least some of the time) is probably because they need to be able read that data dynamically, not just on program startup.

    As for user contributions for this or any other area of Spring, sure, they are much appreciated. Any code can be submitted as a patch in Jira, and discussed in the dev list.
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  3. #3
    Join Date
    Aug 2004
    Location
    Germany
    Posts
    24

    Default

    Colin,
    thanks for the quick reply.
    I will have a closer look at this subject and come back with more thoughts/code.
    Keep your great work up!

  4. #4
    Join Date
    Aug 2004
    Location
    Germany
    Posts
    24

    Default clarification needed

    I just wonder about some things with the functionality of retrieving bean definitions from a DB. Please correct me if I am wrong:
    To retrieve bean configs from a DB, I need to store them as stated in the JdbcBeanDefinitionReader class (beanID, property name and value), then I need to instatiate a new JdbcBeanDefinitionReader, set a Datasource or JdbcTemplate on it. And I could do this with spring in the applicationContext.xml, or?
    After that I have my own ServletContextListener implementation, which follows the spring ContextLoaderListener. In this class I retrieve the JdbcBeanDefinitionReader from the context and call the loadBeanDefinitions(String sql) method with the appropriate SQL.
    The beans will get loaded into the same context as the others? or a new one?
    Is this working at all, or am I missing something.
    Thanx for clarifying.

  5. #5
    Join Date
    Aug 2004
    Location
    Atlanta, GA
    Posts
    129

    Default

    Quote Originally Posted by Colin Sampaleanu
    Karsten,

    Yes, the existing JdbcBeanDefinitionReader can read bean definitions from a database, but it's not incredibly flexible. Additionally, there is the question of dynamic reconfiguration. One of the main reasons why somebody would put some data in a db (at least some of the time) is probably because they need to be able read that data dynamically, not just on program startup.
    I need to do something similar in that it is "policy" that if a configuration file changes, the application must go through a complete 30-day round of regression testing; yet there is no such rule for changing a value in the database. :roll:

  6. #6
    Join Date
    Aug 2004
    Location
    Atlanta, GA
    Posts
    129

    Default

    Quote Originally Posted by Colin Sampaleanu
    Karsten,

    Yes, the existing JdbcBeanDefinitionReader can read bean definitions from a database, but it's not incredibly flexible. Additionally, there is the question of dynamic reconfiguration. One of the main reasons why somebody would put some data in a db (at least some of the time) is probably because they need to be able read that data dynamically, not just on program startup.
    I need to do something similar in that it is "policy" that if a configuration file changes, the application must go through a complete 30-day round of regression testing; yet there is no such rule for changing a value in the database. :roll:

  7. #7
    Join Date
    Aug 2004
    Location
    California
    Posts
    17

    Default Dynamic reconfiguration of bean properties using JDBC

    Quote Originally Posted by Colin Sampaleanu
    Karsten,

    Yes, the existing JdbcBeanDefinitionReader can read bean definitions from a database, but it's not incredibly flexible. Additionally, there is the question of dynamic reconfiguration. One of the main reasons why somebody would put some data in a db (at least some of the time) is probably because they need to be able read that data dynamically, not just on program startup.

    As for user contributions for this or any other area of Spring, sure, they are much appreciated. Any code can be submitted as a patch in Jira, and discussed in the dev list.
    I have written some code to initialize bean properties using initialization parameters stored in various locations e.g. database table, servlet context, servlet init parameters, Map, Properties, etc. It works both during application initialization and later during application execution. i.e. it supports dynamic reinitialization of bean properties,

    I would be happy to submit the code to the Spring project. Let me know if you are interested.

    See my posting from August 30 for additional information

  8. #8
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    The best thing would be to put it on the wiki (Confluence) somewhere, so other people can get at it...
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

  9. #9
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    MHarhen,

    Your approach seems very interesting. I have two questions with regards to beans configurations using PropertyMapper:

    1. Is it possible to configure PropertyMapper to call some initialization methods after properties were updated (to emulate Spring' init-method)?
    2. How do you manage "dynamic reconfiguration": reconfigure a bean that is being used by other beans.

    I am asking these questions because I will be using such "hot-configuration/reconfiguration" in a future project.

    Thank you.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  10. #10
    Join Date
    Aug 2004
    Location
    California
    Posts
    17

    Default

    Quote Originally Posted by irbouho

    1. Is it possible to configure PropertyMapper to call some initialization methods after properties were updated (to emulate Spring' init-method)?
    2. How do you manage "dynamic reconfiguration": reconfigure a bean that is being used by other beans.
    Answers:
    1. Yes - PropertyMapper has an initMethod property.
    2. By dynamic reconfiguration, I mean changing the properties of a bean during execution. It is done by calling the PropertyMappers.refreshAll() method.

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

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