Class StandardServiceRegistryBuilder
- java.lang.Object
-
- org.hibernate.boot.registry.StandardServiceRegistryBuilder
-
public class StandardServiceRegistryBuilder extends Object
Builder for standardServiceRegistryinstances.Configuration properties are enumerated by
AvailableSettings.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_CFG_RESOURCE_NAMEThe default resource name for a Hibernate configuration XML file.
-
Constructor Summary
Constructors Modifier Constructor Description StandardServiceRegistryBuilder()Create a default builder.StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry)Create a builder with the specified bootstrap services.protectedStandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, Map<String,Object> settings, ConfigLoader loader, LoadedConfig loadedConfig, List<StandardServiceInitiator<?>> initiators)Intended for use exclusively from Quarkus bootstrapping, or extensions of this class which need to override the standard ServiceInitiator list.protectedStandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, Map<String,Object> settings, LoadedConfig loadedConfig)Intended for use exclusively from JPA bootstrapping, or extensions of this class.StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, LoadedConfig loadedConfigBaseline)Create a builder with the specified bootstrap services.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StandardServiceRegistryBuilderaddInitiator(StandardServiceInitiator<?> initiator)Adds a service initiator.<T extends Service>
StandardServiceRegistryBuilderaddService(Class<T> serviceRole, T service)Adds a user-provided service.StandardServiceRegistryBuilderapplySetting(String settingName, Object value)Apply a setting value.StandardServiceRegistryBuilderapplySettings(Map<String,Object> settings)Apply a group of settings.StandardServiceRegistryBuilderapplySettings(Properties settings)Apply a group of settings.StandardServiceRegistrybuild()Build and return theStandardServiceRegistry.voidclearSettings()Discard all the settings applied so far.StandardServiceRegistryBuilderconfigure()Read setting information from an XML file using the standard resource location.StandardServiceRegistryBuilderconfigure(File configurationFile)StandardServiceRegistryBuilderconfigure(String resourceName)Read setting information from an XML file using the named resource location.StandardServiceRegistryBuilderconfigure(URL url)StandardServiceRegistryBuilderconfigure(LoadedConfig loadedConfig)static voiddestroy(ServiceRegistry serviceRegistry)Destroy a service registry.StandardServiceRegistryBuilderdisableAutoClose()By default, when aServiceRegistryis no longer referenced by any other registries as a parent it will be closed.StandardServiceRegistryBuilderenableAutoClose()Enablesauto-closing.static StandardServiceRegistryBuilderforJpa(BootstrapServiceRegistry bootstrapServiceRegistry)Creates aStandardServiceRegistryBuilderspecific to the needs of bootstrapping JPA.LoadedConfiggetAggregatedCfgXml()Intended for internal testing use only!!BootstrapServiceRegistrygetBootstrapServiceRegistry()ConfigLoadergetConfigLoader()Map<String,Object>getSettings()Obtain the current aggregated settings.StandardServiceRegistryBuilderloadProperties(File file)Read settings from aPropertiesfile by File referenceStandardServiceRegistryBuilderloadProperties(String resourceName)Read settings from aPropertiesfile by resource name.
-
-
-
Field Detail
-
DEFAULT_CFG_RESOURCE_NAME
public static final String DEFAULT_CFG_RESOURCE_NAME
The default resource name for a Hibernate configuration XML file.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StandardServiceRegistryBuilder
public StandardServiceRegistryBuilder()
Create a default builder.
-
StandardServiceRegistryBuilder
public StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry)
Create a builder with the specified bootstrap services.- Parameters:
bootstrapServiceRegistry- Provided bootstrap registry to use.
-
StandardServiceRegistryBuilder
protected StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, Map<String,Object> settings, LoadedConfig loadedConfig)
Intended for use exclusively from JPA bootstrapping, or extensions of this class. Consider this an SPI.
-
StandardServiceRegistryBuilder
protected StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, Map<String,Object> settings, ConfigLoader loader, LoadedConfig loadedConfig, List<StandardServiceInitiator<?>> initiators)
Intended for use exclusively from Quarkus bootstrapping, or extensions of this class which need to override the standard ServiceInitiator list. Consider this an SPI.
-
StandardServiceRegistryBuilder
public StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, LoadedConfig loadedConfigBaseline)
Create a builder with the specified bootstrap services.- Parameters:
bootstrapServiceRegistry- Provided bootstrap registry to use.
-
-
Method Detail
-
forJpa
public static StandardServiceRegistryBuilder forJpa(BootstrapServiceRegistry bootstrapServiceRegistry)
Creates aStandardServiceRegistryBuilderspecific to the needs of bootstrapping JPA.Intended only for use from
EntityManagerFactoryBuilderImpl.In particular, we ignore properties found in
cfg.xmlfiles.EntityManagerFactoryBuilderImplcollects these properties later.- See Also:
EntityManagerFactoryBuilderImpl
-
getConfigLoader
public ConfigLoader getConfigLoader()
-
getAggregatedCfgXml
public LoadedConfig getAggregatedCfgXml()
Intended for internal testing use only!!
-
getBootstrapServiceRegistry
public BootstrapServiceRegistry getBootstrapServiceRegistry()
-
loadProperties
public StandardServiceRegistryBuilder loadProperties(String resourceName)
Read settings from aPropertiesfile by resource name.Differs from
configure()andconfigure(String)in that here we expect to read a properties file, while forconfigure()we read the configuration from XML.- Parameters:
resourceName- The name by which to perform a resource look up for the properties file- Returns:
- this, for method chaining
- See Also:
configure(),configure(String)
-
loadProperties
public StandardServiceRegistryBuilder loadProperties(File file)
Read settings from aPropertiesfile by File referenceDiffers from
configure()andconfigure(String)in that here we expect to read a properties file, while forconfigure()we read the configuration from XML.- Parameters:
file- The properties File reference- Returns:
- this, for method chaining
- See Also:
configure(),configure(String)
-
configure
public StandardServiceRegistryBuilder configure()
Read setting information from an XML file using the standard resource location.- Returns:
- this, for method chaining
- See Also:
DEFAULT_CFG_RESOURCE_NAME,configure(String),loadProperties(String)
-
configure
public StandardServiceRegistryBuilder configure(String resourceName)
Read setting information from an XML file using the named resource location.- Parameters:
resourceName- The named resource- Returns:
- this, for method chaining
-
configure
public StandardServiceRegistryBuilder configure(File configurationFile)
-
configure
public StandardServiceRegistryBuilder configure(URL url)
-
configure
public StandardServiceRegistryBuilder configure(LoadedConfig loadedConfig)
-
applySetting
public StandardServiceRegistryBuilder applySetting(String settingName, Object value)
Apply a setting value.- Parameters:
settingName- The name of the settingvalue- The value to use.- Returns:
- this, for method chaining
-
applySettings
public StandardServiceRegistryBuilder applySettings(Map<String,Object> settings)
Apply a group of settings.- Parameters:
settings- The incoming settings to apply- Returns:
- this, for method chaining
-
applySettings
public StandardServiceRegistryBuilder applySettings(Properties settings)
Apply a group of settings.- Parameters:
settings- The incoming settings to apply- Returns:
- this, for method chaining
-
clearSettings
public void clearSettings()
Discard all the settings applied so far.
-
addInitiator
public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator<?> initiator)
Adds a service initiator.- Parameters:
initiator- The initiator to be added- Returns:
- this, for method chaining
-
addService
public <T extends Service> StandardServiceRegistryBuilder addService(Class<T> serviceRole, T service)
Adds a user-provided service.- Parameters:
serviceRole- The role of the service being addedservice- The service implementation- Returns:
- this, for method chaining
-
disableAutoClose
public StandardServiceRegistryBuilder 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 need to circumvent that behavior.This method indicates that the registry being built should not be automatically closed. The caller takes responsibility for closing it.
- Returns:
- this, for method chaining
-
enableAutoClose
public StandardServiceRegistryBuilder enableAutoClose()
Enablesauto-closing.- Returns:
- this, for method chaining
-
build
public StandardServiceRegistry build()
Build and return theStandardServiceRegistry.- Returns:
- A newly-instantiated
StandardServiceRegistry
-
getSettings
@Internal public Map<String,Object> getSettings()
Obtain the current aggregated settings.
-
destroy
public static void destroy(ServiceRegistry serviceRegistry)
Destroy a service registry.Applications should only destroy registries they have explicitly created.
- Parameters:
serviceRegistry- The registry to be closed.
-
-