code: public static DataSource wrapSpatialDataSource(DataSource dataSource) {
          try {
              if(dataSource.isWrapperFor(DataSourceWrapper.class)) {
                  return dataSource;
              } else {
                  return new DataSourceWrapper(dataSource);
              }
          } catch (SQLException ex) {
              return new DataSourceWrapper(dataSource);
          }
      }
docs: In order to be able to use {@link ResultSet#unwrap(Class)} and
  {@link java.sql.ResultSetMetaData#unwrap(Class)} to get {@link SpatialResultSet} and
  {@link SpatialResultSetMetaData} this method wrap the provided dataSource.
  
  @param dataSource H2 or PostGIS DataSource
  
  @return Wrapped DataSource, with spatial methods