Class DataSourceUnwrapper

java.lang.Object
org.springframework.boot.jdbc.DataSourceUnwrapper

public final class DataSourceUnwrapper extends Object
Unwraps a DataSource that may have been proxied or wrapped in a custom Wrapper such as DelegatingDataSource.
Since:
2.0.7
  • Method Summary

    Modifier and Type
    Method
    Description
    static <I, T extends I>
    T
    unwrap(DataSource dataSource, Class<I> unwrapInterface, Class<T> target)
    Return an object that implements the given target type, unwrapping delegate or proxy if necessary using the specified unwrapInterface.
    static <T> T
    unwrap(DataSource dataSource, Class<T> target)
    Return an object that implements the given target type, unwrapping delegate or proxy if necessary.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • unwrap

      public static <I, T extends I> T unwrap(DataSource dataSource, Class<I> unwrapInterface, Class<T> target)
      Return an object that implements the given target type, unwrapping delegate or proxy if necessary using the specified unwrapInterface.
      Type Parameters:
      I - the interface that the target type must implement
      T - the target type
      Parameters:
      dataSource - the datasource to handle
      unwrapInterface - the interface that the target type must implement
      target - the type that the result must implement
      Returns:
      an object that implements the target type or null
      Since:
      2.3.8
      See Also:
    • unwrap

      public static <T> T unwrap(DataSource dataSource, Class<T> target)
      Return an object that implements the given target type, unwrapping delegate or proxy if necessary. Consider using unwrap(DataSource, Class, Class) as unwrapping won't be considered if target is not an interface.
      Type Parameters:
      T - the target type
      Parameters:
      dataSource - the datasource to handle
      target - the type that the result must implement
      Returns:
      an object that implements the target type or null