Package org.hibernate.boot.registry
Class StandardServiceRegistryBuilder
- java.lang.Object
-
- org.hibernate.boot.registry.StandardServiceRegistryBuilder
-
public class StandardServiceRegistryBuilder extends java.lang.Object
Builder for standardServiceRegistry
instances.- See Also:
StandardServiceRegistryImpl
,BootstrapServiceRegistryBuilder
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.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, java.util.Map settings, org.hibernate.boot.cfgxml.internal.ConfigLoader loader, LoadedConfig loadedConfig, java.util.List<StandardServiceInitiator> initiators)
Intended for use exclusively from Quarkus boot-strapping, or extensions of this class which need to override the standard ServiceInitiator list.protected
StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, java.util.Map settings, LoadedConfig loadedConfig)
Intended for use exclusively from JPA boot-strapping, or extensions of this class.protected
StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, java.util.Map settings, LoadedConfig loadedConfig, java.util.List<StandardServiceInitiator> initiators)
Deprecated.Quarkus will switch to useStandardServiceRegistryBuilder(BootstrapServiceRegistry, Map, ConfigLoader, LoadedConfig, List)
StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, LoadedConfig loadedConfigBaseline)
Create a builder with the specified bootstrap services.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description StandardServiceRegistryBuilder
addInitiator(StandardServiceInitiator initiator)
Adds a service initiator.StandardServiceRegistryBuilder
addService(java.lang.Class serviceRole, Service service)
Adds a user-provided service.StandardServiceRegistryBuilder
applySetting(java.lang.String settingName, java.lang.Object value)
Apply a setting value.StandardServiceRegistryBuilder
applySettings(java.util.Map settings)
Apply a groups of setting values.StandardServiceRegistry
build()
Build the StandardServiceRegistry.void
clearSettings()
StandardServiceRegistryBuilder
configure()
Read setting information from an XML file using the standard resource location.StandardServiceRegistryBuilder
configure(java.io.File configurationFile)
StandardServiceRegistryBuilder
configure(java.lang.String resourceName)
Read setting information from an XML file using the named resource location.StandardServiceRegistryBuilder
configure(java.net.URL url)
StandardServiceRegistryBuilder
configure(LoadedConfig loadedConfig)
static void
destroy(ServiceRegistry serviceRegistry)
Destroy a service registry.StandardServiceRegistryBuilder
disableAutoClose()
By default, when a ServiceRegistry is no longer referenced by any other registries as a parent it will be closed.StandardServiceRegistryBuilder
enableAutoClose()
See the discussion ondisableAutoClose()
.static StandardServiceRegistryBuilder
forJpa(BootstrapServiceRegistry bootstrapServiceRegistry)
Intended only for use fromEntityManagerFactoryBuilderImpl
.LoadedConfig
getAggregatedCfgXml()
Intended for internal testing use only!!BootstrapServiceRegistry
getBootstrapServiceRegistry()
org.hibernate.boot.cfgxml.internal.ConfigLoader
getConfigLoader()
java.util.Map
getSettings()
Deprecated.Temporarily exposed since Configuration is still around and much code still uses Configuration.StandardServiceRegistryBuilder
loadProperties(java.io.File file)
Read settings from aProperties
file by File referenceStandardServiceRegistryBuilder
loadProperties(java.lang.String resourceName)
Read settings from aProperties
file by resource name.
-
-
-
Field Detail
-
DEFAULT_CFG_RESOURCE_NAME
public static final java.lang.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, java.util.Map settings, LoadedConfig loadedConfig)
Intended for use exclusively from JPA boot-strapping, or extensions of this class. Consider this an SPI.
-
StandardServiceRegistryBuilder
@Deprecated protected StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, java.util.Map settings, LoadedConfig loadedConfig, java.util.List<StandardServiceInitiator> initiators)
Deprecated.Quarkus will switch to useStandardServiceRegistryBuilder(BootstrapServiceRegistry, Map, ConfigLoader, LoadedConfig, List)
Intended for use exclusively from Quarkus boot-strapping, or extensions of this class which need to override the standard ServiceInitiator list. Consider this an SPI.
-
StandardServiceRegistryBuilder
protected StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, java.util.Map settings, org.hibernate.boot.cfgxml.internal.ConfigLoader loader, LoadedConfig loadedConfig, java.util.List<StandardServiceInitiator> initiators)
Intended for use exclusively from Quarkus boot-strapping, 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)
Intended only for use fromEntityManagerFactoryBuilderImpl
. Creates a StandardServiceRegistryBuilder specific to the needs of JPA bootstrapping. Specifically we ignore properties found in `cfg.xml` files in terms of adding them to the builder immediately. EntityManagerFactoryBuilderImpl handles collecting these properties itself.
-
getConfigLoader
public org.hibernate.boot.cfgxml.internal.ConfigLoader getConfigLoader()
-
getAggregatedCfgXml
public LoadedConfig getAggregatedCfgXml()
Intended for internal testing use only!!
-
getBootstrapServiceRegistry
public BootstrapServiceRegistry getBootstrapServiceRegistry()
-
loadProperties
public StandardServiceRegistryBuilder loadProperties(java.lang.String resourceName)
Read settings from aProperties
file by resource name.Differs from
configure()
andconfigure(String)
in that here we expect to read aProperties
file while forconfigure()
we read the XML variant.- 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(java.io.File file)
Read settings from aProperties
file by File referenceDiffers from
configure()
andconfigure(String)
in that here we expect to read aProperties
file while forconfigure()
we read the XML variant.- 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(java.lang.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(java.io.File configurationFile)
-
configure
public StandardServiceRegistryBuilder configure(java.net.URL url)
-
configure
public StandardServiceRegistryBuilder configure(LoadedConfig loadedConfig)
-
applySetting
public StandardServiceRegistryBuilder applySetting(java.lang.String settingName, java.lang.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(java.util.Map settings)
Apply a groups of setting values.- Parameters:
settings
- The incoming settings to apply- Returns:
- this, for method chaining
-
clearSettings
public void clearSettings()
-
addInitiator
public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator)
Adds a service initiator.- Parameters:
initiator
- The initiator to be added- Returns:
- this, for method chaining
-
addService
public StandardServiceRegistryBuilder addService(java.lang.Class serviceRole, Service 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 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 StandardServiceRegistryBuilder enableAutoClose()
See the discussion ondisableAutoClose()
. This method enables the auto-closing.- Returns:
- this, for method chaining
-
build
public StandardServiceRegistry build()
Build the StandardServiceRegistry.- Returns:
- The StandardServiceRegistry.
-
getSettings
@Deprecated public java.util.Map getSettings()
Deprecated.Temporarily exposed since Configuration is still around and much code still uses Configuration. This allows code to configure the builder and access that to configure Configuration object.Temporarily exposed since Configuration is still around and much code still uses Configuration. This allows code to configure the builder and access that to configure Configuration object (used from HEM atm).- Returns:
- The settings map.
-
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.
-
-