Skip to content

Commit

Permalink
Bootstrap SessionFactory implements InfrastructureProxy interface for…
Browse files Browse the repository at this point in the history
… resource key unwrapping

Issue: SPR-14379
  • Loading branch information
jhoeller committed Jun 20, 2016
1 parent f9fec73 commit 01f1158
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -46,6 +46,7 @@
import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.engine.spi.SessionFactoryImplementor;

import org.springframework.core.InfrastructureProxy;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
Expand Down Expand Up @@ -317,7 +318,7 @@ private boolean matchesEntityTypeFilter(MetadataReader reader, MetadataReaderFac
public SessionFactory buildSessionFactory(AsyncTaskExecutor bootstrapExecutor) {
Assert.notNull(bootstrapExecutor, "AsyncTaskExecutor must not be null");
return (SessionFactory) Proxy.newProxyInstance(this.resourcePatternResolver.getClassLoader(),
new Class<?>[] {SessionFactoryImplementor.class},
new Class<?>[] {SessionFactoryImplementor.class, InfrastructureProxy.class},
new BootstrapSessionFactoryInvocationHandler(bootstrapExecutor));
}

Expand Down Expand Up @@ -354,6 +355,10 @@ else if (method.getName().equals("hashCode")) {
else if (method.getName().equals("getProperties")) {
return getProperties();
}
else if (method.getName().equals("getWrappedObject")) {
// Call coming in through InfrastructureProxy interface...
return getSessionFactory();
}
// Regular delegation to the target SessionFactory,
// enforcing its full initialization...
return method.invoke(getSessionFactory(), args);
Expand Down

0 comments on commit 01f1158

Please sign in to comment.