HHH-6144 - Introduce ServiceRegistryBuilder
This commit is contained in:
parent
bd82732dee
commit
53e0439880
|
@ -38,8 +38,8 @@ import org.hibernate.event.EventType;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
import org.hibernate.service.event.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Any action relating to insert/update/delete of a collection
|
* Any action relating to insert/update/delete of a collection
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.hibernate.event.PostCollectionRecreateEventListener;
|
||||||
import org.hibernate.event.PreCollectionRecreateEvent;
|
import org.hibernate.event.PreCollectionRecreateEvent;
|
||||||
import org.hibernate.event.PreCollectionRecreateEventListener;
|
import org.hibernate.event.PreCollectionRecreateEventListener;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
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 {
|
public final class CollectionRecreateAction extends CollectionAction {
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.hibernate.event.PostCollectionRemoveEventListener;
|
||||||
import org.hibernate.event.PreCollectionRemoveEvent;
|
import org.hibernate.event.PreCollectionRemoveEvent;
|
||||||
import org.hibernate.event.PreCollectionRemoveEventListener;
|
import org.hibernate.event.PreCollectionRemoveEventListener;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
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 {
|
public final class CollectionRemoveAction extends CollectionAction {
|
||||||
|
|
||||||
|
|
|
@ -29,17 +29,14 @@ import org.hibernate.AssertionFailure;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.collection.PersistentCollection;
|
import org.hibernate.collection.PersistentCollection;
|
||||||
import org.hibernate.engine.SessionImplementor;
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.event.EventSource;
|
|
||||||
import org.hibernate.event.EventType;
|
import org.hibernate.event.EventType;
|
||||||
import org.hibernate.event.PostCollectionUpdateEvent;
|
import org.hibernate.event.PostCollectionUpdateEvent;
|
||||||
import org.hibernate.event.PostCollectionUpdateEventListener;
|
import org.hibernate.event.PostCollectionUpdateEventListener;
|
||||||
import org.hibernate.event.PreCollectionRemoveEvent;
|
|
||||||
import org.hibernate.event.PreCollectionRemoveEventListener;
|
|
||||||
import org.hibernate.event.PreCollectionUpdateEvent;
|
import org.hibernate.event.PreCollectionUpdateEvent;
|
||||||
import org.hibernate.event.PreCollectionUpdateEventListener;
|
import org.hibernate.event.PreCollectionUpdateEventListener;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
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 {
|
public final class CollectionUpdateAction extends CollectionAction {
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ import org.hibernate.event.EventType;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
import org.hibernate.service.event.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for actions relating to insert/update/delete of an entity
|
* Base class for actions relating to insert/update/delete of an entity
|
||||||
|
|
|
@ -32,14 +32,13 @@ import org.hibernate.cache.access.SoftLock;
|
||||||
import org.hibernate.engine.EntityEntry;
|
import org.hibernate.engine.EntityEntry;
|
||||||
import org.hibernate.engine.PersistenceContext;
|
import org.hibernate.engine.PersistenceContext;
|
||||||
import org.hibernate.engine.SessionImplementor;
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.event.EventSource;
|
|
||||||
import org.hibernate.event.EventType;
|
import org.hibernate.event.EventType;
|
||||||
import org.hibernate.event.PostDeleteEvent;
|
import org.hibernate.event.PostDeleteEvent;
|
||||||
import org.hibernate.event.PostDeleteEventListener;
|
import org.hibernate.event.PostDeleteEventListener;
|
||||||
import org.hibernate.event.PreDeleteEvent;
|
import org.hibernate.event.PreDeleteEvent;
|
||||||
import org.hibernate.event.PreDeleteEventListener;
|
import org.hibernate.event.PreDeleteEventListener;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
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 {
|
public final class EntityDeleteAction extends EntityAction {
|
||||||
private final Object version;
|
private final Object version;
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.hibernate.event.PostInsertEventListener;
|
||||||
import org.hibernate.event.PreInsertEvent;
|
import org.hibernate.event.PreInsertEvent;
|
||||||
import org.hibernate.event.PreInsertEventListener;
|
import org.hibernate.event.PreInsertEventListener;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
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 {
|
public final class EntityIdentityInsertAction extends EntityAction {
|
||||||
|
|
||||||
|
|
|
@ -33,15 +33,13 @@ import org.hibernate.engine.EntityEntry;
|
||||||
import org.hibernate.engine.SessionFactoryImplementor;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.SessionImplementor;
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.engine.Versioning;
|
import org.hibernate.engine.Versioning;
|
||||||
import org.hibernate.event.EventSource;
|
|
||||||
import org.hibernate.event.EventType;
|
import org.hibernate.event.EventType;
|
||||||
import org.hibernate.event.PostInsertEvent;
|
import org.hibernate.event.PostInsertEvent;
|
||||||
import org.hibernate.event.PostInsertEventListener;
|
import org.hibernate.event.PostInsertEventListener;
|
||||||
import org.hibernate.event.PreInsertEvent;
|
import org.hibernate.event.PreInsertEvent;
|
||||||
import org.hibernate.event.PreInsertEventListener;
|
import org.hibernate.event.PreInsertEventListener;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.service.event.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
|
||||||
|
|
||||||
public final class EntityInsertAction extends EntityAction {
|
public final class EntityInsertAction extends EntityAction {
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ import org.hibernate.event.PostUpdateEventListener;
|
||||||
import org.hibernate.event.PreUpdateEvent;
|
import org.hibernate.event.PreUpdateEvent;
|
||||||
import org.hibernate.event.PreUpdateEventListener;
|
import org.hibernate.event.PreUpdateEventListener;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
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;
|
import org.hibernate.type.TypeHelper;
|
||||||
|
|
||||||
public final class EntityUpdateAction extends EntityAction {
|
public final class EntityUpdateAction extends EntityAction {
|
||||||
|
|
|
@ -35,8 +35,8 @@ import org.hibernate.event.PreLoadEvent;
|
||||||
import org.hibernate.event.PreLoadEventListener;
|
import org.hibernate.event.PreLoadEventListener;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.service.event.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
import org.hibernate.type.TypeHelper;
|
import org.hibernate.type.TypeHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -130,6 +130,7 @@ import org.hibernate.mapping.UniqueKey;
|
||||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||||
import org.hibernate.secure.JACCConfiguration;
|
import org.hibernate.secure.JACCConfiguration;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
|
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
|
||||||
import org.hibernate.tool.hbm2ddl.IndexMetadata;
|
import org.hibernate.tool.hbm2ddl.IndexMetadata;
|
||||||
|
@ -1744,7 +1745,7 @@ public class Configuration implements Serializable {
|
||||||
public SessionFactory buildSessionFactory() throws HibernateException {
|
public SessionFactory buildSessionFactory() throws HibernateException {
|
||||||
Environment.verifyProperties( properties );
|
Environment.verifyProperties( properties );
|
||||||
ConfigurationHelper.resolvePlaceHolders( properties );
|
ConfigurationHelper.resolvePlaceHolders( properties );
|
||||||
final ServiceRegistry serviceRegistry = new BasicServiceRegistryImpl( properties );
|
final ServiceRegistry serviceRegistry = new ServiceRegistryBuilder( properties ).buildServiceRegistry();
|
||||||
setSessionFactoryObserver(
|
setSessionFactoryObserver(
|
||||||
new SessionFactoryObserver() {
|
new SessionFactoryObserver() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -33,14 +33,14 @@ import java.util.Set;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.integrator.spi.Integrator;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.SessionFactoryImplementor;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.spi.Integrator;
|
|
||||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
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;
|
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.cfg.beanvalidation;
|
package org.hibernate.cfg.beanvalidation;
|
||||||
|
|
||||||
import org.hibernate.service.event.spi.DuplicationStrategy;
|
import org.hibernate.event.service.spi.DuplicationStrategy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
|
|
|
@ -57,7 +57,7 @@ import org.hibernate.mapping.Component;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.mapping.Property;
|
import org.hibernate.mapping.Property;
|
||||||
import org.hibernate.mapping.SingleTableSubclass;
|
import org.hibernate.mapping.SingleTableSubclass;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
|
|
|
@ -36,11 +36,11 @@ import org.hibernate.event.PostCollectionUpdateEventListener;
|
||||||
import org.hibernate.event.PostDeleteEventListener;
|
import org.hibernate.event.PostDeleteEventListener;
|
||||||
import org.hibernate.event.PostInsertEventListener;
|
import org.hibernate.event.PostInsertEventListener;
|
||||||
import org.hibernate.event.PostUpdateEventListener;
|
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.internal.util.config.ConfigurationHelper;
|
||||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.service.event.spi.DuplicationStrategy;
|
import org.hibernate.event.service.spi.DuplicationStrategy;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -44,8 +44,8 @@ import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
import org.hibernate.property.BackrefPropertyAccessor;
|
import org.hibernate.property.BackrefPropertyAccessor;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.service.event.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
import org.hibernate.type.TypeHelper;
|
import org.hibernate.type.TypeHelper;
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,8 @@ import org.hibernate.internal.util.collections.IdentityMap;
|
||||||
import org.hibernate.internal.util.collections.LazyIterator;
|
import org.hibernate.internal.util.collections.LazyIterator;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.pretty.Printer;
|
import org.hibernate.pretty.Printer;
|
||||||
import org.hibernate.service.event.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A convenience base class for listeners whose functionality results in flushing.
|
* A convenience base class for listeners whose functionality results in flushing.
|
||||||
|
|
|
@ -55,7 +55,7 @@ import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.proxy.LazyInitializer;
|
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.EmbeddedComponentType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
|
@ -21,9 +21,8 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* 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.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
@ -32,9 +31,9 @@ import java.util.ListIterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.event.EventType;
|
import org.hibernate.event.EventType;
|
||||||
import org.hibernate.service.event.spi.DuplicationStrategy;
|
import org.hibernate.event.service.spi.DuplicationStrategy;
|
||||||
import org.hibernate.service.event.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistrationException;
|
import org.hibernate.event.service.spi.EventListenerRegistrationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
|
@ -21,7 +21,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.service.event.internal;
|
package org.hibernate.event.service.internal;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -29,9 +29,6 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
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.EventType;
|
||||||
import org.hibernate.event.def.DefaultAutoFlushEventListener;
|
import org.hibernate.event.def.DefaultAutoFlushEventListener;
|
||||||
import org.hibernate.event.def.DefaultDeleteEventListener;
|
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.DefaultSaveEventListener;
|
||||||
import org.hibernate.event.def.DefaultSaveOrUpdateEventListener;
|
import org.hibernate.event.def.DefaultSaveOrUpdateEventListener;
|
||||||
import org.hibernate.event.def.DefaultUpdateEventListener;
|
import org.hibernate.event.def.DefaultUpdateEventListener;
|
||||||
import org.hibernate.service.event.spi.DuplicationStrategy;
|
import org.hibernate.event.service.spi.DuplicationStrategy;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistrationException;
|
import org.hibernate.event.service.spi.EventListenerRegistrationException;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
|
||||||
import org.hibernate.service.StandardServiceInitiators.EventListenerRegistrationService;
|
|
||||||
|
|
||||||
import static org.hibernate.event.EventType.AUTO_FLUSH;
|
import static org.hibernate.event.EventType.AUTO_FLUSH;
|
||||||
import static org.hibernate.event.EventType.DELETE;
|
import static org.hibernate.event.EventType.DELETE;
|
||||||
|
@ -425,20 +420,4 @@ public class EventListenerRegistryImpl implements EventListenerRegistry {
|
||||||
map.put( type, listeners );
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,11 +21,11 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* 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.cfg.Configuration;
|
||||||
import org.hibernate.engine.SessionFactoryImplementor;
|
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.ServiceRegistryImplementor;
|
||||||
import org.hibernate.service.spi.SessionFactoryServiceInitiator;
|
import org.hibernate.service.spi.SessionFactoryServiceInitiator;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class EventListenerServiceInitiator implements SessionFactoryServiceIniti
|
||||||
SessionFactoryImplementor sessionFactory,
|
SessionFactoryImplementor sessionFactory,
|
||||||
Configuration configuration,
|
Configuration configuration,
|
||||||
ServiceRegistryImplementor registry) {
|
ServiceRegistryImplementor registry) {
|
||||||
return EventListenerRegistryImpl.buildEventListenerRegistry( sessionFactory, configuration, registry );
|
return new EventListenerRegistryImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* 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
|
* Defines listener duplication checking strategy, both in terms of when a duplication is detected (see
|
|
@ -21,7 +21,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.service.event.spi;
|
package org.hibernate.event.service.spi;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.service.event.spi;
|
package org.hibernate.event.service.spi;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.service.event.spi;
|
package org.hibernate.event.service.spi;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
|
@ -39,10 +39,8 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.ServiceLoader;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
@ -56,7 +54,6 @@ import org.hibernate.EmptyInterceptor;
|
||||||
import org.hibernate.EntityMode;
|
import org.hibernate.EntityMode;
|
||||||
import org.hibernate.EntityNameResolver;
|
import org.hibernate.EntityNameResolver;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
|
||||||
import org.hibernate.Interceptor;
|
import org.hibernate.Interceptor;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.ObjectNotFoundException;
|
import org.hibernate.ObjectNotFoundException;
|
||||||
|
@ -80,8 +77,6 @@ import org.hibernate.cache.impl.CacheDataDescriptionImpl;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.cfg.Settings;
|
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.CurrentSessionContext;
|
||||||
import org.hibernate.context.JTASessionContext;
|
import org.hibernate.context.JTASessionContext;
|
||||||
import org.hibernate.context.ManagedSessionContext;
|
import org.hibernate.context.ManagedSessionContext;
|
||||||
|
@ -107,6 +102,8 @@ import org.hibernate.exception.SQLExceptionConverter;
|
||||||
import org.hibernate.id.IdentifierGenerator;
|
import org.hibernate.id.IdentifierGenerator;
|
||||||
import org.hibernate.id.UUIDGenerator;
|
import org.hibernate.id.UUIDGenerator;
|
||||||
import org.hibernate.id.factory.IdentifierGeneratorFactory;
|
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.ReflectHelper;
|
||||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||||
import org.hibernate.internal.util.collections.EmptyIterator;
|
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.pretty.MessageHelper;
|
||||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.integrator.spi.IntegratorService;
|
||||||
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
|
||||||
import org.hibernate.service.jta.platform.spi.JtaPlatform;
|
import org.hibernate.service.jta.platform.spi.JtaPlatform;
|
||||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||||
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
||||||
import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory;
|
import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory;
|
||||||
import org.hibernate.spi.Integrator;
|
|
||||||
import org.hibernate.stat.Statistics;
|
import org.hibernate.stat.Statistics;
|
||||||
import org.hibernate.stat.spi.StatisticsImplementor;
|
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
|
@ -260,7 +257,7 @@ public final class SessionFactoryImpl
|
||||||
|
|
||||||
final IntegratorObserver integratorObserver = new IntegratorObserver();
|
final IntegratorObserver integratorObserver = new IntegratorObserver();
|
||||||
this.observer.addObserver( 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 );
|
integrator.integrate( cfg, this, this.serviceRegistry );
|
||||||
integratorObserver.integrators.add( integrator );
|
integratorObserver.integrators.add( integrator );
|
||||||
}
|
}
|
||||||
|
@ -503,20 +500,6 @@ public final class SessionFactoryImpl
|
||||||
this.observer.sessionFactoryCreated( this );
|
this.observer.sessionFactoryCreated( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Iterable<Integrator> locateIntegrators(ServiceRegistryImplementor serviceRegistry) {
|
|
||||||
List<Integrator> integrators = new ArrayList<Integrator>();
|
|
||||||
|
|
||||||
// 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 {
|
public Session openSession() throws HibernateException {
|
||||||
return withOptions().openSession();
|
return withOptions().openSession();
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,8 +141,8 @@ import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.proxy.LazyInitializer;
|
import org.hibernate.proxy.LazyInitializer;
|
||||||
import org.hibernate.service.event.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
import org.hibernate.stat.SessionStatistics;
|
import org.hibernate.stat.SessionStatistics;
|
||||||
import org.hibernate.stat.internal.SessionStatisticsImpl;
|
import org.hibernate.stat.internal.SessionStatisticsImpl;
|
||||||
import org.hibernate.type.SerializationException;
|
import org.hibernate.type.SerializationException;
|
||||||
|
|
|
@ -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<Integrator> integrators = new LinkedHashSet<Integrator>();
|
||||||
|
|
||||||
|
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<Integrator> getIntegrators() {
|
||||||
|
LinkedHashSet<Integrator> integrators = new LinkedHashSet<Integrator>();
|
||||||
|
integrators.addAll( this.integrators );
|
||||||
|
|
||||||
|
for ( Integrator integrator : ServiceLoader.load( Integrator.class ) ) {
|
||||||
|
integrators.add( integrator );
|
||||||
|
}
|
||||||
|
|
||||||
|
return integrators;
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,25 +21,27 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.event;
|
package org.hibernate.integrator.internal;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.integrator.spi.IntegratorService;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.service.spi.BasicServiceInitiator;
|
||||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
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
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface EventListenerRegistration {
|
public class IntegratorServiceInitiator implements BasicServiceInitiator<IntegratorService> {
|
||||||
public void apply(
|
public static final IntegratorServiceInitiator INSTANCE = new IntegratorServiceInitiator();
|
||||||
EventListenerRegistry eventListenerRegistry,
|
|
||||||
Configuration configuration,
|
@Override
|
||||||
Map<?, ?> configValues,
|
public Class<IntegratorService> getServiceInitiated() {
|
||||||
ServiceRegistryImplementor serviceRegistry
|
return IntegratorService.class;
|
||||||
);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IntegratorService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
|
||||||
|
return new IntegratorServiceImpl( registry );
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.spi;
|
package org.hibernate.integrator.spi;
|
||||||
|
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.engine.SessionFactoryImplementor;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
|
@ -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.
|
||||||
|
* <p/>
|
||||||
|
* 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<Integrator> getIntegrators();
|
||||||
|
}
|
|
@ -1,19 +1,21 @@
|
||||||
//$Id: HibernateService.java 6100 2005-03-17 10:48:03Z turin42 $
|
//$Id: HibernateService.java 6100 2005-03-17 10:48:03Z turin42 $
|
||||||
package org.hibernate.jmx;
|
package org.hibernate.jmx;
|
||||||
|
|
||||||
|
import javax.naming.InitialContext;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import javax.naming.InitialContext;
|
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.cfg.ExternalSessionFactoryConfig;
|
import org.hibernate.cfg.ExternalSessionFactoryConfig;
|
||||||
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.internal.util.jndi.JndiHelper;
|
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.service.jta.platform.internal.JtaPlatformInitiator;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
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 {
|
SessionFactory buildSessionFactory() throws HibernateException {
|
||||||
LOG.startingServiceAtJndiName(boundName);
|
LOG.startingServiceAtJndiName( boundName );
|
||||||
LOG.serviceProperties(properties);
|
LOG.serviceProperties( properties );
|
||||||
return buildConfiguration().buildSessionFactory(new BasicServiceRegistryImpl(properties));
|
return buildConfiguration().buildSessionFactory(
|
||||||
|
new ServiceRegistryBuilder( properties ).buildServiceRegistry()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -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<BasicServiceInitiator> initiators = standardInitiatorList();
|
||||||
|
private final List<ProvidedService> services = new ArrayList<ProvidedService>();
|
||||||
|
|
||||||
|
public ServiceRegistryBuilder() {
|
||||||
|
this( new HashMap() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceRegistryBuilder(Map configurationValues) {
|
||||||
|
this.configurationValues = configurationValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<BasicServiceInitiator> standardInitiatorList() {
|
||||||
|
final List<BasicServiceInitiator> initiators = new ArrayList<BasicServiceInitiator>();
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,12 +26,11 @@ package org.hibernate.service;
|
||||||
import org.hibernate.engine.jdbc.batch.internal.BatchBuilderInitiator;
|
import org.hibernate.engine.jdbc.batch.internal.BatchBuilderInitiator;
|
||||||
import org.hibernate.engine.jdbc.internal.JdbcServicesInitiator;
|
import org.hibernate.engine.jdbc.internal.JdbcServicesInitiator;
|
||||||
import org.hibernate.engine.transaction.internal.TransactionFactoryInitiator;
|
import org.hibernate.engine.transaction.internal.TransactionFactoryInitiator;
|
||||||
import org.hibernate.event.EventListenerRegistration;
|
|
||||||
import org.hibernate.persister.internal.PersisterClassResolverInitiator;
|
import org.hibernate.persister.internal.PersisterClassResolverInitiator;
|
||||||
import org.hibernate.persister.internal.PersisterFactoryInitiator;
|
import org.hibernate.persister.internal.PersisterFactoryInitiator;
|
||||||
import org.hibernate.service.classloading.internal.ClassLoaderServiceInitiator;
|
import org.hibernate.service.classloading.internal.ClassLoaderServiceInitiator;
|
||||||
|
import org.hibernate.integrator.internal.IntegratorServiceInitiator;
|
||||||
import org.hibernate.service.internal.SessionFactoryServiceRegistryFactoryInitiator;
|
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.ConnectionProviderInitiator;
|
||||||
import org.hibernate.service.jdbc.connections.internal.MultiTenantConnectionProviderInitiator;
|
import org.hibernate.service.jdbc.connections.internal.MultiTenantConnectionProviderInitiator;
|
||||||
import org.hibernate.service.jdbc.dialect.internal.DialectFactoryInitiator;
|
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.jndi.internal.JndiServiceInitiator;
|
||||||
import org.hibernate.service.jta.platform.internal.JtaPlatformInitiator;
|
import org.hibernate.service.jta.platform.internal.JtaPlatformInitiator;
|
||||||
import org.hibernate.service.spi.BasicServiceInitiator;
|
import org.hibernate.service.spi.BasicServiceInitiator;
|
||||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
|
@ -73,50 +70,9 @@ public class StandardServiceInitiators {
|
||||||
serviceInitiators.add( TransactionFactoryInitiator.INSTANCE );
|
serviceInitiators.add( TransactionFactoryInitiator.INSTANCE );
|
||||||
|
|
||||||
serviceInitiators.add( SessionFactoryServiceRegistryFactoryInitiator.INSTANCE );
|
serviceInitiators.add( SessionFactoryServiceRegistryFactoryInitiator.INSTANCE );
|
||||||
|
serviceInitiators.add( IntegratorServiceInitiator.INSTANCE );
|
||||||
serviceInitiators.add( EventListenerRegistrationServiceInitiator.INSTANCE );
|
|
||||||
|
|
||||||
return serviceInitiators;
|
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<EventListenerRegistration> getEventListenerRegistrations();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class EventListenerRegistrationServiceImpl implements EventListenerRegistrationService {
|
|
||||||
private List<EventListenerRegistration> registrations = new ArrayList<EventListenerRegistration>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void attachEventListenerRegistration(EventListenerRegistration registration) {
|
|
||||||
registrations.add( registration );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<EventListenerRegistration> getEventListenerRegistrations() {
|
|
||||||
return registrations;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class EventListenerRegistrationServiceInitiator implements BasicServiceInitiator<EventListenerRegistrationService> {
|
|
||||||
public static final EventListenerRegistrationServiceInitiator INSTANCE = new EventListenerRegistrationServiceInitiator();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<EventListenerRegistrationService> getServiceInitiated() {
|
|
||||||
return EventListenerRegistrationService.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public EventListenerRegistrationService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
|
|
||||||
return new EventListenerRegistrationServiceImpl();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ package org.hibernate.service;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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.service.spi.SessionFactoryServiceInitiator;
|
||||||
import org.hibernate.stat.internal.StatisticsInitiator;
|
import org.hibernate.stat.internal.StatisticsInitiator;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.jboss.logging.Logger;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.service.BasicServiceRegistry;
|
import org.hibernate.service.BasicServiceRegistry;
|
||||||
import org.hibernate.service.Service;
|
import org.hibernate.service.Service;
|
||||||
import org.hibernate.service.StandardServiceInitiators;
|
|
||||||
import org.hibernate.service.UnknownServiceException;
|
import org.hibernate.service.UnknownServiceException;
|
||||||
import org.hibernate.service.spi.BasicServiceInitiator;
|
import org.hibernate.service.spi.BasicServiceInitiator;
|
||||||
import org.hibernate.service.spi.Configurable;
|
import org.hibernate.service.spi.Configurable;
|
||||||
|
@ -50,19 +49,25 @@ public class BasicServiceRegistryImpl extends AbstractServiceRegistryImpl implem
|
||||||
private final Map<Class,BasicServiceInitiator> serviceInitiatorMap;
|
private final Map<Class,BasicServiceInitiator> serviceInitiatorMap;
|
||||||
private final Map configurationValues;
|
private final Map configurationValues;
|
||||||
|
|
||||||
public BasicServiceRegistryImpl(Map configurationValues) {
|
|
||||||
this( StandardServiceInitiators.LIST, configurationValues );
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings( {"unchecked"})
|
@SuppressWarnings( {"unchecked"})
|
||||||
public BasicServiceRegistryImpl(List<BasicServiceInitiator> serviceInitiators, Map configurationValues) {
|
public BasicServiceRegistryImpl(
|
||||||
|
List<BasicServiceInitiator> serviceInitiators,
|
||||||
|
List<ProvidedService> providedServices,
|
||||||
|
Map configurationValues) {
|
||||||
super();
|
super();
|
||||||
this.serviceInitiatorMap = toMap( serviceInitiators );
|
|
||||||
this.configurationValues = configurationValues;
|
this.configurationValues = configurationValues;
|
||||||
|
|
||||||
|
this.serviceInitiatorMap = toMap( serviceInitiators );
|
||||||
for ( BasicServiceInitiator initiator : serviceInitiatorMap.values() ) {
|
for ( BasicServiceInitiator initiator : serviceInitiatorMap.values() ) {
|
||||||
// create the bindings up front to help identify to which registry services belong
|
// create the bindings up front to help identify to which registry services belong
|
||||||
createServiceBinding( initiator.getServiceInitiated() );
|
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 );
|
( (Configurable) service ).configure( configurationValues );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,27 +21,27 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.service.event.internal;
|
package org.hibernate.service.internal;
|
||||||
|
|
||||||
import org.hibernate.event.EventType;
|
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for handling various aspects of event listeners. Temporary because generally speaking this is legacy stuff
|
* A service provided as-is.
|
||||||
* that should change as we move forward
|
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class TemporaryListenerHelper {
|
public class ProvidedService<T> {
|
||||||
public static interface ListenerProcessor {
|
private final Class<T> serviceRole;
|
||||||
public void processListener(Object listener);
|
private final T service;
|
||||||
|
|
||||||
|
public ProvidedService(Class<T> serviceRole, T service) {
|
||||||
|
this.serviceRole = serviceRole;
|
||||||
|
this.service = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void processListeners(EventListenerRegistry registryRegistry, ListenerProcessor processer) {
|
public Class<T> getServiceRole() {
|
||||||
for ( EventType eventType : EventType.values() ) {
|
return serviceRole;
|
||||||
for ( Object listener : registryRegistry.getEventListenerGroup( eventType ).listeners() ) {
|
}
|
||||||
processer.processListener( listener );
|
|
||||||
}
|
public T getService() {
|
||||||
}
|
return service;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,13 +23,10 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.service.internal;
|
package org.hibernate.service.internal;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.engine.SessionFactoryImplementor;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.service.Service;
|
import org.hibernate.service.Service;
|
||||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||||
import org.hibernate.service.spi.SessionFactoryServiceInitiator;
|
|
||||||
import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory;
|
import org.hibernate.service.spi.SessionFactoryServiceRegistryFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.service.spi;
|
package org.hibernate.service.spi;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.engine.SessionFactoryImplementor;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.service.Service;
|
import org.hibernate.service.Service;
|
||||||
|
|
|
@ -56,6 +56,7 @@ import org.hibernate.internal.util.ConfigHelper;
|
||||||
import org.hibernate.internal.util.ReflectHelper;
|
import org.hibernate.internal.util.ReflectHelper;
|
||||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
|
||||||
|
|
||||||
|
@ -460,7 +461,7 @@ public class SchemaExport {
|
||||||
private static BasicServiceRegistryImpl createServiceRegistry(Properties properties) {
|
private static BasicServiceRegistryImpl createServiceRegistry(Properties properties) {
|
||||||
Environment.verifyProperties( properties );
|
Environment.verifyProperties( properties );
|
||||||
ConfigurationHelper.resolvePlaceHolders( properties );
|
ConfigurationHelper.resolvePlaceHolders( properties );
|
||||||
return new BasicServiceRegistryImpl( properties );
|
return (BasicServiceRegistryImpl) new ServiceRegistryBuilder( properties ).buildServiceRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -50,6 +50,7 @@ import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||||
import org.hibernate.internal.util.ReflectHelper;
|
import org.hibernate.internal.util.ReflectHelper;
|
||||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,7 +110,7 @@ public class SchemaUpdate {
|
||||||
private static BasicServiceRegistryImpl createServiceRegistry(Properties properties) {
|
private static BasicServiceRegistryImpl createServiceRegistry(Properties properties) {
|
||||||
Environment.verifyProperties( properties );
|
Environment.verifyProperties( properties );
|
||||||
ConfigurationHelper.resolvePlaceHolders( properties );
|
ConfigurationHelper.resolvePlaceHolders( properties );
|
||||||
return new BasicServiceRegistryImpl( properties );
|
return (BasicServiceRegistryImpl) new ServiceRegistryBuilder( properties ).buildServiceRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.internal.util.ReflectHelper;
|
import org.hibernate.internal.util.ReflectHelper;
|
||||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,7 +79,7 @@ public class SchemaValidator {
|
||||||
private static BasicServiceRegistryImpl createServiceRegistry(Properties properties) {
|
private static BasicServiceRegistryImpl createServiceRegistry(Properties properties) {
|
||||||
Environment.verifyProperties( properties );
|
Environment.verifyProperties( properties );
|
||||||
ConfigurationHelper.resolvePlaceHolders( properties );
|
ConfigurationHelper.resolvePlaceHolders( properties );
|
||||||
return new BasicServiceRegistryImpl( properties );
|
return (BasicServiceRegistryImpl) new ServiceRegistryBuilder( properties ).buildServiceRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -51,7 +51,7 @@ import org.hibernate.property.Getter;
|
||||||
import org.hibernate.property.Setter;
|
import org.hibernate.property.Setter;
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.proxy.ProxyFactory;
|
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.Instantiator;
|
||||||
import org.hibernate.tuple.StandardProperty;
|
import org.hibernate.tuple.StandardProperty;
|
||||||
import org.hibernate.tuple.VersionProperty;
|
import org.hibernate.tuple.VersionProperty;
|
||||||
|
|
|
@ -23,16 +23,15 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.metamodel.binding;
|
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.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
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 org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertNotNull;
|
import static junit.framework.Assert.assertNotNull;
|
||||||
|
@ -51,7 +50,7 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
serviceRegistry = new BasicServiceRegistryImpl( Collections.emptyMap() );
|
serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
|
@ -25,14 +25,13 @@ package org.hibernate.metamodel.binding;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import org.jboss.jandex.Index;
|
import org.jboss.jandex.Index;
|
||||||
import org.jboss.jandex.Indexer;
|
import org.jboss.jandex.Indexer;
|
||||||
|
|
||||||
import org.hibernate.metamodel.source.MetadataSources;
|
import org.hibernate.metamodel.source.MetadataSources;
|
||||||
import org.hibernate.metamodel.source.internal.MetadataImpl;
|
import org.hibernate.metamodel.source.internal.MetadataImpl;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -61,7 +60,7 @@ public class BasicAnnotationBindingTests extends AbstractBasicBindingTests {
|
||||||
|
|
||||||
public EntityBinding buildSimpleEntityBinding() {
|
public EntityBinding buildSimpleEntityBinding() {
|
||||||
Index index = indexForClass( SimpleEntity.class );
|
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 );
|
metadata.getAnnotationBinder().bindMappedClasses( index );
|
||||||
|
|
||||||
return metadata.getEntityBinding( SimpleEntity.class.getSimpleName() );
|
return metadata.getEntityBinding( SimpleEntity.class.getSimpleName() );
|
||||||
|
@ -69,7 +68,7 @@ public class BasicAnnotationBindingTests extends AbstractBasicBindingTests {
|
||||||
|
|
||||||
public EntityBinding buildSimpleVersionedEntityBinding() {
|
public EntityBinding buildSimpleVersionedEntityBinding() {
|
||||||
Index index = indexForClass( SimpleEntity.class );
|
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 );
|
metadata.getAnnotationBinder().bindMappedClasses( index );
|
||||||
|
|
||||||
return metadata.getEntityBinding( SimpleVersionedEntity.class.getSimpleName() );
|
return metadata.getEntityBinding( SimpleVersionedEntity.class.getSimpleName() );
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
package org.hibernate.metamodel.source.annotations.global;
|
package org.hibernate.metamodel.source.annotations.global;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.jboss.jandex.Index;
|
import org.jboss.jandex.Index;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.annotations.FetchMode;
|
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.MetadataSources;
|
||||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||||
import org.hibernate.metamodel.source.internal.MetadataImpl;
|
import org.hibernate.metamodel.source.internal.MetadataImpl;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
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 org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
|
||||||
import static junit.framework.Assert.fail;
|
import static junit.framework.Assert.fail;
|
||||||
|
@ -34,7 +36,7 @@ public class FetchProfileBinderTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
serviceRegistry = new BasicServiceRegistryImpl( Collections.emptyMap() );
|
serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry();
|
||||||
service = serviceRegistry.getService( ClassLoaderService.class );
|
service = serviceRegistry.getService( ClassLoaderService.class );
|
||||||
meta = (MetadataImpl) new MetadataSources( serviceRegistry ).buildMetadata();
|
meta = (MetadataImpl) new MetadataSources( serviceRegistry ).buildMetadata();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.junit.Test;
|
||||||
import org.hibernate.AnnotationException;
|
import org.hibernate.AnnotationException;
|
||||||
import org.hibernate.metamodel.source.annotations.ConfiguredClass;
|
import org.hibernate.metamodel.source.annotations.ConfiguredClass;
|
||||||
import org.hibernate.metamodel.source.annotations.ConfiguredClassHierarchy;
|
import org.hibernate.metamodel.source.annotations.ConfiguredClassHierarchy;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
@ -39,7 +40,7 @@ public class ConfiguredClassHierarchyBuilderTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
serviceRegistry = new BasicServiceRegistryImpl( Collections.emptyMap() );
|
serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry();
|
||||||
service = serviceRegistry.getService( ClassLoaderService.class );
|
service = serviceRegistry.getService( ClassLoaderService.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.metamodel.source.MetadataSources;
|
import org.hibernate.metamodel.source.MetadataSources;
|
||||||
import org.hibernate.metamodel.source.internal.MetadataImpl;
|
import org.hibernate.metamodel.source.internal.MetadataImpl;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
|
||||||
|
@ -17,7 +18,7 @@ import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
public class OrmXmlParserTests extends BaseUnitTestCase {
|
public class OrmXmlParserTests extends BaseUnitTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testSingleOrmXml() {
|
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 );
|
OrmXmlParser parser = new OrmXmlParser( metadata );
|
||||||
Set<String> xmlFiles = new HashSet<String>();
|
Set<String> xmlFiles = new HashSet<String>();
|
||||||
xmlFiles.add( "org/hibernate/metamodel/source/annotations/xml/orm.xml" );
|
xmlFiles.add( "org/hibernate/metamodel/source/annotations/xml/orm.xml" );
|
||||||
|
@ -26,7 +27,7 @@ public class OrmXmlParserTests extends BaseUnitTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOrmXmlWithOldSchema() {
|
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 );
|
OrmXmlParser parser = new OrmXmlParser( metadata );
|
||||||
Set<String> xmlFiles = new HashSet<String>();
|
Set<String> xmlFiles = new HashSet<String>();
|
||||||
xmlFiles.add( "org/hibernate/metamodel/source/annotations/xml/orm-star.xml" );
|
xmlFiles.add( "org/hibernate/metamodel/source/annotations/xml/orm-star.xml" );
|
||||||
|
|
|
@ -45,7 +45,7 @@ import org.hibernate.event.PreCollectionRemoveEventListener;
|
||||||
import org.hibernate.event.PreCollectionUpdateEvent;
|
import org.hibernate.event.PreCollectionUpdateEvent;
|
||||||
import org.hibernate.event.PreCollectionUpdateEventListener;
|
import org.hibernate.event.PreCollectionUpdateEventListener;
|
||||||
import org.hibernate.event.def.DefaultInitializeCollectionEventListener;
|
import org.hibernate.event.def.DefaultInitializeCollectionEventListener;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
|
|
|
@ -22,23 +22,24 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.events;
|
package org.hibernate.test.events;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.SessionFactoryObserver;
|
import org.hibernate.SessionFactoryObserver;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.event.DeleteEvent;
|
import org.hibernate.event.DeleteEvent;
|
||||||
import org.hibernate.event.DeleteEventListener;
|
import org.hibernate.event.DeleteEventListener;
|
||||||
import org.hibernate.event.Destructible;
|
import org.hibernate.event.Destructible;
|
||||||
import org.hibernate.event.EventListenerRegistration;
|
|
||||||
import org.hibernate.event.EventType;
|
import org.hibernate.event.EventType;
|
||||||
import org.hibernate.event.Initializable;
|
import org.hibernate.event.Initializable;
|
||||||
import org.hibernate.service.StandardServiceInitiators;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.integrator.spi.IntegratorService;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
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;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -68,15 +69,21 @@ public class CallbackTest extends BaseCoreFunctionalTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected void applyServices(BasicServiceRegistryImpl serviceRegistry) {
|
protected void applyServices(BasicServiceRegistryImpl serviceRegistry) {
|
||||||
super.applyServices( serviceRegistry );
|
super.applyServices( serviceRegistry );
|
||||||
serviceRegistry.getService( StandardServiceInitiators.EventListenerRegistrationService.class ).attachEventListenerRegistration(
|
serviceRegistry.getService( IntegratorService.class ).addIntegrator(
|
||||||
new EventListenerRegistration() {
|
new Integrator() {
|
||||||
@Override
|
@Override
|
||||||
public void apply(
|
public void integrate(
|
||||||
EventListenerRegistry eventListenerRegistry,
|
|
||||||
Configuration configuration,
|
Configuration configuration,
|
||||||
Map<?, ?> configValues,
|
SessionFactoryImplementor sessionFactory,
|
||||||
ServiceRegistryImplementor serviceRegistry) {
|
SessionFactoryServiceRegistry serviceRegistry) {
|
||||||
eventListenerRegistry.setListeners( EventType.DELETE, listener );
|
serviceRegistry.getService( EventListenerRegistry.class ).setListeners(
|
||||||
|
EventType.DELETE, listener
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disintegrate(
|
||||||
|
SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -23,16 +23,15 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.flush;
|
package org.hibernate.test.flush;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.event.EventListenerRegistration;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.event.EventType;
|
import org.hibernate.event.EventType;
|
||||||
import org.hibernate.service.StandardServiceInitiators;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.integrator.spi.IntegratorService;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
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;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -53,15 +52,21 @@ public class TestCollectionInitializingDuringFlush extends BaseCoreFunctionalTes
|
||||||
@Override
|
@Override
|
||||||
protected void applyServices(BasicServiceRegistryImpl serviceRegistry) {
|
protected void applyServices(BasicServiceRegistryImpl serviceRegistry) {
|
||||||
super.applyServices( serviceRegistry );
|
super.applyServices( serviceRegistry );
|
||||||
serviceRegistry.getService( StandardServiceInitiators.EventListenerRegistrationService.class ).attachEventListenerRegistration(
|
serviceRegistry.getService( IntegratorService.class ).addIntegrator(
|
||||||
new EventListenerRegistration() {
|
new Integrator() {
|
||||||
@Override
|
@Override
|
||||||
public void apply(
|
public void integrate(
|
||||||
EventListenerRegistry eventListenerRegistry,
|
|
||||||
Configuration configuration,
|
Configuration configuration,
|
||||||
Map<?, ?> configValues,
|
SessionFactoryImplementor sessionFactory,
|
||||||
ServiceRegistryImplementor serviceRegistry) {
|
SessionFactoryServiceRegistry serviceRegistry) {
|
||||||
eventListenerRegistry.getEventListenerGroup( EventType.PRE_UPDATE ).appendListener( new InitializingPreUpdateEventListener() );
|
serviceRegistry.getService( EventListenerRegistry.class )
|
||||||
|
.getEventListenerGroup( EventType.PRE_UPDATE )
|
||||||
|
.appendListener( new InitializingPreUpdateEventListener() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disintegrate(
|
||||||
|
SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -41,7 +41,7 @@ import org.hibernate.engine.transaction.spi.TransactionContext;
|
||||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
||||||
import org.hibernate.jdbc.Expectation;
|
import org.hibernate.jdbc.Expectation;
|
||||||
import org.hibernate.jdbc.Expectations;
|
import org.hibernate.jdbc.Expectations;
|
||||||
import org.hibernate.service.StandardServiceInitiators;
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -68,10 +68,8 @@ public class BatchingTest extends BaseUnitTestCase implements BatchKey {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
serviceRegistry = new BasicServiceRegistryImpl(
|
serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( ConnectionProviderBuilder.getConnectionProviderProperties() )
|
||||||
StandardServiceInitiators.LIST,
|
.buildServiceRegistry();
|
||||||
ConnectionProviderBuilder.getConnectionProviderProperties()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
|
@ -25,13 +25,12 @@ package org.hibernate.test.jpa;
|
||||||
|
|
||||||
import javax.persistence.EntityNotFoundException;
|
import javax.persistence.EntityNotFoundException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.CascadingAction;
|
import org.hibernate.engine.CascadingAction;
|
||||||
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.event.AutoFlushEventListener;
|
import org.hibernate.event.AutoFlushEventListener;
|
||||||
import org.hibernate.event.EventListenerRegistration;
|
|
||||||
import org.hibernate.event.EventType;
|
import org.hibernate.event.EventType;
|
||||||
import org.hibernate.event.FlushEntityEventListener;
|
import org.hibernate.event.FlushEntityEventListener;
|
||||||
import org.hibernate.event.FlushEventListener;
|
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.DefaultFlushEntityEventListener;
|
||||||
import org.hibernate.event.def.DefaultFlushEventListener;
|
import org.hibernate.event.def.DefaultFlushEventListener;
|
||||||
import org.hibernate.event.def.DefaultPersistEventListener;
|
import org.hibernate.event.def.DefaultPersistEventListener;
|
||||||
|
import org.hibernate.integrator.spi.Integrator;
|
||||||
import org.hibernate.internal.util.collections.IdentityMap;
|
import org.hibernate.internal.util.collections.IdentityMap;
|
||||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||||
import org.hibernate.service.StandardServiceInitiators;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.integrator.spi.IntegratorService;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
|
||||||
|
@ -71,20 +71,27 @@ public abstract class AbstractJPATest extends BaseCoreFunctionalTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected void applyServices(BasicServiceRegistryImpl serviceRegistry) {
|
protected void applyServices(BasicServiceRegistryImpl serviceRegistry) {
|
||||||
super.applyServices( serviceRegistry );
|
super.applyServices( serviceRegistry );
|
||||||
serviceRegistry.getService( StandardServiceInitiators.EventListenerRegistrationService.class ).attachEventListenerRegistration(
|
serviceRegistry.getService( IntegratorService.class ).addIntegrator(
|
||||||
new EventListenerRegistration() {
|
new Integrator() {
|
||||||
@Override
|
@Override
|
||||||
public void apply(
|
public void integrate(
|
||||||
EventListenerRegistry eventListenerRegistry,
|
|
||||||
Configuration configuration,
|
Configuration configuration,
|
||||||
Map<?, ?> configValues,
|
SessionFactoryImplementor sessionFactory,
|
||||||
ServiceRegistryImplementor serviceRegistry) {
|
SessionFactoryServiceRegistry serviceRegistry) {
|
||||||
|
EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
|
||||||
eventListenerRegistry.setListeners( EventType.PERSIST, buildPersistEventListeners() );
|
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.AUTO_FLUSH, buildAutoFlushEventListeners() );
|
||||||
eventListenerRegistry.setListeners( EventType.FLUSH, buildFlushEventListeners() );
|
eventListenerRegistry.setListeners( EventType.FLUSH, buildFlushEventListeners() );
|
||||||
eventListenerRegistry.setListeners( EventType.FLUSH_ENTITY, buildFlushEntityEventListeners() );
|
eventListenerRegistry.setListeners( EventType.FLUSH_ENTITY, buildFlushEntityEventListeners() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disintegrate(
|
||||||
|
SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,21 +23,20 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.keymanytoone.bidir.component;
|
package org.hibernate.test.keymanytoone.bidir.component;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.event.EventListenerRegistration;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.event.EventType;
|
import org.hibernate.event.EventType;
|
||||||
import org.hibernate.event.LoadEvent;
|
import org.hibernate.event.LoadEvent;
|
||||||
import org.hibernate.event.LoadEventListener;
|
import org.hibernate.event.LoadEventListener;
|
||||||
import org.hibernate.event.def.DefaultLoadEventListener;
|
import org.hibernate.event.def.DefaultLoadEventListener;
|
||||||
import org.hibernate.service.StandardServiceInitiators;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.integrator.spi.IntegratorService;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
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;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -65,16 +64,21 @@ public class EagerKeyManyToOneTest extends BaseCoreFunctionalTestCase {
|
||||||
protected void applyServices(BasicServiceRegistryImpl serviceRegistry) {
|
protected void applyServices(BasicServiceRegistryImpl serviceRegistry) {
|
||||||
super.applyServices( serviceRegistry );
|
super.applyServices( serviceRegistry );
|
||||||
|
|
||||||
// (they are different service registries!)
|
serviceRegistry.getService( IntegratorService.class ).addIntegrator(
|
||||||
serviceRegistry.getService( StandardServiceInitiators.EventListenerRegistrationService.class ).attachEventListenerRegistration(
|
new Integrator() {
|
||||||
new EventListenerRegistration() {
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(
|
public void integrate(
|
||||||
EventListenerRegistry eventListenerRegistry,
|
|
||||||
Configuration configuration,
|
Configuration configuration,
|
||||||
Map<?, ?> configValues,
|
SessionFactoryImplementor sessionFactory,
|
||||||
ServiceRegistryImplementor serviceRegistry) {
|
SessionFactoryServiceRegistry serviceRegistry) {
|
||||||
eventListenerRegistry.prependListeners( EventType.LOAD, new CustomLoadListener() );
|
serviceRegistry.getService( EventListenerRegistry.class ).prependListeners(
|
||||||
|
EventType.LOAD, new CustomLoadListener()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disintegrate(
|
||||||
|
SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -29,14 +29,12 @@ import java.sql.SQLException;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MultiTenancyStrategy;
|
import org.hibernate.MultiTenancyStrategy;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
|
||||||
import org.hibernate.cache.HashtableCacheProvider;
|
import org.hibernate.cache.HashtableCacheProvider;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.SessionFactoryImplementor;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
|
||||||
import org.hibernate.mapping.RootClass;
|
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.internal.DriverManagerConnectionProviderImpl;
|
||||||
import org.hibernate.service.jdbc.connections.spi.AbstractMultiTenantConnectionProvider;
|
import org.hibernate.service.jdbc.connections.spi.AbstractMultiTenantConnectionProvider;
|
||||||
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
|
||||||
|
@ -152,8 +150,9 @@ public class SchemaBasedMultiTenancyTest extends BaseUnitTestCase {
|
||||||
false // do not *just* perform the create
|
false // do not *just* perform the create
|
||||||
);
|
);
|
||||||
|
|
||||||
serviceRegistry = new BasicServiceRegistryImpl( cfg.getProperties() );
|
serviceRegistry = (ServiceRegistryImplementor) new ServiceRegistryBuilder( cfg.getProperties() )
|
||||||
serviceRegistry.registerService( MultiTenantConnectionProvider.class, multiTenantConnectionProvider );
|
.addService( MultiTenantConnectionProvider.class, multiTenantConnectionProvider )
|
||||||
|
.buildServiceRegistry();
|
||||||
|
|
||||||
sessionFactory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
sessionFactory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import static org.junit.Assert.assertTrue;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
|
import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
|
||||||
import org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
|
import org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
|
||||||
|
@ -46,7 +47,9 @@ import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
public class ServiceBootstrappingTest extends BaseUnitTestCase {
|
public class ServiceBootstrappingTest extends BaseUnitTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testBasicBuild() {
|
public void testBasicBuild() {
|
||||||
BasicServiceRegistryImpl serviceRegistry = new BasicServiceRegistryImpl( ConnectionProviderBuilder.getConnectionProviderProperties() );
|
BasicServiceRegistryImpl serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder(
|
||||||
|
ConnectionProviderBuilder.getConnectionProviderProperties()
|
||||||
|
).buildServiceRegistry();
|
||||||
JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
|
JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
|
||||||
|
|
||||||
assertTrue( jdbcServices.getDialect() instanceof H2Dialect );
|
assertTrue( jdbcServices.getDialect() instanceof H2Dialect );
|
||||||
|
@ -61,7 +64,8 @@ public class ServiceBootstrappingTest extends BaseUnitTestCase {
|
||||||
Properties props = ConnectionProviderBuilder.getConnectionProviderProperties();
|
Properties props = ConnectionProviderBuilder.getConnectionProviderProperties();
|
||||||
props.put( Environment.SHOW_SQL, "true" );
|
props.put( Environment.SHOW_SQL, "true" );
|
||||||
|
|
||||||
BasicServiceRegistryImpl serviceRegistry = new BasicServiceRegistryImpl( props );
|
BasicServiceRegistryImpl serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( props ).buildServiceRegistry();
|
||||||
|
|
||||||
JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
|
JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
|
||||||
|
|
||||||
assertTrue( jdbcServices.getDialect() instanceof H2Dialect );
|
assertTrue( jdbcServices.getDialect() instanceof H2Dialect );
|
||||||
|
@ -75,7 +79,7 @@ public class ServiceBootstrappingTest extends BaseUnitTestCase {
|
||||||
public void testBuildWithServiceOverride() {
|
public void testBuildWithServiceOverride() {
|
||||||
Properties props = ConnectionProviderBuilder.getConnectionProviderProperties();
|
Properties props = ConnectionProviderBuilder.getConnectionProviderProperties();
|
||||||
|
|
||||||
BasicServiceRegistryImpl serviceRegistry = new BasicServiceRegistryImpl( props );
|
BasicServiceRegistryImpl serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( props ).buildServiceRegistry();
|
||||||
JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
|
JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
|
||||||
|
|
||||||
assertTrue( jdbcServices.getDialect() instanceof H2Dialect );
|
assertTrue( jdbcServices.getDialect() instanceof H2Dialect );
|
||||||
|
|
|
@ -33,23 +33,24 @@ import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor;
|
||||||
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
|
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
|
||||||
import org.hibernate.engine.transaction.spi.TransactionContext;
|
import org.hibernate.engine.transaction.spi.TransactionContext;
|
||||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
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.BasicServiceRegistryImpl;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
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
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
@ -58,10 +59,8 @@ public class TestExpectedUsage extends BaseUnitTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
serviceRegistry = new BasicServiceRegistryImpl(
|
serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( ConnectionProviderBuilder.getConnectionProviderProperties() )
|
||||||
StandardServiceInitiators.LIST,
|
.buildServiceRegistry();
|
||||||
ConnectionProviderBuilder.getConnectionProviderProperties()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
|
||||||
import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory;
|
import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory;
|
||||||
import org.hibernate.engine.transaction.spi.TransactionContext;
|
import org.hibernate.engine.transaction.spi.TransactionContext;
|
||||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.ServiceProxy;
|
import org.hibernate.service.internal.ServiceProxy;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
import org.hibernate.service.jta.platform.spi.JtaPlatform;
|
import org.hibernate.service.jta.platform.spi.JtaPlatform;
|
||||||
|
@ -71,7 +72,7 @@ public class BasicDrivingTest extends BaseUnitTestCase {
|
||||||
configValues.putAll( ConnectionProviderBuilder.getConnectionProviderProperties() );
|
configValues.putAll( ConnectionProviderBuilder.getConnectionProviderProperties() );
|
||||||
configValues.put( Environment.TRANSACTION_STRATEGY, JtaTransactionFactory.class.getName() );
|
configValues.put( Environment.TRANSACTION_STRATEGY, JtaTransactionFactory.class.getName() );
|
||||||
TestingJtaBootstrap.prepare( configValues );
|
TestingJtaBootstrap.prepare( configValues );
|
||||||
serviceRegistry = new BasicServiceRegistryImpl( configValues );
|
serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( configValues ).buildServiceRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
|
@ -38,7 +38,7 @@ import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
|
||||||
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
|
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
|
||||||
import org.hibernate.engine.transaction.spi.TransactionContext;
|
import org.hibernate.engine.transaction.spi.TransactionContext;
|
||||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
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.BasicServiceRegistryImpl;
|
||||||
import org.hibernate.service.internal.ServiceProxy;
|
import org.hibernate.service.internal.ServiceProxy;
|
||||||
import org.hibernate.service.jta.platform.spi.JtaPlatform;
|
import org.hibernate.service.jta.platform.spi.JtaPlatform;
|
||||||
|
@ -71,10 +71,9 @@ public class ManagedDrivingTest extends BaseUnitTestCase {
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
Map configValues = new HashMap();
|
Map configValues = new HashMap();
|
||||||
TestingJtaBootstrap.prepare( configValues );
|
TestingJtaBootstrap.prepare( configValues );
|
||||||
// configValues.putAll( ConnectionProviderBuilder.getConnectionProviderProperties() );
|
|
||||||
configValues.put( Environment.TRANSACTION_STRATEGY, CMTTransactionFactory.class.getName() );
|
configValues.put( Environment.TRANSACTION_STRATEGY, CMTTransactionFactory.class.getName() );
|
||||||
|
|
||||||
serviceRegistry = new BasicServiceRegistryImpl( StandardServiceInitiators.LIST, configValues );
|
serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( configValues ).buildServiceRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
|
@ -75,7 +75,7 @@ import org.hibernate.cfg.NamingStrategy;
|
||||||
import org.hibernate.cfg.annotations.reflection.XMLContext;
|
import org.hibernate.cfg.annotations.reflection.XMLContext;
|
||||||
import org.hibernate.cfg.beanvalidation.BeanValidationIntegrator;
|
import org.hibernate.cfg.beanvalidation.BeanValidationIntegrator;
|
||||||
import org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider;
|
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.instrument.InterceptFieldClassFileTransformer;
|
||||||
import org.hibernate.ejb.internal.EntityManagerMessageLogger;
|
import org.hibernate.ejb.internal.EntityManagerMessageLogger;
|
||||||
import org.hibernate.ejb.packaging.JarVisitorFactory;
|
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.FilterDefinition;
|
||||||
import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory;
|
import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory;
|
||||||
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
|
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.ReflectHelper;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||||
|
@ -101,8 +102,7 @@ import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||||
import org.hibernate.secure.JACCConfiguration;
|
import org.hibernate.secure.JACCConfiguration;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.service.StandardServiceInitiators;
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
|
||||||
import org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl;
|
import org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -872,7 +872,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityManagerFactory buildEntityManagerFactory() {
|
public EntityManagerFactory buildEntityManagerFactory() {
|
||||||
return buildEntityManagerFactory( new BasicServiceRegistryImpl( cfg.getProperties() ) );
|
return buildEntityManagerFactory( new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityManagerFactory buildEntityManagerFactory(ServiceRegistry serviceRegistry) {
|
public EntityManagerFactory buildEntityManagerFactory(ServiceRegistry serviceRegistry) {
|
||||||
|
@ -886,9 +886,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
||||||
try {
|
try {
|
||||||
configure( (Properties)null, null );
|
configure( (Properties)null, null );
|
||||||
NamingHelper.bind(this);
|
NamingHelper.bind(this);
|
||||||
// todo : temporary -> HHH-5562
|
serviceRegistry.getService( IntegratorService.class ).addIntegrator( new JpaIntegrator() );
|
||||||
serviceRegistry.getService( StandardServiceInitiators.EventListenerRegistrationService.class )
|
|
||||||
.attachEventListenerRegistration( new JpaEventListenerRegistration() );
|
|
||||||
return new EntityManagerFactoryImpl(
|
return new EntityManagerFactoryImpl(
|
||||||
transactionType,
|
transactionType,
|
||||||
discardOnClose,
|
discardOnClose,
|
||||||
|
|
|
@ -31,8 +31,9 @@ import org.hibernate.MappingException;
|
||||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.ejb.AvailableSettings;
|
import org.hibernate.ejb.AvailableSettings;
|
||||||
import org.hibernate.event.EventListenerRegistration;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.event.EventType;
|
import org.hibernate.event.EventType;
|
||||||
|
import org.hibernate.integrator.spi.Integrator;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.secure.JACCPreDeleteEventListener;
|
import org.hibernate.secure.JACCPreDeleteEventListener;
|
||||||
import org.hibernate.secure.JACCPreInsertEventListener;
|
import org.hibernate.secure.JACCPreInsertEventListener;
|
||||||
|
@ -40,19 +41,18 @@ import org.hibernate.secure.JACCPreLoadEventListener;
|
||||||
import org.hibernate.secure.JACCPreUpdateEventListener;
|
import org.hibernate.secure.JACCPreUpdateEventListener;
|
||||||
import org.hibernate.secure.JACCSecurityListener;
|
import org.hibernate.secure.JACCSecurityListener;
|
||||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.service.event.spi.DuplicationStrategy;
|
import org.hibernate.event.service.spi.DuplicationStrategy;
|
||||||
import org.hibernate.service.event.spi.EventListenerGroup;
|
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||||
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.ServiceRegistryImplementor;
|
||||||
|
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the HEM-specific event listeners.
|
* Prepare the HEM-specific event listeners.
|
||||||
*
|
|
||||||
* @todo : make this into Integrator per HHH-5562 ??
|
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class JpaEventListenerRegistration implements EventListenerRegistration {
|
public class JpaIntegrator implements Integrator {
|
||||||
private static final DuplicationStrategy JPA_DUPLICATION_STRATEGY = new DuplicationStrategy() {
|
private static final DuplicationStrategy JPA_DUPLICATION_STRATEGY = new DuplicationStrategy() {
|
||||||
@Override
|
@Override
|
||||||
public boolean areMatch(Object listener, Object original) {
|
public boolean areMatch(Object listener, Object original) {
|
||||||
|
@ -81,12 +81,13 @@ public class JpaEventListenerRegistration implements EventListenerRegistration {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings( {"unchecked"})
|
@SuppressWarnings( {"unchecked"})
|
||||||
public void apply(
|
public void integrate(
|
||||||
EventListenerRegistry eventListenerRegistry,
|
|
||||||
Configuration configuration,
|
Configuration configuration,
|
||||||
Map<?, ?> configValues,
|
SessionFactoryImplementor sessionFactory,
|
||||||
ServiceRegistryImplementor serviceRegistry) {
|
SessionFactoryServiceRegistry serviceRegistry) {
|
||||||
boolean isSecurityEnabled = configValues.containsKey( AvailableSettings.JACC_ENABLED );
|
final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
|
||||||
|
|
||||||
|
boolean isSecurityEnabled = configuration.getProperties().containsKey( AvailableSettings.JACC_ENABLED );
|
||||||
|
|
||||||
eventListenerRegistry.addDuplicationStrategy( JPA_DUPLICATION_STRATEGY );
|
eventListenerRegistry.addDuplicationStrategy( JPA_DUPLICATION_STRATEGY );
|
||||||
eventListenerRegistry.addDuplicationStrategy( JACC_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_LOAD, new EJB3PostLoadEventListener() );
|
||||||
eventListenerRegistry.prependListeners( EventType.POST_UPDATE, new EJB3PostUpdateEventListener() );
|
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() ) ) {
|
if ( ! String.class.isInstance( entry.getKey() ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -127,14 +128,11 @@ public class JpaEventListenerRegistration implements EventListenerRegistration {
|
||||||
final String eventTypeName = propertyName.substring( AvailableSettings.EVENT_LISTENER_PREFIX.length() + 1 );
|
final String eventTypeName = propertyName.substring( AvailableSettings.EVENT_LISTENER_PREFIX.length() + 1 );
|
||||||
final EventType eventType = EventType.resolveEventTypeByName( eventTypeName );
|
final EventType eventType = EventType.resolveEventTypeByName( eventTypeName );
|
||||||
final EventListenerGroup eventListenerGroup = eventListenerRegistry.getEventListenerGroup( eventType );
|
final EventListenerGroup eventListenerGroup = eventListenerRegistry.getEventListenerGroup( eventType );
|
||||||
eventListenerGroup.clear();
|
|
||||||
for ( String listenerImpl : ( (String) entry.getValue() ).split( " ," ) ) {
|
for ( String listenerImpl : ( (String) entry.getValue() ).split( " ," ) ) {
|
||||||
eventListenerGroup.appendListener( instantiate( listenerImpl, serviceRegistry ) );
|
eventListenerGroup.appendListener( instantiate( listenerImpl, serviceRegistry ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo : we may need to account for callback handlers previously set (shared across EMFs)
|
|
||||||
|
|
||||||
final EntityCallbackHandler callbackHandler = new EntityCallbackHandler();
|
final EntityCallbackHandler callbackHandler = new EntityCallbackHandler();
|
||||||
Iterator classes = configuration.getClassMappings();
|
Iterator classes = configuration.getClassMappings();
|
||||||
ReflectionManager reflectionManager = configuration.getReflectionManager();
|
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) {
|
private Object instantiate(String listenerImpl, ServiceRegistryImplementor serviceRegistry) {
|
||||||
try {
|
try {
|
||||||
return serviceRegistry.getService( ClassLoaderService.class ).classForName( listenerImpl ).newInstance();
|
return serviceRegistry.getService( ClassLoaderService.class ).classForName( listenerImpl ).newInstance();
|
|
@ -42,6 +42,7 @@ import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.ejb.AvailableSettings;
|
import org.hibernate.ejb.AvailableSettings;
|
||||||
import org.hibernate.ejb.Ejb3Configuration;
|
import org.hibernate.ejb.Ejb3Configuration;
|
||||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -203,7 +204,7 @@ public abstract class BaseEntityManagerFunctionalTestCase extends BaseUnitTestCa
|
||||||
properties.putAll( configuration.getProperties() );
|
properties.putAll( configuration.getProperties() );
|
||||||
Environment.verifyProperties( properties );
|
Environment.verifyProperties( properties );
|
||||||
ConfigurationHelper.resolvePlaceHolders( properties );
|
ConfigurationHelper.resolvePlaceHolders( properties );
|
||||||
return new BasicServiceRegistryImpl( properties );
|
return (BasicServiceRegistryImpl) new ServiceRegistryBuilder( properties ).buildServiceRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings( {"UnusedParameters"})
|
@SuppressWarnings( {"UnusedParameters"})
|
||||||
|
|
|
@ -58,7 +58,7 @@ import org.hibernate.ejb.test.pack.various.Seat;
|
||||||
import org.hibernate.engine.SessionImplementor;
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.event.EventType;
|
import org.hibernate.event.EventType;
|
||||||
import org.hibernate.internal.util.ConfigHelper;
|
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.hibernate.stat.Statistics;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.hibernate.envers.exception.AuditException;
|
||||||
import org.hibernate.envers.reader.AuditReaderImpl;
|
import org.hibernate.envers.reader.AuditReaderImpl;
|
||||||
import org.hibernate.event.EventType;
|
import org.hibernate.event.EventType;
|
||||||
import org.hibernate.event.PostInsertEventListener;
|
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)
|
* @author Adam Warski (adam at warski dot org)
|
||||||
|
|
|
@ -30,9 +30,9 @@ import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.engine.SessionFactoryImplementor;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.envers.configuration.AuditConfiguration;
|
import org.hibernate.envers.configuration.AuditConfiguration;
|
||||||
import org.hibernate.event.EventType;
|
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.internal.util.config.ConfigurationHelper;
|
||||||
import org.hibernate.service.event.spi.EventListenerRegistry;
|
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||||
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.envers.event;
|
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
|
* Event listener duplication strategy for envers
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.hibernate.ejb.Ejb3Configuration;
|
||||||
import org.hibernate.envers.AuditReader;
|
import org.hibernate.envers.AuditReader;
|
||||||
import org.hibernate.envers.AuditReaderFactory;
|
import org.hibernate.envers.AuditReaderFactory;
|
||||||
import org.hibernate.envers.event.EnversIntegrator;
|
import org.hibernate.envers.event.EnversIntegrator;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
import org.hibernate.testing.AfterClassOnce;
|
import org.hibernate.testing.AfterClassOnce;
|
||||||
import org.hibernate.testing.BeforeClassOnce;
|
import org.hibernate.testing.BeforeClassOnce;
|
||||||
|
@ -97,7 +98,7 @@ public abstract class AbstractEntityTest extends AbstractEnversTest {
|
||||||
|
|
||||||
configure( cfg );
|
configure( cfg );
|
||||||
|
|
||||||
serviceRegistry = new BasicServiceRegistryImpl(configValues);
|
serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( configValues ).buildServiceRegistry();
|
||||||
|
|
||||||
emf = cfg.buildEntityManagerFactory( serviceRegistry );
|
emf = cfg.buildEntityManagerFactory( serviceRegistry );
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ import org.hibernate.cache.Region;
|
||||||
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
||||||
import org.hibernate.cache.infinispan.util.CacheAdapter;
|
import org.hibernate.cache.infinispan.util.CacheAdapter;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -79,7 +81,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
||||||
private void evictOrRemoveTest() throws Exception {
|
private void evictOrRemoveTest() throws Exception {
|
||||||
Configuration cfg = createConfiguration();
|
Configuration cfg = createConfiguration();
|
||||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||||
new BasicServiceRegistryImpl( cfg.getProperties() ),
|
new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(),
|
||||||
cfg,
|
cfg,
|
||||||
getCacheTestSupport()
|
getCacheTestSupport()
|
||||||
);
|
);
|
||||||
|
@ -96,7 +98,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
||||||
|
|
||||||
cfg = createConfiguration();
|
cfg = createConfiguration();
|
||||||
regionFactory = CacheTestUtil.startRegionFactory(
|
regionFactory = CacheTestUtil.startRegionFactory(
|
||||||
new BasicServiceRegistryImpl( cfg.getProperties() ),
|
new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(),
|
||||||
cfg,
|
cfg,
|
||||||
getCacheTestSupport()
|
getCacheTestSupport()
|
||||||
);
|
);
|
||||||
|
@ -142,7 +144,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
||||||
private void evictOrRemoveAllTest(String configName) throws Exception {
|
private void evictOrRemoveAllTest(String configName) throws Exception {
|
||||||
Configuration cfg = createConfiguration();
|
Configuration cfg = createConfiguration();
|
||||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||||
new BasicServiceRegistryImpl( cfg.getProperties() ),
|
new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(),
|
||||||
cfg,
|
cfg,
|
||||||
getCacheTestSupport()
|
getCacheTestSupport()
|
||||||
);
|
);
|
||||||
|
@ -160,7 +162,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
|
||||||
|
|
||||||
cfg = createConfiguration();
|
cfg = createConfiguration();
|
||||||
regionFactory = CacheTestUtil.startRegionFactory(
|
regionFactory = CacheTestUtil.startRegionFactory(
|
||||||
new BasicServiceRegistryImpl( cfg.getProperties() ),
|
new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(),
|
||||||
cfg,
|
cfg,
|
||||||
getCacheTestSupport()
|
getCacheTestSupport()
|
||||||
);
|
);
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.hibernate.cache.infinispan.collection.CollectionRegionImpl;
|
||||||
import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
|
import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
|
||||||
import org.hibernate.cache.infinispan.util.FlagAdapter;
|
import org.hibernate.cache.infinispan.util.FlagAdapter;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
|
|
||||||
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
|
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
|
||||||
|
@ -108,7 +109,7 @@ public class NodeEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prepare() throws Exception {
|
public void prepare() throws Exception {
|
||||||
serviceRegistry = new BasicServiceRegistryImpl( configuration.getProperties() );
|
serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder( configuration.getProperties() ).buildServiceRegistry();
|
||||||
regionFactory = CacheTestUtil.startRegionFactory( serviceRegistry, configuration );
|
regionFactory = CacheTestUtil.startRegionFactory( serviceRegistry, configuration );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.hibernate.cache.infinispan.InfinispanRegionFactory;
|
||||||
import org.hibernate.cache.infinispan.util.CacheAdapter;
|
import org.hibernate.cache.infinispan.util.CacheAdapter;
|
||||||
import org.hibernate.cache.infinispan.util.CacheAdapterImpl;
|
import org.hibernate.cache.infinispan.util.CacheAdapterImpl;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
|
|
||||||
import junit.framework.AssertionFailedError;
|
import junit.framework.AssertionFailedError;
|
||||||
|
@ -89,7 +90,7 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
|
||||||
private void putDoesNotBlockGetTest() throws Exception {
|
private void putDoesNotBlockGetTest() throws Exception {
|
||||||
Configuration cfg = createConfiguration();
|
Configuration cfg = createConfiguration();
|
||||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||||
new BasicServiceRegistryImpl( cfg.getProperties() ),
|
new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(),
|
||||||
cfg,
|
cfg,
|
||||||
getCacheTestSupport()
|
getCacheTestSupport()
|
||||||
);
|
);
|
||||||
|
@ -189,7 +190,7 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
|
||||||
private void getDoesNotBlockPutTest() throws Exception {
|
private void getDoesNotBlockPutTest() throws Exception {
|
||||||
Configuration cfg = createConfiguration();
|
Configuration cfg = createConfiguration();
|
||||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||||
new BasicServiceRegistryImpl( cfg.getProperties() ),
|
new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(),
|
||||||
cfg,
|
cfg,
|
||||||
getCacheTestSupport()
|
getCacheTestSupport()
|
||||||
);
|
);
|
||||||
|
|
|
@ -48,6 +48,7 @@ import org.hibernate.cache.infinispan.util.CacheAdapter;
|
||||||
import org.hibernate.cache.infinispan.util.CacheAdapterImpl;
|
import org.hibernate.cache.infinispan.util.CacheAdapterImpl;
|
||||||
import org.hibernate.cache.infinispan.util.FlagAdapter;
|
import org.hibernate.cache.infinispan.util.FlagAdapter;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||||
|
|
||||||
import org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTestCase;
|
import org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTestCase;
|
||||||
|
@ -82,7 +83,7 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC
|
||||||
public void testClearTimestampsRegionInIsolated() throws Exception {
|
public void testClearTimestampsRegionInIsolated() throws Exception {
|
||||||
Configuration cfg = createConfiguration();
|
Configuration cfg = createConfiguration();
|
||||||
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
|
||||||
new BasicServiceRegistryImpl( cfg.getProperties() ),
|
new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(),
|
||||||
cfg,
|
cfg,
|
||||||
getCacheTestSupport()
|
getCacheTestSupport()
|
||||||
);
|
);
|
||||||
|
@ -91,7 +92,7 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC
|
||||||
|
|
||||||
Configuration cfg2 = createConfiguration();
|
Configuration cfg2 = createConfiguration();
|
||||||
InfinispanRegionFactory regionFactory2 = CacheTestUtil.startRegionFactory(
|
InfinispanRegionFactory regionFactory2 = CacheTestUtil.startRegionFactory(
|
||||||
new BasicServiceRegistryImpl( cfg.getProperties() ),
|
new ServiceRegistryBuilder( cfg.getProperties() ).buildServiceRegistry(),
|
||||||
cfg2,
|
cfg2,
|
||||||
getCacheTestSupport()
|
getCacheTestSupport()
|
||||||
);
|
);
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class ServiceRegistryBuilder {
|
||||||
properties.putAll( serviceRegistryConfig );
|
properties.putAll( serviceRegistryConfig );
|
||||||
Environment.verifyProperties( properties );
|
Environment.verifyProperties( properties );
|
||||||
ConfigurationHelper.resolvePlaceHolders( properties );
|
ConfigurationHelper.resolvePlaceHolders( properties );
|
||||||
return new BasicServiceRegistryImpl( properties );
|
return (BasicServiceRegistryImpl) new org.hibernate.service.ServiceRegistryBuilder( properties ).buildServiceRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void destroy(ServiceRegistry serviceRegistry) {
|
public static void destroy(ServiceRegistry serviceRegistry) {
|
||||||
|
|
|
@ -248,7 +248,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
|
||||||
properties.putAll( configuration.getProperties() );
|
properties.putAll( configuration.getProperties() );
|
||||||
Environment.verifyProperties( properties );
|
Environment.verifyProperties( properties );
|
||||||
ConfigurationHelper.resolvePlaceHolders( properties );
|
ConfigurationHelper.resolvePlaceHolders( properties );
|
||||||
BasicServiceRegistryImpl serviceRegistry = new BasicServiceRegistryImpl( properties );
|
BasicServiceRegistryImpl serviceRegistry = (BasicServiceRegistryImpl) new org.hibernate.service.ServiceRegistryBuilder( properties ).buildServiceRegistry();
|
||||||
applyServices( serviceRegistry );
|
applyServices( serviceRegistry );
|
||||||
return serviceRegistry;
|
return serviceRegistry;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue