Class BootstrapServiceRegistryBuilder

java.lang.Object
org.hibernate.boot.registry.BootstrapServiceRegistryBuilder

public class BootstrapServiceRegistryBuilder extends Object
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 Integrators, and a StrategySelectorBuilder responsible for creation and management of StrategySelectors.

See Also:
  • Constructor Details

    • BootstrapServiceRegistryBuilder

      public BootstrapServiceRegistryBuilder()
  • Method Details

    • applyIntegrator

      public BootstrapServiceRegistryBuilder applyIntegrator(Integrator integrator)
      Add an Integrator to 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 provided ClassLoader for 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 context ClassLoader is done.
      Parameters:
      precedence - The lookup precedence
    • applyClassLoaderService

      public BootstrapServiceRegistryBuilder applyClassLoaderService(ClassLoaderService classLoaderService)
      Adds a provided ClassLoaderService 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 strategy
      name - The registered name
      implementation - 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

      public BootstrapServiceRegistryBuilder disableAutoClose()
      By default, when a ServiceRegistry 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

      public BootstrapServiceRegistryBuilder enableAutoClose()
      See the discussion on disableAutoClose(). 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.