Class StandardServiceRegistryBuilder
- java.lang.Object
-
- org.hibernate.boot.registry.StandardServiceRegistryBuilder
-
public class StandardServiceRegistryBuilder extends Object
Builder for standardServiceRegistry
instances.Configuration properties are enumerated by
AvailableSettings
.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_CFG_RESOURCE_NAME
The 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.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.protected
StandardServiceRegistryBuilder(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 StandardServiceRegistryBuilder
addInitiator(StandardServiceInitiator<?> initiator)
Adds a service initiator.<T extends Service>
StandardServiceRegistryBuilderaddService(Class<T> serviceRole, T service)
Adds a user-provided service.StandardServiceRegistryBuilder
applySetting(String settingName, Object value)
Apply a setting value.StandardServiceRegistryBuilder
applySettings(Map<String,Object> settings)
Apply a group of settings.StandardServiceRegistryBuilder
applySettings(Properties settings)
Apply a group of settings.StandardServiceRegistry
build()
Build and return theStandardServiceRegistry
.void
clearSettings()
Discard all the settings applied so far.StandardServiceRegistryBuilder
configure()
Read setting information from an XML file using the standard resource location.StandardServiceRegistryBuilder
configure(File configurationFile)
StandardServiceRegistryBuilder
configure(String resourceName)
Read setting information from an XML file using the named resource location.StandardServiceRegistryBuilder
configure(URL url)
StandardServiceRegistryBuilder
configure(LoadedConfig loadedConfig)
static void
destroy(ServiceRegistry serviceRegistry)
Destroy a service registry.StandardServiceRegistryBuilder
disableAutoClose()
By default, when aServiceRegistry
is no longer referenced by any other registries as a parent it will be closed.StandardServiceRegistryBuilder
enableAutoClose()
Enablesauto-closing
.static StandardServiceRegistryBuilder
forJpa(BootstrapServiceRegistry bootstrapServiceRegistry)
Creates aStandardServiceRegistryBuilder
specific to the needs of bootstrapping JPA.LoadedConfig
getAggregatedCfgXml()
Intended for internal testing use only!!BootstrapServiceRegistry
getBootstrapServiceRegistry()
ConfigLoader
getConfigLoader()
Map<String,Object>
getSettings()
Obtain the current aggregated settings.StandardServiceRegistryBuilder
loadProperties(File file)
Read settings from aProperties
file by File referenceStandardServiceRegistryBuilder
loadProperties(String resourceName)
Read settings from aProperties
file 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 aStandardServiceRegistryBuilder
specific to the needs of bootstrapping JPA.Intended only for use from
EntityManagerFactoryBuilderImpl
.In particular, we ignore properties found in
cfg.xml
files.EntityManagerFactoryBuilderImpl
collects 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 aProperties
file 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 aProperties
file 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 aServiceRegistry
is 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.
-
-