List of usage examples for org.hibernate.service.spi Wrapped unwrap
public <T> T unwrap(Class<T> unwrapType);
From source file:org.springframework.orm.hibernate4.SessionFactoryUtils.java
License:Apache License
/** * Determine the DataSource of the given SessionFactory. * @param sessionFactory the SessionFactory to check * @return the DataSource, or {@code null} if none found * @see org.hibernate.engine.spi.SessionFactoryImplementor#getConnectionProvider */// w w w . j a v a2s . com public static DataSource getDataSource(SessionFactory sessionFactory) { if (getConnectionProviderMethod != null && sessionFactory instanceof SessionFactoryImplementor) { Wrapped cp = (Wrapped) ReflectionUtils.invokeMethod(getConnectionProviderMethod, sessionFactory); if (cp != null) { return cp.unwrap(DataSource.class); } } return null; }