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 the
ServiceRegistry and ServiceRegistryImplementor contracts.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionAbstractServiceRegistryImpl(BootstrapServiceRegistry bootstrapServiceRegistry) AbstractServiceRegistryImpl(BootstrapServiceRegistry bootstrapServiceRegistry, boolean autoCloseRegistry) protectedAbstractServiceRegistryImpl(@Nullable ServiceRegistryImplementor parent) protectedAbstractServiceRegistryImpl(@Nullable ServiceRegistryImplementor parent, boolean autoCloseRegistry) -
Method Summary
Modifier and TypeMethodDescriptionprotected <R extends Service>
@Nullable RcreateService(ServiceBinding<R> serviceBinding) protected <R extends Service>
voidcreateServiceBinding(ProvidedService<R> providedService) protected <R extends Service>
voidcreateServiceBinding(ServiceInitiator<R> initiator) voidWhen a registry is created with a parent, the parent is notified of the child via this callback.voiddestroy()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 ServiceRegistryRetrieve 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<R extends Service>
voidinjectDependencies(ServiceBinding<R> serviceBinding) booleanisActive()<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) voidNot intended for general use.voidWhen 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) voidresetParent(@Nullable BootstrapServiceRegistry newParent) Not intended for general use.<R extends Service>
voidstartService(ServiceBinding<R> serviceBinding) <R extends Service>
voidstopService(ServiceBinding<R> binding) protected voidvisitServiceBindings(Consumer<ServiceBinding<?>> action) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.service.spi.ServiceBinding.ServiceLifecycleOwner
configureService, initiateServiceMethods inherited from interface org.hibernate.service.ServiceRegistry
requireServiceMethods inherited from interface org.hibernate.service.spi.ServiceRegistryImplementor
close
-
Field Details
-
ALLOW_CRAWLING
- See Also:
-
-
Constructor Details
-
AbstractServiceRegistryImpl
-
AbstractServiceRegistryImpl
protected AbstractServiceRegistryImpl(@Nullable ServiceRegistryImplementor parent, boolean autoCloseRegistry) -
AbstractServiceRegistryImpl
-
AbstractServiceRegistryImpl
public AbstractServiceRegistryImpl(BootstrapServiceRegistry bootstrapServiceRegistry, boolean autoCloseRegistry)
-
-
Method Details
-
initialize
protected void initialize() -
createServiceBinding
-
createServiceBinding
-
visitServiceBindings
-
getParentServiceRegistry
Description copied from interface:ServiceRegistryRetrieve this registry's parent registry.- Specified by:
getParentServiceRegistryin interfaceServiceRegistry- Returns:
- The parent registry. May be null.
-
locateServiceBinding
Description copied from interface:ServiceRegistryImplementorLocate the binding for the given role. Should, generally speaking, look into parent registry if one.- Specified by:
locateServiceBindingin 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
Description copied from interface:ServiceRegistryRetrieve a service by role, returning null if there is no such service. If service is not found, but aServiceInitiatoris 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 aNullPointerExceptionin the client.- Specified by:
getServicein 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
-
createService
-
injectDependencies
- Specified by:
injectDependenciesin interfaceServiceBinding.ServiceLifecycleOwner
-
startService
- Specified by:
startServicein interfaceServiceBinding.ServiceLifecycleOwner
-
isActive
public boolean isActive() -
destroy
public void destroy()Description copied from interface:ServiceRegistryImplementorRelease resources- Specified by:
destroyin interfaceServiceRegistryImplementor
-
stopService
- Specified by:
stopServicein interfaceServiceBinding.ServiceLifecycleOwner
-
registerChild
Description copied from interface:ServiceRegistryImplementorWhen a registry is created with a parent, the parent is notified of the child via this callback.- Specified by:
registerChildin interfaceServiceRegistryImplementor
-
deRegisterChild
Description copied from interface:ServiceRegistryImplementorWhen a registry is created with a parent, the parent is notified of the child via this callback.- Specified by:
deRegisterChildin interfaceServiceRegistryImplementor
-
resetParent
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
- Specified by:
fromRegistryOrChildrenin interfaceServiceRegistryImplementor
-
fromRegistryOrChildren
public static <T extends Service> @Nullable T fromRegistryOrChildren(Class<T> serviceRole, ServiceRegistryImplementor serviceRegistry, @Nullable Set<ServiceRegistryImplementor> childRegistries) -
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.
-