Announcement Announcement Module
Collapse
No announcement yet.
How destroy-method="close" on JavaConfig? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How destroy-method="close" on JavaConfig?

    Hello Guys

    If in XML I have

    Code:
    <bean id="dataSource"
              class="com.mchange.v2.c3p0.ComboPooledDataSource" 
              destroy-method="close">
    ...
    </bean>
    What is the equivalent on Java Config?

    Code:
    @Bean
    public DataSource dataSource() throws Exception{
    		
    	
    	ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
             ....		
    		
    	return comboPooledDataSource;
    		
    }
    Thank You....

  • #2
    You can do the same using destroyMethod argument of the
    @Bean
    annotation in the method. By default it will detect no argument method named close as the destroy method.
    @Bean(destroyMethod = "shutdown")
    public DataSource dataSource() throws Exception{


    ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
    ....

    return comboPooledDataSource;

    }

    Comment


    • #3
      Hi.

      Yes Thank You..

      Kind Regards.

      Comment

      Working...
      X