Package org.hibernate.boot.registry
Class BootstrapServiceRegistryBuilder
java.lang.Object
org.hibernate.boot.registry.BootstrapServiceRegistryBuilder
Builder for
BootstrapServiceRegistry
instances.
An instance of this class may be obtained simply by
instantiation. Then a new
BootstrapServiceRegistry
may be obtained by calling build()
.
It should be later destroyed by calling destroy(ServiceRegistry)
.
Alternatively, auto-close may be enabled.
Provides a registry of services needed for most operations.
Manages a ClassLoaderService
, a set of Integrator
s, and a
StrategySelectorBuilder
responsible for creation and management
of StrategySelector
s.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyClassLoader
(ClassLoader classLoader) Adds a providedClassLoader
for use in classloading and resource lookup.applyClassLoaderService
(ClassLoaderService classLoaderService) Adds a providedClassLoaderService
for use in classloading and resource lookup.applyIntegrator
(Integrator integrator) Add anIntegrator
to be applied to the bootstrap registry.applyStrategySelector
(Class<T> strategy, String name, Class<? extends T> implementation) Applies a named strategy implementation to the bootstrap registry.applyStrategySelectors
(StrategyRegistrationProvider strategyRegistrationProvider) Applies one or more strategy selectors announced as available by the passed announcer.void
applyTcclLookupPrecedence
(TcclLookupPrecedence precedence) Defines when the lookup in the thread contextClassLoader
is done.build()
Build the bootstrap registry.static void
destroy
(ServiceRegistry serviceRegistry) Destroy a service registry.By default, when aServiceRegistry
is no longer referenced by any other registries as a parent it will be closed.See the discussion ondisableAutoClose()
.
-
Constructor Details
-
BootstrapServiceRegistryBuilder
public BootstrapServiceRegistryBuilder()
-
-
Method Details
-
applyIntegrator
Add anIntegrator
to be applied to the bootstrap registry.- Parameters:
integrator
- The integrator to add.- Returns:
this
, for method chaining
-
applyClassLoader
Adds a providedClassLoader
for use in classloading and resource lookup.- Parameters:
classLoader
- The class loader to use- Returns:
this
, for method chaining
-
applyTcclLookupPrecedence
Defines when the lookup in the thread contextClassLoader
is done.- Parameters:
precedence
- The lookup precedence
-
applyClassLoaderService
public BootstrapServiceRegistryBuilder applyClassLoaderService(ClassLoaderService classLoaderService) Adds a providedClassLoaderService
for 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:
-
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:
-
disableAutoClose
By default, when aServiceRegistry
is 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
See the discussion ondisableAutoClose()
. This method enables the auto-closing.- Returns:
- this, for method chaining
-
build
Build the bootstrap registry.- Returns:
- The built bootstrap registry
-
destroy
Destroy a service registry. Clients should only destroy registries they have created.- Parameters:
serviceRegistry
- The registry to be closed.
-