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: 5.6.15.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;

/**
 * A registry of {@link Service services}.
 *
 * @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.
	 * 

* NOTE: 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. *

* NOTE: 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