Package org.hibernate.service.internal
Class AbstractServiceRegistryImpl
- java.lang.Object
-
- org.hibernate.service.internal.AbstractServiceRegistryImpl
-
- All Implemented Interfaces:
AutoCloseable
,ServiceRegistry
,ServiceBinding.ServiceLifecycleOwner
,ServiceRegistryImplementor
- Direct Known Subclasses:
SessionFactoryServiceRegistryImpl
,StandardServiceRegistryImpl
public abstract class AbstractServiceRegistryImpl extends Object implements ServiceRegistryImplementor, ServiceBinding.ServiceLifecycleOwner
Basic implementation of theServiceRegistry
andServiceRegistryImplementor
contracts.
-
-
Field Summary
Fields Modifier and Type Field Description static String
ALLOW_CRAWLING
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractServiceRegistryImpl(@Nullable ServiceRegistryImplementor parent)
protected
AbstractServiceRegistryImpl(@Nullable ServiceRegistryImplementor parent, boolean autoCloseRegistry)
AbstractServiceRegistryImpl(BootstrapServiceRegistry bootstrapServiceRegistry)
AbstractServiceRegistryImpl(BootstrapServiceRegistry bootstrapServiceRegistry, boolean autoCloseRegistry)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <R extends Service>
@Nullable RcreateService(ServiceBinding<R> serviceBinding)
protected <R extends Service>
voidcreateServiceBinding(ProvidedService<R> providedService)
protected <R extends Service>
voidcreateServiceBinding(ServiceInitiator<R> initiator)
void
deRegisterChild(ServiceRegistryImplementor child)
When a registry is created with a parent, the parent is notified of the child via this callback.void
destroy()
Release resources<T extends Service>
@Nullable TfromRegistryOrChildren(Class<T> serviceRole)
static <T extends Service>
@Nullable TfromRegistryOrChildren(Class<T> serviceRole, ServiceRegistryImplementor serviceRegistry, @Nullable Set<ServiceRegistryImplementor> childRegistries)
@Nullable ServiceRegistry
getParentServiceRegistry()
Retrieve this registry's parent registry.<R extends Service>
@Nullable RgetService(Class<R> serviceRole)
Retrieve a service by role, returning null if there is no such service.protected void
initialize()
<R extends Service>
voidinjectDependencies(ServiceBinding<R> serviceBinding)
boolean
isActive()
<R extends Service>
@Nullable ServiceBinding<R>locateServiceBinding(Class<R> serviceRole)
Locate the binding for the given role.protected <R extends Service>
@Nullable ServiceBinding<R>locateServiceBinding(Class<R> serviceRole, boolean checkParent)
void
reactivate()
Not intended for general use.void
registerChild(ServiceRegistryImplementor child)
When a registry is created with a parent, the parent is notified of the child via this callback.protected <R extends Service>
voidregisterService(ServiceBinding<R> serviceBinding, R service)
void
resetParent(@Nullable BootstrapServiceRegistry newParent)
Not intended for general use.<R extends Service>
voidstartService(ServiceBinding<R> serviceBinding)
<R extends Service>
voidstopService(ServiceBinding<R> binding)
protected void
visitServiceBindings(Consumer<ServiceBinding<?>> action)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.service.spi.ServiceBinding.ServiceLifecycleOwner
configureService, initiateService
-
Methods inherited from interface org.hibernate.service.ServiceRegistry
requireService
-
Methods inherited from interface org.hibernate.service.spi.ServiceRegistryImplementor
close
-
-
-
-
Field Detail
-
ALLOW_CRAWLING
public static final String ALLOW_CRAWLING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractServiceRegistryImpl
protected AbstractServiceRegistryImpl(@Nullable ServiceRegistryImplementor parent)
-
AbstractServiceRegistryImpl
protected AbstractServiceRegistryImpl(@Nullable ServiceRegistryImplementor parent, boolean autoCloseRegistry)
-
AbstractServiceRegistryImpl
public AbstractServiceRegistryImpl(BootstrapServiceRegistry bootstrapServiceRegistry)
-
AbstractServiceRegistryImpl
public AbstractServiceRegistryImpl(BootstrapServiceRegistry bootstrapServiceRegistry, boolean autoCloseRegistry)
-
-
Method Detail
-
initialize
protected void initialize()
-
createServiceBinding
protected <R extends Service> void createServiceBinding(ServiceInitiator<R> initiator)
-
createServiceBinding
protected <R extends Service> void createServiceBinding(ProvidedService<R> providedService)
-
visitServiceBindings
protected void visitServiceBindings(Consumer<ServiceBinding<?>> action)
-
getParentServiceRegistry
public @Nullable ServiceRegistry getParentServiceRegistry()
Description copied from interface:ServiceRegistry
Retrieve this registry's parent registry.- Specified by:
getParentServiceRegistry
in interfaceServiceRegistry
- Returns:
- The parent registry. May be null.
-
locateServiceBinding
public <R extends Service> @Nullable ServiceBinding<R> locateServiceBinding(Class<R> serviceRole)
Description copied from interface:ServiceRegistryImplementor
Locate the binding for the given role. Should, generally speaking, look into parent registry if one.- Specified by:
locateServiceBinding
in interfaceServiceRegistryImplementor
- Type Parameters:
R
- generic return type.- Parameters:
serviceRole
- The service role for which to locate a binding.- Returns:
- The located binding; may be
null
-
locateServiceBinding
protected <R extends Service> @Nullable ServiceBinding<R> locateServiceBinding(Class<R> serviceRole, boolean checkParent)
-
getService
public <R extends Service> @Nullable R getService(Class<R> serviceRole)
Description copied from interface:ServiceRegistry
Retrieve a service by role, returning null if there is no such service. If service is not found, but aServiceInitiator
is registered for this service role, the service will be initialized and returned. Most of the time, use ofServiceRegistry.requireService(Class)
is preferred, being much less likely to cause aNullPointerException
in the client.- Specified by:
getService
in interfaceServiceRegistry
- Type Parameters:
R
- The service role type- Parameters:
serviceRole
- The service role- Returns:
- The requested service or null if the service was not found.
-
registerService
protected <R extends Service> void registerService(ServiceBinding<R> serviceBinding, R service)
-
createService
protected <R extends Service> @Nullable R createService(ServiceBinding<R> serviceBinding)
-
injectDependencies
public <R extends Service> void injectDependencies(ServiceBinding<R> serviceBinding)
- Specified by:
injectDependencies
in interfaceServiceBinding.ServiceLifecycleOwner
-
startService
public <R extends Service> void startService(ServiceBinding<R> serviceBinding)
- Specified by:
startService
in interfaceServiceBinding.ServiceLifecycleOwner
-
isActive
public boolean isActive()
-
destroy
public void destroy()
Description copied from interface:ServiceRegistryImplementor
Release resources- Specified by:
destroy
in interfaceServiceRegistryImplementor
-
stopService
public <R extends Service> void stopService(ServiceBinding<R> binding)
- Specified by:
stopService
in interfaceServiceBinding.ServiceLifecycleOwner
-
registerChild
public void registerChild(ServiceRegistryImplementor child)
Description copied from interface:ServiceRegistryImplementor
When a registry is created with a parent, the parent is notified of the child via this callback.- Specified by:
registerChild
in interfaceServiceRegistryImplementor
-
deRegisterChild
public void deRegisterChild(ServiceRegistryImplementor child)
Description copied from interface:ServiceRegistryImplementor
When a registry is created with a parent, the parent is notified of the child via this callback.- Specified by:
deRegisterChild
in interfaceServiceRegistryImplementor
-
resetParent
public 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.
-
fromRegistryOrChildren
public <T extends Service> @Nullable T fromRegistryOrChildren(Class<T> serviceRole)
- Specified by:
fromRegistryOrChildren
in interfaceServiceRegistryImplementor
-
fromRegistryOrChildren
public static <T extends Service> @Nullable T fromRegistryOrChildren(Class<T> serviceRole, ServiceRegistryImplementor serviceRegistry, @Nullable Set<ServiceRegistryImplementor> childRegistries)
-
reactivate
public 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.
-
-