HHH-10664 - Prep 6.0 feature branch - merge hibernate-entitymanager into hibernate-core (added org.hibernate.boot.spi.SessionFactoryOptions.isJpaBootstrap)

This commit is contained in:
Steve Ebersole 2016-04-27 10:28:41 -05:00
parent 2d2e496e10
commit 8e6d51d56d
8 changed files with 45 additions and 2 deletions

View File

@ -475,6 +475,11 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
return new SessionFactoryImpl( metadata, buildSessionFactoryOptions() );
}
@Override
public void markAsJpaBootstrap(boolean jpaBootstrap) {
this.options.jpaBootstrap = jpaBootstrap;
}
@Override
public SessionFactoryOptions buildSessionFactoryOptions() {
return new SessionFactoryOptionsImpl( this );
@ -492,6 +497,7 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
private Object validatorFactoryReference;
// SessionFactory behavior
private boolean jpaBootstrap;
private String sessionFactoryName;
private boolean sessionFactoryNameAlsoJndiName;
@ -804,6 +810,11 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
return serviceRegistry;
}
@Override
public boolean isJpaBootstrap() {
return jpaBootstrap;
}
@Override
public Object getBeanManagerReference() {
return beanManagerReference;
@ -1085,6 +1096,11 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement
return options.getServiceRegistry();
}
@Override
public boolean isJpaBootstrap() {
return options.isJpaBootstrap();
}
@Override
public Object getBeanManagerReference() {
return options.getBeanManagerReference();

View File

@ -44,6 +44,7 @@ public class SessionFactoryOptionsImpl implements SessionFactoryOptions {
private final Object validatorFactoryReference;
// SessionFactory behavior
private boolean jpaBootstrap;
private final String sessionFactoryName;
private final boolean sessionFactoryNameAlsoJndiName;
@ -122,6 +123,7 @@ public class SessionFactoryOptionsImpl implements SessionFactoryOptions {
this.beanManagerReference = state.getBeanManagerReference();
this.validatorFactoryReference = state.getValidatorFactoryReference();
this.jpaBootstrap = state.isJpaBootstrap();
this.sessionFactoryName = state.getSessionFactoryName();
this.sessionFactoryNameAlsoJndiName = state.isSessionFactoryNameAlsoJndiName();
@ -190,6 +192,11 @@ public class SessionFactoryOptionsImpl implements SessionFactoryOptions {
return serviceRegistry;
}
@Override
public boolean isJpaBootstrap() {
return jpaBootstrap;
}
@Override
public Object getBeanManagerReference() {
return beanManagerReference;

View File

@ -38,6 +38,8 @@ import org.hibernate.tuple.entity.EntityTuplizerFactory;
public interface SessionFactoryOptionsState {
StandardServiceRegistry getServiceRegistry();
boolean isJpaBootstrap();
Object getBeanManagerReference();
Object getValidatorFactoryReference();

View File

@ -36,7 +36,7 @@ import org.hibernate.tuple.entity.EntityTuplizerFactory;
* @author Steve Ebersole
*/
@SuppressWarnings("unused")
public abstract class AbstractDelegatingSessionFactoryOptions implements SessionFactoryOptions {
public class AbstractDelegatingSessionFactoryOptions implements SessionFactoryOptions {
private final SessionFactoryOptions delegate;
public AbstractDelegatingSessionFactoryOptions(SessionFactoryOptions delegate) {
@ -48,6 +48,11 @@ public abstract class AbstractDelegatingSessionFactoryOptions implements Session
return delegate.getServiceRegistry();
}
@Override
public boolean isJpaBootstrap() {
return delegate.isJpaBootstrap();
}
@Override
public Object getBeanManagerReference() {
return delegate.getBeanManagerReference();
@ -323,4 +328,9 @@ public abstract class AbstractDelegatingSessionFactoryOptions implements Session
public boolean isPreferUserTransaction() {
return delegate.isPreferUserTransaction();
}
@Override
public Class<? extends Interceptor> getStatelessInterceptorImplementor() {
return delegate.getStatelessInterceptorImplementor();
}
}

View File

@ -15,5 +15,6 @@ import org.hibernate.boot.SessionFactoryBuilder;
* @author Steve Ebersole
*/
public interface SessionFactoryBuilderImplementor extends SessionFactoryBuilder {
public SessionFactoryOptions buildSessionFactoryOptions();
void markAsJpaBootstrap(boolean jpaBootstrap);
SessionFactoryOptions buildSessionFactoryOptions();
}

View File

@ -43,6 +43,8 @@ public interface SessionFactoryOptions {
*/
StandardServiceRegistry getServiceRegistry();
boolean isJpaBootstrap();
Object getBeanManagerReference();
Object getValidatorFactoryReference();

View File

@ -158,6 +158,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
private final String name;
private final String uuid;
private final boolean jpaBootstrap;
private transient boolean isClosed;
private final transient SessionFactoryObserverChain observer = new SessionFactoryObserverChain();
@ -220,6 +221,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
catch (Exception e) {
throw new AssertionFailure("Could not generate UUID");
}
this.jpaBootstrap = options.isJpaBootstrap();
final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );

View File

@ -48,6 +48,7 @@ import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.boot.spi.MetadataBuilderImplementor;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.boot.spi.SessionFactoryBuilderImplementor;
import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext;
import org.hibernate.bytecode.enhance.spi.EnhancementContext;
import org.hibernate.cfg.AttributeConverterDefinition;
@ -868,6 +869,8 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
}
protected void populate(SessionFactoryBuilder sfBuilder, StandardServiceRegistry ssr) {
( ( SessionFactoryBuilderImplementor) sfBuilder ).markAsJpaBootstrap( true );
final StrategySelector strategySelector = ssr.getService( StrategySelector.class );
// Locate and apply the requested SessionFactory-level interceptor (if one)