HHH-6047 - allow nesting of ServiceRegistry

This commit is contained in:
Steve Ebersole 2011-03-24 14:31:50 -05:00
parent 4d3ad4b4c8
commit 731d00fd6d
53 changed files with 469 additions and 364 deletions

View File

@ -159,7 +159,7 @@ import org.hibernate.mapping.TypeDef;
import org.hibernate.mapping.UniqueKey;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.secure.JACCConfiguration;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
import org.hibernate.tool.hbm2ddl.IndexMetadata;
@ -1848,7 +1848,7 @@ public class Configuration implements Serializable {
public SessionFactory buildSessionFactory() throws HibernateException {
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
final ServiceRegistry serviceRegistry = new ServiceRegistryImpl( properties );
final ServiceRegistry serviceRegistry = new BasicServiceRegistryImpl( properties );
setSessionFactoryObserver(
new SessionFactoryObserver() {
@Override
@ -1857,7 +1857,7 @@ public class Configuration implements Serializable {
@Override
public void sessionFactoryClosed(SessionFactory factory) {
( (ServiceRegistryImpl ) serviceRegistry ).destroy();
( (BasicServiceRegistryImpl) serviceRegistry ).destroy();
}
}
);

View File

@ -23,20 +23,22 @@
*/
package org.hibernate.engine.jdbc.batch.internal;
import java.util.Map;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.batch.spi.BatchBuilder;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.internal.ServiceRegistryImplementor;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistry;
import java.util.Map;
/**
* Initiator for the {@link BatchBuilder} service
*
* @author Steve Ebersole
*/
public class BatchBuilderInitiator implements ServiceInitiator<BatchBuilder> {
public class BatchBuilderInitiator implements BasicServiceInitiator<BatchBuilder> {
public static final BatchBuilderInitiator INSTANCE = new BatchBuilderInitiator();
public static final String BUILDER = "hibernate.jdbc.batch.builder";
@ -46,7 +48,7 @@ public class BatchBuilderInitiator implements ServiceInitiator<BatchBuilder> {
}
@Override
public BatchBuilder initiateService(Map configurationValues, ServiceRegistry registry) {
public BatchBuilder initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
final Object builder = configurationValues.get( BUILDER );
if ( builder == null ) {
return new BatchBuilderImpl(

View File

@ -22,30 +22,30 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.engine.jdbc.internal;
import java.util.Map;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.service.internal.ServiceRegistryImplementor;
import org.hibernate.service.spi.BasicServiceInitiator;
/**
* Standard initiator for the standard {@link JdbcServices} service
*
* @todo : should this maybe be a SessionFactory service?
*
* @author Steve Ebersole
*/
public class JdbcServicesInitiator implements ServiceInitiator<JdbcServices> {
public class JdbcServicesInitiator implements BasicServiceInitiator<JdbcServices> {
public static final JdbcServicesInitiator INSTANCE = new JdbcServicesInitiator();
/**
* {@inheritDoc}
*/
@Override
public Class<JdbcServices> getServiceInitiated() {
return JdbcServices.class;
}
/**
* {@inheritDoc}
*/
public JdbcServices initiateService(Map configValues, ServiceRegistry registry) {
@Override
public JdbcServices initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
return new JdbcServicesImpl();
}
}

View File

@ -22,14 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.engine.jdbc.spi;
import java.sql.Connection;
import java.sql.ResultSet;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.ColumnNameCache;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.engine.jdbc.LobCreator;
import org.hibernate.engine.jdbc.ResultSetWrapperProxy;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.Service;
@ -69,12 +68,11 @@ public interface JdbcServices extends Service {
public SqlExceptionHelper getSqlExceptionHelper();
/**
* Obtain infomration about supported behavior reported by the JDBC driver.
* Obtain information about supported behavior reported by the JDBC driver.
* <p/>
* Yuck, yuck, yuck! Much prefer this to be part of a "basic settings" type object. See discussion
* on {@link org.hibernate.cfg.internal.JdbcServicesBuilder}
* Yuck, yuck, yuck! Much prefer this to be part of a "basic settings" type object.
*
* @return
* @return The extracted database metadata, oddly enough :)
*/
public ExtractedDatabaseMetaData getExtractedMetaDataSupport();

View File

@ -24,6 +24,9 @@
package org.hibernate.engine.transaction.internal;
import java.util.Map;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.HibernateLogger;
import org.hibernate.cfg.Environment;
@ -31,31 +34,32 @@ import org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory;
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory;
import org.hibernate.engine.transaction.spi.TransactionFactory;
import org.hibernate.engine.transaction.spi.TransactionImplementor;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistry;
import org.jboss.logging.Logger;
import org.hibernate.service.internal.ServiceRegistryImplementor;
import org.hibernate.service.spi.BasicServiceInitiator;
/**
* Standard instantiator for the standard {@link TransactionFactory} service.
*
* @author Steve Ebersole
*/
public class TransactionFactoryInitiator implements ServiceInitiator<TransactionFactory> {
public class TransactionFactoryInitiator<T extends TransactionImplementor> implements BasicServiceInitiator<TransactionFactory> {
private static final HibernateLogger LOG = Logger.getMessageLogger(HibernateLogger.class,
TransactionFactoryInitiator.class.getName());
public static final TransactionFactoryInitiator INSTANCE = new TransactionFactoryInitiator();
@Override
@SuppressWarnings( {"unchecked"})
public Class<TransactionFactory> getServiceInitiated() {
return TransactionFactory.class;
}
@Override
public TransactionFactory initiateService(Map configVales, ServiceRegistry registry) {
final Object strategy = configVales.get( Environment.TRANSACTION_STRATEGY );
@SuppressWarnings( {"unchecked"})
public TransactionFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
final Object strategy = configurationValues.get( Environment.TRANSACTION_STRATEGY );
if ( TransactionFactory.class.isInstance( strategy ) ) {
return (TransactionFactory) strategy;
}

View File

@ -24,7 +24,6 @@
package org.hibernate.engine.transaction.internal.jdbc;
import org.hibernate.ConnectionReleaseMode;
import org.hibernate.engine.transaction.spi.JoinStatus;
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
import org.hibernate.engine.transaction.spi.TransactionFactory;

View File

@ -10,7 +10,7 @@ import org.hibernate.SessionFactory;
import org.hibernate.cfg.Environment;
import org.hibernate.cfg.ExternalSessionFactoryConfig;
import org.hibernate.internal.util.jndi.JndiHelper;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.service.jta.platform.internal.JtaPlatformInitiator;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.jboss.logging.Logger;
@ -61,7 +61,7 @@ public class HibernateService extends ExternalSessionFactoryConfig implements Hi
SessionFactory buildSessionFactory() throws HibernateException {
LOG.startingServiceAtJndiName(boundName);
LOG.serviceProperties(properties);
return buildConfiguration().buildSessionFactory(new ServiceRegistryImpl(properties));
return buildConfiguration().buildSessionFactory(new BasicServiceRegistryImpl(properties));
}
@Override

View File

@ -23,18 +23,18 @@
*/
package org.hibernate.persister.internal;
import java.util.Map;
import org.hibernate.persister.spi.PersisterClassResolver;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.internal.ServiceRegistryImplementor;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistry;
import java.util.Map;
/**
* @author Steve Ebersole
*/
public class PersisterClassResolverInitiator implements ServiceInitiator<PersisterClassResolver> {
public class PersisterClassResolverInitiator implements BasicServiceInitiator<PersisterClassResolver> {
public static final PersisterClassResolverInitiator INSTANCE = new PersisterClassResolverInitiator();
public static final String IMPL_NAME = "hibernate.persister.resolver";
@ -45,7 +45,7 @@ public class PersisterClassResolverInitiator implements ServiceInitiator<Persist
@Override
@SuppressWarnings( {"unchecked"})
public PersisterClassResolver initiateService(Map configurationValues, ServiceRegistry registry) {
public PersisterClassResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
final Object customImpl = configurationValues.get( IMPL_NAME );
if ( customImpl == null ) {
return new StandardPersisterClassResolver();

View File

@ -23,18 +23,18 @@
*/
package org.hibernate.persister.internal;
import java.util.Map;
import org.hibernate.persister.spi.PersisterFactory;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.internal.ServiceRegistryImplementor;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistry;
import java.util.Map;
/**
* @author Steve Ebersole
*/
public class PersisterFactoryInitiator implements ServiceInitiator<PersisterFactory> {
public class PersisterFactoryInitiator implements BasicServiceInitiator<PersisterFactory> {
public static final PersisterFactoryInitiator INSTANCE = new PersisterFactoryInitiator();
public static final String IMPL_NAME = "hibernate.persister.factory";
@ -46,7 +46,7 @@ public class PersisterFactoryInitiator implements ServiceInitiator<PersisterFact
@Override
@SuppressWarnings( {"unchecked"})
public PersisterFactory initiateService(Map configurationValues, ServiceRegistry registry) {
public PersisterFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
final Object customImpl = configurationValues.get( IMPL_NAME );
if ( customImpl == null ) {
return new PersisterFactoryImpl();

View File

@ -43,12 +43,20 @@ public interface PersisterClassResolver extends Service {
/**
* Returns the entity persister class for a given entityName or null
* if the entity persister class should be the default.
*
* @param metadata The entity metadata
*
* @return The entity persister class to use
*/
Class<? extends EntityPersister> getEntityPersisterClass(PersistentClass metadata);
/**
* Returns the collection persister class for a given collection role or null
* if the collection persister class should be the default.
*
* @param metadata The collection metadata
*
* @return The collection persister class to use
*/
Class<? extends CollectionPersister> getCollectionPersisterClass(Collection metadata);
}

View File

@ -36,7 +36,7 @@ import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.service.spi.Service;
/**
* Contract for creating persister instances (both {@link EntityPersister} and {@link } varieties).
* Contract for creating persister instances (both {@link EntityPersister} and {@link CollectionPersister} varieties).
*
* @author Steve Ebersole
*/

View File

@ -22,18 +22,19 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.classloading.internal;
import java.util.Map;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistry;
import java.util.Map;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.internal.ServiceRegistryImplementor;
import org.hibernate.service.spi.BasicServiceInitiator;
/**
* Standard initiator for the stanndard {@link ClassLoaderService} service.
* Standard initiator for the standard {@link ClassLoaderService} service.
*
* @author Steve Ebersole
*/
public class ClassLoaderServiceInitiator implements ServiceInitiator<ClassLoaderService> {
public class ClassLoaderServiceInitiator implements BasicServiceInitiator<ClassLoaderService> {
public static final ClassLoaderServiceInitiator INSTANCE = new ClassLoaderServiceInitiator();
@Override
@ -42,7 +43,7 @@ public class ClassLoaderServiceInitiator implements ServiceInitiator<ClassLoader
}
@Override
public ClassLoaderService initiateService(Map configurationValues, ServiceRegistry registry) {
public ClassLoaderService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
return new ClassLoaderServiceImpl( configurationValues );
}
}

View File

@ -22,9 +22,11 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.classloading.spi;
import java.io.InputStream;
import java.net.URL;
import java.util.List;
import org.hibernate.service.spi.Service;
/**

View File

@ -1,7 +1,7 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* 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.
@ -26,49 +26,116 @@ package org.hibernate.service.internal;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.HibernateLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.internal.proxy.javassist.ServiceProxyFactoryFactoryImpl;
import org.hibernate.service.spi.Service;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.StandardServiceInitiators;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.service.spi.Stoppable;
import org.hibernate.service.spi.UnknownServiceException;
import org.hibernate.service.spi.proxy.ServiceProxyFactory;
import org.hibernate.service.spi.proxy.ServiceProxyTargetSource;
import org.jboss.logging.Logger;
/**
* Standard Hibernate implementation of the service registry.
*
* @author Steve Ebersole
*/
public class ServiceRegistryImpl implements ServiceProxyTargetSource {
public abstract class AbstractServiceRegistryImpl implements ServiceRegistryImplementor {
private static final HibernateLogger LOG = Logger.getMessageLogger( HibernateLogger.class, AbstractServiceRegistryImpl.class.getName() );
private static final HibernateLogger LOG = Logger.getMessageLogger(HibernateLogger.class, ServiceRegistryImpl.class.getName());
private final ServiceRegistryImplementor parent;
private final ServiceInitializer initializer;
// for now just hardcode the javassist factory
// for now just hard-code the javassist factory
private ServiceProxyFactory serviceProxyFactory = new ServiceProxyFactoryFactoryImpl().makeServiceProxyFactory( this );
private ConcurrentHashMap<Class,ServiceBinding> serviceBindingMap;
// IMPL NOTE : the list used for ordered destruction. Cannot used ordered map above because we need to
// IMPL NOTE : the list used for ordered destruction. Cannot used map above because we need to
// iterate it in reverse order which is only available through ListIterator
private List<Service> serviceList = new ArrayList<Service>();
public ServiceRegistryImpl(Map configurationValues) {
this( StandardServiceInitiators.LIST, configurationValues );
protected AbstractServiceRegistryImpl() {
this( null );
}
public ServiceRegistryImpl(List<ServiceInitiator> serviceInitiators, Map configurationValues) {
this.initializer = new ServiceInitializer( this, serviceInitiators, ConfigurationHelper.clone( configurationValues ) );
final int anticipatedSize = serviceInitiators.size() + 5; // allow some growth
serviceBindingMap = CollectionHelper.concurrentMap( anticipatedSize );
serviceList = CollectionHelper.arrayList( anticipatedSize );
protected AbstractServiceRegistryImpl(ServiceRegistryImplementor parent) {
this.parent = parent;
// assume 20 services for initial sizing
this.serviceBindingMap = CollectionHelper.concurrentMap( 20 );
this.serviceList = CollectionHelper.arrayList( 20 );
}
@Override
@SuppressWarnings( {"unchecked"})
public ServiceRegistry getParentServiceRegistry() {
return parent;
}
@Override
@SuppressWarnings({ "unchecked" })
public <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole) {
return locateServiceBinding( serviceRole, true );
}
@SuppressWarnings({ "unchecked" })
protected <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole, boolean checkParent) {
ServiceBinding<R> serviceBinding = serviceBindingMap.get( serviceRole );
if ( serviceBinding == null && checkParent && parent != null ) {
// look in parent
serviceBinding = parent.locateServiceBinding( serviceRole );
}
return serviceBinding;
}
@Override
public <R extends Service> R getService(Class<R> serviceRole) {
return locateOrCreateServiceBinding( serviceRole, true ).getProxy();
}
@SuppressWarnings({ "unchecked" })
protected <R extends Service> ServiceBinding<R> locateOrCreateServiceBinding(Class<R> serviceRole, boolean checkParent) {
ServiceBinding<R> serviceBinding = locateServiceBinding( serviceRole, checkParent );
if ( serviceBinding == null ) {
R proxy = serviceProxyFactory.makeProxy( serviceRole );
serviceBinding = new ServiceBinding<R>( proxy );
serviceBindingMap.put( serviceRole, serviceBinding );
}
return serviceBinding;
}
@Override
public <R extends Service> void registerService(Class<R> serviceRole, R service) {
ServiceBinding<R> serviceBinding = locateOrCreateServiceBinding( serviceRole, false );
R priorServiceInstance = serviceBinding.getTarget();
serviceBinding.setTarget( service );
if ( priorServiceInstance != null ) {
serviceList.remove( priorServiceInstance );
}
serviceList.add( service );
}
protected abstract <R extends Service> R initializeService(Class<R> serviceRole);
@Override
@SuppressWarnings( {"unchecked"})
public <R extends Service> R getServiceInternal(Class<R> serviceRole) {
// this call comes from the binding proxy, we most definitely do not want to look up into the parent
// in this case!
ServiceBinding<R> serviceBinding = locateServiceBinding( serviceRole, false );
if ( serviceBinding == null ) {
throw new HibernateException( "Only proxies should invoke #getServiceInternal" );
}
R service = serviceBinding.getTarget();
if ( service == null ) {
service = initializeService( serviceRole );
serviceBinding.setTarget( service );
}
if ( service == null ) {
throw new UnknownServiceException( serviceRole );
}
return service;
}
public void destroy() {
@ -90,80 +157,4 @@ public class ServiceRegistryImpl implements ServiceProxyTargetSource {
serviceBindingMap = null;
}
@Override
@SuppressWarnings({ "unchecked" })
public <T extends Service> T getService(Class<T> serviceRole) {
return locateOrCreateServiceBinding( serviceRole ).getProxy();
}
@SuppressWarnings({ "unchecked" })
private <T extends Service> ServiceBinding<T> locateOrCreateServiceBinding(Class<T> serviceRole) {
ServiceBinding<T> serviceBinding = serviceBindingMap.get( serviceRole );
if ( serviceBinding == null ) {
T proxy = serviceProxyFactory.makeProxy( serviceRole );
serviceBinding = new ServiceBinding<T>( proxy );
serviceBindingMap.put( serviceRole, serviceBinding );
}
return serviceBinding;
}
@Override
@SuppressWarnings( {"unchecked"})
public <T extends Service> T getServiceInternal(Class<T> serviceRole) {
ServiceBinding<T> serviceBinding = serviceBindingMap.get( serviceRole );
if ( serviceBinding == null ) {
throw new HibernateException( "Only proxies should invoke #getServiceInternal" );
}
T service = serviceBinding.getTarget();
if ( service == null ) {
service = initializer.initializeService( serviceRole );
serviceBinding.setTarget( service );
}
if ( service == null ) {
throw new UnknownServiceException( serviceRole );
}
return service;
}
@Override
public <T extends Service> void registerService(Class<T> serviceRole, T service) {
ServiceBinding<T> serviceBinding = locateOrCreateServiceBinding( serviceRole );
T priorServiceInstance = serviceBinding.getTarget();
serviceBinding.setTarget( service );
if ( priorServiceInstance != null ) {
serviceList.remove( priorServiceInstance );
}
serviceList.add( service );
}
@Override
@SuppressWarnings( {"unchecked"})
public void registerServiceInitiator(ServiceInitiator initiator) {
ServiceBinding serviceBinding = serviceBindingMap.get( initiator.getServiceInitiated() );
if ( serviceBinding != null ) {
serviceBinding.setTarget( null );
}
initializer.registerServiceInitiator( initiator );
}
private static final class ServiceBinding<T> {
private final T proxy;
private T target;
private ServiceBinding(T proxy) {
this.proxy = proxy;
}
public T getProxy() {
return proxy;
}
public T getTarget() {
return target;
}
public void setTarget(T target) {
this.target = target;
}
}
}

View File

@ -27,37 +27,39 @@ import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jboss.logging.Logger;
import org.hibernate.HibernateLogger;
import org.hibernate.service.jmx.spi.JmxService;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.service.spi.Configurable;
import org.hibernate.service.spi.InjectService;
import org.hibernate.service.spi.Manageable;
import org.hibernate.service.spi.Service;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.StandardServiceInitiators;
import org.hibernate.service.spi.Startable;
import org.hibernate.service.spi.UnknownServiceException;
import org.jboss.logging.Logger;
/**
* Delegate responsible for initializing services
* Standard Hibernate implementation of the service registry.
*
* @author Steve Ebersole
*/
public class ServiceInitializer {
public class BasicServiceRegistryImpl extends AbstractServiceRegistryImpl {
private static final HibernateLogger LOG = Logger.getMessageLogger(HibernateLogger.class, BasicServiceRegistryImpl.class.getName());
private static final HibernateLogger LOG = Logger.getMessageLogger(HibernateLogger.class, ServiceInitializer.class.getName());
private final ServiceRegistryImpl servicesRegistry;
private final Map<Class,ServiceInitiator> serviceInitiatorMap;
private final Map<Class,BasicServiceInitiator> serviceInitiatorMap;
private final Map configurationValues;
public ServiceInitializer(
ServiceRegistryImpl servicesRegistry,
List<ServiceInitiator> serviceInitiators,
Map configurationValues) {
this.servicesRegistry = servicesRegistry;
public BasicServiceRegistryImpl(Map configurationValues) {
this( StandardServiceInitiators.LIST, configurationValues );
}
public BasicServiceRegistryImpl(List<BasicServiceInitiator> serviceInitiators, Map configurationValues) {
super();
this.serviceInitiatorMap = toMap( serviceInitiators );
this.configurationValues = configurationValues;
}
@ -72,34 +74,32 @@ public class ServiceInitializer {
*
* @return The map of initiators keyed by the service rle they initiate.
*/
private static Map<Class, ServiceInitiator> toMap(List<ServiceInitiator> serviceInitiators) {
final Map<Class, ServiceInitiator> result = new HashMap<Class, ServiceInitiator>();
for ( ServiceInitiator initiator : serviceInitiators ) {
private static Map<Class, BasicServiceInitiator> toMap(List<BasicServiceInitiator> serviceInitiators) {
final Map<Class, BasicServiceInitiator> result = new HashMap<Class, BasicServiceInitiator>();
for ( BasicServiceInitiator initiator : serviceInitiators ) {
result.put( initiator.getServiceInitiated(), initiator );
}
return result;
}
void registerServiceInitiator(ServiceInitiator serviceInitiator) {
final Object previous = serviceInitiatorMap.put( serviceInitiator.getServiceInitiated(), serviceInitiator );
final boolean overwritten = previous != null;
if (overwritten) LOG.debugf("Over-wrote existing service initiator [role=%s]",
serviceInitiator.getServiceInitiated().getName());
@SuppressWarnings( {"unchecked"})
public void registerServiceInitiator(BasicServiceInitiator initiator) {
ServiceBinding serviceBinding = locateServiceBinding( initiator.getServiceInitiated(), false );
if ( serviceBinding != null ) {
serviceBinding.setTarget( null );
}
final Object previous = serviceInitiatorMap.put( initiator.getServiceInitiated(), initiator );
if ( previous != null ) {
LOG.debugf( "Over-wrote existing service initiator [role=%s]", initiator.getServiceInitiated().getName() );
}
}
/**
* The main function of this delegate. Used to initialize the service of a given role.
*
* @param serviceRole The service role
* @param <T> The type of service role
*
* @return The intiialized instance of the service
*/
public <T extends Service> T initializeService(Class<T> serviceRole) {
@Override
protected <R extends Service> R initializeService(Class<R> serviceRole) {
LOG.trace("Initializing service [role=" + serviceRole.getName() + "]");
// PHASE 1 : create service
T service = createService( serviceRole );
R service = createService( serviceRole );
if ( service == null ) {
return null;
}
@ -115,15 +115,15 @@ public class ServiceInitializer {
@SuppressWarnings({ "unchecked" })
private <T extends Service> T createService(Class<T> serviceRole) {
ServiceInitiator<T> initiator = serviceInitiatorMap.get( serviceRole );
BasicServiceInitiator<T> initiator = serviceInitiatorMap.get( serviceRole );
if ( initiator == null ) {
throw new UnknownServiceException( serviceRole );
}
try {
T service = initiator.initiateService( configurationValues, servicesRegistry );
T service = initiator.initiateService( configurationValues, this );
// IMPL NOTE : the register call here is important to avoid potential stack overflow issues
// from recursive calls through #configureService
servicesRegistry.registerService( serviceRole, service );
registerService( serviceRole, service );
return service;
}
catch ( ServiceException e ) {
@ -142,7 +142,7 @@ public class ServiceInitializer {
}
if ( ServiceRegistryAwareService.class.isInstance( service ) ) {
( (ServiceRegistryAwareService) service ).injectServices( servicesRegistry );
( (ServiceRegistryAwareService) service ).injectServices( this );
}
}
@ -177,7 +177,7 @@ public class ServiceInitializer {
// todo : because of the use of proxies, this is no longer returning null here...
final Service dependantService = servicesRegistry.getService( dependentServiceRole );
final Service dependantService = getService( dependentServiceRole );
if ( dependantService == null ) {
if ( injectService.required() ) {
throw new ServiceDependencyException(
@ -202,7 +202,7 @@ public class ServiceInitializer {
}
if ( Manageable.class.isInstance( service ) ) {
servicesRegistry.getService( JmxService.class ).registerService( (Manageable) service, serviceRole );
getService( JmxService.class ).registerService( (Manageable) service, serviceRole );
}
}
}

View File

@ -0,0 +1,48 @@
/*
* 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.internal;
/**
* @author Steve Ebersole
*/
final class ServiceBinding<R> {
private final R proxy;
private R target;
ServiceBinding(R proxy) {
this.proxy = proxy;
}
public R getProxy() {
return proxy;
}
public R getTarget() {
return target;
}
public void setTarget(R target) {
this.target = target;
}
}

View File

@ -0,0 +1,35 @@
/*
* 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.internal;
import org.hibernate.service.spi.Service;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.service.spi.proxy.ServiceProxyTargetSource;
/**
* @author Steve Ebersole
*/
public interface ServiceRegistryImplementor extends ServiceRegistry, ServiceProxyTargetSource {
public <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole);
}

View File

@ -31,15 +31,17 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.HibernateLogger;
import org.hibernate.cfg.Environment;
import org.hibernate.internal.util.beans.BeanInfoHelper;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.internal.ServiceRegistryImplementor;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistry;
import org.jboss.logging.Logger;
import org.hibernate.service.spi.BasicServiceInitiator;
/**
* Instantiates and configures an appropriate {@link ConnectionProvider}.
@ -47,12 +49,11 @@ import org.jboss.logging.Logger;
* @author Gavin King
* @author Steve Ebersole
*/
public class ConnectionProviderInitiator implements ServiceInitiator<ConnectionProvider> {
public class ConnectionProviderInitiator implements BasicServiceInitiator<ConnectionProvider> {
public static final ConnectionProviderInitiator INSTANCE = new ConnectionProviderInitiator();
private static final HibernateLogger LOG = Logger.getMessageLogger(HibernateLogger.class,
ConnectionProviderInitiator.class.getName());
public static final String C3P0_CONFIG_PREFIX = "hibernate.c3p0";
public static final String C3P0_PROVIDER_CLASS_NAME =
"org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider";
@ -92,17 +93,13 @@ public class ConnectionProviderInitiator implements ServiceInitiator<ConnectionP
);
}
/**
* {@inheritDoc}
*/
@Override
public Class<ConnectionProvider> getServiceInitiated() {
return ConnectionProvider.class;
}
/**
* {@inheritDoc}
*/
public ConnectionProvider initiateService(Map configurationValues, ServiceRegistry registry) {
@Override
public ConnectionProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
final ClassLoaderService classLoaderService = registry.getService( ClassLoaderService.class );
ConnectionProvider connectionProvider = null;
@ -233,10 +230,14 @@ public class ConnectionProviderInitiator implements ServiceInitiator<ConnectionP
}
/**
* Transform JDBC connection properties.
* Build the connection properties capable of being passed to the {@link java.sql.DriverManager#getConnection}
* forms taking {@link Properties} argument. We seek out all keys in the passed map which start with
* {@code hibernate.connection.}, using them to create a new {@link Properties} instance. The keys in this
* new {@link Properties} have the {@code hibernate.connection.} prefix trimmed.
*
* Passed in the form <tt>hibernate.connection.*</tt> to the
* format accepted by <tt>DriverManager</tt> by trimming the leading "<tt>hibernate.connection</tt>".
* @param properties The map from which to build the connection specific properties.
*
* @return The connection properties.
*/
public static Properties getConnectionProperties(Map<?,?> properties) {
Properties result = new Properties();
@ -253,8 +254,10 @@ public class ConnectionProviderInitiator implements ServiceInitiator<ConnectionP
}
}
else {
final String passThruKey = key.substring( Environment.CONNECTION_PREFIX.length() + 1 );
result.setProperty( passThruKey, value );
result.setProperty(
key.substring( Environment.CONNECTION_PREFIX.length() + 1 ),
value
);
}
}
}

View File

@ -45,7 +45,7 @@ public interface ConnectionProvider extends Service, Wrapped {
* @return The obtained JDBC connection
*
* @throws SQLException Indicates a problem opening a connection
* @throws HibernateException Inidcates a problem otherwise obtaining a connnection.
* @throws HibernateException Indicates a problem otherwise obtaining a connection.
*/
public Connection getConnection() throws SQLException;
@ -55,13 +55,13 @@ public interface ConnectionProvider extends Service, Wrapped {
* @param conn The JDBC connection to release
*
* @throws SQLException Indicates a problem closing the connection
* @throws HibernateException Inidcates a problem otherwise releasing a connnection.
* @throws HibernateException Indicates a problem otherwise releasing a connection.
*/
public void closeConnection(Connection conn) throws SQLException;
/**
* Does this connection provider support aggressive release of JDBC
* connections and re-acquistion of those connections (if need be) later?
* connections and re-acquisition of those connections (if need be) later?
* <p/>
* This is used in conjunction with {@link org.hibernate.cfg.Environment#RELEASE_CONNECTIONS}
* to aggressively release JDBC connections. However, the configured ConnectionProvider
@ -72,6 +72,8 @@ public interface ConnectionProvider extends Service, Wrapped {
*
* Note that JTA semantic depends on the fact that the underlying connection provider does
* support aggressive release.
*
* @return {@code true} if aggressive releasing is supported; {@code false} otherwise.
*/
public boolean supportsAggressiveRelease();
}

View File

@ -22,30 +22,28 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.internal;
import java.util.Map;
import org.hibernate.service.internal.ServiceRegistryImplementor;
import org.hibernate.service.jdbc.dialect.spi.DialectFactory;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.service.spi.BasicServiceInitiator;
/**
* Standard initiator for the standard {@link DialectFactory} service
*
* @author Steve Ebersole
*/
public class DialectFactoryInitiator implements ServiceInitiator<DialectFactory> {
public class DialectFactoryInitiator implements BasicServiceInitiator<DialectFactory> {
public static final DialectFactoryInitiator INSTANCE = new DialectFactoryInitiator();
/**
* {@inheritDoc}
*/
@Override
public Class<DialectFactory> getServiceInitiated() {
return DialectFactory.class;
}
/**
* {@inheritDoc}
*/
public DialectFactory initiateService(Map configVales, ServiceRegistry registry) {
@Override
public DialectFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
return new DialectFactoryImpl();
}
}

View File

@ -22,30 +22,28 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.internal;
import java.util.Map;
import org.hibernate.service.internal.ServiceRegistryImplementor;
import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.service.spi.BasicServiceInitiator;
/**
* Standard initiator for the standard {@link DialectResolver} service
*
* @author Steve Ebersole
*/
public class DialectResolverInitiator implements ServiceInitiator<DialectResolver> {
public class DialectResolverInitiator implements BasicServiceInitiator<DialectResolver> {
public static final DialectResolverInitiator INSTANCE = new DialectResolverInitiator();
/**
* {@inheritDoc}
*/
@Override
public Class<DialectResolver> getServiceInitiated() {
return DialectResolver.class;
}
/**
* {@inheritDoc}
*/
public DialectResolver initiateService(Map configVales, ServiceRegistry registry) {
@Override
public DialectResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
return new StandardDialectResolver();
}
}

View File

@ -22,8 +22,10 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.spi;
import java.sql.Connection;
import java.util.Map;
import org.hibernate.HibernateException;
import org.hibernate.dialect.Dialect;
import org.hibernate.service.spi.Service;

View File

@ -22,7 +22,9 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jdbc.dialect.spi;
import java.sql.DatabaseMetaData;
import org.hibernate.dialect.Dialect;
import org.hibernate.exception.JDBCConnectionException;
import org.hibernate.service.spi.Service;
@ -47,5 +49,4 @@ public interface DialectResolver extends Service {
* we should stop resolution attempts.
*/
public Dialect resolveDialect(DatabaseMetaData metaData) throws JDBCConnectionException;
}

View File

@ -22,18 +22,20 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jmx.internal;
import java.util.Map;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.internal.ServiceRegistryImplementor;
import org.hibernate.service.jmx.spi.JmxService;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.service.spi.BasicServiceInitiator;
/**
* Standard initiator for the standard {@link JmxService} service
*
* @author Steve Ebersole
*/
public class JmxServiceInitiator implements ServiceInitiator<JmxService> {
public class JmxServiceInitiator implements BasicServiceInitiator<JmxService> {
public static final String JMX_ENABLED = "hibernate.jmx.enabled";
public static final JmxServiceInitiator INSTANCE = new JmxServiceInitiator();
@ -43,9 +45,9 @@ public class JmxServiceInitiator implements ServiceInitiator<JmxService> {
}
@Override
public JmxService initiateService(Map configValues, ServiceRegistry registry) {
return ConfigurationHelper.getBoolean( JMX_ENABLED, configValues, false )
? new JmxServiceImpl( configValues )
public JmxService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
return ConfigurationHelper.getBoolean( JMX_ENABLED, configurationValues, false )
? new JmxServiceImpl( configurationValues )
: DisabledJmxServiceImpl.INSTANCE;
}
}

View File

@ -22,7 +22,9 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jmx.spi;
import javax.management.ObjectName;
import org.hibernate.service.spi.Manageable;
import org.hibernate.service.spi.Service;
@ -33,7 +35,7 @@ import org.hibernate.service.spi.Service;
*/
public interface JmxService extends Service {
/**
* Handles regsitration of a manageable service.
* Handles registration of a manageable service.
*
* @param service The manageable service
* @param serviceRole The service's role.

View File

@ -22,17 +22,19 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jndi.internal;
import java.util.Map;
import org.hibernate.service.internal.ServiceRegistryImplementor;
import org.hibernate.service.jndi.spi.JndiService;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.service.spi.BasicServiceInitiator;
/**
* Standard initiator for the standard {@link JndiService} service
*
* @author Steve Ebersole
*/
public class JndiServiceInitiator implements ServiceInitiator<JndiService> {
public class JndiServiceInitiator implements BasicServiceInitiator<JndiService> {
public static final JndiServiceInitiator INSTANCE = new JndiServiceInitiator();
@Override
@ -41,7 +43,7 @@ public class JndiServiceInitiator implements ServiceInitiator<JndiService> {
}
@Override
public JndiService initiateService(Map configurationValues, ServiceRegistry registry) {
public JndiService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
return new JndiServiceImpl( configurationValues );
}
}

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jndi.spi;
import org.hibernate.service.spi.Service;
/**

View File

@ -22,25 +22,28 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jta.platform.internal;
import java.util.Map;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.HibernateLogger;
import org.hibernate.cfg.Environment;
import org.hibernate.internal.util.jndi.JndiHelper;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.internal.ServiceRegistryImplementor;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.service.jta.platform.spi.JtaPlatformException;
import org.hibernate.service.spi.ServiceInitiator;
import org.hibernate.service.spi.ServiceRegistry;
import org.hibernate.service.spi.BasicServiceInitiator;
import org.hibernate.transaction.TransactionManagerLookup;
import org.jboss.logging.Logger;
/**
* Standard initiator for the standard {@link org.hibernate.service.jta.platform.spi.JtaPlatform}
*
* @author Steve Ebersole
*/
public class JtaPlatformInitiator implements ServiceInitiator<JtaPlatform> {
public class JtaPlatformInitiator implements BasicServiceInitiator<JtaPlatform> {
public static final JtaPlatformInitiator INSTANCE = new JtaPlatformInitiator();
public static final String JTA_PLATFORM = "hibernate.jta.platform";
@ -51,10 +54,10 @@ public class JtaPlatformInitiator implements ServiceInitiator<JtaPlatform> {
return JtaPlatform.class;
}
@SuppressWarnings( {"unchecked"})
@Override
public JtaPlatform initiateService(Map configVales, ServiceRegistry registry) {
final Object platform = getConfiguredPlatform( configVales, registry );
@SuppressWarnings( {"unchecked"})
public JtaPlatform initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
final Object platform = getConfiguredPlatform( configurationValues, registry );
if ( platform == null ) {
return new NoJtaPlatform();
}
@ -87,7 +90,7 @@ public class JtaPlatformInitiator implements ServiceInitiator<JtaPlatform> {
}
}
private Object getConfiguredPlatform(Map configVales, ServiceRegistry registry) {
private Object getConfiguredPlatform(Map configVales, ServiceRegistryImplementor registry) {
Object platform = configVales.get( JTA_PLATFORM );
if ( platform == null ) {
final String transactionManagerLookupImplName = (String) configVales.get( Environment.TRANSACTION_MANAGER_STRATEGY );
@ -103,75 +106,72 @@ public class JtaPlatformInitiator implements ServiceInitiator<JtaPlatform> {
return platform;
}
private JtaPlatform mapLegacyClasses(
String transactionManagerLookupImplName,
Map configVales,
ServiceRegistry registry) {
if ( transactionManagerLookupImplName == null ) {
private JtaPlatform mapLegacyClasses(String tmlImplName, Map configVales, ServiceRegistryImplementor registry) {
if ( tmlImplName == null ) {
return null;
}
LOG.legacyTransactionManagerStrategy(JtaPlatform.class.getName(), JTA_PLATFORM);
if ( "org.hibernate.transaction.BESTransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.BESTransactionManagerLookup".equals( tmlImplName ) ) {
return new BorlandEnterpriseServerJtaPlatform();
}
if ( "org.hibernate.transaction.BTMTransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.BTMTransactionManagerLookup".equals( tmlImplName ) ) {
return new BitronixJtaPlatform();
}
if ( "org.hibernate.transaction.JBossTransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.JBossTransactionManagerLookup".equals( tmlImplName ) ) {
return new JBossAppServerPlatform();
}
if ( "org.hibernate.transaction.JBossTSStandaloneTransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.JBossTSStandaloneTransactionManagerLookup".equals( tmlImplName ) ) {
return new JBossStandAloneJtaPlatform();
}
if ( "org.hibernate.transaction.JOnASTransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.JOnASTransactionManagerLookup".equals( tmlImplName ) ) {
return new JOnASJtaPlatform();
}
if ( "org.hibernate.transaction.JOTMTransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.JOTMTransactionManagerLookup".equals( tmlImplName ) ) {
return new JOTMJtaPlatform();
}
if ( "org.hibernate.transaction.JRun4TransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.JRun4TransactionManagerLookup".equals( tmlImplName ) ) {
return new JRun4JtaPlatform();
}
if ( "org.hibernate.transaction.OC4JTransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.OC4JTransactionManagerLookup".equals( tmlImplName ) ) {
return new OC4JJtaPlatform();
}
if ( "org.hibernate.transaction.OrionTransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.OrionTransactionManagerLookup".equals( tmlImplName ) ) {
return new OrionJtaPlatform();
}
if ( "org.hibernate.transaction.ResinTransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.ResinTransactionManagerLookup".equals( tmlImplName ) ) {
return new ResinJtaPlatform();
}
if ( "org.hibernate.transaction.SunONETransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.SunONETransactionManagerLookup".equals( tmlImplName ) ) {
return new SunOneJtaPlatform();
}
if ( "org.hibernate.transaction.WeblogicTransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.WeblogicTransactionManagerLookup".equals( tmlImplName ) ) {
return new WeblogicJtaPlatform();
}
if ( "org.hibernate.transaction.WebSphereTransactionManagerLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.WebSphereTransactionManagerLookup".equals( tmlImplName ) ) {
return new WebSphereJtaPlatform();
}
if ( "org.hibernate.transaction.WebSphereExtendedJTATransactionLookup".equals( transactionManagerLookupImplName ) ) {
if ( "org.hibernate.transaction.WebSphereExtendedJTATransactionLookup".equals( tmlImplName ) ) {
return new WebSphereExtendedJtaPlatform();
}
try {
TransactionManagerLookup lookup = (TransactionManagerLookup) registry.getService( ClassLoaderService.class )
.classForName( transactionManagerLookupImplName )
.classForName( tmlImplName )
.newInstance();
return new TransactionManagerLookupBridge( lookup, JndiHelper.extractJndiProperties( configVales ) );
}
@ -179,7 +179,7 @@ public class JtaPlatformInitiator implements ServiceInitiator<JtaPlatform> {
throw new JtaPlatformException(
"Unable to build " + TransactionManagerLookupBridge.class.getName() + " from specified " +
TransactionManagerLookup.class.getName() + " implementation: " +
transactionManagerLookupImplName
tmlImplName
);
}
}

View File

@ -22,11 +22,13 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.jta.platform.spi;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
import org.hibernate.service.spi.Service;
/**

View File

@ -22,20 +22,23 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.service.spi;
import java.util.Map;
import org.hibernate.service.internal.ServiceRegistryImplementor;
/**
* Responsible for initiating services.
*
* @author Steve Ebersole
*/
public interface ServiceInitiator<T extends Service> {
public interface BasicServiceInitiator<R extends Service> {
/**
* Obtains the service role initiated by this initiator. Should be uniqie withion a registry
* Obtains the service role initiated by this initiator. Should be unique within a registry
*
* @return The service role.
*/
public Class<T> getServiceInitiated();
public Class<R> getServiceInitiated();
/**
* Initiates the managed service.
@ -45,5 +48,5 @@ public interface ServiceInitiator<T extends Service> {
*
* @return The initiated service.
*/
public T initiateService(Map configurationValues, ServiceRegistry registry);
public R initiateService(Map configurationValues, ServiceRegistryImplementor registry);
}

View File

@ -24,36 +24,39 @@
package org.hibernate.service.spi;
/**
* The registry of services used by Hibernate
* The registry of {@link Service services}.
*
* @author Steve Ebersole
*/
public interface ServiceRegistry {
/**
* Retrieve a service by role. If service is not found, but a {@link ServiceInitiator} is registered for
* Retrieve this registry's parent registry.
*
* @return The parent registry. May be null.
*/
public ServiceRegistry getParentServiceRegistry();
/**
* Retrieve a service by role. If service is not found, but a {@link BasicServiceInitiator} is registered for
* this service role, the service will be initialized and returned.
* <p/>
* NOTE: We cannot return {@code <R extends Service<T>>} here because the service might come from the parent...
*
* @param serviceRole The service role
* @param <T> The type of the service
* @param <R> The service role type
*
* @return The requested service.
*
* @throws UnknownServiceException Indicates the service was not known.
*/
public <T extends Service> T getService(Class<T> serviceRole);
public <R extends Service> R getService(Class<R> serviceRole);
/**
* Register a service into the registry.
*
* @param serviceRole The service role.
* @param service The service to register
* @param <R> The service role type
*/
public <T extends Service> void registerService(Class<T> serviceRole, T service);
/**
* Register a service initiator.
*
* @param initiator The initiator of a service
*/
public void registerServiceInitiator(ServiceInitiator initiator);
public <R extends Service> void registerService(Class<R> serviceRole, R service);
}

View File

@ -23,7 +23,6 @@
*/
package org.hibernate.service.spi;
/**
* Allows services to be injected with the {@link ServiceRegistry} during configuration phase.
*

View File

@ -43,10 +43,10 @@ import java.util.List;
* @author Steve Ebersole
*/
public class StandardServiceInitiators {
public static List<ServiceInitiator> LIST = buildStandardServiceInitiatorList();
public static List<BasicServiceInitiator> LIST = buildStandardServiceInitiatorList();
private static List<ServiceInitiator> buildStandardServiceInitiatorList() {
final List<ServiceInitiator> serviceInitiators = new ArrayList<ServiceInitiator>();
private static List<BasicServiceInitiator> buildStandardServiceInitiatorList() {
final List<BasicServiceInitiator> serviceInitiators = new ArrayList<BasicServiceInitiator>();
serviceInitiators.add( ClassLoaderServiceInitiator.INSTANCE );
serviceInitiators.add( JndiServiceInitiator.INSTANCE );

View File

@ -36,11 +36,11 @@ public interface ServiceProxyTargetSource extends ServiceRegistry {
* Retrieve a service by role. Unlike {@link ServiceRegistry#getService}, this version will never return a proxy.
*
* @param serviceRole The service role
* @param <T> The type of the service
* @param <R> The service role type
*
* @return The requested service.
*
* @throws org.hibernate.service.spi.UnknownServiceException Indicates the service was not known.
*/
public <T extends Service> T getServiceInternal(Class<T> serviceRole);
public <R extends Service> R getServiceInternal(Class<R> serviceRole);
}

View File

@ -55,7 +55,7 @@ import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.internal.util.ConfigHelper;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.jboss.logging.Logger;
@ -429,10 +429,10 @@ public class SchemaExport {
}
private static ServiceRegistryImpl createServiceRegistry(Properties properties) {
private static BasicServiceRegistryImpl createServiceRegistry(Properties properties) {
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
return new ServiceRegistryImpl( properties );
return new BasicServiceRegistryImpl( properties );
}
public static void main(String[] args) {
@ -515,7 +515,7 @@ public class SchemaExport {
cfg.setProperty( Environment.HBM2DDL_IMPORT_FILES, importFile );
}
ServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
BasicServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
try {
SchemaExport se = new SchemaExport( serviceRegistry.getService( JdbcServices.class ), cfg )
.setHaltOnError( halt )

View File

@ -46,7 +46,7 @@ import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.jboss.logging.Logger;
@ -96,10 +96,10 @@ public class SchemaUpdate {
formatter = ( sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
}
private static ServiceRegistryImpl createServiceRegistry(Properties properties) {
private static BasicServiceRegistryImpl createServiceRegistry(Properties properties) {
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
return new ServiceRegistryImpl( properties );
return new BasicServiceRegistryImpl( properties );
}
public static void main(String[] args) {
@ -144,7 +144,7 @@ public class SchemaUpdate {
cfg.setProperties( props );
}
ServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
BasicServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
try {
new SchemaUpdate( serviceRegistry.getService( JdbcServices.class ), cfg ).execute( script, doUpdate );
}

View File

@ -37,7 +37,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.jboss.logging.Logger;
@ -76,10 +76,10 @@ public class SchemaValidator {
);
}
private static ServiceRegistryImpl createServiceRegistry(Properties properties) {
private static BasicServiceRegistryImpl createServiceRegistry(Properties properties) {
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
return new ServiceRegistryImpl( properties );
return new BasicServiceRegistryImpl( properties );
}
public static void main(String[] args) {
@ -115,7 +115,7 @@ public class SchemaValidator {
cfg.setProperties( props );
}
ServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
BasicServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
try {
new SchemaValidator( serviceRegistry.getService( JdbcServices.class ), cfg ).validate();
}

View File

@ -3,7 +3,7 @@ package org.hibernate.test.extendshbm;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.junit.After;
import org.junit.Before;
@ -20,7 +20,7 @@ import static org.junit.Assert.fail;
* @author Gavin King
*/
public class ExtendsTest extends BaseUnitTestCase {
private ServiceRegistryImpl serviceRegistry;
private BasicServiceRegistryImpl serviceRegistry;
@Before
public void setUp() {

View File

@ -41,7 +41,7 @@ import org.hibernate.engine.transaction.spi.TransactionContext;
import org.hibernate.engine.transaction.spi.TransactionImplementor;
import org.hibernate.jdbc.Expectation;
import org.hibernate.jdbc.Expectations;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.service.spi.StandardServiceInitiators;
import org.junit.After;
@ -64,11 +64,11 @@ import static org.junit.Assert.assertTrue;
* @author Steve Ebersole
*/
public class BatchingTest extends BaseUnitTestCase implements BatchKey {
private ServiceRegistryImpl serviceRegistry;
private BasicServiceRegistryImpl serviceRegistry;
@Before
public void setUp() throws Exception {
serviceRegistry = new ServiceRegistryImpl(
serviceRegistry = new BasicServiceRegistryImpl(
StandardServiceInitiators.LIST,
ConnectionProviderBuilder.getConnectionProviderProperties()
);

View File

@ -32,7 +32,7 @@ import static org.junit.Assert.assertTrue;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
import org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
@ -46,7 +46,7 @@ import org.hibernate.testing.junit4.BaseUnitTestCase;
public class ServiceBootstrappingTest extends BaseUnitTestCase {
@Test
public void testBasicBuild() {
ServiceRegistryImpl serviceRegistry = new ServiceRegistryImpl( ConnectionProviderBuilder.getConnectionProviderProperties() );
BasicServiceRegistryImpl serviceRegistry = new BasicServiceRegistryImpl( ConnectionProviderBuilder.getConnectionProviderProperties() );
JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
assertTrue( jdbcServices.getDialect() instanceof H2Dialect );
@ -61,7 +61,7 @@ public class ServiceBootstrappingTest extends BaseUnitTestCase {
Properties props = ConnectionProviderBuilder.getConnectionProviderProperties();
props.put( Environment.SHOW_SQL, "true" );
ServiceRegistryImpl serviceRegistry = new ServiceRegistryImpl( props );
BasicServiceRegistryImpl serviceRegistry = new BasicServiceRegistryImpl( props );
JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
assertTrue( jdbcServices.getDialect() instanceof H2Dialect );
@ -75,7 +75,7 @@ public class ServiceBootstrappingTest extends BaseUnitTestCase {
public void testBuildWithServiceOverride() {
Properties props = ConnectionProviderBuilder.getConnectionProviderProperties();
ServiceRegistryImpl serviceRegistry = new ServiceRegistryImpl( props );
BasicServiceRegistryImpl serviceRegistry = new BasicServiceRegistryImpl( props );
JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
assertTrue( jdbcServices.getDialect() instanceof H2Dialect );

View File

@ -33,7 +33,7 @@ import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor;
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
import org.hibernate.engine.transaction.spi.TransactionContext;
import org.hibernate.engine.transaction.spi.TransactionImplementor;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.service.spi.StandardServiceInitiators;
import org.junit.After;
@ -54,11 +54,11 @@ import org.hibernate.test.common.TransactionEnvironmentImpl;
* @author Steve Ebersole
*/
public class TestExpectedUsage extends BaseUnitTestCase {
private ServiceRegistryImpl serviceRegistry;
private BasicServiceRegistryImpl serviceRegistry;
@Before
public void setUp() throws Exception {
serviceRegistry = new ServiceRegistryImpl(
serviceRegistry = new BasicServiceRegistryImpl(
StandardServiceInitiators.LIST,
ConnectionProviderBuilder.getConnectionProviderProperties()
);

View File

@ -37,7 +37,7 @@ import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory;
import org.hibernate.engine.transaction.spi.TransactionContext;
import org.hibernate.engine.transaction.spi.TransactionImplementor;
import org.hibernate.service.internal.ServiceProxy;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.junit.After;
@ -62,7 +62,7 @@ import static org.junit.Assert.fail;
* @author Steve Ebersole
*/
public class BasicDrivingTest extends BaseUnitTestCase {
private ServiceRegistryImpl serviceRegistry;
private BasicServiceRegistryImpl serviceRegistry;
@Before
@SuppressWarnings( {"unchecked"})
@ -71,7 +71,7 @@ public class BasicDrivingTest extends BaseUnitTestCase {
configValues.putAll( ConnectionProviderBuilder.getConnectionProviderProperties() );
configValues.put( Environment.TRANSACTION_STRATEGY, JtaTransactionFactory.class.getName() );
TestingJtaBootstrap.prepare( configValues );
serviceRegistry = new ServiceRegistryImpl( configValues );
serviceRegistry = new BasicServiceRegistryImpl( configValues );
}
@After

View File

@ -38,8 +38,8 @@ import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
import org.hibernate.engine.transaction.spi.TransactionContext;
import org.hibernate.engine.transaction.spi.TransactionImplementor;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.service.internal.ServiceProxy;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.service.spi.StandardServiceInitiators;
@ -64,7 +64,7 @@ import static org.junit.Assert.fail;
* @author Steve Ebersole
*/
public class ManagedDrivingTest extends BaseUnitTestCase {
private ServiceRegistryImpl serviceRegistry;
private BasicServiceRegistryImpl serviceRegistry;
@Before
@SuppressWarnings( {"unchecked"})
@ -74,7 +74,7 @@ public class ManagedDrivingTest extends BaseUnitTestCase {
// configValues.putAll( ConnectionProviderBuilder.getConnectionProviderProperties() );
configValues.put( Environment.TRANSACTION_STRATEGY, CMTTransactionFactory.class.getName() );
serviceRegistry = new ServiceRegistryImpl( StandardServiceInitiators.LIST, configValues );
serviceRegistry = new BasicServiceRegistryImpl( StandardServiceInitiators.LIST, configValues );
}
@After

View File

@ -99,7 +99,7 @@ import org.hibernate.mapping.AuxiliaryDatabaseObject;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.secure.JACCConfiguration;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl;
import org.hibernate.service.spi.ServiceRegistry;
@ -868,7 +868,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
}
public EntityManagerFactory buildEntityManagerFactory() {
return buildEntityManagerFactory( new ServiceRegistryImpl( cfg.getProperties() ) );
return buildEntityManagerFactory( new BasicServiceRegistryImpl( cfg.getProperties() ) );
}
public EntityManagerFactory buildEntityManagerFactory(ServiceRegistry serviceRegistry) {

View File

@ -40,7 +40,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.ejb.AvailableSettings;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.junit.After;
import org.junit.Before;
@ -62,7 +62,7 @@ public abstract class BaseEntityManagerFunctionalTestCase extends BaseUnitTestCa
private static final Dialect dialect = Dialect.getDialect();
private Ejb3Configuration ejb3Configuration;
private ServiceRegistryImpl serviceRegistry;
private BasicServiceRegistryImpl serviceRegistry;
private EntityManagerFactory entityManagerFactory;
private EntityManager em;
@ -76,7 +76,7 @@ public abstract class BaseEntityManagerFunctionalTestCase extends BaseUnitTestCa
return entityManagerFactory;
}
protected ServiceRegistryImpl serviceRegistry() {
protected BasicServiceRegistryImpl serviceRegistry() {
return serviceRegistry;
}
@ -196,16 +196,16 @@ public abstract class BaseEntityManagerFunctionalTestCase extends BaseUnitTestCa
protected void afterConfigurationBuilt(Ejb3Configuration ejb3Configuration) {
}
protected ServiceRegistryImpl buildServiceRegistry(Configuration configuration) {
protected BasicServiceRegistryImpl buildServiceRegistry(Configuration configuration) {
Properties properties = new Properties();
properties.putAll( configuration.getProperties() );
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
return new ServiceRegistryImpl( properties );
return new BasicServiceRegistryImpl( properties );
}
@SuppressWarnings( {"UnusedParameters"})
protected void applyServices(ServiceRegistryImpl serviceRegistry) {
protected void applyServices(BasicServiceRegistryImpl serviceRegistry) {
}
protected void afterEntityManagerFactoryBuilt() {

View File

@ -34,7 +34,6 @@ import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.ejb.AvailableSettings;
import org.hibernate.ejb.Ejb3Configuration;
import org.hibernate.envers.AuditReader;
@ -46,7 +45,7 @@ import org.hibernate.event.PostInsertEventListener;
import org.hibernate.event.PostUpdateEventListener;
import org.hibernate.event.PreCollectionRemoveEventListener;
import org.hibernate.event.PreCollectionUpdateEventListener;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.testing.jta.TestingJtaBootstrap;
@ -58,7 +57,7 @@ public abstract class AbstractEntityTest {
private EntityManager entityManager;
private AuditReader auditReader;
private Ejb3Configuration cfg;
private ServiceRegistryImpl serviceRegistry;
private BasicServiceRegistryImpl serviceRegistry;
private boolean audited;
public abstract void configure(Ejb3Configuration cfg);
@ -118,7 +117,7 @@ public abstract class AbstractEntityTest {
cfg.configure( cfg.getHibernateConfiguration().getProperties() );
serviceRegistry = new ServiceRegistryImpl( cfg.getProperties() );
serviceRegistry = new BasicServiceRegistryImpl( cfg.getProperties() );
emf = cfg.buildEntityManagerFactory( serviceRegistry );

View File

@ -33,7 +33,7 @@ import org.hibernate.cache.Region;
import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.util.CacheAdapter;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.junit.Test;
@ -77,7 +77,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
private void evictOrRemoveTest() throws Exception {
Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
new ServiceRegistryImpl( cfg.getProperties() ),
new BasicServiceRegistryImpl( cfg.getProperties() ),
cfg,
getCacheTestSupport()
);
@ -94,7 +94,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
cfg = createConfiguration();
regionFactory = CacheTestUtil.startRegionFactory(
new ServiceRegistryImpl( cfg.getProperties() ),
new BasicServiceRegistryImpl( cfg.getProperties() ),
cfg,
getCacheTestSupport()
);
@ -140,7 +140,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
private void evictOrRemoveAllTest(String configName) throws Exception {
Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
new ServiceRegistryImpl( cfg.getProperties() ),
new BasicServiceRegistryImpl( cfg.getProperties() ),
cfg,
getCacheTestSupport()
);
@ -158,7 +158,7 @@ public abstract class AbstractGeneralDataRegionTestCase extends AbstractRegionIm
cfg = createConfiguration();
regionFactory = CacheTestUtil.startRegionFactory(
new ServiceRegistryImpl( cfg.getProperties() ),
new BasicServiceRegistryImpl( cfg.getProperties() ),
cfg,
getCacheTestSupport()
);

View File

@ -32,7 +32,7 @@ import org.hibernate.cache.infinispan.collection.CollectionRegionImpl;
import org.hibernate.cache.infinispan.entity.EntityRegionImpl;
import org.hibernate.cache.infinispan.util.FlagAdapter;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
@ -44,7 +44,7 @@ import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
public class NodeEnvironment {
private final Configuration configuration;
private ServiceRegistryImpl serviceRegistry;
private BasicServiceRegistryImpl serviceRegistry;
private InfinispanRegionFactory regionFactory;
private Map<String,EntityRegionImpl> entityRegionMap;
@ -58,7 +58,7 @@ public class NodeEnvironment {
return configuration;
}
public ServiceRegistryImpl getServiceRegistry() {
public BasicServiceRegistryImpl getServiceRegistry() {
return serviceRegistry;
}
@ -108,7 +108,7 @@ public class NodeEnvironment {
}
public void prepare() throws Exception {
serviceRegistry = new ServiceRegistryImpl( configuration.getProperties() );
serviceRegistry = new BasicServiceRegistryImpl( configuration.getProperties() );
regionFactory = CacheTestUtil.startRegionFactory( serviceRegistry, configuration );
}

View File

@ -30,7 +30,7 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.service.jta.platform.internal.JtaPlatformInitiator;
import org.junit.After;
@ -142,7 +142,7 @@ public abstract class DualNodeTestCase extends BaseCoreFunctionalTestCase {
public class SecondNodeEnvironment {
private Configuration configuration;
private ServiceRegistryImpl serviceRegistry;
private BasicServiceRegistryImpl serviceRegistry;
private SessionFactoryImplementor sessionFactory;
public SecondNodeEnvironment() {
@ -163,7 +163,7 @@ public abstract class DualNodeTestCase extends BaseCoreFunctionalTestCase {
return configuration;
}
public ServiceRegistryImpl getServiceRegistry() {
public BasicServiceRegistryImpl getServiceRegistry() {
return serviceRegistry;
}

View File

@ -41,7 +41,7 @@ import org.hibernate.cache.infinispan.InfinispanRegionFactory;
import org.hibernate.cache.infinispan.util.CacheAdapter;
import org.hibernate.cache.infinispan.util.CacheAdapterImpl;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import junit.framework.AssertionFailedError;
@ -88,7 +88,7 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
private void putDoesNotBlockGetTest() throws Exception {
Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
new ServiceRegistryImpl( cfg.getProperties() ),
new BasicServiceRegistryImpl( cfg.getProperties() ),
cfg,
getCacheTestSupport()
);
@ -188,7 +188,7 @@ public class QueryRegionImplTestCase extends AbstractGeneralDataRegionTestCase {
private void getDoesNotBlockPutTest() throws Exception {
Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
new ServiceRegistryImpl( cfg.getProperties() ),
new BasicServiceRegistryImpl( cfg.getProperties() ),
cfg,
getCacheTestSupport()
);

View File

@ -48,7 +48,7 @@ import org.hibernate.cache.infinispan.util.CacheAdapter;
import org.hibernate.cache.infinispan.util.CacheAdapterImpl;
import org.hibernate.cache.infinispan.util.FlagAdapter;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.test.cache.infinispan.AbstractGeneralDataRegionTestCase;
import org.hibernate.test.cache.infinispan.functional.classloader.Account;
@ -82,7 +82,7 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC
public void testClearTimestampsRegionInIsolated() throws Exception {
Configuration cfg = createConfiguration();
InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
new ServiceRegistryImpl( cfg.getProperties() ),
new BasicServiceRegistryImpl( cfg.getProperties() ),
cfg,
getCacheTestSupport()
);
@ -91,7 +91,7 @@ public class TimestampsRegionImplTestCase extends AbstractGeneralDataRegionTestC
Configuration cfg2 = createConfiguration();
InfinispanRegionFactory regionFactory2 = CacheTestUtil.startRegionFactory(
new ServiceRegistryImpl( cfg.getProperties() ),
new BasicServiceRegistryImpl( cfg.getProperties() ),
cfg2,
getCacheTestSupport()
);

View File

@ -25,7 +25,7 @@ package org.hibernate.testing;
import org.hibernate.cfg.Environment;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.hibernate.service.spi.ServiceRegistry;
import java.util.Map;
@ -35,19 +35,19 @@ import java.util.Properties;
* @author Steve Ebersole
*/
public class ServiceRegistryBuilder {
public static ServiceRegistryImpl buildServiceRegistry() {
public static BasicServiceRegistryImpl buildServiceRegistry() {
return buildServiceRegistry( Environment.getProperties() );
}
public static ServiceRegistryImpl buildServiceRegistry(Map serviceRegistryConfig) {
public static BasicServiceRegistryImpl buildServiceRegistry(Map serviceRegistryConfig) {
Properties properties = new Properties();
properties.putAll( serviceRegistryConfig );
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
return new ServiceRegistryImpl( properties );
return new BasicServiceRegistryImpl( properties );
}
public static void destroy(ServiceRegistry serviceRegistry) {
( (ServiceRegistryImpl) serviceRegistry ).destroy();
( (BasicServiceRegistryImpl) serviceRegistry ).destroy();
}
}

View File

@ -50,7 +50,7 @@ import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.service.internal.ServiceRegistryImpl;
import org.hibernate.service.internal.BasicServiceRegistryImpl;
import org.junit.After;
import org.junit.Before;
@ -73,7 +73,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
public static final Dialect DIALECT = Dialect.getDialect();
private Configuration configuration;
private ServiceRegistryImpl serviceRegistry;
private BasicServiceRegistryImpl serviceRegistry;
private SessionFactoryImplementor sessionFactory;
private Session session;
@ -86,7 +86,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
return configuration;
}
protected ServiceRegistryImpl serviceRegistry() {
protected BasicServiceRegistryImpl serviceRegistry() {
return serviceRegistry;
}
@ -241,17 +241,17 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
protected void afterConfigurationBuilt(Mappings mappings, Dialect dialect) {
}
protected ServiceRegistryImpl buildServiceRegistry(Configuration configuration) {
protected BasicServiceRegistryImpl buildServiceRegistry(Configuration configuration) {
Properties properties = new Properties();
properties.putAll( configuration.getProperties() );
Environment.verifyProperties( properties );
ConfigurationHelper.resolvePlaceHolders( properties );
ServiceRegistryImpl serviceRegistry = new ServiceRegistryImpl( properties );
BasicServiceRegistryImpl serviceRegistry = new BasicServiceRegistryImpl( properties );
applyServices( serviceRegistry );
return serviceRegistry;
}
protected void applyServices(ServiceRegistryImpl serviceRegistry) {
protected void applyServices(BasicServiceRegistryImpl serviceRegistry) {
}
protected void afterSessionFactoryBuilt() {