Example usage for org.hibernate.service.spi Wrapped unwrap

List of usage examples for org.hibernate.service.spi Wrapped unwrap

Introduction

In this page you can find the example usage for org.hibernate.service.spi Wrapped unwrap.

Prototype

public <T> T unwrap(Class<T> unwrapType);

Source Link

Document

Unproxy the service proxy

Usage

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;
}