博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
企业搜索引擎开发之连接器connector(十三)
阅读量:6815 次
发布时间:2019-06-26

本文共 3780 字,大约阅读时间需要 12 分钟。

本文分析一下ConnectorInterfaces类的代码,该类主要提供了访问连接器的相关依赖类的一下方法,供ConnectorCoordinatorImpl类调用,其源码如下:

/** * Access to the AuthenticationManager, AuthorizationManager, and * TraversalManagager for a Connector instance. */public class ConnectorInterfaces {  private final String connectorName;  private final Connector connector;  // these are lazily constructed  private TraversalManager traversalManager;  private AuthenticationManager authenticationManager;  private AuthorizationManager authorizationManager;  ConnectorInterfaces(String connectorName, Connector connector) {    this.connectorName = connectorName;    this.connector = connector;  }  /**   * Constructs a ConnectorIntefaces with Managers supplied by the caller   * rather than the connector. This is for testing only.   */  ConnectorInterfaces(String connectorName, TraversalManager traversalManager,                      AuthenticationManager authenticationManager,                      AuthorizationManager authorizationManager) {    this.connectorName = connectorName;    this.connector = null;    this.traversalManager = traversalManager;    this.authenticationManager = authenticationManager;    this.authorizationManager = authorizationManager;  }  /**   * @return the authenticationManager   * @throws InstantiatorException   */  AuthenticationManager getAuthenticationManager() throws InstantiatorException {    if (authenticationManager == null) {      Session s = getSession();      try {        authenticationManager = s.getAuthenticationManager();      } catch (RepositoryException e) {        // TODO(ziff): think about how this could be re-tried        throw new InstantiatorException(e);      } catch (Exception e) {        throw new InstantiatorException(e);      }    }    return authenticationManager;  }  /**   * @return the authorizationManager   * @throws InstantiatorException   */  AuthorizationManager getAuthorizationManager() throws InstantiatorException {    if (authorizationManager == null) {      Session s = getSession();      try {        authorizationManager = s.getAuthorizationManager();      } catch (RepositoryException e) {        // TODO(ziff): think about how this could be re-tried        throw new InstantiatorException(e);      } catch (Exception e) {        throw new InstantiatorException(e);      }    }    return authorizationManager;  }  /**   * @return the connector   */  // TODO(strellis) Remove this method or make it private so all connector  // access is through InstanceInfo.  Connector getConnector() {    return connector;  }  /**   * @return the connectorName   */  String getConnectorName() {    return connectorName;  }  /**   * @return the traverser   * @throws InstantiatorException   */  TraversalManager getTraversalManager() throws InstantiatorException {    if (traversalManager == null) {      Session s = getSession();      try {        traversalManager = s.getTraversalManager();      } catch (RepositoryException ie) {        throw new InstantiatorException(ie);      } catch (Exception e) {        throw new InstantiatorException(e);      }    }    return traversalManager;  }  private Session getSession() throws InstantiatorException {    Session s = null;    try {      s = connector.login();    } catch (RepositoryLoginException e) {      // this is un-recoverable      throw new InstantiatorException(e);    } catch (RepositoryException e) {      // for this one, we could try again later      // TODO(ziff): think about how this could be re-tried      throw new InstantiatorException(e);    } catch (Exception e) {      throw new InstantiatorException(e);    }    return s;  }}

 可以看到,连接器的相关TraversalManager对象是通过这里获取的,该类源码容易读懂,我不解释了

本系列企业搜索引擎开发之连接器connector系本人原创

转载请注明出处 博客园 刺猬的温驯

本文链接http://www.cnblogs.com/chenying99/archive/2013/03/20/2970354.html

你可能感兴趣的文章
newusers和chpasswd的用法
查看>>
关键字AUTO_INCREMENT 重命名表 修改列的属性。
查看>>
fastreport(B)
查看>>
伪造邮件***,社工钓鱼,你中招了吗【一】
查看>>
Context 使用不当造成内存泄露
查看>>
C#双缓冲机制
查看>>
12.17 Nginx负载均衡;12.18 ssl原理;12.19 生产ssl密钥对;12.20 N
查看>>
P2P概览与原理解析
查看>>
zabbix监控端口状态
查看>>
php检测函数是否存在函数 function_exists
查看>>
登陆界面上下左右居中自适应屏幕显示的简单实现
查看>>
【解决】Windows Mobile 6 Professional SDK Refresh.msi 在xp上一直卡死
查看>>
RH124 Chapter 2 Managing Files From the Command Line
查看>>
内核里面writel(readl)是如何实现的
查看>>
python--multiprocessing多进程总结
查看>>
tomcat lb cluster
查看>>
小米2系列板砖自救行动
查看>>
登录亿邮网关windows脚本
查看>>
UML 类图
查看>>
研究:窗口映射
查看>>