HHH-9492 - Migrate to new bootstrap API (MetadataSources, etc)
This commit is contained in:
parent
a92ddea9ca
commit
599c10cd5a
|
@ -48,9 +48,9 @@ If you wish to alter how the `BootstrapServiceRegistry` is built, you would use
|
|||
----
|
||||
BootstrapServiceRegistryBuilder bootstrapRegistryBuilder = new BootstrapServiceRegistryBuilder();
|
||||
// add a special ClassLoader
|
||||
bootstrapRegistryBuilder.with( mySpecialClassLoader );
|
||||
bootstrapRegistryBuilder.applyClassLoader( mySpecialClassLoader );
|
||||
// manually add an Integrator
|
||||
bootstrapRegistryBuilder.with( mySpecialIntegrator );
|
||||
bootstrapRegistryBuilder.applyIntegrator( mySpecialIntegrator );
|
||||
...
|
||||
|
||||
BootstrapServiceRegistry bootstrapRegistry = bootstrapRegistryBuilder.build();
|
||||
|
@ -188,10 +188,10 @@ over the `Metadata` building process. See its javadocs for full details.
|
|||
MetadataBuilder metadataBuilder = sources.getMetadataBuilder();
|
||||
|
||||
// Use the JPA-compliant implicit naming strategy
|
||||
metadataBuilder.with( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE );
|
||||
metadataBuilder.applyImplicitNamingStrategy( ImplicitNamingStrategyJpaCompliantImpl.INSTANCE );
|
||||
|
||||
// specify the schema name to use for tables, etc when none is explicitly specified
|
||||
metadataBuilder.withImplicitSchemaName( "my_default_schema" );
|
||||
metadataBuilder.applyImplicitSchemaName( "my_default_schema" );
|
||||
|
||||
Metadata metadata = metadataBuilder.build();
|
||||
----
|
||||
|
@ -213,13 +213,13 @@ over the `SessionFactory` building process.
|
|||
SessionFactoryBuilder sessionFactoryBuilder = metadata.getSessionFactoryBuilder();
|
||||
|
||||
// Supply an SessionFactory-level Interceptor
|
||||
sessionFactoryBuilder.with( new MySessionFactoryInterceptor() );
|
||||
sessionFactoryBuilder.applyInterceptor( new MySessionFactoryInterceptor() );
|
||||
|
||||
// Add a custom observer
|
||||
sessionFactoryBuilder.add( new MySessionFactoryObserver() );
|
||||
sessionFactoryBuilder.addSessionFactoryObservers( new MySessionFactoryObserver() );
|
||||
|
||||
// Apply a CDI BeanManager (for JPA event listeners)
|
||||
sessionFactoryBuilder.withBeanManager( getBeanManagerFromSomewhere() );
|
||||
sessionFactoryBuilder.applyBeanManager( getBeanManagerFromSomewhere() );
|
||||
|
||||
SessionFactory sessionFactory = sessionFactoryBuilder.build();
|
||||
----
|
||||
|
@ -234,4 +234,5 @@ over the `SessionFactory` building process.
|
|||
=== TypeContributor
|
||||
=== MetadataSourcesContributor
|
||||
=== MetadataBuilderContributor
|
||||
=== SessionFactoryBuilderContributor (todo)
|
||||
=== SessionFactoryBuilderContributor (todo)
|
||||
=== SessionFactoryObserver
|
|
@ -58,6 +58,14 @@ public class BootstrapServiceRegistryBuilder {
|
|||
|
||||
private boolean autoCloseRegistry = true;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #applyIntegrator} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public BootstrapServiceRegistryBuilder with(Integrator integrator) {
|
||||
return applyIntegrator( integrator );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link Integrator} to be applied to the bootstrap registry.
|
||||
*
|
||||
|
@ -65,11 +73,19 @@ public class BootstrapServiceRegistryBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public BootstrapServiceRegistryBuilder with(Integrator integrator) {
|
||||
public BootstrapServiceRegistryBuilder applyIntegrator(Integrator integrator) {
|
||||
providedIntegrators.add( integrator );
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #applyClassLoader} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public BootstrapServiceRegistryBuilder with(ClassLoader classLoader) {
|
||||
return applyClassLoader( classLoader );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a provided {@link ClassLoader} for use in class-loading and resource-lookup.
|
||||
*
|
||||
|
@ -77,7 +93,7 @@ public class BootstrapServiceRegistryBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public BootstrapServiceRegistryBuilder with(ClassLoader classLoader) {
|
||||
public BootstrapServiceRegistryBuilder applyClassLoader(ClassLoader classLoader) {
|
||||
if ( providedClassLoaders == null ) {
|
||||
providedClassLoaders = new ArrayList<ClassLoader>();
|
||||
}
|
||||
|
@ -85,6 +101,14 @@ public class BootstrapServiceRegistryBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #applyClassLoaderService} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public BootstrapServiceRegistryBuilder with(ClassLoaderService classLoaderService) {
|
||||
return applyClassLoaderService( classLoaderService );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a provided {@link ClassLoaderService} for use in class-loading and resource-lookup.
|
||||
*
|
||||
|
@ -92,69 +116,18 @@ public class BootstrapServiceRegistryBuilder {
|
|||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public BootstrapServiceRegistryBuilder with(ClassLoaderService classLoaderService) {
|
||||
public BootstrapServiceRegistryBuilder applyClassLoaderService(ClassLoaderService classLoaderService) {
|
||||
providedClassLoaderService = classLoaderService;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the specified {@link ClassLoader} as the application class loader for the bootstrap registry.
|
||||
*
|
||||
* @param classLoader The class loader to use
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @deprecated Use {@link #with(ClassLoader)} instead
|
||||
* @deprecated Use {@link #applyStrategySelector} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings( {"UnusedDeclaration"})
|
||||
public BootstrapServiceRegistryBuilder withApplicationClassLoader(ClassLoader classLoader) {
|
||||
return with( classLoader );
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the specified {@link ClassLoader} as the resource class loader for the bootstrap registry.
|
||||
*
|
||||
* @param classLoader The class loader to use
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @deprecated Use {@link #with(ClassLoader)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings( {"UnusedDeclaration"})
|
||||
public BootstrapServiceRegistryBuilder withResourceClassLoader(ClassLoader classLoader) {
|
||||
return with( classLoader );
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the specified {@link ClassLoader} as the Hibernate class loader for the bootstrap registry.
|
||||
*
|
||||
* @param classLoader The class loader to use
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @deprecated Use {@link #with(ClassLoader)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings( {"UnusedDeclaration"})
|
||||
public BootstrapServiceRegistryBuilder withHibernateClassLoader(ClassLoader classLoader) {
|
||||
return with( classLoader );
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the specified {@link ClassLoader} as the environment (or system) class loader for the bootstrap registry.
|
||||
*
|
||||
* @param classLoader The class loader to use
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*
|
||||
* @deprecated Use {@link #with(ClassLoader)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings( {"UnusedDeclaration"})
|
||||
public BootstrapServiceRegistryBuilder withEnvironmentClassLoader(ClassLoader classLoader) {
|
||||
return with( classLoader );
|
||||
public <T> BootstrapServiceRegistryBuilder withStrategySelector(Class<T> strategy, String name, Class<? extends T> implementation) {
|
||||
return applyStrategySelector( strategy, name, implementation );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,11 +144,20 @@ public class BootstrapServiceRegistryBuilder {
|
|||
* @see org.hibernate.boot.registry.selector.spi.StrategySelector#registerStrategyImplementor(Class, String, Class)
|
||||
*/
|
||||
@SuppressWarnings( {"UnusedDeclaration"})
|
||||
public <T> BootstrapServiceRegistryBuilder withStrategySelector(Class<T> strategy, String name, Class<? extends T> implementation) {
|
||||
public <T> BootstrapServiceRegistryBuilder applyStrategySelector(Class<T> strategy, String name, Class<? extends T> implementation) {
|
||||
this.strategySelectorBuilder.addExplicitStrategyRegistration( strategy, implementation, name );
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #applyStrategySelectors} instead
|
||||
*/
|
||||
@SuppressWarnings( {"UnusedDeclaration"})
|
||||
@Deprecated
|
||||
public BootstrapServiceRegistryBuilder withStrategySelectors(StrategyRegistrationProvider strategyRegistrationProvider) {
|
||||
return applyStrategySelectors( strategyRegistrationProvider );
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies one or more strategy selectors announced as available by the passed announcer.
|
||||
*
|
||||
|
@ -186,7 +168,7 @@ public class BootstrapServiceRegistryBuilder {
|
|||
* @see org.hibernate.boot.registry.selector.spi.StrategySelector#registerStrategyImplementor(Class, String, Class)
|
||||
*/
|
||||
@SuppressWarnings( {"UnusedDeclaration"})
|
||||
public BootstrapServiceRegistryBuilder withStrategySelectors(StrategyRegistrationProvider strategyRegistrationProvider) {
|
||||
public BootstrapServiceRegistryBuilder applyStrategySelectors(StrategyRegistrationProvider strategyRegistrationProvider) {
|
||||
for ( StrategyRegistration strategyRegistration : strategyRegistrationProvider.getStrategyRegistrations() ) {
|
||||
this.strategySelectorBuilder.addExplicitStrategyRegistration( strategyRegistration );
|
||||
}
|
||||
|
|
|
@ -332,7 +332,7 @@ public class StandardServiceRegistryBuilder {
|
|||
* @return The settings map.
|
||||
*
|
||||
* @deprecated Temporarily exposed since Configuration is still around and much code still uses Configuration.
|
||||
* This allows code to configure the builder and access that to configure Configuration object (used from HEM atm).
|
||||
* This allows code to configure the builder and access that to configure Configuration object.
|
||||
*/
|
||||
@Deprecated
|
||||
public Map getSettings() {
|
||||
|
|
|
@ -52,11 +52,6 @@ import org.hibernate.service.spi.Stoppable;
|
|||
* <li>{@link StrategySelector}</li>
|
||||
* </ul>
|
||||
*
|
||||
* IMPL NOTE : Currently implements the deprecated {@link org.hibernate.service.BootstrapServiceRegistry} contract
|
||||
* so that the registry returned from the builder works on the deprecated sense. Once
|
||||
* {@link org.hibernate.service.BootstrapServiceRegistry} goes away, this should be updated to instead implement
|
||||
* {@link org.hibernate.boot.registry.BootstrapServiceRegistry}.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BootstrapServiceRegistryImpl
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.service;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link org.hibernate.boot.registry.BootstrapServiceRegistry} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public interface BootstrapServiceRegistry extends org.hibernate.boot.registry.BootstrapServiceRegistry {
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.service;
|
||||
|
||||
import org.hibernate.integrator.spi.Integrator;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link org.hibernate.boot.registry.BootstrapServiceRegistryBuilder} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public class BootstrapServiceRegistryBuilder extends org.hibernate.boot.registry.BootstrapServiceRegistryBuilder {
|
||||
@Override
|
||||
public BootstrapServiceRegistryBuilder with(Integrator integrator) {
|
||||
super.with( integrator );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BootstrapServiceRegistryBuilder withApplicationClassLoader(ClassLoader classLoader) {
|
||||
super.withApplicationClassLoader( classLoader );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BootstrapServiceRegistryBuilder withResourceClassLoader(ClassLoader classLoader) {
|
||||
super.withResourceClassLoader( classLoader );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BootstrapServiceRegistryBuilder withHibernateClassLoader(ClassLoader classLoader) {
|
||||
super.withHibernateClassLoader( classLoader );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BootstrapServiceRegistryBuilder withEnvironmentClassLoader(ClassLoader classLoader) {
|
||||
super.withEnvironmentClassLoader( classLoader );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> BootstrapServiceRegistryBuilder withStrategySelector(Class<T> strategy, String name, Class<? extends T> implementation) {
|
||||
super.withStrategySelector( strategy, name, implementation );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BootstrapServiceRegistry build() {
|
||||
return (BootstrapServiceRegistry) super.build();
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2012, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.boot.registry.StandardServiceInitiator;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public class ServiceRegistryBuilder extends org.hibernate.boot.registry.StandardServiceRegistryBuilder {
|
||||
public ServiceRegistryBuilder() {
|
||||
super(); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public ServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry) {
|
||||
super( bootstrapServiceRegistry ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistryBuilder loadProperties(String resourceName) {
|
||||
super.loadProperties( resourceName );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistryBuilder configure() {
|
||||
super.configure();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistryBuilder configure(String resourceName) {
|
||||
super.configure( resourceName );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistryBuilder applySetting(String settingName, Object value) {
|
||||
super.applySetting( settingName, value );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistryBuilder applySettings(Map settings) {
|
||||
super.applySettings( settings );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) {
|
||||
super.addInitiator( initiator );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistryBuilder addService(Class serviceRole, Service service) {
|
||||
super.addService( serviceRole, service );
|
||||
return this;
|
||||
}
|
||||
|
||||
public StandardServiceRegistry build() {
|
||||
return super.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't remove yet: used by JBoss Tools
|
||||
*/
|
||||
public ServiceRegistry buildServiceRegistry() {
|
||||
return build();
|
||||
}
|
||||
|
||||
}
|
|
@ -23,7 +23,6 @@
|
|||
*/
|
||||
package org.hibernate.dialect.resolver;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -47,7 +46,6 @@ import org.hibernate.dialect.H2Dialect;
|
|||
import org.hibernate.dialect.HSQLDialect;
|
||||
import org.hibernate.dialect.InformixDialect;
|
||||
import org.hibernate.dialect.IngresDialect;
|
||||
import org.hibernate.dialect.Mocks;
|
||||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
import org.hibernate.dialect.MySQLDialect;
|
||||
import org.hibernate.dialect.Oracle10gDialect;
|
||||
|
@ -69,11 +67,10 @@ import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfoSource;
|
|||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
@ -87,7 +84,9 @@ public class DialectFactoryTest extends BaseUnitTestCase {
|
|||
|
||||
@Before
|
||||
public void setUp() {
|
||||
final BootstrapServiceRegistry bootReg = new BootstrapServiceRegistryBuilder().with( DialectFactoryTest.class.getClassLoader() ).build();
|
||||
final BootstrapServiceRegistry bootReg = new BootstrapServiceRegistryBuilder().applyClassLoader(
|
||||
DialectFactoryTest.class.getClassLoader()
|
||||
).build();
|
||||
registry = new StandardServiceRegistryBuilder( bootReg ).build();
|
||||
|
||||
dialectFactory = new DialectFactoryImpl();
|
||||
|
|
|
@ -74,7 +74,7 @@ public class MergeCollectionEventTest extends BaseCoreFunctionalTestCase {
|
|||
@Override
|
||||
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
|
||||
super.prepareBootstrapRegistryBuilder( builder );
|
||||
builder.with( collectionListenerIntegrator );
|
||||
builder.applyIntegrator( collectionListenerIntegrator );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -67,7 +67,7 @@ public class CallbackTest extends BaseCoreFunctionalTestCase {
|
|||
@Override
|
||||
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
|
||||
super.prepareBootstrapRegistryBuilder( builder );
|
||||
builder.with(
|
||||
builder.applyIntegrator(
|
||||
new Integrator() {
|
||||
@Override
|
||||
public void integrate(
|
||||
|
@ -77,10 +77,13 @@ public class CallbackTest extends BaseCoreFunctionalTestCase {
|
|||
integrate( serviceRegistry );
|
||||
}
|
||||
|
||||
private void integrate( SessionFactoryServiceRegistry serviceRegistry ) {
|
||||
serviceRegistry.getService( EventListenerRegistry.class ).setListeners(EventType.DELETE, listener);
|
||||
listener.initialize();
|
||||
}
|
||||
private void integrate(SessionFactoryServiceRegistry serviceRegistry) {
|
||||
serviceRegistry.getService( EventListenerRegistry.class ).setListeners(
|
||||
EventType.DELETE,
|
||||
listener
|
||||
);
|
||||
listener.initialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disintegrate(
|
||||
|
|
|
@ -83,7 +83,7 @@ public class ClearEventListenerTest extends BaseCoreFunctionalTestCase {
|
|||
@Override
|
||||
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
|
||||
super.prepareBootstrapRegistryBuilder( builder );
|
||||
builder.with(
|
||||
builder.applyIntegrator(
|
||||
new Integrator() {
|
||||
@Override
|
||||
public void integrate(
|
||||
|
@ -93,7 +93,7 @@ public class ClearEventListenerTest extends BaseCoreFunctionalTestCase {
|
|||
integrate( serviceRegistry );
|
||||
}
|
||||
|
||||
private void integrate( SessionFactoryServiceRegistry serviceRegistry ) {
|
||||
private void integrate(SessionFactoryServiceRegistry serviceRegistry) {
|
||||
serviceRegistry.getService( EventListenerRegistry.class ).setListeners(
|
||||
EventType.CLEAR,
|
||||
listener
|
||||
|
|
|
@ -43,7 +43,7 @@ public class LegacyPostCommitListenerTest extends BaseCoreFunctionalTestCase {
|
|||
@Override
|
||||
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
|
||||
super.prepareBootstrapRegistryBuilder( builder );
|
||||
builder.with(
|
||||
builder.applyIntegrator(
|
||||
new Integrator() {
|
||||
@Override
|
||||
public void integrate(
|
||||
|
|
|
@ -49,7 +49,7 @@ public class PostCommitListenerTest extends BaseCoreFunctionalTestCase {
|
|||
@Override
|
||||
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
|
||||
super.prepareBootstrapRegistryBuilder( builder );
|
||||
builder.with(
|
||||
builder.applyIntegrator(
|
||||
new Integrator() {
|
||||
@Override
|
||||
public void integrate(
|
||||
|
|
|
@ -226,7 +226,7 @@ public class TestAutoFlushBeforeQueryExecution extends BaseCoreFunctionalTestCas
|
|||
@Override
|
||||
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
|
||||
super.prepareBootstrapRegistryBuilder( builder );
|
||||
builder.with(
|
||||
builder.applyIntegrator(
|
||||
new Integrator() {
|
||||
@Override
|
||||
public void integrate(
|
||||
|
|
|
@ -89,7 +89,7 @@ public class TestCollectionInitializingDuringFlush extends BaseCoreFunctionalTes
|
|||
@Override
|
||||
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
|
||||
super.prepareBootstrapRegistryBuilder( builder );
|
||||
builder.with(
|
||||
builder.applyIntegrator(
|
||||
new Integrator() {
|
||||
@Override
|
||||
public void integrate(
|
||||
|
|
|
@ -71,7 +71,7 @@ public abstract class AbstractJPATest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
@Override
|
||||
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
|
||||
builder.with(
|
||||
builder.applyIntegrator(
|
||||
new Integrator() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -64,7 +64,7 @@ public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
|
|||
@Override
|
||||
protected void prepareBootstrapRegistryBuilder(BootstrapServiceRegistryBuilder builder) {
|
||||
super.prepareBootstrapRegistryBuilder( builder );
|
||||
builder.with(
|
||||
builder.applyIntegrator(
|
||||
new Integrator() {
|
||||
@Override
|
||||
public void integrate(
|
||||
|
@ -74,10 +74,12 @@ public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
|
|||
integrate( serviceRegistry );
|
||||
}
|
||||
|
||||
private void integrate( SessionFactoryServiceRegistry serviceRegistry ) {
|
||||
serviceRegistry.getService( EventListenerRegistry.class ).prependListeners(EventType.LOAD,
|
||||
new CustomLoadListener());
|
||||
}
|
||||
private void integrate(SessionFactoryServiceRegistry serviceRegistry) {
|
||||
serviceRegistry.getService( EventListenerRegistry.class ).prependListeners(
|
||||
EventType.LOAD,
|
||||
new CustomLoadListener()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disintegrate(
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
package org.hibernate.test.service;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
||||
|
@ -20,10 +15,15 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
|||
import org.hibernate.integrator.spi.Integrator;
|
||||
import org.hibernate.internal.util.ConfigHelper;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
/**
|
||||
* @author Artem V. Navrotskiy
|
||||
* @author Emmanuel Bernard <emmanuel@hibernate.org>
|
||||
|
@ -62,7 +62,7 @@ public class ClassLoaderServiceImplTest {
|
|||
@TestForIssue(jiraKey = "HHH-8363")
|
||||
public void testStoppableClassLoaderService() {
|
||||
final BootstrapServiceRegistryBuilder bootstrapBuilder = new BootstrapServiceRegistryBuilder();
|
||||
bootstrapBuilder.with( new TestClassLoader() );
|
||||
bootstrapBuilder.applyClassLoader( new TestClassLoader() );
|
||||
final ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder( bootstrapBuilder.build() ).build();
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
|
||||
|
|
|
@ -244,12 +244,12 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
|||
Map integrationSettings,
|
||||
ClassLoader providedClassLoader) {
|
||||
final BootstrapServiceRegistryBuilder bsrBuilder = new BootstrapServiceRegistryBuilder();
|
||||
bsrBuilder.with( new JpaIntegrator() );
|
||||
bsrBuilder.applyIntegrator( new JpaIntegrator() );
|
||||
|
||||
final IntegratorProvider integratorProvider = (IntegratorProvider) integrationSettings.get( INTEGRATOR_PROVIDER );
|
||||
if ( integratorProvider != null ) {
|
||||
for ( Integrator integrator : integratorProvider.getIntegrators() ) {
|
||||
bsrBuilder.with( integrator );
|
||||
bsrBuilder.applyIntegrator( integrator );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,11 +266,11 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
|||
// ClassLoaders ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if ( persistenceUnit.getClassLoader() != null ) {
|
||||
bsrBuilder.with( persistenceUnit.getClassLoader() );
|
||||
bsrBuilder.applyClassLoader( persistenceUnit.getClassLoader() );
|
||||
}
|
||||
|
||||
if ( providedClassLoader != null ) {
|
||||
bsrBuilder.with( providedClassLoader );
|
||||
bsrBuilder.applyClassLoader( providedClassLoader );
|
||||
}
|
||||
|
||||
final ClassLoader appClassLoader = (ClassLoader) integrationSettings.get( org.hibernate.cfg.AvailableSettings.APP_CLASSLOADER );
|
||||
|
@ -285,16 +285,16 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
|||
if ( classLoadersSetting != null ) {
|
||||
if ( java.util.Collection.class.isInstance( classLoadersSetting ) ) {
|
||||
for ( ClassLoader classLoader : (java.util.Collection<ClassLoader>) classLoadersSetting ) {
|
||||
bsrBuilder.with( classLoader );
|
||||
bsrBuilder.applyClassLoader( classLoader );
|
||||
}
|
||||
}
|
||||
else if ( classLoadersSetting.getClass().isArray() ) {
|
||||
for ( ClassLoader classLoader : (ClassLoader[]) classLoadersSetting ) {
|
||||
bsrBuilder.with( classLoader );
|
||||
bsrBuilder.applyClassLoader( classLoader );
|
||||
}
|
||||
}
|
||||
else if ( ClassLoader.class.isInstance( classLoadersSetting ) ) {
|
||||
bsrBuilder.with( (ClassLoader) classLoadersSetting );
|
||||
bsrBuilder.applyClassLoader( (ClassLoader) classLoadersSetting );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,11 +89,11 @@ public class OsgiSessionFactoryService implements ServiceFactory {
|
|||
osgiClassLoader.addBundle( requestingBundle );
|
||||
|
||||
final BootstrapServiceRegistryBuilder bsrBuilder = new BootstrapServiceRegistryBuilder();
|
||||
bsrBuilder.with( new OSGiClassLoaderServiceImpl( osgiClassLoader, osgiServiceUtil ) );
|
||||
bsrBuilder.applyClassLoaderService( new OSGiClassLoaderServiceImpl( osgiClassLoader, osgiServiceUtil ) );
|
||||
|
||||
final Integrator[] integrators = osgiServiceUtil.getServiceImpls( Integrator.class );
|
||||
for ( Integrator integrator : integrators ) {
|
||||
bsrBuilder.with( integrator );
|
||||
bsrBuilder.applyIntegrator( integrator );
|
||||
}
|
||||
|
||||
final StrategyRegistrationProvider[] strategyRegistrationProviders
|
||||
|
|
Loading…
Reference in New Issue