Example usage for org.apache.ibatis.plugin InterceptorChain addInterceptor

List of usage examples for org.apache.ibatis.plugin InterceptorChain addInterceptor

Introduction

In this page you can find the example usage for org.apache.ibatis.plugin InterceptorChain addInterceptor.

Prototype

public void addInterceptor(Interceptor interceptor) 

Source Link

Usage

From source file:tk.mybatis.mapper.mapperhelper.MapperOnceInterceptor.java

License:Open Source License

/**
 * ?Mapper?//from w ww  .  ja  va  2 s  .c o  m
 *
 * @param invocation
 */
public synchronized void processInvocation(Invocation invocation) {
    if (!hasRan) {
        Object[] objects = invocation.getArgs();
        MappedStatement ms = (MappedStatement) objects[0];
        mapperHelper.processConfiguration(ms.getConfiguration());
        //?
        InterceptorChain interceptorChain = new InterceptorChain();
        List<Interceptor> interceptorList = ms.getConfiguration().getInterceptors();
        for (Interceptor interceptor : interceptorList) {
            if (interceptor != this) {
                interceptorChain.addInterceptor(interceptor);
            }
        }
        MetaObject metaObject = SystemMetaObject.forObject(ms.getConfiguration());
        metaObject.setValue("interceptorChain", interceptorChain);
        hasRan = true;
    }
}