From 53e043988049e46b64207f49d3f03a629e8f81e1 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 20 Apr 2011 15:58:10 -0500 Subject: [PATCH] HHH-6144 - Introduce ServiceRegistryBuilder --- .../action/internal/CollectionAction.java | 4 +- .../internal/CollectionRecreateAction.java | 2 +- .../internal/CollectionRemoveAction.java | 2 +- .../internal/CollectionUpdateAction.java | 5 +- .../action/internal/EntityAction.java | 4 +- .../action/internal/EntityDeleteAction.java | 3 +- .../internal/EntityIdentityInsertAction.java | 2 +- .../action/internal/EntityInsertAction.java | 4 +- .../action/internal/EntityUpdateAction.java | 2 +- .../org/hibernate/cache/entry/CacheEntry.java | 4 +- .../java/org/hibernate/cfg/Configuration.java | 3 +- .../BeanValidationIntegrator.java | 4 +- .../DuplicationStrategyImpl.java | 2 +- .../cfg/beanvalidation/TypeSafeActivator.java | 2 +- .../cfg/search/HibernateSearchIntegrator.java | 6 +- .../org/hibernate/engine/TwoPhaseLoad.java | 4 +- .../def/AbstractFlushingEventListener.java | 4 +- .../event/def/DefaultLoadEventListener.java | 2 +- .../internal/EventListenerGroupImpl.java | 9 ++- .../internal/EventListenerRegistryImpl.java | 29 ++------ .../EventListenerServiceInitiator.java | 6 +- .../service}/spi/DuplicationStrategy.java | 2 +- .../service}/spi/EventListenerGroup.java | 2 +- .../EventListenerRegistrationException.java | 2 +- .../service}/spi/EventListenerRegistry.java | 2 +- .../hibernate/impl/SessionFactoryImpl.java | 25 ++----- .../java/org/hibernate/impl/SessionImpl.java | 4 +- .../internal/IntegratorServiceImpl.java | 66 +++++++++++++++++ .../internal/IntegratorServiceInitiator.java} | 28 ++++---- .../{ => integrator}/spi/Integrator.java | 2 +- .../integrator/spi/IntegratorService.java | 47 ++++++++++++ .../org/hibernate/jmx/HibernateService.java | 18 +++-- .../service/ServiceRegistryBuilder.java | 71 +++++++++++++++++++ .../service/StandardServiceInitiators.java | 48 +------------ ...andardSessionFactoryServiceInitiators.java | 2 +- .../internal/BasicServiceRegistryImpl.java | 20 ++++-- .../ProvidedService.java} | 30 ++++---- ...sionFactoryServiceRegistryFactoryImpl.java | 3 - .../SessionFactoryServiceRegistryFactory.java | 2 - .../hibernate/tool/hbm2ddl/SchemaExport.java | 3 +- .../hibernate/tool/hbm2ddl/SchemaUpdate.java | 3 +- .../tool/hbm2ddl/SchemaValidator.java | 3 +- .../tuple/entity/AbstractEntityTuplizer.java | 2 +- .../binding/AbstractBasicBindingTests.java | 11 ++- .../binding/BasicAnnotationBindingTests.java | 7 +- .../global/FetchProfileBinderTest.java | 12 ++-- .../ConfiguredClassHierarchyBuilderTest.java | 3 +- .../annotations/xml/OrmXmlParserTests.java | 5 +- .../event/collection/CollectionListeners.java | 2 +- .../hibernate/test/events/CallbackTest.java | 31 ++++---- ...TestCollectionInitializingDuringFlush.java | 31 ++++---- .../test/jdbc/proxies/BatchingTest.java | 8 +-- .../hibernate/test/jpa/AbstractJPATest.java | 31 ++++---- .../component/EagerKeyManyToOneTest.java | 32 +++++---- .../schema/SchemaBasedMultiTenancyTest.java | 9 ++- .../service/ServiceBootstrappingTest.java | 10 ++- .../transaction/jdbc/TestExpectedUsage.java | 21 +++--- .../transaction/jta/BasicDrivingTest.java | 3 +- .../transaction/jta/ManagedDrivingTest.java | 5 +- .../org/hibernate/ejb/Ejb3Configuration.java | 12 ++-- ...erRegistration.java => JpaIntegrator.java} | 34 ++++----- .../BaseEntityManagerFunctionalTestCase.java | 3 +- .../packaging/PackagedEntityManagerTest.java | 2 +- .../hibernate/envers/AuditReaderFactory.java | 2 +- .../envers/event/EnversIntegrator.java | 4 +- .../EnversListenerDuplicationStrategy.java | 2 +- .../envers/test/AbstractEntityTest.java | 3 +- .../AbstractGeneralDataRegionTestCase.java | 10 +-- .../cache/infinispan/NodeEnvironment.java | 3 +- .../query/QueryRegionImplTestCase.java | 5 +- .../TimestampsRegionImplTestCase.java | 5 +- .../testing/ServiceRegistryBuilder.java | 2 +- .../junit4/BaseCoreFunctionalTestCase.java | 2 +- 73 files changed, 468 insertions(+), 330 deletions(-) rename hibernate-core/src/main/java/org/hibernate/{service/event => event/service}/internal/EventListenerGroupImpl.java (94%) rename hibernate-core/src/main/java/org/hibernate/{service/event => event/service}/internal/EventListenerRegistryImpl.java (90%) rename hibernate-core/src/main/java/org/hibernate/{service/event => event/service}/internal/EventListenerServiceInitiator.java (89%) rename hibernate-core/src/main/java/org/hibernate/{service/event => event/service}/spi/DuplicationStrategy.java (97%) rename hibernate-core/src/main/java/org/hibernate/{service/event => event/service}/spi/EventListenerGroup.java (98%) rename hibernate-core/src/main/java/org/hibernate/{service/event => event/service}/spi/EventListenerRegistrationException.java (97%) rename hibernate-core/src/main/java/org/hibernate/{service/event => event/service}/spi/EventListenerRegistry.java (98%) create mode 100644 hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java rename hibernate-core/src/main/java/org/hibernate/{event/EventListenerRegistration.java => integrator/internal/IntegratorServiceInitiator.java} (65%) rename hibernate-core/src/main/java/org/hibernate/{ => integrator}/spi/Integrator.java (98%) create mode 100644 hibernate-core/src/main/java/org/hibernate/integrator/spi/IntegratorService.java create mode 100644 hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java rename hibernate-core/src/main/java/org/hibernate/service/{event/internal/TemporaryListenerHelper.java => internal/ProvidedService.java} (59%) rename hibernate-entitymanager/src/main/java/org/hibernate/ejb/event/{JpaEventListenerRegistration.java => JpaIntegrator.java} (87%) diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionAction.java index eade926163..ec3ec06f46 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionAction.java @@ -38,8 +38,8 @@ import org.hibernate.event.EventType; import org.hibernate.internal.util.StringHelper; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.pretty.MessageHelper; -import org.hibernate.service.event.spi.EventListenerGroup; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerRegistry; /** * Any action relating to insert/update/delete of a collection diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRecreateAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRecreateAction.java index c0a70e56c1..773077bcce 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRecreateAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRecreateAction.java @@ -35,7 +35,7 @@ import org.hibernate.event.PostCollectionRecreateEventListener; import org.hibernate.event.PreCollectionRecreateEvent; import org.hibernate.event.PreCollectionRecreateEventListener; import org.hibernate.persister.collection.CollectionPersister; -import org.hibernate.service.event.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerGroup; public final class CollectionRecreateAction extends CollectionAction { diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRemoveAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRemoveAction.java index 77bac41205..b56607faf6 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRemoveAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRemoveAction.java @@ -35,7 +35,7 @@ import org.hibernate.event.PostCollectionRemoveEventListener; import org.hibernate.event.PreCollectionRemoveEvent; import org.hibernate.event.PreCollectionRemoveEventListener; import org.hibernate.persister.collection.CollectionPersister; -import org.hibernate.service.event.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerGroup; public final class CollectionRemoveAction extends CollectionAction { diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionUpdateAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionUpdateAction.java index 4b5b08986b..93907573b7 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionUpdateAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/CollectionUpdateAction.java @@ -29,17 +29,14 @@ import org.hibernate.AssertionFailure; import org.hibernate.HibernateException; import org.hibernate.collection.PersistentCollection; import org.hibernate.engine.SessionImplementor; -import org.hibernate.event.EventSource; import org.hibernate.event.EventType; import org.hibernate.event.PostCollectionUpdateEvent; import org.hibernate.event.PostCollectionUpdateEventListener; -import org.hibernate.event.PreCollectionRemoveEvent; -import org.hibernate.event.PreCollectionRemoveEventListener; import org.hibernate.event.PreCollectionUpdateEvent; import org.hibernate.event.PreCollectionUpdateEventListener; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.pretty.MessageHelper; -import org.hibernate.service.event.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerGroup; public final class CollectionUpdateAction extends CollectionAction { diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java index 606a97d67c..0791105a9b 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java @@ -35,8 +35,8 @@ import org.hibernate.event.EventType; import org.hibernate.internal.util.StringHelper; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.pretty.MessageHelper; -import org.hibernate.service.event.spi.EventListenerGroup; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerRegistry; /** * Base class for actions relating to insert/update/delete of an entity diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityDeleteAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityDeleteAction.java index 833ff2123d..7adba234f2 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityDeleteAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityDeleteAction.java @@ -32,14 +32,13 @@ import org.hibernate.cache.access.SoftLock; import org.hibernate.engine.EntityEntry; import org.hibernate.engine.PersistenceContext; import org.hibernate.engine.SessionImplementor; -import org.hibernate.event.EventSource; import org.hibernate.event.EventType; import org.hibernate.event.PostDeleteEvent; import org.hibernate.event.PostDeleteEventListener; import org.hibernate.event.PreDeleteEvent; import org.hibernate.event.PreDeleteEventListener; import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.service.event.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerGroup; public final class EntityDeleteAction extends EntityAction { private final Object version; diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityIdentityInsertAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityIdentityInsertAction.java index c36731f3f0..9b70a7c34a 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityIdentityInsertAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityIdentityInsertAction.java @@ -36,7 +36,7 @@ import org.hibernate.event.PostInsertEventListener; import org.hibernate.event.PreInsertEvent; import org.hibernate.event.PreInsertEventListener; import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.service.event.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerGroup; public final class EntityIdentityInsertAction extends EntityAction { diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityInsertAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityInsertAction.java index 1d29eb47d6..c9fccab70a 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityInsertAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityInsertAction.java @@ -33,15 +33,13 @@ import org.hibernate.engine.EntityEntry; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.SessionImplementor; import org.hibernate.engine.Versioning; -import org.hibernate.event.EventSource; import org.hibernate.event.EventType; import org.hibernate.event.PostInsertEvent; import org.hibernate.event.PostInsertEventListener; import org.hibernate.event.PreInsertEvent; import org.hibernate.event.PreInsertEventListener; import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.service.event.spi.EventListenerGroup; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerGroup; public final class EntityInsertAction extends EntityAction { diff --git a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java index 6c2275e39c..3c5036cfa0 100644 --- a/hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java +++ b/hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java @@ -42,7 +42,7 @@ import org.hibernate.event.PostUpdateEventListener; import org.hibernate.event.PreUpdateEvent; import org.hibernate.event.PreUpdateEventListener; import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.service.event.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerGroup; import org.hibernate.type.TypeHelper; public final class EntityUpdateAction extends EntityAction { diff --git a/hibernate-core/src/main/java/org/hibernate/cache/entry/CacheEntry.java b/hibernate-core/src/main/java/org/hibernate/cache/entry/CacheEntry.java index 51ad7ab088..bb7ec2c92b 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/entry/CacheEntry.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/entry/CacheEntry.java @@ -35,8 +35,8 @@ import org.hibernate.event.PreLoadEvent; import org.hibernate.event.PreLoadEventListener; import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.service.event.spi.EventListenerGroup; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.type.TypeHelper; /** diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java index 31feee59b5..e388e200a8 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java @@ -130,6 +130,7 @@ import org.hibernate.mapping.UniqueKey; import org.hibernate.proxy.EntityNotFoundDelegate; import org.hibernate.secure.JACCConfiguration; import org.hibernate.service.ServiceRegistry; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.hibernate.tool.hbm2ddl.DatabaseMetadata; import org.hibernate.tool.hbm2ddl.IndexMetadata; @@ -1744,7 +1745,7 @@ public class Configuration implements Serializable { public SessionFactory buildSessionFactory() throws HibernateException { Environment.verifyProperties( properties ); ConfigurationHelper.resolvePlaceHolders( properties ); - final ServiceRegistry serviceRegistry = new BasicServiceRegistryImpl( properties ); + final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder( properties ).buildServiceRegistry(); setSessionFactoryObserver( new SessionFactoryObserver() { @Override diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java index aaca83f799..8865fa6bb0 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java @@ -33,14 +33,14 @@ import java.util.Set; import org.jboss.logging.Logger; import org.hibernate.HibernateException; +import org.hibernate.integrator.spi.Integrator; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.engine.SessionFactoryImplementor; -import org.hibernate.spi.Integrator; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.service.spi.SessionFactoryServiceRegistry; /** diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/DuplicationStrategyImpl.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/DuplicationStrategyImpl.java index 68d747b6a5..c86e79018c 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/DuplicationStrategyImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/DuplicationStrategyImpl.java @@ -23,7 +23,7 @@ */ package org.hibernate.cfg.beanvalidation; -import org.hibernate.service.event.spi.DuplicationStrategy; +import org.hibernate.event.service.spi.DuplicationStrategy; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java index ae49adadde..2dd6ce5c75 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java @@ -57,7 +57,7 @@ import org.hibernate.mapping.Component; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; import org.hibernate.mapping.SingleTableSubclass; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; /** * @author Emmanuel Bernard diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/search/HibernateSearchIntegrator.java b/hibernate-core/src/main/java/org/hibernate/cfg/search/HibernateSearchIntegrator.java index 0116060bad..126f4017d3 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/search/HibernateSearchIntegrator.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/search/HibernateSearchIntegrator.java @@ -36,11 +36,11 @@ import org.hibernate.event.PostCollectionUpdateEventListener; import org.hibernate.event.PostDeleteEventListener; import org.hibernate.event.PostInsertEventListener; import org.hibernate.event.PostUpdateEventListener; -import org.hibernate.spi.Integrator; +import org.hibernate.integrator.spi.Integrator; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.event.spi.DuplicationStrategy; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.DuplicationStrategy; +import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.service.spi.SessionFactoryServiceRegistry; /** diff --git a/hibernate-core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java b/hibernate-core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java index 89ee2e4a21..eea9204636 100755 --- a/hibernate-core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/TwoPhaseLoad.java @@ -44,8 +44,8 @@ import org.hibernate.persister.entity.EntityPersister; import org.hibernate.pretty.MessageHelper; import org.hibernate.property.BackrefPropertyAccessor; import org.hibernate.proxy.HibernateProxy; -import org.hibernate.service.event.spi.EventListenerGroup; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.type.Type; import org.hibernate.type.TypeHelper; diff --git a/hibernate-core/src/main/java/org/hibernate/event/def/AbstractFlushingEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/def/AbstractFlushingEventListener.java index 272aba4a38..c0b0c14dd3 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/def/AbstractFlushingEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/def/AbstractFlushingEventListener.java @@ -56,8 +56,8 @@ import org.hibernate.internal.util.collections.IdentityMap; import org.hibernate.internal.util.collections.LazyIterator; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.pretty.Printer; -import org.hibernate.service.event.spi.EventListenerGroup; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerRegistry; /** * A convenience base class for listeners whose functionality results in flushing. diff --git a/hibernate-core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java index b4e0000801..9ceed6463f 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/def/DefaultLoadEventListener.java @@ -55,7 +55,7 @@ import org.hibernate.persister.entity.EntityPersister; import org.hibernate.pretty.MessageHelper; import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.LazyInitializer; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.type.EmbeddedComponentType; import org.hibernate.type.EntityType; import org.hibernate.type.Type; diff --git a/hibernate-core/src/main/java/org/hibernate/service/event/internal/EventListenerGroupImpl.java b/hibernate-core/src/main/java/org/hibernate/event/service/internal/EventListenerGroupImpl.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/service/event/internal/EventListenerGroupImpl.java rename to hibernate-core/src/main/java/org/hibernate/event/service/internal/EventListenerGroupImpl.java index 0d49c518d9..c099edcd90 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/event/internal/EventListenerGroupImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/event/service/internal/EventListenerGroupImpl.java @@ -21,9 +21,8 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.event.internal; +package org.hibernate.event.service.internal; -import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; @@ -32,9 +31,9 @@ import java.util.ListIterator; import java.util.Set; import org.hibernate.event.EventType; -import org.hibernate.service.event.spi.DuplicationStrategy; -import org.hibernate.service.event.spi.EventListenerGroup; -import org.hibernate.service.event.spi.EventListenerRegistrationException; +import org.hibernate.event.service.spi.DuplicationStrategy; +import org.hibernate.event.service.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerRegistrationException; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/service/event/internal/EventListenerRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/event/service/internal/EventListenerRegistryImpl.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/service/event/internal/EventListenerRegistryImpl.java rename to hibernate-core/src/main/java/org/hibernate/event/service/internal/EventListenerRegistryImpl.java index 0b88b9bfd5..b96bb46b9f 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/event/internal/EventListenerRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/event/service/internal/EventListenerRegistryImpl.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.event.internal; +package org.hibernate.event.service.internal; import java.lang.reflect.Array; import java.util.Collections; @@ -29,9 +29,6 @@ import java.util.HashMap; import java.util.Map; import org.hibernate.HibernateException; -import org.hibernate.cfg.Configuration; -import org.hibernate.engine.SessionFactoryImplementor; -import org.hibernate.event.EventListenerRegistration; import org.hibernate.event.EventType; import org.hibernate.event.def.DefaultAutoFlushEventListener; import org.hibernate.event.def.DefaultDeleteEventListener; @@ -52,11 +49,9 @@ import org.hibernate.event.def.DefaultReplicateEventListener; import org.hibernate.event.def.DefaultSaveEventListener; import org.hibernate.event.def.DefaultSaveOrUpdateEventListener; import org.hibernate.event.def.DefaultUpdateEventListener; -import org.hibernate.service.event.spi.DuplicationStrategy; -import org.hibernate.service.event.spi.EventListenerRegistrationException; -import org.hibernate.service.event.spi.EventListenerRegistry; -import org.hibernate.service.spi.ServiceRegistryImplementor; -import org.hibernate.service.StandardServiceInitiators.EventListenerRegistrationService; +import org.hibernate.event.service.spi.DuplicationStrategy; +import org.hibernate.event.service.spi.EventListenerRegistrationException; +import org.hibernate.event.service.spi.EventListenerRegistry; import static org.hibernate.event.EventType.AUTO_FLUSH; import static org.hibernate.event.EventType.DELETE; @@ -425,20 +420,4 @@ public class EventListenerRegistryImpl implements EventListenerRegistry { map.put( type, listeners ); } - public static EventListenerRegistryImpl buildEventListenerRegistry( - SessionFactoryImplementor sessionFactory, - Configuration configuration, - ServiceRegistryImplementor serviceRegistry) { - final EventListenerRegistryImpl registry = new EventListenerRegistryImpl(); - - final EventListenerRegistrationService registrationService = serviceRegistry.getService( - EventListenerRegistrationService.class - ); - for ( EventListenerRegistration registration : registrationService.getEventListenerRegistrations() ) { - registration.apply( registry, configuration, configuration.getProperties(), serviceRegistry ); - } - - return registry; - } - } diff --git a/hibernate-core/src/main/java/org/hibernate/service/event/internal/EventListenerServiceInitiator.java b/hibernate-core/src/main/java/org/hibernate/event/service/internal/EventListenerServiceInitiator.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/service/event/internal/EventListenerServiceInitiator.java rename to hibernate-core/src/main/java/org/hibernate/event/service/internal/EventListenerServiceInitiator.java index 0479485c34..6bf781a768 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/event/internal/EventListenerServiceInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/event/service/internal/EventListenerServiceInitiator.java @@ -21,11 +21,11 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.event.internal; +package org.hibernate.event.service.internal; import org.hibernate.cfg.Configuration; import org.hibernate.engine.SessionFactoryImplementor; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.SessionFactoryServiceInitiator; @@ -47,7 +47,7 @@ public class EventListenerServiceInitiator implements SessionFactoryServiceIniti SessionFactoryImplementor sessionFactory, Configuration configuration, ServiceRegistryImplementor registry) { - return EventListenerRegistryImpl.buildEventListenerRegistry( sessionFactory, configuration, registry ); + return new EventListenerRegistryImpl(); } } \ No newline at end of file diff --git a/hibernate-core/src/main/java/org/hibernate/service/event/spi/DuplicationStrategy.java b/hibernate-core/src/main/java/org/hibernate/event/service/spi/DuplicationStrategy.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/service/event/spi/DuplicationStrategy.java rename to hibernate-core/src/main/java/org/hibernate/event/service/spi/DuplicationStrategy.java index 18da5d3f35..8f8ed93db4 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/event/spi/DuplicationStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/event/service/spi/DuplicationStrategy.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.event.spi; +package org.hibernate.event.service.spi; /** * Defines listener duplication checking strategy, both in terms of when a duplication is detected (see diff --git a/hibernate-core/src/main/java/org/hibernate/service/event/spi/EventListenerGroup.java b/hibernate-core/src/main/java/org/hibernate/event/service/spi/EventListenerGroup.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/event/spi/EventListenerGroup.java rename to hibernate-core/src/main/java/org/hibernate/event/service/spi/EventListenerGroup.java index f379bc2324..4336ca0cae 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/event/spi/EventListenerGroup.java +++ b/hibernate-core/src/main/java/org/hibernate/event/service/spi/EventListenerGroup.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.event.spi; +package org.hibernate.event.service.spi; import java.io.Serializable; diff --git a/hibernate-core/src/main/java/org/hibernate/service/event/spi/EventListenerRegistrationException.java b/hibernate-core/src/main/java/org/hibernate/event/service/spi/EventListenerRegistrationException.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/service/event/spi/EventListenerRegistrationException.java rename to hibernate-core/src/main/java/org/hibernate/event/service/spi/EventListenerRegistrationException.java index 922dff24d0..9fdbac34c0 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/event/spi/EventListenerRegistrationException.java +++ b/hibernate-core/src/main/java/org/hibernate/event/service/spi/EventListenerRegistrationException.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.event.spi; +package org.hibernate.event.service.spi; import org.hibernate.HibernateException; diff --git a/hibernate-core/src/main/java/org/hibernate/service/event/spi/EventListenerRegistry.java b/hibernate-core/src/main/java/org/hibernate/event/service/spi/EventListenerRegistry.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/service/event/spi/EventListenerRegistry.java rename to hibernate-core/src/main/java/org/hibernate/event/service/spi/EventListenerRegistry.java index 6ae929ae09..a80ca5793c 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/event/spi/EventListenerRegistry.java +++ b/hibernate-core/src/main/java/org/hibernate/event/service/spi/EventListenerRegistry.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.event.spi; +package org.hibernate.event.service.spi; import java.io.Serializable; diff --git a/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java index f3bbbcad7f..bf8698ed19 100644 --- a/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/impl/SessionFactoryImpl.java @@ -39,10 +39,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; -import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.ServiceLoader; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -56,7 +54,6 @@ import org.hibernate.EmptyInterceptor; import org.hibernate.EntityMode; import org.hibernate.EntityNameResolver; import org.hibernate.HibernateException; -import org.hibernate.internal.CoreMessageLogger; import org.hibernate.Interceptor; import org.hibernate.MappingException; import org.hibernate.ObjectNotFoundException; @@ -80,8 +77,6 @@ import org.hibernate.cache.impl.CacheDataDescriptionImpl; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.cfg.Settings; -import org.hibernate.cfg.beanvalidation.BeanValidationIntegrator; -import org.hibernate.cfg.search.HibernateSearchIntegrator; import org.hibernate.context.CurrentSessionContext; import org.hibernate.context.JTASessionContext; import org.hibernate.context.ManagedSessionContext; @@ -107,6 +102,8 @@ import org.hibernate.exception.SQLExceptionConverter; import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.UUIDGenerator; import org.hibernate.id.factory.IdentifierGeneratorFactory; +import org.hibernate.integrator.spi.Integrator; +import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.EmptyIterator; @@ -123,12 +120,12 @@ import org.hibernate.persister.spi.PersisterFactory; import org.hibernate.pretty.MessageHelper; import org.hibernate.proxy.EntityNotFoundDelegate; import org.hibernate.service.ServiceRegistry; +import org.hibernate.integrator.spi.IntegratorService; import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; import org.hibernate.service.jta.platform.spi.JtaPlatform; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.SessionFactoryServiceRegistry; import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory; -import org.hibernate.spi.Integrator; import org.hibernate.stat.Statistics; import org.hibernate.stat.spi.StatisticsImplementor; import org.hibernate.tool.hbm2ddl.SchemaExport; @@ -260,7 +257,7 @@ public final class SessionFactoryImpl final IntegratorObserver integratorObserver = new IntegratorObserver(); this.observer.addObserver( integratorObserver ); - for ( Integrator integrator : locateIntegrators( this.serviceRegistry ) ) { + for ( Integrator integrator : serviceRegistry.getService( IntegratorService.class ).getIntegrators() ) { integrator.integrate( cfg, this, this.serviceRegistry ); integratorObserver.integrators.add( integrator ); } @@ -503,20 +500,6 @@ public final class SessionFactoryImpl this.observer.sessionFactoryCreated( this ); } - private Iterable locateIntegrators(ServiceRegistryImplementor serviceRegistry) { - List integrators = new ArrayList(); - - // todo : Envers needs to be handled by discovery to be because it is in a separate project - integrators.add( new BeanValidationIntegrator() ); - integrators.add( new HibernateSearchIntegrator() ); - - for ( Integrator integrator : ServiceLoader.load( Integrator.class ) ) { - integrators.add( integrator ); - } - - return integrators; - } - public Session openSession() throws HibernateException { return withOptions().openSession(); } diff --git a/hibernate-core/src/main/java/org/hibernate/impl/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/impl/SessionImpl.java index 7742d5c3f1..fd2d54282a 100644 --- a/hibernate-core/src/main/java/org/hibernate/impl/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/impl/SessionImpl.java @@ -141,8 +141,8 @@ import org.hibernate.persister.entity.OuterJoinLoadable; import org.hibernate.pretty.MessageHelper; import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.LazyInitializer; -import org.hibernate.service.event.spi.EventListenerGroup; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.stat.SessionStatistics; import org.hibernate.stat.internal.SessionStatisticsImpl; import org.hibernate.type.SerializationException; diff --git a/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java b/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java new file mode 100644 index 0000000000..871eea8b83 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceImpl.java @@ -0,0 +1,66 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2011, 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.integrator.internal; + +import java.util.LinkedHashSet; +import java.util.ServiceLoader; + +import org.hibernate.cfg.beanvalidation.BeanValidationIntegrator; +import org.hibernate.cfg.search.HibernateSearchIntegrator; +import org.hibernate.integrator.spi.Integrator; +import org.hibernate.integrator.spi.IntegratorService; +import org.hibernate.service.spi.ServiceRegistryImplementor; + +/** + * @author Steve Ebersole + */ +public class IntegratorServiceImpl implements IntegratorService { + private final ServiceRegistryImplementor serviceRegistry; + private LinkedHashSet integrators = new LinkedHashSet(); + + public IntegratorServiceImpl(ServiceRegistryImplementor serviceRegistry) { + this.serviceRegistry = serviceRegistry; + // Standard integrators nameable from here. Envers and JPA, for example, need to be handled by discovery + // because in separate project/jars + integrators.add( new BeanValidationIntegrator() ); + integrators.add( new HibernateSearchIntegrator() ); + } + + @Override + public void addIntegrator(Integrator integrator) { + integrators.add( integrator ); + } + + @Override + public Iterable getIntegrators() { + LinkedHashSet integrators = new LinkedHashSet(); + integrators.addAll( this.integrators ); + + for ( Integrator integrator : ServiceLoader.load( Integrator.class ) ) { + integrators.add( integrator ); + } + + return integrators; + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/event/EventListenerRegistration.java b/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceInitiator.java similarity index 65% rename from hibernate-core/src/main/java/org/hibernate/event/EventListenerRegistration.java rename to hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceInitiator.java index 6cc9a875d9..30654b0a9b 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/EventListenerRegistration.java +++ b/hibernate-core/src/main/java/org/hibernate/integrator/internal/IntegratorServiceInitiator.java @@ -21,25 +21,27 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.event; +package org.hibernate.integrator.internal; import java.util.Map; -import org.hibernate.cfg.Configuration; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.integrator.spi.IntegratorService; +import org.hibernate.service.spi.BasicServiceInitiator; import org.hibernate.service.spi.ServiceRegistryImplementor; /** - * Contract for performing event listener registration. This is completely a work in progress for now. The - * expectation is that this gets tied in with the "service locator" pattern defined by HHH-5562 - * * @author Steve Ebersole */ -public interface EventListenerRegistration { - public void apply( - EventListenerRegistry eventListenerRegistry, - Configuration configuration, - Map configValues, - ServiceRegistryImplementor serviceRegistry - ); +public class IntegratorServiceInitiator implements BasicServiceInitiator { + public static final IntegratorServiceInitiator INSTANCE = new IntegratorServiceInitiator(); + + @Override + public Class getServiceInitiated() { + return IntegratorService.class; + } + + @Override + public IntegratorService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { + return new IntegratorServiceImpl( registry ); + } } diff --git a/hibernate-core/src/main/java/org/hibernate/spi/Integrator.java b/hibernate-core/src/main/java/org/hibernate/integrator/spi/Integrator.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/spi/Integrator.java rename to hibernate-core/src/main/java/org/hibernate/integrator/spi/Integrator.java index b01d1dc513..c61e69bcbc 100644 --- a/hibernate-core/src/main/java/org/hibernate/spi/Integrator.java +++ b/hibernate-core/src/main/java/org/hibernate/integrator/spi/Integrator.java @@ -21,7 +21,7 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.spi; +package org.hibernate.integrator.spi; import org.hibernate.cfg.Configuration; import org.hibernate.engine.SessionFactoryImplementor; diff --git a/hibernate-core/src/main/java/org/hibernate/integrator/spi/IntegratorService.java b/hibernate-core/src/main/java/org/hibernate/integrator/spi/IntegratorService.java new file mode 100644 index 0000000000..662d44558e --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/integrator/spi/IntegratorService.java @@ -0,0 +1,47 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2011, 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.integrator.spi; + +import org.hibernate.service.Service; + +/** + * @author Steve Ebersole + */ +public interface IntegratorService extends Service { + /** + * Manually add an integrator. Added integrators supplement the set of discovered ones. + *

+ * This is mostly an internal contract used between modules. + * + * @param integrator The integrator + */ + public void addIntegrator(Integrator integrator); + + /** + * Retrieve all integrators. + * + * @return All integrators. + */ + public Iterable getIntegrators(); +} diff --git a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java b/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java index 9d4a46b4b5..5bc8e0285a 100644 --- a/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java +++ b/hibernate-core/src/main/java/org/hibernate/jmx/HibernateService.java @@ -1,19 +1,21 @@ //$Id: HibernateService.java 6100 2005-03-17 10:48:03Z turin42 $ package org.hibernate.jmx; +import javax.naming.InitialContext; import java.util.Map; import java.util.Properties; -import javax.naming.InitialContext; + +import org.jboss.logging.Logger; + import org.hibernate.HibernateException; -import org.hibernate.internal.CoreMessageLogger; import org.hibernate.SessionFactory; import org.hibernate.cfg.Environment; import org.hibernate.cfg.ExternalSessionFactoryConfig; +import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.jndi.JndiHelper; -import org.hibernate.service.internal.BasicServiceRegistryImpl; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.jta.platform.internal.JtaPlatformInitiator; import org.hibernate.tool.hbm2ddl.SchemaExport; -import org.jboss.logging.Logger; /** @@ -59,9 +61,11 @@ public class HibernateService extends ExternalSessionFactoryConfig implements Hi } SessionFactory buildSessionFactory() throws HibernateException { - LOG.startingServiceAtJndiName(boundName); - LOG.serviceProperties(properties); - return buildConfiguration().buildSessionFactory(new BasicServiceRegistryImpl(properties)); + LOG.startingServiceAtJndiName( boundName ); + LOG.serviceProperties( properties ); + return buildConfiguration().buildSessionFactory( + new ServiceRegistryBuilder( properties ).buildServiceRegistry() + ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java b/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java new file mode 100644 index 0000000000..e18028371a --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/service/ServiceRegistryBuilder.java @@ -0,0 +1,71 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2011, 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.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.hibernate.service.internal.BasicServiceRegistryImpl; +import org.hibernate.service.internal.ProvidedService; +import org.hibernate.service.spi.BasicServiceInitiator; + +/** + * @author Steve Ebersole + */ +public class ServiceRegistryBuilder { + private final Map configurationValues; + private final List initiators = standardInitiatorList(); + private final List services = new ArrayList(); + + public ServiceRegistryBuilder() { + this( new HashMap() ); + } + + public ServiceRegistryBuilder(Map configurationValues) { + this.configurationValues = configurationValues; + } + + private static List standardInitiatorList() { + final List initiators = new ArrayList(); + initiators.addAll( StandardServiceInitiators.LIST ); + return initiators; + } + + public ServiceRegistryBuilder addInitiator(BasicServiceInitiator initiator) { + initiators.add( initiator ); + return this; + } + + @SuppressWarnings( {"unchecked"}) + public ServiceRegistryBuilder addService(final Class serviceRole, final Service service) { + services.add( new ProvidedService( serviceRole, service ) ); + return this; + } + + public BasicServiceRegistry buildServiceRegistry() { + return new BasicServiceRegistryImpl( initiators, services, configurationValues ); + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java b/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java index 5bc7f1c9c8..24b3c21297 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java +++ b/hibernate-core/src/main/java/org/hibernate/service/StandardServiceInitiators.java @@ -26,12 +26,11 @@ package org.hibernate.service; import org.hibernate.engine.jdbc.batch.internal.BatchBuilderInitiator; import org.hibernate.engine.jdbc.internal.JdbcServicesInitiator; import org.hibernate.engine.transaction.internal.TransactionFactoryInitiator; -import org.hibernate.event.EventListenerRegistration; import org.hibernate.persister.internal.PersisterClassResolverInitiator; import org.hibernate.persister.internal.PersisterFactoryInitiator; import org.hibernate.service.classloading.internal.ClassLoaderServiceInitiator; +import org.hibernate.integrator.internal.IntegratorServiceInitiator; import org.hibernate.service.internal.SessionFactoryServiceRegistryFactoryInitiator; -import org.hibernate.service.event.internal.EventListenerServiceInitiator; import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator; import org.hibernate.service.jdbc.connections.internal.MultiTenantConnectionProviderInitiator; import org.hibernate.service.jdbc.dialect.internal.DialectFactoryInitiator; @@ -40,11 +39,9 @@ import org.hibernate.service.jmx.internal.JmxServiceInitiator; import org.hibernate.service.jndi.internal.JndiServiceInitiator; import org.hibernate.service.jta.platform.internal.JtaPlatformInitiator; import org.hibernate.service.spi.BasicServiceInitiator; -import org.hibernate.service.spi.ServiceRegistryImplementor; import java.util.ArrayList; import java.util.List; -import java.util.Map; /** * @author Steve Ebersole @@ -73,50 +70,9 @@ public class StandardServiceInitiators { serviceInitiators.add( TransactionFactoryInitiator.INSTANCE ); serviceInitiators.add( SessionFactoryServiceRegistryFactoryInitiator.INSTANCE ); - - serviceInitiators.add( EventListenerRegistrationServiceInitiator.INSTANCE ); + serviceInitiators.add( IntegratorServiceInitiator.INSTANCE ); return serviceInitiators; } - - // todo : completely temporary. See HHH-5562 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - /** - * Acts as a service in the basic registry to which users/integrators can attach things that perform event listener - * registration. The event listeners live in the SessionFactory registry, but it has access to the basic registry. - * So when it starts up, it looks in the basic registry for this service and does the requested registrations. - */ - public static interface EventListenerRegistrationService extends Service { - public void attachEventListenerRegistration(EventListenerRegistration registration); - public Iterable getEventListenerRegistrations(); - } - - public static class EventListenerRegistrationServiceImpl implements EventListenerRegistrationService { - private List registrations = new ArrayList(); - - @Override - public void attachEventListenerRegistration(EventListenerRegistration registration) { - registrations.add( registration ); - } - - @Override - public Iterable getEventListenerRegistrations() { - return registrations; - } - } - - public static class EventListenerRegistrationServiceInitiator implements BasicServiceInitiator { - public static final EventListenerRegistrationServiceInitiator INSTANCE = new EventListenerRegistrationServiceInitiator(); - - @Override - public Class getServiceInitiated() { - return EventListenerRegistrationService.class; - } - - @Override - public EventListenerRegistrationService initiateService(Map configurationValues, ServiceRegistryImplementor registry) { - return new EventListenerRegistrationServiceImpl(); - } - } } diff --git a/hibernate-core/src/main/java/org/hibernate/service/StandardSessionFactoryServiceInitiators.java b/hibernate-core/src/main/java/org/hibernate/service/StandardSessionFactoryServiceInitiators.java index 6a10d48b12..00b06c2108 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/StandardSessionFactoryServiceInitiators.java +++ b/hibernate-core/src/main/java/org/hibernate/service/StandardSessionFactoryServiceInitiators.java @@ -26,7 +26,7 @@ package org.hibernate.service; import java.util.ArrayList; import java.util.List; -import org.hibernate.service.event.internal.EventListenerServiceInitiator; +import org.hibernate.event.service.internal.EventListenerServiceInitiator; import org.hibernate.service.spi.SessionFactoryServiceInitiator; import org.hibernate.stat.internal.StatisticsInitiator; diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/BasicServiceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/BasicServiceRegistryImpl.java index 3ae90cf755..58c22ba0da 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/BasicServiceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/BasicServiceRegistryImpl.java @@ -32,7 +32,6 @@ import org.jboss.logging.Logger; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.service.BasicServiceRegistry; import org.hibernate.service.Service; -import org.hibernate.service.StandardServiceInitiators; import org.hibernate.service.UnknownServiceException; import org.hibernate.service.spi.BasicServiceInitiator; import org.hibernate.service.spi.Configurable; @@ -50,19 +49,25 @@ public class BasicServiceRegistryImpl extends AbstractServiceRegistryImpl implem private final Map serviceInitiatorMap; private final Map configurationValues; - public BasicServiceRegistryImpl(Map configurationValues) { - this( StandardServiceInitiators.LIST, configurationValues ); - } - @SuppressWarnings( {"unchecked"}) - public BasicServiceRegistryImpl(List serviceInitiators, Map configurationValues) { + public BasicServiceRegistryImpl( + List serviceInitiators, + List providedServices, + Map configurationValues) { super(); - this.serviceInitiatorMap = toMap( serviceInitiators ); + this.configurationValues = configurationValues; + + this.serviceInitiatorMap = toMap( serviceInitiators ); for ( BasicServiceInitiator initiator : serviceInitiatorMap.values() ) { // create the bindings up front to help identify to which registry services belong createServiceBinding( initiator.getServiceInitiated() ); } + + for ( ProvidedService providedService : providedServices ) { + ServiceBinding binding = locateOrCreateServiceBinding( providedService.getServiceRole(), false ); + binding.setTarget( providedService.getService() ); + } } /** @@ -133,4 +138,5 @@ public class BasicServiceRegistryImpl extends AbstractServiceRegistryImpl implem ( (Configurable) service ).configure( configurationValues ); } } + } diff --git a/hibernate-core/src/main/java/org/hibernate/service/event/internal/TemporaryListenerHelper.java b/hibernate-core/src/main/java/org/hibernate/service/internal/ProvidedService.java similarity index 59% rename from hibernate-core/src/main/java/org/hibernate/service/event/internal/TemporaryListenerHelper.java rename to hibernate-core/src/main/java/org/hibernate/service/internal/ProvidedService.java index bed2e92d84..74a2fd92dc 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/event/internal/TemporaryListenerHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/ProvidedService.java @@ -21,27 +21,27 @@ * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA */ -package org.hibernate.service.event.internal; - -import org.hibernate.event.EventType; -import org.hibernate.service.event.spi.EventListenerRegistry; +package org.hibernate.service.internal; /** - * Helper for handling various aspects of event listeners. Temporary because generally speaking this is legacy stuff - * that should change as we move forward + * A service provided as-is. * * @author Steve Ebersole */ -public class TemporaryListenerHelper { - public static interface ListenerProcessor { - public void processListener(Object listener); +public class ProvidedService { + private final Class serviceRole; + private final T service; + + public ProvidedService(Class serviceRole, T service) { + this.serviceRole = serviceRole; + this.service = service; } - public static void processListeners(EventListenerRegistry registryRegistry, ListenerProcessor processer) { - for ( EventType eventType : EventType.values() ) { - for ( Object listener : registryRegistry.getEventListenerGroup( eventType ).listeners() ) { - processer.processListener( listener ); - } - } + public Class getServiceRole() { + return serviceRole; + } + + public T getService() { + return service; } } diff --git a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryImpl.java index b3aec976e4..446a2a71ae 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/service/internal/SessionFactoryServiceRegistryFactoryImpl.java @@ -23,13 +23,10 @@ */ package org.hibernate.service.internal; -import java.util.List; - import org.hibernate.cfg.Configuration; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.service.Service; import org.hibernate.service.spi.ServiceRegistryImplementor; -import org.hibernate.service.spi.SessionFactoryServiceInitiator; import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory; /** diff --git a/hibernate-core/src/main/java/org/hibernate/service/spi/SessionFactoryServiceRegistryFactory.java b/hibernate-core/src/main/java/org/hibernate/service/spi/SessionFactoryServiceRegistryFactory.java index 121bd487cd..8d5106ee5d 100644 --- a/hibernate-core/src/main/java/org/hibernate/service/spi/SessionFactoryServiceRegistryFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/service/spi/SessionFactoryServiceRegistryFactory.java @@ -23,8 +23,6 @@ */ package org.hibernate.service.spi; -import java.util.List; - import org.hibernate.cfg.Configuration; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.service.Service; diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java index 20ac7dbac3..51f93a824f 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaExport.java @@ -56,6 +56,7 @@ import org.hibernate.internal.util.ConfigHelper; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.ServiceRegistry; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; @@ -460,7 +461,7 @@ public class SchemaExport { private static BasicServiceRegistryImpl createServiceRegistry(Properties properties) { Environment.verifyProperties( properties ); ConfigurationHelper.resolvePlaceHolders( properties ); - return new BasicServiceRegistryImpl( properties ); + return (BasicServiceRegistryImpl) new ServiceRegistryBuilder( properties ).buildServiceRegistry(); } public static void main(String[] args) { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java index 3c2840e6c9..44de7b0060 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaUpdate.java @@ -50,6 +50,7 @@ import org.hibernate.engine.jdbc.spi.SqlStatementLogger; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.ServiceRegistry; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; /** @@ -109,7 +110,7 @@ public class SchemaUpdate { private static BasicServiceRegistryImpl createServiceRegistry(Properties properties) { Environment.verifyProperties( properties ); ConfigurationHelper.resolvePlaceHolders( properties ); - return new BasicServiceRegistryImpl( properties ); + return (BasicServiceRegistryImpl) new ServiceRegistryBuilder( properties ).buildServiceRegistry(); } public static void main(String[] args) { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java index 9d6169d270..980bfff2ef 100755 --- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SchemaValidator.java @@ -40,6 +40,7 @@ import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.service.ServiceRegistry; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; /** @@ -78,7 +79,7 @@ public class SchemaValidator { private static BasicServiceRegistryImpl createServiceRegistry(Properties properties) { Environment.verifyProperties( properties ); ConfigurationHelper.resolvePlaceHolders( properties ); - return new BasicServiceRegistryImpl( properties ); + return (BasicServiceRegistryImpl) new ServiceRegistryBuilder( properties ).buildServiceRegistry(); } public static void main(String[] args) { diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java b/hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java index 88c1a6bd17..4d0fdfbe1a 100644 --- a/hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java +++ b/hibernate-core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java @@ -51,7 +51,7 @@ import org.hibernate.property.Getter; import org.hibernate.property.Setter; import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.ProxyFactory; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.tuple.Instantiator; import org.hibernate.tuple.StandardProperty; import org.hibernate.tuple.VersionProperty; diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/binding/AbstractBasicBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/binding/AbstractBasicBindingTests.java index ab1a2b001e..32628dcbb9 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/binding/AbstractBasicBindingTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/binding/AbstractBasicBindingTests.java @@ -23,16 +23,15 @@ */ package org.hibernate.metamodel.binding; -import java.util.Collections; +import org.hibernate.metamodel.relational.Column; +import org.hibernate.service.BasicServiceRegistry; +import org.hibernate.service.ServiceRegistryBuilder; +import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.hibernate.metamodel.relational.Column; -import org.hibernate.service.BasicServiceRegistry; -import org.hibernate.service.internal.BasicServiceRegistryImpl; - import org.hibernate.testing.junit4.BaseUnitTestCase; import static junit.framework.Assert.assertNotNull; @@ -51,7 +50,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase { @Before public void setUp() { - serviceRegistry = new BasicServiceRegistryImpl( Collections.emptyMap() ); + serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry(); } @After diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/binding/BasicAnnotationBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/binding/BasicAnnotationBindingTests.java index 90c09d0590..60dbbb46d9 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/binding/BasicAnnotationBindingTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/binding/BasicAnnotationBindingTests.java @@ -25,14 +25,13 @@ package org.hibernate.metamodel.binding; import java.io.IOException; import java.io.InputStream; -import java.util.Collections; import org.jboss.jandex.Index; import org.jboss.jandex.Indexer; import org.hibernate.metamodel.source.MetadataSources; import org.hibernate.metamodel.source.internal.MetadataImpl; -import org.hibernate.service.internal.BasicServiceRegistryImpl; +import org.hibernate.service.ServiceRegistryBuilder; import org.junit.Test; @@ -61,7 +60,7 @@ public class BasicAnnotationBindingTests extends AbstractBasicBindingTests { public EntityBinding buildSimpleEntityBinding() { Index index = indexForClass( SimpleEntity.class ); - MetadataImpl metadata = (MetadataImpl) new MetadataSources( new BasicServiceRegistryImpl( Collections.emptyMap() ) ).buildMetadata(); + MetadataImpl metadata = (MetadataImpl) new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ).buildMetadata(); metadata.getAnnotationBinder().bindMappedClasses( index ); return metadata.getEntityBinding( SimpleEntity.class.getSimpleName() ); @@ -69,7 +68,7 @@ public class BasicAnnotationBindingTests extends AbstractBasicBindingTests { public EntityBinding buildSimpleVersionedEntityBinding() { Index index = indexForClass( SimpleEntity.class ); - MetadataImpl metadata = (MetadataImpl) new MetadataSources( new BasicServiceRegistryImpl( Collections.emptyMap() ) ).buildMetadata(); + MetadataImpl metadata = (MetadataImpl) new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ).buildMetadata(); metadata.getAnnotationBinder().bindMappedClasses( index ); return metadata.getEntityBinding( SimpleVersionedEntity.class.getSimpleName() ); diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/global/FetchProfileBinderTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/global/FetchProfileBinderTest.java index 8bbc038e9c..fc32734ccc 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/global/FetchProfileBinderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/global/FetchProfileBinderTest.java @@ -1,12 +1,8 @@ package org.hibernate.metamodel.source.annotations.global; -import java.util.Collections; import java.util.Iterator; import org.jboss.jandex.Index; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; import org.hibernate.MappingException; import org.hibernate.annotations.FetchMode; @@ -15,8 +11,14 @@ import org.hibernate.annotations.FetchProfiles; import org.hibernate.metamodel.source.MetadataSources; import org.hibernate.metamodel.source.annotations.util.JandexHelper; import org.hibernate.metamodel.source.internal.MetadataImpl; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.classloading.spi.ClassLoaderService; import org.hibernate.service.internal.BasicServiceRegistryImpl; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import org.hibernate.testing.junit4.BaseUnitTestCase; import static junit.framework.Assert.fail; @@ -34,7 +36,7 @@ public class FetchProfileBinderTest extends BaseUnitTestCase { @Before public void setUp() { - serviceRegistry = new BasicServiceRegistryImpl( Collections.emptyMap() ); + serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry(); service = serviceRegistry.getService( ClassLoaderService.class ); meta = (MetadataImpl) new MetadataSources( serviceRegistry ).buildMetadata(); } diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/util/ConfiguredClassHierarchyBuilderTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/util/ConfiguredClassHierarchyBuilderTest.java index 8d0763b212..4be69d7d0a 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/util/ConfiguredClassHierarchyBuilderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/util/ConfiguredClassHierarchyBuilderTest.java @@ -21,6 +21,7 @@ import org.junit.Test; import org.hibernate.AnnotationException; import org.hibernate.metamodel.source.annotations.ConfiguredClass; import org.hibernate.metamodel.source.annotations.ConfiguredClassHierarchy; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.classloading.spi.ClassLoaderService; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.hibernate.testing.junit4.BaseUnitTestCase; @@ -39,7 +40,7 @@ public class ConfiguredClassHierarchyBuilderTest extends BaseUnitTestCase { @Before public void setUp() { - serviceRegistry = new BasicServiceRegistryImpl( Collections.emptyMap() ); + serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry(); service = serviceRegistry.getService( ClassLoaderService.class ); } diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParserTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParserTests.java index 158831e4bc..7a606d58db 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParserTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParserTests.java @@ -8,6 +8,7 @@ import org.junit.Test; import org.hibernate.metamodel.source.MetadataSources; import org.hibernate.metamodel.source.internal.MetadataImpl; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.hibernate.testing.junit4.BaseUnitTestCase; @@ -17,7 +18,7 @@ import org.hibernate.testing.junit4.BaseUnitTestCase; public class OrmXmlParserTests extends BaseUnitTestCase { @Test public void testSingleOrmXml() { - MetadataImpl metadata = (MetadataImpl) new MetadataSources( new BasicServiceRegistryImpl( Collections.emptyMap() ) ).buildMetadata(); + MetadataImpl metadata = (MetadataImpl) new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ).buildMetadata(); OrmXmlParser parser = new OrmXmlParser( metadata ); Set xmlFiles = new HashSet(); xmlFiles.add( "org/hibernate/metamodel/source/annotations/xml/orm.xml" ); @@ -26,7 +27,7 @@ public class OrmXmlParserTests extends BaseUnitTestCase { @Test public void testOrmXmlWithOldSchema() { - MetadataImpl metadata = (MetadataImpl) new MetadataSources( new BasicServiceRegistryImpl( Collections.emptyMap() ) ).buildMetadata(); + MetadataImpl metadata = (MetadataImpl) new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ).buildMetadata(); OrmXmlParser parser = new OrmXmlParser( metadata ); Set xmlFiles = new HashSet(); xmlFiles.add( "org/hibernate/metamodel/source/annotations/xml/orm-star.xml" ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/event/collection/CollectionListeners.java b/hibernate-core/src/test/java/org/hibernate/test/event/collection/CollectionListeners.java index be17efb04b..f76692ac33 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/event/collection/CollectionListeners.java +++ b/hibernate-core/src/test/java/org/hibernate/test/event/collection/CollectionListeners.java @@ -45,7 +45,7 @@ import org.hibernate.event.PreCollectionRemoveEventListener; import org.hibernate.event.PreCollectionUpdateEvent; import org.hibernate.event.PreCollectionUpdateEventListener; import org.hibernate.event.def.DefaultInitializeCollectionEventListener; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; /** * @author Gail Badner diff --git a/hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java b/hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java index 454515193b..9dbe9c7d86 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/events/CallbackTest.java @@ -22,23 +22,24 @@ * Boston, MA 02110-1301 USA */ package org.hibernate.test.events; -import java.util.Map; + import java.util.Set; import org.hibernate.HibernateException; import org.hibernate.SessionFactory; import org.hibernate.SessionFactoryObserver; import org.hibernate.cfg.Configuration; +import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.event.DeleteEvent; import org.hibernate.event.DeleteEventListener; import org.hibernate.event.Destructible; -import org.hibernate.event.EventListenerRegistration; import org.hibernate.event.EventType; import org.hibernate.event.Initializable; -import org.hibernate.service.StandardServiceInitiators; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; +import org.hibernate.integrator.spi.IntegratorService; import org.hibernate.service.internal.BasicServiceRegistryImpl; -import org.hibernate.service.spi.ServiceRegistryImplementor; +import org.hibernate.service.spi.SessionFactoryServiceRegistry; +import org.hibernate.integrator.spi.Integrator; import org.junit.Test; @@ -68,15 +69,21 @@ public class CallbackTest extends BaseCoreFunctionalTestCase { @Override protected void applyServices(BasicServiceRegistryImpl serviceRegistry) { super.applyServices( serviceRegistry ); - serviceRegistry.getService( StandardServiceInitiators.EventListenerRegistrationService.class ).attachEventListenerRegistration( - new EventListenerRegistration() { + serviceRegistry.getService( IntegratorService.class ).addIntegrator( + new Integrator() { @Override - public void apply( - EventListenerRegistry eventListenerRegistry, + public void integrate( Configuration configuration, - Map configValues, - ServiceRegistryImplementor serviceRegistry) { - eventListenerRegistry.setListeners( EventType.DELETE, listener ); + SessionFactoryImplementor sessionFactory, + SessionFactoryServiceRegistry serviceRegistry) { + serviceRegistry.getService( EventListenerRegistry.class ).setListeners( + EventType.DELETE, listener + ); + } + + @Override + public void disintegrate( + SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { } } ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java b/hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java index 47ba305144..64d4acb02a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java +++ b/hibernate-core/src/test/java/org/hibernate/test/flush/TestCollectionInitializingDuringFlush.java @@ -23,16 +23,15 @@ */ package org.hibernate.test.flush; -import java.util.Map; - import org.hibernate.Session; import org.hibernate.cfg.Configuration; -import org.hibernate.event.EventListenerRegistration; +import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.event.EventType; -import org.hibernate.service.StandardServiceInitiators; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; +import org.hibernate.integrator.spi.IntegratorService; import org.hibernate.service.internal.BasicServiceRegistryImpl; -import org.hibernate.service.spi.ServiceRegistryImplementor; +import org.hibernate.service.spi.SessionFactoryServiceRegistry; +import org.hibernate.integrator.spi.Integrator; import org.junit.Test; @@ -53,15 +52,21 @@ public class TestCollectionInitializingDuringFlush extends BaseCoreFunctionalTes @Override protected void applyServices(BasicServiceRegistryImpl serviceRegistry) { super.applyServices( serviceRegistry ); - serviceRegistry.getService( StandardServiceInitiators.EventListenerRegistrationService.class ).attachEventListenerRegistration( - new EventListenerRegistration() { + serviceRegistry.getService( IntegratorService.class ).addIntegrator( + new Integrator() { @Override - public void apply( - EventListenerRegistry eventListenerRegistry, + public void integrate( Configuration configuration, - Map configValues, - ServiceRegistryImplementor serviceRegistry) { - eventListenerRegistry.getEventListenerGroup( EventType.PRE_UPDATE ).appendListener( new InitializingPreUpdateEventListener() ); + SessionFactoryImplementor sessionFactory, + SessionFactoryServiceRegistry serviceRegistry) { + serviceRegistry.getService( EventListenerRegistry.class ) + .getEventListenerGroup( EventType.PRE_UPDATE ) + .appendListener( new InitializingPreUpdateEventListener() ); + } + + @Override + public void disintegrate( + SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { } } ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/jdbc/proxies/BatchingTest.java b/hibernate-core/src/test/java/org/hibernate/test/jdbc/proxies/BatchingTest.java index 2dad3fb5f1..00a09106c8 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jdbc/proxies/BatchingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jdbc/proxies/BatchingTest.java @@ -41,7 +41,7 @@ import org.hibernate.engine.transaction.spi.TransactionContext; import org.hibernate.engine.transaction.spi.TransactionImplementor; import org.hibernate.jdbc.Expectation; import org.hibernate.jdbc.Expectations; -import org.hibernate.service.StandardServiceInitiators; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.junit.After; @@ -68,10 +68,8 @@ public class BatchingTest extends BaseUnitTestCase implements BatchKey { @Before public void setUp() throws Exception { - serviceRegistry = new BasicServiceRegistryImpl( - StandardServiceInitiators.LIST, - ConnectionProviderBuilder.getConnectionProviderProperties() - ); + serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( ConnectionProviderBuilder.getConnectionProviderProperties() ) + .buildServiceRegistry(); } @After diff --git a/hibernate-core/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java b/hibernate-core/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java index 0680a7e167..7ac2c51fed 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jpa/AbstractJPATest.java @@ -25,13 +25,12 @@ package org.hibernate.test.jpa; import javax.persistence.EntityNotFoundException; import java.io.Serializable; -import java.util.Map; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.engine.CascadingAction; +import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.event.AutoFlushEventListener; -import org.hibernate.event.EventListenerRegistration; import org.hibernate.event.EventType; import org.hibernate.event.FlushEntityEventListener; import org.hibernate.event.FlushEventListener; @@ -40,12 +39,13 @@ import org.hibernate.event.def.DefaultAutoFlushEventListener; import org.hibernate.event.def.DefaultFlushEntityEventListener; import org.hibernate.event.def.DefaultFlushEventListener; import org.hibernate.event.def.DefaultPersistEventListener; +import org.hibernate.integrator.spi.Integrator; import org.hibernate.internal.util.collections.IdentityMap; import org.hibernate.proxy.EntityNotFoundDelegate; -import org.hibernate.service.StandardServiceInitiators; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; +import org.hibernate.integrator.spi.IntegratorService; import org.hibernate.service.internal.BasicServiceRegistryImpl; -import org.hibernate.service.spi.ServiceRegistryImplementor; +import org.hibernate.service.spi.SessionFactoryServiceRegistry; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; @@ -71,20 +71,27 @@ public abstract class AbstractJPATest extends BaseCoreFunctionalTestCase { @Override protected void applyServices(BasicServiceRegistryImpl serviceRegistry) { super.applyServices( serviceRegistry ); - serviceRegistry.getService( StandardServiceInitiators.EventListenerRegistrationService.class ).attachEventListenerRegistration( - new EventListenerRegistration() { + serviceRegistry.getService( IntegratorService.class ).addIntegrator( + new Integrator() { @Override - public void apply( - EventListenerRegistry eventListenerRegistry, + public void integrate( Configuration configuration, - Map configValues, - ServiceRegistryImplementor serviceRegistry) { + SessionFactoryImplementor sessionFactory, + SessionFactoryServiceRegistry serviceRegistry) { + EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class ); eventListenerRegistry.setListeners( EventType.PERSIST, buildPersistEventListeners() ); - eventListenerRegistry.setListeners( EventType.PERSIST_ONFLUSH, buildPersisOnFlushEventListeners() ); + eventListenerRegistry.setListeners( + EventType.PERSIST_ONFLUSH, buildPersisOnFlushEventListeners() + ); eventListenerRegistry.setListeners( EventType.AUTO_FLUSH, buildAutoFlushEventListeners() ); eventListenerRegistry.setListeners( EventType.FLUSH, buildFlushEventListeners() ); eventListenerRegistry.setListeners( EventType.FLUSH_ENTITY, buildFlushEntityEventListeners() ); } + + @Override + public void disintegrate( + SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { + } } ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java index e42fa71373..e22d4d8ffc 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/bidir/component/EagerKeyManyToOneTest.java @@ -23,21 +23,20 @@ */ package org.hibernate.test.keymanytoone.bidir.component; -import java.util.Map; - import org.hibernate.HibernateException; import org.hibernate.Session; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; -import org.hibernate.event.EventListenerRegistration; +import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.event.EventType; import org.hibernate.event.LoadEvent; import org.hibernate.event.LoadEventListener; import org.hibernate.event.def.DefaultLoadEventListener; -import org.hibernate.service.StandardServiceInitiators; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; +import org.hibernate.integrator.spi.IntegratorService; import org.hibernate.service.internal.BasicServiceRegistryImpl; -import org.hibernate.service.spi.ServiceRegistryImplementor; +import org.hibernate.service.spi.SessionFactoryServiceRegistry; +import org.hibernate.integrator.spi.Integrator; import org.junit.Test; @@ -65,16 +64,21 @@ public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase { protected void applyServices(BasicServiceRegistryImpl serviceRegistry) { super.applyServices( serviceRegistry ); - // (they are different service registries!) - serviceRegistry.getService( StandardServiceInitiators.EventListenerRegistrationService.class ).attachEventListenerRegistration( - new EventListenerRegistration() { + serviceRegistry.getService( IntegratorService.class ).addIntegrator( + new Integrator() { @Override - public void apply( - EventListenerRegistry eventListenerRegistry, + public void integrate( Configuration configuration, - Map configValues, - ServiceRegistryImplementor serviceRegistry) { - eventListenerRegistry.prependListeners( EventType.LOAD, new CustomLoadListener() ); + SessionFactoryImplementor sessionFactory, + SessionFactoryServiceRegistry serviceRegistry) { + serviceRegistry.getService( EventListenerRegistry.class ).prependListeners( + EventType.LOAD, new CustomLoadListener() + ); + } + + @Override + public void disintegrate( + SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { } } ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java index 87f589cadb..74d78f51cb 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/multitenancy/schema/SchemaBasedMultiTenancyTest.java @@ -29,14 +29,12 @@ import java.sql.SQLException; import org.hibernate.HibernateException; import org.hibernate.MultiTenancyStrategy; import org.hibernate.Session; -import org.hibernate.SessionFactory; import org.hibernate.cache.HashtableCacheProvider; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.engine.SessionFactoryImplementor; -import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.RootClass; -import org.hibernate.service.internal.BasicServiceRegistryImpl; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl; import org.hibernate.service.jdbc.connections.spi.AbstractMultiTenantConnectionProvider; import org.hibernate.service.jdbc.connections.spi.ConnectionProvider; @@ -152,8 +150,9 @@ public class SchemaBasedMultiTenancyTest extends BaseUnitTestCase { false // do not *just* perform the create ); - serviceRegistry = new BasicServiceRegistryImpl( cfg.getProperties() ); - serviceRegistry.registerService( MultiTenantConnectionProvider.class, multiTenantConnectionProvider ); + serviceRegistry = (ServiceRegistryImplementor) new ServiceRegistryBuilder( cfg.getProperties() ) + .addService( MultiTenantConnectionProvider.class, multiTenantConnectionProvider ) + .buildServiceRegistry(); sessionFactory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry ); } diff --git a/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java b/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java index 7c596512f3..cbe1f046b9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/service/ServiceBootstrappingTest.java @@ -32,6 +32,7 @@ import static org.junit.Assert.assertTrue; import org.hibernate.cfg.Environment; import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.jdbc.spi.JdbcServices; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl; import org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl; @@ -46,7 +47,9 @@ import org.hibernate.testing.junit4.BaseUnitTestCase; public class ServiceBootstrappingTest extends BaseUnitTestCase { @Test public void testBasicBuild() { - BasicServiceRegistryImpl serviceRegistry = new BasicServiceRegistryImpl( ConnectionProviderBuilder.getConnectionProviderProperties() ); + BasicServiceRegistryImpl serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( + ConnectionProviderBuilder.getConnectionProviderProperties() + ).buildServiceRegistry(); JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); assertTrue( jdbcServices.getDialect() instanceof H2Dialect ); @@ -61,7 +64,8 @@ public class ServiceBootstrappingTest extends BaseUnitTestCase { Properties props = ConnectionProviderBuilder.getConnectionProviderProperties(); props.put( Environment.SHOW_SQL, "true" ); - BasicServiceRegistryImpl serviceRegistry = new BasicServiceRegistryImpl( props ); + BasicServiceRegistryImpl serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( props ).buildServiceRegistry(); + JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); assertTrue( jdbcServices.getDialect() instanceof H2Dialect ); @@ -75,7 +79,7 @@ public class ServiceBootstrappingTest extends BaseUnitTestCase { public void testBuildWithServiceOverride() { Properties props = ConnectionProviderBuilder.getConnectionProviderProperties(); - BasicServiceRegistryImpl serviceRegistry = new BasicServiceRegistryImpl( props ); + BasicServiceRegistryImpl serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( props ).buildServiceRegistry(); JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); assertTrue( jdbcServices.getDialect() instanceof H2Dialect ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/transaction/jdbc/TestExpectedUsage.java b/hibernate-core/src/test/java/org/hibernate/test/transaction/jdbc/TestExpectedUsage.java index 7b47132d88..c0f77af919 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/transaction/jdbc/TestExpectedUsage.java +++ b/hibernate-core/src/test/java/org/hibernate/test/transaction/jdbc/TestExpectedUsage.java @@ -33,23 +33,24 @@ import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor; import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl; import org.hibernate.engine.transaction.spi.TransactionContext; import org.hibernate.engine.transaction.spi.TransactionImplementor; -import org.hibernate.service.StandardServiceInitiators; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.junit.After; import org.junit.Before; import org.junit.Test; + +import org.hibernate.testing.env.ConnectionProviderBuilder; +import org.hibernate.testing.junit4.BaseUnitTestCase; +import org.hibernate.test.common.JournalingTransactionObserver; +import org.hibernate.test.common.TransactionContextImpl; +import org.hibernate.test.common.TransactionEnvironmentImpl; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.hibernate.testing.env.ConnectionProviderBuilder; -import org.hibernate.test.common.JournalingTransactionObserver; -import org.hibernate.test.common.TransactionContextImpl; -import org.hibernate.test.common.TransactionEnvironmentImpl; - /** * @author Steve Ebersole */ @@ -58,10 +59,8 @@ public class TestExpectedUsage extends BaseUnitTestCase { @Before public void setUp() throws Exception { - serviceRegistry = new BasicServiceRegistryImpl( - StandardServiceInitiators.LIST, - ConnectionProviderBuilder.getConnectionProviderProperties() - ); + serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( ConnectionProviderBuilder.getConnectionProviderProperties() ) + .buildServiceRegistry(); } @After diff --git a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/BasicDrivingTest.java b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/BasicDrivingTest.java index b1c5d57766..26d44c02c4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/BasicDrivingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/BasicDrivingTest.java @@ -36,6 +36,7 @@ import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl; import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory; import org.hibernate.engine.transaction.spi.TransactionContext; import org.hibernate.engine.transaction.spi.TransactionImplementor; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.ServiceProxy; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.hibernate.service.jta.platform.spi.JtaPlatform; @@ -71,7 +72,7 @@ public class BasicDrivingTest extends BaseUnitTestCase { configValues.putAll( ConnectionProviderBuilder.getConnectionProviderProperties() ); configValues.put( Environment.TRANSACTION_STRATEGY, JtaTransactionFactory.class.getName() ); TestingJtaBootstrap.prepare( configValues ); - serviceRegistry = new BasicServiceRegistryImpl( configValues ); + serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( configValues ).buildServiceRegistry(); } @After diff --git a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java index 0f0413535d..4756608460 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/transaction/jta/ManagedDrivingTest.java @@ -38,7 +38,7 @@ import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; import org.hibernate.engine.transaction.spi.TransactionContext; import org.hibernate.engine.transaction.spi.TransactionImplementor; -import org.hibernate.service.StandardServiceInitiators; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.hibernate.service.internal.ServiceProxy; import org.hibernate.service.jta.platform.spi.JtaPlatform; @@ -71,10 +71,9 @@ public class ManagedDrivingTest extends BaseUnitTestCase { public void setUp() throws Exception { Map configValues = new HashMap(); TestingJtaBootstrap.prepare( configValues ); -// configValues.putAll( ConnectionProviderBuilder.getConnectionProviderProperties() ); configValues.put( Environment.TRANSACTION_STRATEGY, CMTTransactionFactory.class.getName() ); - serviceRegistry = new BasicServiceRegistryImpl( StandardServiceInitiators.LIST, configValues ); + serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( configValues ).buildServiceRegistry(); } @After diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java b/hibernate-entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java index e3446f5a5c..23583b4dac 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/ejb/Ejb3Configuration.java @@ -75,7 +75,7 @@ import org.hibernate.cfg.NamingStrategy; import org.hibernate.cfg.annotations.reflection.XMLContext; import org.hibernate.cfg.beanvalidation.BeanValidationIntegrator; import org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider; -import org.hibernate.ejb.event.JpaEventListenerRegistration; +import org.hibernate.ejb.event.JpaIntegrator; import org.hibernate.ejb.instrument.InterceptFieldClassFileTransformer; import org.hibernate.ejb.internal.EntityManagerMessageLogger; import org.hibernate.ejb.packaging.JarVisitorFactory; @@ -90,6 +90,7 @@ import org.hibernate.ejb.util.NamingHelper; import org.hibernate.engine.FilterDefinition; import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory; import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory; +import org.hibernate.integrator.spi.IntegratorService; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.collections.CollectionHelper; @@ -101,8 +102,7 @@ import org.hibernate.mapping.PersistentClass; import org.hibernate.proxy.EntityNotFoundDelegate; import org.hibernate.secure.JACCConfiguration; import org.hibernate.service.ServiceRegistry; -import org.hibernate.service.StandardServiceInitiators; -import org.hibernate.service.internal.BasicServiceRegistryImpl; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl; /** @@ -872,7 +872,7 @@ public class Ejb3Configuration implements Serializable, Referenceable { } public EntityManagerFactory buildEntityManagerFactory() { - return buildEntityManagerFactory( new BasicServiceRegistryImpl( cfg.getProperties() ) ); + return buildEntityManagerFactory( new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry() ); } public EntityManagerFactory buildEntityManagerFactory(ServiceRegistry serviceRegistry) { @@ -886,9 +886,7 @@ public class Ejb3Configuration implements Serializable, Referenceable { try { configure( (Properties)null, null ); NamingHelper.bind(this); - // todo : temporary -> HHH-5562 - serviceRegistry.getService( StandardServiceInitiators.EventListenerRegistrationService.class ) - .attachEventListenerRegistration( new JpaEventListenerRegistration() ); + serviceRegistry.getService( IntegratorService.class ).addIntegrator( new JpaIntegrator() ); return new EntityManagerFactoryImpl( transactionType, discardOnClose, diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/ejb/event/JpaEventListenerRegistration.java b/hibernate-entitymanager/src/main/java/org/hibernate/ejb/event/JpaIntegrator.java similarity index 87% rename from hibernate-entitymanager/src/main/java/org/hibernate/ejb/event/JpaEventListenerRegistration.java rename to hibernate-entitymanager/src/main/java/org/hibernate/ejb/event/JpaIntegrator.java index f43b693782..abe9ce611e 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/ejb/event/JpaEventListenerRegistration.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/ejb/event/JpaIntegrator.java @@ -31,8 +31,9 @@ import org.hibernate.MappingException; import org.hibernate.annotations.common.reflection.ReflectionManager; import org.hibernate.cfg.Configuration; import org.hibernate.ejb.AvailableSettings; -import org.hibernate.event.EventListenerRegistration; +import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.event.EventType; +import org.hibernate.integrator.spi.Integrator; import org.hibernate.mapping.PersistentClass; import org.hibernate.secure.JACCPreDeleteEventListener; import org.hibernate.secure.JACCPreInsertEventListener; @@ -40,19 +41,18 @@ import org.hibernate.secure.JACCPreLoadEventListener; import org.hibernate.secure.JACCPreUpdateEventListener; import org.hibernate.secure.JACCSecurityListener; import org.hibernate.service.classloading.spi.ClassLoaderService; -import org.hibernate.service.event.spi.DuplicationStrategy; -import org.hibernate.service.event.spi.EventListenerGroup; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.DuplicationStrategy; +import org.hibernate.event.service.spi.EventListenerGroup; +import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.service.spi.ServiceRegistryImplementor; +import org.hibernate.service.spi.SessionFactoryServiceRegistry; /** * Prepare the HEM-specific event listeners. - * - * @todo : make this into Integrator per HHH-5562 ?? * * @author Steve Ebersole */ -public class JpaEventListenerRegistration implements EventListenerRegistration { +public class JpaIntegrator implements Integrator { private static final DuplicationStrategy JPA_DUPLICATION_STRATEGY = new DuplicationStrategy() { @Override public boolean areMatch(Object listener, Object original) { @@ -81,12 +81,13 @@ public class JpaEventListenerRegistration implements EventListenerRegistration { @Override @SuppressWarnings( {"unchecked"}) - public void apply( - EventListenerRegistry eventListenerRegistry, + public void integrate( Configuration configuration, - Map configValues, - ServiceRegistryImplementor serviceRegistry) { - boolean isSecurityEnabled = configValues.containsKey( AvailableSettings.JACC_ENABLED ); + SessionFactoryImplementor sessionFactory, + SessionFactoryServiceRegistry serviceRegistry) { + final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class ); + + boolean isSecurityEnabled = configuration.getProperties().containsKey( AvailableSettings.JACC_ENABLED ); eventListenerRegistry.addDuplicationStrategy( JPA_DUPLICATION_STRATEGY ); eventListenerRegistry.addDuplicationStrategy( JACC_DUPLICATION_STRATEGY ); @@ -116,7 +117,7 @@ public class JpaEventListenerRegistration implements EventListenerRegistration { eventListenerRegistry.prependListeners( EventType.POST_LOAD, new EJB3PostLoadEventListener() ); eventListenerRegistry.prependListeners( EventType.POST_UPDATE, new EJB3PostUpdateEventListener() ); - for ( Map.Entry entry : configValues.entrySet() ) { + for ( Map.Entry entry : configuration.getProperties().entrySet() ) { if ( ! String.class.isInstance( entry.getKey() ) ) { continue; } @@ -127,14 +128,11 @@ public class JpaEventListenerRegistration implements EventListenerRegistration { final String eventTypeName = propertyName.substring( AvailableSettings.EVENT_LISTENER_PREFIX.length() + 1 ); final EventType eventType = EventType.resolveEventTypeByName( eventTypeName ); final EventListenerGroup eventListenerGroup = eventListenerRegistry.getEventListenerGroup( eventType ); - eventListenerGroup.clear(); for ( String listenerImpl : ( (String) entry.getValue() ).split( " ," ) ) { eventListenerGroup.appendListener( instantiate( listenerImpl, serviceRegistry ) ); } } - // todo : we may need to account for callback handlers previously set (shared across EMFs) - final EntityCallbackHandler callbackHandler = new EntityCallbackHandler(); Iterator classes = configuration.getClassMappings(); ReflectionManager reflectionManager = configuration.getReflectionManager(); @@ -162,6 +160,10 @@ public class JpaEventListenerRegistration implements EventListenerRegistration { } } + @Override + public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { + } + private Object instantiate(String listenerImpl, ServiceRegistryImplementor serviceRegistry) { try { return serviceRegistry.getService( ClassLoaderService.class ).classForName( listenerImpl ).newInstance(); diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/BaseEntityManagerFunctionalTestCase.java b/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/BaseEntityManagerFunctionalTestCase.java index fcaed74ce6..b29b63a850 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/BaseEntityManagerFunctionalTestCase.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/BaseEntityManagerFunctionalTestCase.java @@ -42,6 +42,7 @@ import org.hibernate.dialect.Dialect; import org.hibernate.ejb.AvailableSettings; import org.hibernate.ejb.Ejb3Configuration; import org.hibernate.internal.util.config.ConfigurationHelper; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.junit.After; @@ -203,7 +204,7 @@ public abstract class BaseEntityManagerFunctionalTestCase extends BaseUnitTestCa properties.putAll( configuration.getProperties() ); Environment.verifyProperties( properties ); ConfigurationHelper.resolvePlaceHolders( properties ); - return new BasicServiceRegistryImpl( properties ); + return (BasicServiceRegistryImpl) new ServiceRegistryBuilder( properties ).buildServiceRegistry(); } @SuppressWarnings( {"UnusedParameters"}) diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/packaging/PackagedEntityManagerTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/packaging/PackagedEntityManagerTest.java index 34788c7ac2..4d440aacfb 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/packaging/PackagedEntityManagerTest.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/ejb/test/packaging/PackagedEntityManagerTest.java @@ -58,7 +58,7 @@ import org.hibernate.ejb.test.pack.various.Seat; import org.hibernate.engine.SessionImplementor; import org.hibernate.event.EventType; import org.hibernate.internal.util.ConfigHelper; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.stat.Statistics; import org.junit.Test; diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java b/hibernate-envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java index 8faa0a7ae0..21a9190620 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/AuditReaderFactory.java @@ -32,7 +32,7 @@ import org.hibernate.envers.exception.AuditException; import org.hibernate.envers.reader.AuditReaderImpl; import org.hibernate.event.EventType; import org.hibernate.event.PostInsertEventListener; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; /** * @author Adam Warski (adam at warski dot org) diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java b/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java index f83f57e40c..58fcc4714a 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversIntegrator.java @@ -30,9 +30,9 @@ import org.hibernate.cfg.Configuration; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.envers.configuration.AuditConfiguration; import org.hibernate.event.EventType; -import org.hibernate.spi.Integrator; +import org.hibernate.integrator.spi.Integrator; import org.hibernate.internal.util.config.ConfigurationHelper; -import org.hibernate.service.event.spi.EventListenerRegistry; +import org.hibernate.event.service.spi.EventListenerRegistry; import org.hibernate.service.spi.SessionFactoryServiceRegistry; /** diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversListenerDuplicationStrategy.java b/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversListenerDuplicationStrategy.java index 6791760298..ae46616d89 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversListenerDuplicationStrategy.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/event/EnversListenerDuplicationStrategy.java @@ -23,7 +23,7 @@ */ package org.hibernate.envers.event; -import org.hibernate.service.event.spi.DuplicationStrategy; +import org.hibernate.event.service.spi.DuplicationStrategy; /** * Event listener duplication strategy for envers diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/AbstractEntityTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/AbstractEntityTest.java index b6765777ef..4bde4e66a4 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/AbstractEntityTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/AbstractEntityTest.java @@ -28,6 +28,7 @@ import org.hibernate.ejb.Ejb3Configuration; import org.hibernate.envers.AuditReader; import org.hibernate.envers.AuditReaderFactory; import org.hibernate.envers.event.EnversIntegrator; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.hibernate.testing.AfterClassOnce; import org.hibernate.testing.BeforeClassOnce; @@ -97,7 +98,7 @@ public abstract class AbstractEntityTest extends AbstractEnversTest { configure( cfg ); - serviceRegistry = new BasicServiceRegistryImpl(configValues); + serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( configValues ).buildServiceRegistry(); emf = cfg.buildEntityManagerFactory( serviceRegistry ); diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java index d18d556b2c..8ee94d5db0 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/AbstractGeneralDataRegionTestCase.java @@ -34,6 +34,8 @@ import org.hibernate.cache.Region; import org.hibernate.cache.infinispan.InfinispanRegionFactory; import org.hibernate.cache.infinispan.util.CacheAdapter; import org.hibernate.cfg.Configuration; +import org.hibernate.service.ServiceRegistry; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.junit.Test; @@ -79,7 +81,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm private void evictOrRemoveTest() throws Exception { Configuration cfg = createConfiguration(); InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( - new BasicServiceRegistryImpl( cfg.getProperties() ), + new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); @@ -96,7 +98,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm cfg = createConfiguration(); regionFactory = CacheTestUtil.startRegionFactory( - new BasicServiceRegistryImpl( cfg.getProperties() ), + new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); @@ -142,7 +144,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm private void evictOrRemoveAllTest(String configName) throws Exception { Configuration cfg = createConfiguration(); InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( - new BasicServiceRegistryImpl( cfg.getProperties() ), + new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); @@ -160,7 +162,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm cfg = createConfiguration(); regionFactory = CacheTestUtil.startRegionFactory( - new BasicServiceRegistryImpl( cfg.getProperties() ), + new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java index cf8e57de0b..c8ad070713 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/NodeEnvironment.java @@ -32,6 +32,7 @@ import org.hibernate.cache.infinispan.collection.CollectionRegionImpl; import org.hibernate.cache.infinispan.entity.EntityRegionImpl; import org.hibernate.cache.infinispan.util.FlagAdapter; import org.hibernate.cfg.Configuration; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.hibernate.test.cache.infinispan.util.CacheTestUtil; @@ -108,7 +109,7 @@ public class NodeEnvironment { } public void prepare() throws Exception { - serviceRegistry = new BasicServiceRegistryImpl( configuration.getProperties() ); + serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( configuration.getProperties() ).buildServiceRegistry(); regionFactory = CacheTestUtil.startRegionFactory( serviceRegistry, configuration ); } diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java index dc8a56ef8f..9defaf1502 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/query/QueryRegionImplTestCase.java @@ -42,6 +42,7 @@ import org.hibernate.cache.infinispan.InfinispanRegionFactory; import org.hibernate.cache.infinispan.util.CacheAdapter; import org.hibernate.cache.infinispan.util.CacheAdapterImpl; import org.hibernate.cfg.Configuration; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import junit.framework.AssertionFailedError; @@ -89,7 +90,7 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase { private void putDoesNotBlockGetTest() throws Exception { Configuration cfg = createConfiguration(); InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( - new BasicServiceRegistryImpl( cfg.getProperties() ), + new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); @@ -189,7 +190,7 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase { private void getDoesNotBlockPutTest() throws Exception { Configuration cfg = createConfiguration(); InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( - new BasicServiceRegistryImpl( cfg.getProperties() ), + new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/timestamp/TimestampsRegionImplTestCase.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/timestamp/TimestampsRegionImplTestCase.java index 729925d7d4..9a412ffa16 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/timestamp/TimestampsRegionImplTestCase.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/timestamp/TimestampsRegionImplTestCase.java @@ -48,6 +48,7 @@ import org.hibernate.cache.infinispan.util.CacheAdapter; import org.hibernate.cache.infinispan.util.CacheAdapterImpl; import org.hibernate.cache.infinispan.util.FlagAdapter; import org.hibernate.cfg.Configuration; +import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.service.internal.BasicServiceRegistryImpl; import org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTestCase; @@ -82,7 +83,7 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC public void testClearTimestampsRegionInIsolated() throws Exception { Configuration cfg = createConfiguration(); InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory( - new BasicServiceRegistryImpl( cfg.getProperties() ), + new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(), cfg, getCacheTestSupport() ); @@ -91,7 +92,7 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC Configuration cfg2 = createConfiguration(); InfinispanRegionFactory regionFactory2 = CacheTestUtil.startRegionFactory( - new BasicServiceRegistryImpl( cfg.getProperties() ), + new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(), cfg2, getCacheTestSupport() ); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java b/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java index f110dcbfad..d51f8389e8 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/ServiceRegistryBuilder.java @@ -44,7 +44,7 @@ public class ServiceRegistryBuilder { properties.putAll( serviceRegistryConfig ); Environment.verifyProperties( properties ); ConfigurationHelper.resolvePlaceHolders( properties ); - return new BasicServiceRegistryImpl( properties ); + return (BasicServiceRegistryImpl) new org.hibernate.service.ServiceRegistryBuilder( properties ).buildServiceRegistry(); } public static void destroy(ServiceRegistry serviceRegistry) { diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java index 9df8ec1445..4730870b1a 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseCoreFunctionalTestCase.java @@ -248,7 +248,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase { properties.putAll( configuration.getProperties() ); Environment.verifyProperties( properties ); ConfigurationHelper.resolvePlaceHolders( properties ); - BasicServiceRegistryImpl serviceRegistry = new BasicServiceRegistryImpl( properties ); + BasicServiceRegistryImpl serviceRegistry = (BasicServiceRegistryImpl) new org.hibernate.service.ServiceRegistryBuilder( properties ).buildServiceRegistry(); applyServices( serviceRegistry ); return serviceRegistry; }