Top Description Fields Constructors Methods
org.hibernate.boot.registry

public Class StandardServiceRegistryBuilder

extends Object
Class Inheritance
Imports
java.io.File, java.net.URL, java.util.ArrayList, .HashMap, .List, .Map, .Properties, org.hibernate.Internal, org.hibernate.boot.cfgxml.internal.ConfigLoader, org.hibernate.boot.cfgxml.spi.LoadedConfig, org.hibernate.boot.registry.classloading.spi.ClassLoaderService, org.hibernate.boot.registry.internal.StandardServiceRegistryImpl, org.hibernate.cfg.AvailableSettings, .Environment, org.hibernate.internal.util.PropertiesHelper, org.hibernate.internal.util.config.ConfigurationHelper, org.hibernate.service.Service, .ServiceRegistry, .StandardServiceInitiators, org.hibernate.service.internal.ProvidedService, org.hibernate.service.spi.ServiceContributor

Builder for standard ServiceRegistry instances.

Configuration properties are enumerated by AvailableSettings.

Author
Steve Ebersole
See Also
StandardServiceRegistryImpl, BootstrapServiceRegistryBuilder

Field Summary

Modifier and TypeField and Description
private final LoadedConfig
private boolean
private final BootstrapServiceRegistry
private final ConfigLoader
public static final String
DEFAULT_CFG_RESOURCE_NAME

The default resource name for a Hibernate configuration XML file.

private final List<StandardServiceInitiator<?>>
private final List<ProvidedService<?>>
private final Map<String, Object>

Constructor Summary

AccessConstructor and Description
public
StandardServiceRegistryBuilder()

Create a default builder.

public
StandardServiceRegistryBuilder(BootstrapServiceRegistry
Provided bootstrap registry to use.
bootstrapServiceRegistry
)

Create a builder with the specified bootstrap services.

protected
StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, Map<String, Object> settings, LoadedConfig loadedConfig)

Intended for use exclusively from JPA bootstrapping, or extensions of this class.

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.

public
StandardServiceRegistryBuilder(BootstrapServiceRegistry
Provided bootstrap registry to use.
bootstrapServiceRegistry
,
LoadedConfig loadedConfigBaseline)

Create a builder with the specified bootstrap services.

Method Summary

Modifier and TypeMethod and Description
public StandardServiceRegistryBuilder

Returns:

this, for method chaining
addInitiator
(StandardServiceInitiator<?>
The initiator to be added
initiator
)

Adds a service initiator.

public <T extends Service> StandardServiceRegistryBuilder

Returns:

this, for method chaining
addService
(Class<T>
The role of the service being added
serviceRole
,
T
The service implementation
service
)

Adds a user-provided service.

private void
public StandardServiceRegistryBuilder

Returns:

this, for method chaining
applySetting
(String
The name of the setting
settingName
,
Object
The value to use.
value
)

Apply a setting value.

public StandardServiceRegistryBuilder

Returns:

this, for method chaining
applySettings
(Map<String, Object>
The incoming settings to apply
settings
)

Apply a group of settings.

public StandardServiceRegistryBuilder

Returns:

this, for method chaining
applySettings
(Properties
The incoming settings to apply
settings
)

Apply a group of settings.

public StandardServiceRegistry

Returns:

A newly-instantiated StandardServiceRegistry
build
()

Build and return the StandardServiceRegistry.

public void
clearSettings()

Discard all the settings applied so far.

public StandardServiceRegistryBuilder

Returns:

this, for method chaining
configure
()

Read setting information from an XML file using the standard resource location.

public StandardServiceRegistryBuilder

Returns:

this, for method chaining
configure
(String
The named resource
resourceName
)

Read setting information from an XML file using the named resource location.

public StandardServiceRegistryBuilder
configure(File configurationFile)

public StandardServiceRegistryBuilder
public StandardServiceRegistryBuilder
configure(LoadedConfig loadedConfig)

