org.apache.ibatis.session.Configuration.addInterceptor()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中org.apache.ibatis.session.Configuration.addInterceptor()方法的一些代码示例,展示了Configuration.addInterceptor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.addInterceptor()方法的具体详情如下:
包路径:org.apache.ibatis.session.Configuration
类名称:Configuration
方法名:addInterceptor

Configuration.addInterceptor介绍

暂无

代码示例

代码示例来源:origin: baomidou/mybatis-plus

private void pluginElement(XNode parent) throws Exception {
  if (parent != null) {
    for (XNode child : parent.getChildren()) {
      String interceptor = child.getStringAttribute("interceptor");
      Properties properties = child.getChildrenAsProperties();
      Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).newInstance();
      interceptorInstance.setProperties(properties);
      configuration.addInterceptor(interceptorInstance);
    }
  }
}

代码示例来源:origin: pagehelper/pagehelper-spring-boot

@PostConstruct
public void addPageInterceptor() {
  PageInterceptor interceptor = new PageInterceptor();
  Properties properties = new Properties();
  //先把一般方式配置的属性放进去
  properties.putAll(pageHelperProperties());
  //在把特殊配置放进去,由于close-conn 利用上面方式时,属性名就是 close-conn 而不是 closeConn,所以需要额外的一步
  properties.putAll(this.properties.getProperties());
  interceptor.setProperties(properties);
  for (SqlSessionFactory sqlSessionFactory : sqlSessionFactoryList) {
    sqlSessionFactory.getConfiguration().addInterceptor(interceptor);
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void pluginElement(XNode parent) throws Exception {
 if (parent != null) {
  for (XNode child : parent.getChildren()) {
   String interceptor = child.getStringAttribute("interceptor");
   Properties properties = child.getChildrenAsProperties();
   Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).newInstance();
   interceptorInstance.setProperties(properties);
   configuration.addInterceptor(interceptorInstance);
  }
 }
}

代码示例来源:origin: org.mybatis/mybatis

private void pluginElement(XNode parent) throws Exception {
 if (parent != null) {
  for (XNode child : parent.getChildren()) {
   String interceptor = child.getStringAttribute("interceptor");
   Properties properties = child.getChildrenAsProperties();
   Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).newInstance();
   interceptorInstance.setProperties(properties);
   configuration.addInterceptor(interceptorInstance);
  }
 }
}

代码示例来源:origin: org.flowable/flowable-engine-common

public void initCustomMybatisInterceptors(Configuration configuration) {
 if (customMybatisInterceptors!=null){
  for (Interceptor interceptor :customMybatisInterceptors){
    configuration.addInterceptor(interceptor);
  }
 }
}

代码示例来源:origin: com.gitee.hengboy/spring-boot-autoconfigure-mybatis-pageable

/**
 * 循环添加插件到mybatis
 *
 * @param interceptors      插件列表
 * @param sqlSessionFactory sqlSessionFactory对象实例
 */
void loopAddInterceptor(List<Interceptor> interceptors, SqlSessionFactory sqlSessionFactory) {
  for (Interceptor interceptor : interceptors) {
    sqlSessionFactory.getConfiguration().addInterceptor(interceptor);
  }
}

代码示例来源:origin: org.flowable/flowable-engine-common

public void initMyBatisLogSqlExecutionTimePlugin(Configuration configuration) {
  configuration.addInterceptor(new LogSqlExecutionTimePlugin());
}

代码示例来源:origin: com.hand.hap.cloud/hap-mybatis-mapper-starter

@Bean
public String zipkinInterceptor(SqlSessionFactory sqlSessionFactory,SpanAccessor spanAccessor) {
  ZipkinInterceptor zipkinInterceptor = new ZipkinInterceptor(spanAccessor);
  sqlSessionFactory.getConfiguration().addInterceptor(zipkinInterceptor);
  return "";
}

代码示例来源:origin: hatunet/spring-data-mybatis

@Override
public void afterPropertiesSet() throws Exception {
  this.sqlSessionTemplate.getConfiguration()
      .addInterceptor(new AuditingInterceptor(this));
}

代码示例来源:origin: lord-of-code/loc-framework

@PostConstruct
 public void addPageInterceptor() {
  PageInterceptor interceptor = new PageInterceptor();
  Properties properties = pageHelperProperties.getProperties();
  interceptor.setProperties(properties);
  Optional.ofNullable(sqlSessionFactoryList).ifPresent(list -> list.forEach(
    sqlSessionFactory -> sqlSessionFactory.getConfiguration().addInterceptor(interceptor)));
 }
}

代码示例来源:origin: com.github.pagehelper/pagehelper-spring-boot-autoconfigure

@PostConstruct
public void addPageInterceptor() {
  PageInterceptor interceptor = new PageInterceptor();
  Properties properties = new Properties();
  //先把一般方式配置的属性放进去
  properties.putAll(pageHelperProperties());
  //在把特殊配置放进去,由于close-conn 利用上面方式时,属性名就是 close-conn 而不是 closeConn,所以需要额外的一步
  properties.putAll(this.properties.getProperties());
  interceptor.setProperties(properties);
  for (SqlSessionFactory sqlSessionFactory : sqlSessionFactoryList) {
    sqlSessionFactory.getConfiguration().addInterceptor(interceptor);
  }
}

