## org.hibernate.service
Class ServiceRegistryBuilder

    java.lang.Object
      org.hibernate.service.ServiceRegistryBuilder

    public class ServiceRegistryBuilder

extends Object

Builder for standard `ServiceRegistry` instances.

See Also:
  `StandardServiceRegistryImpl`, `BootstrapServiceRegistryBuilder`

Field Summary
`static String` `DEFAULT_CFG_RESOURCE_NAME`

Constructor Summary
`ServiceRegistryBuilder()` Create a default builder
`ServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry)` Create a builder with the specified bootstrap services.

Method Summary
`ServiceRegistryBuilder` `addInitiator(BasicServiceInitiator initiator)` Adds a service initiator.
`ServiceRegistryBuilder` `addService(Class serviceRole, Service service)` Adds a user-provided service
`ServiceRegistryBuilder` `applySetting(String settingName, Object value)` Apply a setting value
`ServiceRegistryBuilder` `applySettings(Map settings)` Apply a groups of setting values
`ServiceRegistry` `buildServiceRegistry()` Build the service registry accounting for all settings and service initiators and services.
`ServiceRegistryBuilder` `configure()` Read setting information from an XML file using the standard resource location
`ServiceRegistryBuilder` `configure(String resourceName)` Read setting information from an XML file using the named resource location
`static void` `destroy(ServiceRegistry serviceRegistry)` Destroy a service registry.
`ServiceRegistryBuilder` `loadProperties(String resourceName)` Read settings from a `Properties` file.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_CFG_RESOURCE_NAME

    public static final String DEFAULT_CFG_RESOURCE_NAME

See Also:
  Constant Field Values

Constructor Detail

### ServiceRegistryBuilder

    public ServiceRegistryBuilder()

  Create a default builder

### ServiceRegistryBuilder

    public ServiceRegistryBuilder(BootstrapServiceRegistry bootstrapServiceRegistry)

  Create a builder with the specified bootstrap services.

  Parameters:
    `bootstrapServiceRegistry` - Provided bootstrap registry to use.

Method Detail

### loadProperties

    public ServiceRegistryBuilder loadProperties(String resourceName)

  Read settings from a `Properties` file. Differs from `configure()` and `configure(String)` in that here we read a `Properties` file while for `configure()` 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)`

### configure

    public ServiceRegistryBuilder 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 ServiceRegistryBuilder 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
  See Also:
    `loadProperties(String)`

### applySetting

    public ServiceRegistryBuilder applySetting(String settingName,
                                               Object value)

  Apply a setting value

  Parameters:
    `settingName` - The name of the setting
    `value` - The value to use.
  Returns:
    this, for method chaining

### applySettings

    public ServiceRegistryBuilder applySettings(Map settings)

  Apply a groups of setting values

  Parameters:
    `settings` - The incoming settings to apply
  Returns:
    this, for method chaining

### addInitiator

    public ServiceRegistryBuilder addInitiator(BasicServiceInitiator initiator)

  Adds a service initiator.

  Parameters:
    `initiator` - The initiator to be added
  Returns:
    this, for method chaining

### addService

    public ServiceRegistryBuilder addService(Class serviceRole,
                                             Service service)

  Adds a user-provided service

  Parameters:
    `serviceRole` - The role of the service being added
    `service` - The service implementation
  Returns:
    this, for method chaining

### buildServiceRegistry

    public ServiceRegistry buildServiceRegistry()

  Build the service registry accounting for all settings and service initiators and services.

  Returns:
    The built service registry

### 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.

Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.