org.hibernate.service.ServiceRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of beangle-hibernate-core Show documentation
Show all versions of beangle-hibernate-core Show documentation
Hibernate Orm Core Shade,Support Scala Collection
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.service;
/**
* A registry of {@linkplain Service services}. This interface abstracts
* the operations of:
*
* - {@linkplain org.hibernate.boot.registry.BootstrapServiceRegistry
* bootstrap service registries}, which may be obtained from a
* {@link org.hibernate.boot.registry.BootstrapServiceRegistryBuilder},
* and
*
- {@linkplain org.hibernate.boot.registry.StandardServiceRegistry
* standard service registries}, which may be obtained from a
* {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder}.
*
*
* @author Steve Ebersole
*/
public interface ServiceRegistry extends AutoCloseable {
/**
* Retrieve this registry's parent registry.
*
* @return The parent registry. May be null.
*/
ServiceRegistry getParentServiceRegistry();
/**
* Retrieve a service by role. If service is not found, but a {@link org.hibernate.service.spi.ServiceInitiator} is
* registered for this service role, the service will be initialized and returned.
*
* @apiNote We cannot return {@code >} here because the service might come from the parent.
*
* @param serviceRole The service role
* @param The service role type
*
* @return The requested service or null if the service was not found.
*
* @throws UnknownServiceException Indicates the service was not known.
*/
R getService(Class serviceRole);
/**
* Retrieve a service by role. If service is not found, but a {@link org.hibernate.service.spi.ServiceInitiator} is
* registered for this service role, the service will be initialized and returned.
*
* @apiNote We cannot return {@code >} here because the service might come from the parent.
*
* @param serviceRole The service role
* @param The service role type
*
* @return The requested service .
*
* @throws UnknownServiceException Indicates the service was not known.
* @throws NullServiceException Indicates the service was null.
*/
default R requireService(Class serviceRole) {
final R service = getService( serviceRole );
if ( service == null ) {
throw new NullServiceException( serviceRole );
}
return service;
}
@Override
void close();
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy