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

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

Introduction

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

Prototype

InterceptorChain

Source Link

Usage

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

License:Open Source License

/**
 * ?Mapper?//from   w  w w.  ja v  a2 s.co 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;
    }
}