Package org.hibernate.boot.registry
Class BootstrapServiceRegistryBuilder
- java.lang.Object
-
- org.hibernate.boot.registry.BootstrapServiceRegistryBuilder
-
public class BootstrapServiceRegistryBuilder extends Object
Builder forBootstrapServiceRegistryinstances.An instance of this class may be obtained simply by instantiation. Then a new
BootstrapServiceRegistrymay be obtained by callingbuild(). It should be later destroyed by callingdestroy(ServiceRegistry). Alternatively, auto-close may be enabled.Provides a registry of services needed for most operations. Manages a
ClassLoaderService, a set ofIntegrators, and aStrategySelectorBuilderresponsible for creation and management ofStrategySelectors.- See Also:
StandardServiceRegistryBuilder
-
-
Constructor Summary
Constructors Constructor Description BootstrapServiceRegistryBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BootstrapServiceRegistryBuilderapplyClassLoader(ClassLoader classLoader)Adds a providedClassLoaderfor use in classloading and resource lookup.BootstrapServiceRegistryBuilderapplyClassLoaderService(ClassLoaderService classLoaderService)Adds a providedClassLoaderServicefor use in classloading and resource lookup.BootstrapServiceRegistryBuilderapplyIntegrator(Integrator integrator)Add anIntegratorto be applied to the bootstrap registry.<T> BootstrapServiceRegistryBuilderapplyStrategySelector(Class<T> strategy, String name, Class<? extends T> implementation)Applies a named strategy implementation to the bootstrap registry.BootstrapServiceRegistryBuilderapplyStrategySelectors(StrategyRegistrationProvider strategyRegistrationProvider)Applies one or more strategy selectors announced as available by the passed announcer.voidapplyTcclLookupPrecedence(TcclLookupPrecedence precedence)Defines when the lookup in the thread contextClassLoaderis done.BootstrapServiceRegistrybuild()Build the bootstrap registry.static voiddestroy(ServiceRegistry serviceRegistry)Destroy a service registry.BootstrapServiceRegistryBuilderdisableAutoClose()By default, when aServiceRegistryis no longer referenced by any other registries as a parent it will be closed.BootstrapServiceRegistryBuilderenableAutoClose()See the discussion ondisableAutoClose().
-
-
-
Method Detail
-
applyIntegrator
public BootstrapServiceRegistryBuilder applyIntegrator(Integrator integrator)
Add anIntegratorto be applied to the bootstrap registry.- Parameters:
integrator- The integrator to add.- Returns:
this, for method chaining
-
applyClassLoader
public BootstrapServiceRegistryBuilder applyClassLoader(ClassLoader classLoader)
Adds a providedClassLoaderfor use in classloading and resource lookup.- Parameters:
classLoader- The class loader to use- Returns:
this, for method chaining
-
applyTcclLookupPrecedence
public void applyTcclLookupPrecedence(TcclLookupPrecedence precedence)
Defines when the lookup in the thread contextClassLoaderis done.- Parameters:
precedence- The lookup precedence
-
applyClassLoaderService
public BootstrapServiceRegistryBuilder applyClassLoaderService(ClassLoaderService classLoaderService)
Adds a providedClassLoaderServicefor use in classloading and resource lookup.- Parameters:
classLoaderService- The class loader service to use- Returns:
this, for method chaining
-
applyStrategySelector
public <T> BootstrapServiceRegistryBuilder applyStrategySelector(Class<T> strategy, String name, Class<? extends T> implementation)
Applies a named strategy implementation to the bootstrap registry.- Type Parameters:
T- Defines the strategy type and makes sure that the strategy and implementation are of compatible types.- Parameters:
strategy- The strategyname- The registered nameimplementation- The strategy implementation Class- Returns:
this, for method chaining- See Also:
StrategySelector.registerStrategyImplementor(Class, String, Class)
-
applyStrategySelectors
public BootstrapServiceRegistryBuilder applyStrategySelectors(StrategyRegistrationProvider strategyRegistrationProvider)
Applies one or more strategy selectors announced as available by the passed announcer.- Parameters:
strategyRegistrationProvider- A provider for one or more available selectors- Returns:
this, for method chaining- See Also:
StrategySelector.registerStrategyImplementor(Class, String, Class)
-
disableAutoClose
public BootstrapServiceRegistryBuilder disableAutoClose()
By default, when aServiceRegistryis no longer referenced by any other registries as a parent it will be closed.Some applications that explicitly build "shared registries" may want to circumvent that behavior.
This method indicates that the registry being built should not be automatically closed. The caller agrees to take responsibility to close it themselves.
- Returns:
- this, for method chaining
-
enableAutoClose
public BootstrapServiceRegistryBuilder enableAutoClose()
See the discussion ondisableAutoClose(). This method enables the auto-closing.- Returns:
- this, for method chaining
-
build
public BootstrapServiceRegistry build()
Build the bootstrap registry.- Returns:
- The built bootstrap registry
-
destroy
public static void destroy(ServiceRegistry serviceRegistry)
Destroy a service registry. Clients should only destroy registries they have created.- Parameters:
serviceRegistry- The registry to be closed.
-
-