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, 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.Environment, org.hibernate.integrator.spi.Integrator, .IntegratorService, 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 org.hibernate.service.ServiceRegistry instances.
Author
Steve Ebersole
See Also
StandardServiceRegistryImpl, org.hibernate.boot.registry.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<R extends Service>>
private final List<ProvidedService<R>>
private final Map<K, V>

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<K, V> settings, LoadedConfig loadedConfig)

Intended for use exclusively from JPA boot-strapping, or extensions of this class.

protected
StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, Map<K, V> settings, LoadedConfig loadedConfig, List<StandardServiceInitiator<R extends Service>> 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, Map<K, V> settings, ConfigLoader loader, LoadedConfig loadedConfig, List<StandardServiceInitiator<R extends Service>> initiators)

Intended for use exclusively from Quarkus boot-strapping, 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<R extends Service>
The initiator to be added
initiator
)

Adds a service initiator.

public StandardServiceRegistryBuilder

Returns:

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

Adds a user-provided service.

private void
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<K, V>
The incoming settings to apply
settings
)

Apply a groups of setting values.

public StandardServiceRegistry

Returns:

The StandardServiceRegistry.
build
()

Build the StandardServiceRegistry.

public void
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
()

See the discussion on disableAutoClose.

public static StandardServiceRegistryBuilder
public LoadedConfig
getAggregatedCfgXml()

Intended for internal testing use only!!

public BootstrapServiceRegistry
public ConfigLoader
public Map<K, V>

Returns:

The settings 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.
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 java.util.Properties file while for configure we read the XML variant.

private static List<StandardServiceInitiator<R extends Service>>

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<R extends Service>> initiators
providedServicesback to summary
private final List<ProvidedService<R>> providedServices
settingsback to summary
private final Map<K, V> 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<K, V> settings, LoadedConfig loadedConfig)

Intended for use exclusively from JPA boot-strapping, or extensions of this class. Consider this an SPI.

See Also
forJpa
StandardServiceRegistryBuilderback to summary
protected StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, Map<K, V> settings, LoadedConfig loadedConfig, List<StandardServiceInitiator<R extends Service>> 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.

Annotations
@Deprecated
StandardServiceRegistryBuilderback to summary
protected StandardServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry, Map<K, V> settings, ConfigLoader loader, LoadedConfig loadedConfig, List<StandardServiceInitiator<R extends Service>> 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.

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<R extends Service> initiator)

Adds a service initiator.

Parameters
initiator:StandardServiceInitiator<R extends Service>

The initiator to be added

Returns:StandardServiceRegistryBuilder

this, for method chaining

Annotations
@SuppressWarnings:UnusedDeclaration
addServiceback to summary
public StandardServiceRegistryBuilder addService(final Class<T> serviceRole, final Service service)

Adds a user-provided service.

Parameters
serviceRole:Class<T>

The role of the service being added

service:Service

The service implementation

Returns:StandardServiceRegistryBuilder

this, for method chaining

Annotations
@SuppressWarnings:unchecked
applyServiceContributingIntegratorsback to summary
private void applyServiceContributingIntegrators()
Annotations
@SuppressWarnings:deprecation
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

Annotations
@SuppressWarnings:unchecked, UnusedDeclaration
applySettingsback to summary
public StandardServiceRegistryBuilder applySettings(Map<K, V> settings)

Apply a groups of setting values.

Parameters
settings:Map<K, V>

The incoming settings to apply

Returns:StandardServiceRegistryBuilder

this, for method chaining

Annotations
@SuppressWarnings:unchecked, UnusedDeclaration
buildback to summary
public StandardServiceRegistry build()

Build the StandardServiceRegistry.

Returns:StandardServiceRegistry

The StandardServiceRegistry.

Annotations
@SuppressWarnings:unchecked
clearSettingsback to summary
public void clearSettings()
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)
Annotations
@SuppressWarnings:unchecked
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 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:StandardServiceRegistryBuilder

this, for method chaining

enableAutoCloseback to summary
public StandardServiceRegistryBuilder enableAutoClose()

See the discussion on disableAutoClose. This method enables the auto-closing.

Returns:StandardServiceRegistryBuilder

this, for method chaining

forJpaback to summary
public static StandardServiceRegistryBuilder forJpa(BootstrapServiceRegistry bootstrapServiceRegistry)

Intended only for use from org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl. 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.

getAggregatedCfgXmlback to summary
public LoadedConfig getAggregatedCfgXml()

Intended for internal testing use only!!

getBootstrapServiceRegistryback to summary
public BootstrapServiceRegistry getBootstrapServiceRegistry()
Annotations
@SuppressWarnings:unused
getConfigLoaderback to summary
public ConfigLoader getConfigLoader()
getSettingsback to summary
public Map<K, V> 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:Map<K, V>

The settings map.

Annotations
@Deprecated
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 java.util.Properties file while for configure we read the XML variant.

Parameters
resourceName:String

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

Returns:StandardServiceRegistryBuilder

this, for method chaining

Annotations
@SuppressWarnings:unchecked
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 java.util.Properties file while for configure we read the XML variant.

Parameters
file:File

The properties File reference

Returns:StandardServiceRegistryBuilder

this, for method chaining

Annotations
@SuppressWarnings:unchecked
See Also
configure(), configure(String)
standardInitiatorListback to summary
private static List<StandardServiceInitiator<R extends Service>> standardInitiatorList()

Used from the initiators variable initializer

Returns:List<StandardServiceInitiator<R extends Service>>

List of standard initiators