Top Description Fields Constructors Methods
org.hibernate.service.internal

public abstract Class AbstractServiceRegistryImpl

extends Object
implements ServiceRegistryImplementor, ServiceLifecycleOwner
Class Inheritance
All Implemented Interfaces
org.hibernate.service.spi.ServiceBinding.ServiceLifecycleOwner, org.hibernate.service.spi.ServiceRegistryImplementor, org.hibernate.service.ServiceRegistry, java.lang.AutoCloseable
Known Direct Subclasses
org.hibernate.service.internal.SessionFactoryServiceRegistryImpl, org.hibernate.boot.registry.internal.StandardServiceRegistryImpl
Imports
java.lang.reflect.Method, java.util.HashSet, .List, .ListIterator, .Set, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, java.util.concurrent.atomic.AtomicBoolean, java.util.function.Consumer, org.hibernate.boot.registry.BootstrapServiceRegistry, org.hibernate.boot.registry.classloading.spi.ClassLoaderService, org.hibernate.cfg.Environment, org.hibernate.internal.CoreLogging, .CoreMessageLogger, org.hibernate.internal.util.collections.CollectionHelper, org.hibernate.internal.util.config.ConfigurationHelper, org.hibernate.jmx.spi.JmxService, org.hibernate.service.Service, .ServiceRegistry, .UnknownServiceException, org.hibernate.service.spi.InjectService, .Manageable, .ServiceBinding, .ServiceException, .ServiceInitiator, .ServiceRegistryAwareService, .ServiceRegistryImplementor, .Startable, .Stoppable

Basic implementation of the ServiceRegistry and ServiceRegistryImplementor contracts
Authors
Steve Ebersole, Sanne Grinovero

Field Summary

Modifier and TypeField and Description
private final AtomicBoolean
public static final String
private final boolean
private boolean
private Set<ServiceRegistryImplementor>
private final ConcurrentMap<Class<T>, Service>
private static final CoreMessageLogger
private volatile ServiceRegistryImplementor
private final ConcurrentMap<Class<T>, Class<T>>
private final List<ServiceBinding<R extends Service>>
private final ConcurrentMap<Class<T>, ServiceBinding<R extends Service>>

Constructor Summary

AccessConstructor and Description
protected
protected
AbstractServiceRegistryImpl(boolean autoCloseRegistry)

protected
protected
AbstractServiceRegistryImpl(ServiceRegistryImplementor parent, boolean autoCloseRegistry)

public
public
AbstractServiceRegistryImpl(BootstrapServiceRegistry bootstrapServiceRegistry, boolean autoCloseRegistry)

Method Summary

Modifier and TypeMethod and Description
private <R extends Service> void
applyInjections(R service)

protected <R extends Service> R
createService(ServiceBinding<R> serviceBinding)

protected <R extends Service> void
protected <R extends Service> void
public synchronized void
deRegisterChild(ServiceRegistryImplementor child)

Implements org.hibernate.service.spi.ServiceRegistryImplementor.deRegisterChild.

When a registry is created with a parent, the parent is notified of the child via this callback.
public synchronized void
public ServiceRegistry
public <R extends Service> R
getService(Class<R>
The service role
serviceRole
)

Implements org.hibernate.service.ServiceRegistry.getService.

Retrieve a service by role.
private <R extends Service> R
initializeService(ServiceBinding<R> serviceBinding)

public <R extends Service> void
public boolean
public <R extends Service> ServiceBinding<R>
locateServiceBinding(Class<R>
The service role for which to locate a binding.
serviceRole
)

Implements org.hibernate.service.spi.ServiceRegistryImplementor.locateServiceBinding.

Locate the binding for the given role.
protected <R extends Service> ServiceBinding<R>
locateServiceBinding(Class<R> serviceRole, boolean checkParent)

private <T extends Service> void
processInjection(T service, Method injectionMethod, InjectService injectService)

public synchronized void
private void
registerAlternate(Class<T> alternate, Class<T> target)

public synchronized void
registerChild(ServiceRegistryImplementor child)

Implements org.hibernate.service.spi.ServiceRegistryImplementor.registerChild.

When a registry is created with a parent, the parent is notified of the child via this callback.
protected <R extends Service> void
registerService(ServiceBinding<R> serviceBinding, R service)

public synchronized void
resetParent(BootstrapServiceRegistry newParent)

Very advanced and tricky to handle: not designed for this.

public <R extends Service> void
public synchronized <R extends Service> void
protected void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

activeback to summary
private final AtomicBoolean active
ALLOW_CRAWLINGback to summary
public static final String ALLOW_CRAWLING
allowCrawlingback to summary
private final boolean allowCrawling
autoCloseRegistryback to summary
private boolean autoCloseRegistry
childRegistriesback to summary
private Set<ServiceRegistryImplementor> childRegistries
initializedServiceByRoleback to summary
private final ConcurrentMap<Class<T>, Service> initializedServiceByRole
logback to summary
private static final CoreMessageLogger log
parentback to summary
private volatile ServiceRegistryImplementor parent
roleXrefback to summary
private final ConcurrentMap<Class<T>, Class<T>> roleXref
serviceBindingListback to summary
private final List<ServiceBinding<R extends Service>> serviceBindingList
serviceBindingMapback to summary
private final ConcurrentMap<Class<T>, ServiceBinding<R extends Service>> serviceBindingMap

Constructor Detail

