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.service.Service, .ServiceRegistry, .UnknownServiceException, org.hibernate.service.spi.InjectService, .ServiceBinding, .ServiceException, .ServiceInitiator, .ServiceRegistryAwareService, .ServiceRegistryImplementor, .Startable, .Stoppable, org.checkerframework.checker.nullness.qual.Nullable

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 final boolean
private Set<ServiceRegistryImplementor>
private final ConcurrentMap<Class<?>, Service>
private static final CoreMessageLogger
private volatile @Nullable ServiceRegistryImplementor
private final ConcurrentMap<Class<?>, Class<?>>
private final List<ServiceBinding<?>>
private final ConcurrentMap<Class<?>, ServiceBinding<?>>

Constructor Summary

AccessConstructor and Description
protected
protected
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> @Nullable 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 <T extends Service> @Nullable T
public static <T extends Service> @Nullable T
public @Nullable ServiceRegistry
public <R extends Service> @Nullable R
getService(Class<R>
The service role
serviceRole
)

Implements org.hibernate.service.ServiceRegistry.getService.

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

public <R extends Service> void
public boolean
public <R extends Service> @Nullable 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> @Nullable ServiceBinding<R>
locateServiceBinding(Class<R> serviceRole, boolean checkParent)

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

public synchronized void
reactivate()

Not intended for general use.

private void
registerAlternate(Class<?> alternate, Class<?> 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(@Nullable BootstrapServiceRegistry newParent)

Not intended for general use.

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 final boolean autoCloseRegistry
childRegistriesback to summary
private Set<ServiceRegistryImplementor> childRegistries
initializedServiceByRoleback to summary
private final ConcurrentMap<Class<?>, Service> initializedServiceByRole
logback to summary
private static final CoreMessageLogger log
parentback to summary
private volatile @Nullable ServiceRegistryImplementor parent
roleXrefback to summary
private final ConcurrentMap<Class<?>, Class<?>> roleXref
serviceBindingListback to summary
private final List<ServiceBinding<?>> serviceBindingList
serviceBindingMapback to summary
private final ConcurrentMap<Class<?>, ServiceBinding<?>> serviceBindingMap

Constructor Detail

AbstractServiceRegistryImplback to summary
protected AbstractServiceRegistryImpl(@Nullable ServiceRegistryImplementor parent)
AbstractServiceRegistryImplback to summary
protected AbstractServiceRegistryImpl(@Nullable 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> @Nullable R createService(ServiceBinding<R> serviceBinding)
createServiceBindingback to summary
protected <R extends Service> void createServiceBinding(ServiceInitiator<R> initiator)
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
fromRegistryOrChildrenback to summary
public <T extends Service> @Nullable T fromRegistryOrChildren(Class<T> serviceRole)

Implements org.hibernate.service.spi.ServiceRegistryImplementor.fromRegistryOrChildren.

Annotations
@Override
fromRegistryOrChildrenback to summary
public static <T extends Service> @Nullable T fromRegistryOrChildren(Class<T> serviceRole, ServiceRegistryImplementor serviceRegistry, @Nullable Set<ServiceRegistryImplementor> childRegistries)
getParentServiceRegistryback to summary
public @Nullable ServiceRegistry getParentServiceRegistry()

Implements org.hibernate.service.ServiceRegistry.getParentServiceRegistry.

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

Retrieve this registry's parent registry.

Returns:@Nullable ServiceRegistry

The parent registry. May be null.

Annotations
@Override
getServiceback to summary
public <R extends Service> @Nullable 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.

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

The service role

Returns:@Nullable R

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

Annotations
@Override
initializeback to summary
protected void initialize()
initializeServiceback to summary
private <R extends Service> @Nullable 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> @Nullable 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:@Nullable ServiceBinding<R>

The located binding; may be null

Annotations
@Override
locateServiceBindingback to summary
protected <R extends Service> @Nullable 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)
reactivateback to summary
public synchronized void reactivate()

Not intended for general use. We need the ability to stop and "reactivate" a registry to allow experimentation with technologies such as GraalVM, Quarkus and Cri-O.

registerAlternateback to summary
private void registerAlternate(Class<?> alternate, Class<?> 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(@Nullable BootstrapServiceRegistry newParent)

Not intended for general use. We need the ability to stop and "reactivate" a registry to allow experimentation with technologies such as GraalVM, Quarkus and Cri-O.

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

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

Annotations
@Override
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<?>> action)