Class DataSourceUnwrapper
java.lang.Object
org.springframework.boot.jdbc.DataSourceUnwrapper
Unwraps a
DataSource that may have been proxied or wrapped in a custom
Wrapper such as DelegatingDataSource.- Since:
- 2.0.7
- Author:
- Tadaya Tsuyukubo, Stephane Nicoll
-
Method Summary
Modifier and TypeMethodDescriptionstatic <I, T extends I>
@Nullable Tunwrap(DataSource dataSource, Class<I> unwrapInterface, Class<T> target) Return an object that implements the giventargettype, unwrapping delegate or proxy if necessary using the specifiedunwrapInterface.static <T> @Nullable Tunwrap(DataSource dataSource, Class<T> target) Return an object that implements the giventargettype, unwrapping delegate or proxy if necessary.static DataSourceunwrapRoot(DataSource dataSource) Return the rootDataSourceby recursively unwrapping alldelegating, proxy, andWrapperlayers until no further unwrapping is possible.
-
Method Details
-
unwrap
public static <I, T extends I> @Nullable T unwrap(DataSource dataSource, Class<I> unwrapInterface, Class<T> target) Return an object that implements the giventargettype, unwrapping delegate or proxy if necessary using the specifiedunwrapInterface.- Type Parameters:
I- the interface that the target type must implementT- the target type- Parameters:
dataSource- the datasource to handleunwrapInterface- the interface that the target type must implementtarget- the type that the result must implement- Returns:
- an object that implements the target type or
null - Since:
- 2.3.8
- See Also:
-
unwrap
Return an object that implements the giventargettype, unwrapping delegate or proxy if necessary. Consider usingunwrap(DataSource, Class, Class)asunwrappingwon't be considered iftargetis not an interface.- Type Parameters:
T- the target type- Parameters:
dataSource- the datasource to handletarget- the type that the result must implement- Returns:
- an object that implements the target type or
null
-
unwrapRoot
Return the rootDataSourceby recursively unwrapping alldelegating, proxy, andWrapperlayers until no further unwrapping is possible.- Parameters:
dataSource- the datasource to unwrap- Returns:
- the root
DataSource - Since:
- 4.1.0
-