AbstractServiceRegistryImplback to summary
protected AbstractServiceRegistryImpl()
Annotations
@SuppressWarnings:UnusedDeclaration
AbstractServiceRegistryImplback to summary
protected AbstractServiceRegistryImpl(boolean autoCloseRegistry)
Annotations
@SuppressWarnings:UnusedDeclaration
AbstractServiceRegistryImplback to summary
protected AbstractServiceRegistryImpl(ServiceRegistryImplementor parent)
AbstractServiceRegistryImplback to summary
protected AbstractServiceRegistryImpl(ServiceRegistryImplementor parent, boolean autoCloseRegistry)
AbstractServiceRegistryImplback to summary
public AbstractServiceRegistryImpl(BootstrapServiceRegistry bootstrapServiceRegistry)
AbstractServiceRegistryImplback to summary
public AbstractServiceRegistryImpl(BootstrapServiceRegistry bootstrapServiceRegistry, boolean autoCloseRegistry)

Method Detail

applyInjectionsback to summary
private <R extends Service> void applyInjections(R service)
createServiceback to summary
protected <R extends Service> R createService(ServiceBinding<R> serviceBinding)
Annotations
@SuppressWarnings:unchecked
createServiceBindingback to summary
protected <R extends Service> void createServiceBinding(ServiceInitiator<R> initiator)
Annotations
@SuppressWarnings:unchecked
createServiceBindingback to summary
protected <R extends Service> void createServiceBinding(ProvidedService<R> providedService)
deRegisterChildback to summary
public synchronized void deRegisterChild(ServiceRegistryImplementor child)

Implements org.hibernate.service.spi.ServiceRegistryImplementor.deRegisterChild.

Doc from org.hibernate.service.spi.ServiceRegistryImplementor.deRegisterChild.

When a registry is created with a parent, the parent is notified of the child via this callback.

Annotations
@Override
destroyback to summary
public synchronized void destroy()

Implements org.hibernate.service.spi.ServiceRegistryImplementor.destroy.

Doc from org.hibernate.service.spi.ServiceRegistryImplementor.destroy.

Release resources

Annotations
@Override
@SuppressWarnings:unchecked
getParentServiceRegistryback to summary
public ServiceRegistry getParentServiceRegistry()

Implements org.hibernate.service.ServiceRegistry.getParentServiceRegistry.

Doc from org.hibernate.service.ServiceRegistry.getParentServiceRegistry.

Retrieve this registry's parent registry.

Returns:ServiceRegistry

The parent registry. May be null.

Annotations
@Override
@SuppressWarnings:unchecked
getServiceback to summary
public <R extends Service> R getService(Class<R> serviceRole)

Implements org.hibernate.service.ServiceRegistry.getService.

Doc from org.hibernate.service.ServiceRegistry.getService.

Retrieve a service by role. If service is not found, but a org.hibernate.service.spi.ServiceInitiator is registered for this service role, the service will be initialized and returned.

Note

We cannot return <R extends Service<T>> here because the service might come from the parent...

Parameters
<R>
The service role type
serviceRole:Class<R>

The service role

Returns:R

The requested service or null if the service was not found.

Annotations
@Override
initializeServiceback to summary
private <R extends Service> R initializeService(ServiceBinding<R> serviceBinding)
injectDependenciesback to summary
public <R extends Service> void injectDependencies(ServiceBinding<R> serviceBinding)

Implements org.hibernate.service.spi.ServiceBinding.ServiceLifecycleOwner.injectDependencies.

Annotations
@Override
isActiveback to summary
public boolean isActive()
locateServiceBindingback to summary
public <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole)

Implements org.hibernate.service.spi.ServiceRegistryImplementor.locateServiceBinding.

Doc from org.hibernate.service.spi.ServiceRegistryImplementor.locateServiceBinding.

Locate the binding for the given role. Should, generally speaking, look into parent registry if one.

Parameters
<R>
generic return type.
serviceRole:Class<R>

The service role for which to locate a binding.

Returns:ServiceBinding<R>

The located binding; may be null

Annotations
@Override
@SuppressWarnings:unchecked
locateServiceBindingback to summary
protected <R extends Service> ServiceBinding<R> locateServiceBinding(Class<R> serviceRole, boolean checkParent)
Annotations
@SuppressWarnings:unchecked
processInjectionback to summary
private <T extends Service> void processInjection(T service, Method injectionMethod, InjectService injectService)
Annotations
@SuppressWarnings:unchecked
reactivateback to summary
public synchronized void reactivate()
registerAlternateback to summary
private void registerAlternate(Class<T> alternate, Class<T> target)
registerChildback to summary
public synchronized void registerChild(ServiceRegistryImplementor child)

Implements org.hibernate.service.spi.ServiceRegistryImplementor.registerChild.

Doc from org.hibernate.service.spi.ServiceRegistryImplementor.registerChild.

When a registry is created with a parent, the parent is notified of the child via this callback.

Annotations
@Override
registerServiceback to summary
protected <R extends Service> void registerService(ServiceBinding<R> serviceBinding, R service)
resetParentback to summary
public synchronized void resetParent(BootstrapServiceRegistry newParent)

Very advanced and tricky to handle: not designed for this. Intended for experiments only!

startServiceback to summary
public <R extends Service> void startService(ServiceBinding<R> serviceBinding)

Implements org.hibernate.service.spi.ServiceBinding.ServiceLifecycleOwner.startService.

Annotations
@Override
@SuppressWarnings:unchecked
stopServiceback to summary
public synchronized <R extends Service> void stopService(ServiceBinding<R> binding)

Implements org.hibernate.service.spi.ServiceBinding.ServiceLifecycleOwner.stopService.

Annotations
@Override
visitServiceBindingsback to summary
protected void visitServiceBindings(Consumer<ServiceBinding<R extends Service>> action)