Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

spring @Bean destroyMethod

The optional name of a method to call on the bean instance upon closing the application context, for example a close() method on a JDBC DataSource implementation, or a Hibernate SessionFactory object. The method must have no arguments but may throw any exception.
As a convenience to the user, the container will attempt to infer a destroy method against an object returned from the @Bean method. For example, given an @Bean method returning an Apache Commons DBCP BasicDataSource, the container will notice the close() method available on that object and automatically register it as the destroyMethod. This 'destroy method inference' is currently limited to detecting only public, no-arg methods named 'close' or 'shutdown'. The method may be declared at any level of the inheritance hierarchy and will be detected regardless of the return type of the @Bean method (i.e., detection occurs reflectively against the bean instance itself at creation time).

To disable destroy method inference for a particular @Bean, specify an empty string as the value, e.g. @Bean(destroyMethod=""). Note that the DisposableBean callback interface will nevertheless get detected and the corresponding destroy method invoked: In other words, destroyMethod="" only affects custom close/shutdown methods and Closeable/AutoCloseable declared close methods.

Note: Only invoked on beans whose lifecycle is under the full control of the factory, which is always the case for singletons but not guaranteed for any other scope.
Comment

PREVIOUS NEXT
Code Example
Java :: minecraft java 
Java :: convert string to byte java 
Java :: how to change maven java version in po, 
Java :: java get current date without time 
Java :: java ModelMapper class 
Java :: how to change color page in latex 
Java :: app dashboard cardview click effect and animation android studio 
Java :: java string builder 
Java :: how to count lines from txt java 
Java :: Triangle Pattern In Java 
Java :: change drawable color programmatically android 
Java :: java number 
Java :: map string list string in java 
Java :: open camera in android 
Java :: java get constructor 
Java :: java parallel sort 
Java :: list to array java 
Java :: replace all punctuation in string java 
Java :: java resource file 
Java :: how to make an int into a string java 
Java :: data java 
Java :: reverse string using recursion java with explanation 
Java :: java xmx example 
Java :: java random guid 
Java :: jframe visibility 
Java :: selenium java wait for page load 
Java :: java datetime now 
Java :: add stringarrays to string list java 
Java :: check whether a double is not a number in java 
Java :: jframe change icon 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =