Hibernate源码阅读2——Service Registry

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:

 

 

 

 

 

转载于:https://my.oschina.net/ZGang/blog/812188

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值