Package com.skyline.energy.interceptor

Source Code of com.skyline.energy.interceptor.DataAccessInterceptor

package com.skyline.energy.interceptor;

import java.lang.reflect.Method;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import com.skyline.energy.cache.CacheManager;
import com.skyline.energy.dataaccess.jdbc.JdbcDataAccessor;
import com.skyline.energy.executor.DataAccessExecutor;
import com.skyline.energy.executor.ExecutorFactory;

public class DataAccessInterceptor implements MethodInterceptor {
  private final CacheManager cacheManager;
  private final JdbcDataAccessor dataAccessor;

  public DataAccessInterceptor(CacheManager cacheManager, JdbcDataAccessor dataAccessor) {
    this.cacheManager = cacheManager;
    this.dataAccessor = dataAccessor;
  }

  public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
    DataAccessExecutor executor = ExecutorFactory.getExecutor(cacheManager, dataAccessor, method);
    if (executor != null) {
      return executor.execute(obj, args);
    }
    return null;
  }

}
TOP

Related Classes of com.skyline.energy.interceptor.DataAccessInterceptor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.