public static void
destroy(ServiceRegistry
The registry to be closed.
serviceRegistry
)

Destroy a service registry.

public StandardServiceRegistryBuilder

Returns:

this, for method chaining
disableAutoClose
()

By default, when a ServiceRegistry is no longer referenced by any other registries as a parent it will be closed.

public StandardServiceRegistryBuilder

Returns:

this, for method chaining
enableAutoClose
()

Enables auto-closing.

public static StandardServiceRegistryBuilder
forJpa(BootstrapServiceRegistry bootstrapServiceRegistry)

Creates a StandardServiceRegistryBuilder specific to the needs of bootstrapping JPA.

public LoadedConfig
getAggregatedCfgXml()

Intended for internal testing use only!!

public BootstrapServiceRegistry
public ConfigLoader
public Map<String, Object>
getSettings()

Obtain the current aggregated settings.

public StandardServiceRegistryBuilder

Returns:

this, for method chaining
loadProperties
(String
The name by which to perform a resource look up for the properties file
resourceName
)

Read settings from a java.util.Properties file by resource name.

public StandardServiceRegistryBuilder

Returns:

this, for method chaining
loadProperties
(File
The properties File reference
file
)

Read settings from a java.util.Properties file by File reference

Differs from configure() and configure(String) in that here we expect to read a properties file, while for configure we read the configuration from XML.

private static List<StandardServiceInitiator<?>>

Returns:

List of standard initiators
standardInitiatorList
()

Used from the initiators variable initializer

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

aggregatedCfgXmlback to summary
private final LoadedConfig aggregatedCfgXml
autoCloseRegistryback to summary
private boolean autoCloseRegistry
bootstrapServiceRegistryback to summary
private final BootstrapServiceRegistry bootstrapServiceRegistry
configLoaderback to summary
private final ConfigLoader configLoader
DEFAULT_CFG_RESOURCE_NAMEback to summary
public static final String DEFAULT_CFG_RESOURCE_NAME

The default resource name for a Hibernate configuration XML file.

initiatorsback to summary
private final List<StandardServiceInitiator<?>> initiators
providedServicesback to summary
private final List<ProvidedService<?>> providedServices
settingsback to summary
private final Map<String, Object> settings

Constructor Detail

StandardServiceRegistryBuilderback to summary
public StandardServiceRegistryBuilder()

Create a default builder.

StandardServiceRegistryBuilderback to summary
public StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry)

Create a builder with the specified bootstrap services.

Parameters
bootstrapServiceRegistry:BootstrapServiceRegistry

Provided bootstrap registry to use.

StandardServiceRegistryBuilderback to summary
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.

See Also
forJpa
StandardServiceRegistryBuilderback to summary
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.

StandardServiceRegistryBuilderback to summary
public StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, LoadedConfig loadedConfigBaseline)

Create a builder with the specified bootstrap services.

Parameters
bootstrapServiceRegistry:BootstrapServiceRegistry

Provided bootstrap registry to use.

Method Detail

addInitiatorback to summary
public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator<?> initiator)

Adds a service initiator.

Parameters
initiator:StandardServiceInitiator<?>

The initiator to be added

Returns:StandardServiceRegistryBuilder

this, for method chaining

addServiceback to summary
public <T extends Service> StandardServiceRegistryBuilder addService(Class<T> serviceRole, T service)

Adds a user-provided service.

Parameters
serviceRole:Class<T>

The role of the service being added

service:T

The service implementation

Returns:StandardServiceRegistryBuilder

this, for method chaining

applyServiceContributorsback to summary
private void applyServiceContributors()
applySettingback to summary
public StandardServiceRegistryBuilder applySetting(String settingName, Object value)

Apply a setting value.

Parameters
settingName:String

The name of the setting

value:Object

The value to use.

Returns:StandardServiceRegistryBuilder

this, for method chaining