代码示例来源:origin: com.lodsve/lodsve-mybatis

@Override
  public void customize(Configuration configuration) {
    configuration.setMapUnderscoreToCamelCase(mapUnderscoreToCamelCase);

    configuration.addInterceptor(new PaginationInterceptor());
    configuration.addInterceptor(new BaseRepositoryInterceptor());

    if (ArrayUtils.isNotEmpty(enumsLocations)) {
      TypeHandler<?>[] handlers = new TypeHandlerScanner().find(enumsLocations);
      Arrays.stream(handlers).forEach(configuration.getTypeHandlerRegistry()::register);
    }
  }
}

代码示例来源:origin: com.hand.hap.cloud/hap-mybatis-mapper-starter

PageInterceptor pageInterceptor = new PageInterceptor(dialect);
pageInterceptor.setProperties(new Properties());
sqlSessionFactory.getConfiguration().addInterceptor(pageInterceptor);
sqlSessionFactory.getConfiguration().addInterceptor(parameterInterceptor);
sqlSessionFactory.getConfiguration().addInterceptor(multiLanguageInterceptor);

代码示例来源:origin: org.alfresco/alfresco-repository

private void pluginElement(XNode parent) throws Exception {
  if (parent != null) {
    for (XNode child : parent.getChildren()) {
      String interceptor = child.getStringAttribute("interceptor");
      Properties properties = child.getChildrenAsProperties();
      Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).newInstance();
      interceptorInstance.setProperties(properties);
      configuration.addInterceptor(interceptorInstance);
    }
  }
}

代码示例来源:origin: Alfresco/alfresco-repository

private void pluginElement(XNode parent) throws Exception {
  if (parent != null) {
    for (XNode child : parent.getChildren()) {
      String interceptor = child.getStringAttribute("interceptor");
      Properties properties = child.getChildrenAsProperties();
      Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).newInstance();
      interceptorInstance.setProperties(properties);
      configuration.addInterceptor(interceptorInstance);
    }
  }
}

代码示例来源:origin: chanedi/QuickProject

private void pluginElement(XNode parent) throws Exception {
 if (parent != null) {
  for (XNode child : parent.getChildren()) {
   String interceptor = child.getStringAttribute("interceptor");
   Properties properties = child.getChildrenAsProperties();
   Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).newInstance();
   interceptorInstance.setProperties(properties);
   configuration.addInterceptor(interceptorInstance);
  }
 }
}

代码示例来源:origin: org.apache.ibatis/ibatis-core

private void pluginElement(XNode parent) throws Exception {
 if (parent != null) {
  for (XNode child : parent.getChildren()) {
   String interceptor = child.getStringAttribute("interceptor");
   Properties properties = child.getChildrenAsProperties();
   Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).newInstance();
   interceptorInstance.setProperties(properties);
   configuration.addInterceptor(interceptorInstance);
  }
 }
}

代码示例来源:origin: deas/alfresco

private void pluginElement(XNode parent) throws Exception {
  if (parent != null) {
    for (XNode child : parent.getChildren()) {
      String interceptor = child.getStringAttribute("interceptor");
      Properties properties = child.getChildrenAsProperties();
      Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).newInstance();
      interceptorInstance.setProperties(properties);
      configuration.addInterceptor(interceptorInstance);
    }
  }
}

代码示例来源:origin: com.github.drtrang/spring-boot-autoconfigure

@Override
  public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (bean instanceof SqlSessionFactory) {
      SqlFormatterInterceptor sqlFormatterInterceptor =
          new SqlFormatterInterceptor(dbTypeProperties.getDbType(), sqlFormatProperties.getSqlFormatOption());
      SqlSessionFactory sqlSessionFactory = (SqlSessionFactory) bean;
      sqlSessionFactory.getConfiguration().addInterceptor(sqlFormatterInterceptor);
    }
    return bean;
  }
}

代码示例来源:origin: com.gitee.hengboy/spring-boot-autoconfigure-mybatis-pageable

/**
 * 实例化自动化分页拦截器
 */
@PostConstruct
void addInterceptors() {
  Interceptor interceptor = new MyBatisExecutePageableInterceptor();
  // 设置配置信息
  interceptor.setProperties(myBatisPageableProperties.getProperties());
  // 遍历sqlSessionFactory内的配置信息并添加自动化分页插件到拦截器内
  for (SqlSessionFactory sqlSessionFactory : sqlSessionFactoryList) {
    // 添加pageable执行前的插件
    addPreInterceptors(sqlSessionFactory);
    // 添加pageable执行插件
    sqlSessionFactory.getConfiguration().addInterceptor(interceptor);
    // 添加pageable执行后的插件
    addPostInterceptors(sqlSessionFactory);
  }
}

相关文章

微信公众号

最新文章

更多

Configuration类方法