1.3. ServiceBinding

The association of a given Service to a given ServiceRegistry is called a binding and is represented by the org.hibernate.service.spi.ServiceBinding interface. Furthermore, the specific contract between a ServiceBinding and the ServiceRegistry is represented by the org.hibernate.service.spi.ServiceBinding.ServiceLifecycleOwner interface.

There are two ways a Service becomes associated (bound) to a ServiceRegistry.

  • the Service can be directly instantiated and then handed to the ServiceRegistry

  • a ServiceInitiator can be given to the ServiceRegistry (which the ServiceRegistry will use if and when the Service is needed)

ServiceRegistry implementations register bindings through calls to the overloaded org.hibernate.service.internal.AbstractServiceRegistryImpl#createServiceBinding method accepting either a Service instance or a ServiceInitiator instance.

Each specific type of registry defines its own ServiceInitiator specialization.