applySettingsback to summary
public StandardServiceRegistryBuilder applySettings(Map<String, Object> settings)

Apply a group of settings.

Parameters
settings:Map<String, Object>

The incoming settings to apply

Returns:StandardServiceRegistryBuilder

this, for method chaining

applySettingsback to summary
public StandardServiceRegistryBuilder applySettings(Properties settings)

Apply a group of settings.

Parameters
settings:Properties

The incoming settings to apply

Returns:StandardServiceRegistryBuilder

this, for method chaining

buildback to summary
public StandardServiceRegistry build()

Build and return the StandardServiceRegistry.

Returns:StandardServiceRegistry

A newly-instantiated StandardServiceRegistry

clearSettingsback to summary
public void clearSettings()

Discard all the settings applied so far.

configureback to summary
public StandardServiceRegistryBuilder configure()

Read setting information from an XML file using the standard resource location.

Returns:StandardServiceRegistryBuilder

this, for method chaining

See Also
DEFAULT_CFG_RESOURCE_NAME, configure(String), loadProperties(String)
configureback to summary
public StandardServiceRegistryBuilder configure(String resourceName)

Read setting information from an XML file using the named resource location.

Parameters
resourceName:String

The named resource

Returns:StandardServiceRegistryBuilder

this, for method chaining

configureback to summary
public StandardServiceRegistryBuilder configure(File configurationFile)
configureback to summary
public StandardServiceRegistryBuilder configure(URL url)
configureback to summary
public StandardServiceRegistryBuilder configure(LoadedConfig loadedConfig)
destroyback to summary
public static void destroy(ServiceRegistry serviceRegistry)

Destroy a service registry.

Applications should only destroy registries they have explicitly created.

Parameters
serviceRegistry:ServiceRegistry

The registry to be closed.

disableAutoCloseback to summary
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 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:StandardServiceRegistryBuilder

this, for method chaining

enableAutoCloseback to summary
public StandardServiceRegistryBuilder enableAutoClose()

Enables auto-closing.

Returns:StandardServiceRegistryBuilder

this, for method chaining

forJpaback to summary
public static StandardServiceRegistryBuilder forJpa(BootstrapServiceRegistry bootstrapServiceRegistry)

Creates a StandardServiceRegistryBuilder specific to the needs of bootstrapping JPA.

Intended only for use from org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.

In particular, we ignore properties found in cfg.xml files. EntityManagerFactoryBuilderImpl collects these properties later.

See Also
org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl
getAggregatedCfgXmlback to summary
public LoadedConfig getAggregatedCfgXml()

Intended for internal testing use only!!

getBootstrapServiceRegistryback to summary
public BootstrapServiceRegistry getBootstrapServiceRegistry()
getConfigLoaderback to summary
public ConfigLoader getConfigLoader()
getSettingsback to summary
public Map<String, Object> getSettings()

Obtain the current aggregated settings.

Annotations
@Internal
loadPropertiesback to summary
public StandardServiceRegistryBuilder loadProperties(String resourceName)

Read settings from a java.util.Properties file by resource name.

Differs from configure() and configure(String) in that here we expect to read a properties file, while for configure we read the configuration from XML.

Parameters
resourceName:String

The name by which to perform a resource look up for the properties file

Returns:StandardServiceRegistryBuilder

this, for method chaining

See Also
configure(), configure(String)
loadPropertiesback to summary
public StandardServiceRegistryBuilder loadProperties(File file)

Read settings from a java.util.Properties file by File reference

Differs from configure() and configure(String) in that here we expect to read a properties file, while for configure we read the configuration from XML.

Parameters
file:File

The properties File reference

Returns:StandardServiceRegistryBuilder

this, for method chaining

See Also
configure(), configure(String)
standardInitiatorListback to summary
private static List<StandardServiceInitiator<?>> standardInitiatorList()

Used from the initiators variable initializer

Returns:List<StandardServiceInitiator<?>>

List of standard initiators