All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.service.ServiceRegistry Maven / Gradle / Ivy

There is a newer version: 6.6.2.Final
Show newest version
/*
 * 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;

import org.checkerframework.checker.nullness.qual.Nullable;

/**
 * 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. */ @Nullable 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. */ @Nullable 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