Seervice服务:
A services provides a certain types of functionality, in a pluggable manner.
按照可插拔的方式提供摸个特定类型的功能;
/**
* Marker interface for services.
*
* NOTE : All services must be {@link Serializable}! * * @author Steve Ebersole */ public interface Service extends Serializable { }
ServiceRegistry服务注册表:
A ServiceRegistry, at its most basic, hosts and manages Services.
服务注册表是用于创建 组织 存储 管理服务(IOC);
注:Services have a lifecycle. They have a scope. Services might depend on other services. And they need to be produced (choose using one implementation over another). The ServiceRegistry fulfills all these needs.
服务注册表主要是为了方便控制Service生命周期而存在;
public interface ServiceRegistry {
/**
* Retrieve this registry's parent registry.
*
* @return The parent registry. May be null.
*/
public ServiceRegistry getParentServiceRegistry();
/**
* Retrieve a service by role. If service is not found, but a {@link org.hibernate.service.spi.ServiceInitiator} is
* registered for this service role, the service will be initialized and returned.
*
* NOTE: We cannot return {@code >} here because the service might come from the parent... * 获得当服务 * @param serviceRole The service role * @param The service role type * * @return The requested service. * * @throws UnknownServiceException Indicates the service was not known. */ public R getService(Class serviceRole); }
ServiceBinding服务关联:
服务如何和服务注册表关联通常是通过ServiceRegistry来初始化服务来进行关联;
ServiceRegistry的分类:
在hibernate中有三种注册表 BootstrapServiceRegistry(引导服务注册表),StandardServiceRegistry(标准服务注册表),SessionFactoryServiceRegistry(会话工厂注册表);
BootstrapServiceRegistry:
此注册表主要管理ClassLoaderService,IntegratorService,StrategySelector服务;
ClassLoaderService主要是用来和加载类资源 文件资源以及和java.util.ServiceLoader相互作用;(注:ServiceLoader是Java中提出的动态加载资源的方法I);
IntegratorService主要用于应用 第三方平台和Hibernate的集成;
StrategySelector
StandardServiceRegistry:
SessionFactoryServiceRegistry: