当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionUtil类代码示例

本文整理汇总了Java中org.apache.ibatis.reflection.ExceptionUtil的典型用法代码示例。如果您正苦于以下问题:Java ExceptionUtil类的具体用法?Java ExceptionUtil怎么用?Java ExceptionUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExceptionUtil类属于org.apache.ibatis.reflection包,在下文中一共展示了ExceptionUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invoke

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  String methodName = method.getName();
  if (CLOSE.hashCode() == methodName.hashCode() && CLOSE.equals(methodName)) {
    dataSource.pushConnection(this);
    return null;
  } else {
    try {
      if (!Object.class.equals(method.getDeclaringClass())) {
        // issue #579 toString() should never fail
        // throw an SQLException instead of a Runtime
        checkConnection();
      }
      return method.invoke(realConnection, args);
    } catch (Throwable t) {
      throw ExceptionUtil.unwrapThrowable(t);
    }
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:20,代码来源:PooledConnection.java

示例2: invoke

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  String methodName = method.getName();
  //如果调用close的话,忽略它,反而将这个connection加入到池中
  if (CLOSE.hashCode() == methodName.hashCode() && CLOSE.equals(methodName)) {
    dataSource.pushConnection(this);
    return null;
  } else {
    try {
      if (!Object.class.equals(method.getDeclaringClass())) {
        // issue #579 toString() should never fail
        // throw an SQLException instead of a Runtime
      	//除了toString()方法,其他方法调用之前要检查connection是否还是合法的,不合法要抛出SQLException
        checkConnection();
      }
      //其他的方法,则交给真正的connection去调用
      return method.invoke(realConnection, args);
    } catch (Throwable t) {
      throw ExceptionUtil.unwrapThrowable(t);
    }
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:23,代码来源:PooledConnection.java

示例3: invoke

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  try {
    //看看如何拦截
    Set<Method> methods = signatureMap.get(method.getDeclaringClass());
    //看哪些方法需要拦截
    if (methods != null && methods.contains(method)) {
      //调用Interceptor.intercept,也即插入了我们自己的逻辑
      return interceptor.intercept(new Invocation(target, method, args));
    }
    //最后还是执行原来逻辑
    return method.invoke(target, args);
  } catch (Exception e) {
    throw ExceptionUtil.unwrapThrowable(e);
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:17,代码来源:Plugin.java

示例4: invoke

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  //代理以后,所有Mapper的方法调用时,都会调用这个invoke方法
  //并不是任何一个方法都需要执行调用代理对象进行执行,如果这个方法是Object中通用的方法(toString、hashCode等)无需执行
  if (Object.class.equals(method.getDeclaringClass())) {
    try {
      return method.invoke(this, args);
    } catch (Throwable t) {
      throw ExceptionUtil.unwrapThrowable(t);
    }
  }
  //这里优化了,去缓存中找MapperMethod
  final MapperMethod mapperMethod = cachedMapperMethod(method);
  //执行
  return mapperMethod.execute(sqlSession, args);
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:17,代码来源:MapperProxy.java

示例5: invoke

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  String methodName = method.getName();
  //当调用关闭的时候,回收此Connection到PooledDataSource中  
  if (CLOSE.hashCode() == methodName.hashCode() && CLOSE.equals(methodName)) {
    dataSource.pushConnection(this);
    return null;
  } else {
    try {
      if (!Object.class.equals(method.getDeclaringClass())) {
        // issue #579 toString() should never fail
        // throw an SQLException instead of a Runtime
        checkConnection();
      }
      return method.invoke(realConnection, args);
    } catch (Throwable t) {
      throw ExceptionUtil.unwrapThrowable(t);
    }
  }
}
 
开发者ID:toulezu,项目名称:play,代码行数:21,代码来源:PooledConnection.java

示例6: invoke

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  try {
    Set<Method> methods = signatureMap.get(method.getDeclaringClass());
    if (methods != null && methods.contains(method)) {
      return interceptor.intercept(new Invocation(target, method, args));
    }
    return method.invoke(target, args);
  } catch (Exception e) {
    throw ExceptionUtil.unwrapThrowable(e);
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:13,代码来源:Plugin.java

示例7: invoke

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] params) throws Throwable {
  try {
    if (Object.class.equals(method.getDeclaringClass())) {
      return method.invoke(this, params);
    }    
    Object o = method.invoke(rs, params);
    if ("next".equals(method.getName())) {
      if (((Boolean) o)) {
        rows++;
        if (isTraceEnabled()) {
          ResultSetMetaData rsmd = rs.getMetaData();
          final int columnCount = rsmd.getColumnCount();
          if (first) {
            first = false;
            printColumnHeaders(rsmd, columnCount);
          }
          printColumnValues(columnCount);
        }
      } else {
        debug("     Total: " + rows, false);
      }
    }
    clearColumnInfo();
    return o;
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:30,代码来源:ResultSetLogger.java

示例8: invoke

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  try {
    if (Object.class.equals(method.getDeclaringClass())) {
      return method.invoke(this, args);
    } else if (isDefaultMethod(method)) {
      return invokeDefaultMethod(proxy, method, args);
    }
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
  final MapperMethod mapperMethod = cachedMapperMethod(method);
  return mapperMethod.execute(sqlSession, args);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:15,代码来源:MapperProxy.java

示例9: invoke

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object invoke(Object enhanced, Method method, Method methodProxy, Object[] args) throws Throwable {
  final String methodName = method.getName();
  try {
    synchronized (lazyLoader) {
      if (WRITE_REPLACE_METHOD.equals(methodName)) {
        Object original;
        if (constructorArgTypes.isEmpty()) {
          original = objectFactory.create(type);
        } else {
          original = objectFactory.create(type, constructorArgTypes, constructorArgs);
        }
        PropertyCopier.copyBeanProperties(type, enhanced, original);
        if (lazyLoader.size() > 0) {
          return new JavassistSerialStateHolder(original, lazyLoader.getProperties(), objectFactory, constructorArgTypes, constructorArgs);
        } else {
          return original;
        }
      } else {
        if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
          if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
            lazyLoader.loadAll();
          } else if (PropertyNamer.isProperty(methodName)) {
            final String property = PropertyNamer.methodToProperty(methodName);
            if (lazyLoader.hasLoader(property)) {
              lazyLoader.load(property);
            }
          }
        }
      }
    }
    return methodProxy.invoke(enhanced, args);
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:37,代码来源:JavassistProxyFactory.java

示例10: intercept

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object intercept(Object enhanced, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
  final String methodName = method.getName();
  try {
    synchronized (lazyLoader) {
      if (WRITE_REPLACE_METHOD.equals(methodName)) {
        Object original;
        if (constructorArgTypes.isEmpty()) {
          original = objectFactory.create(type);
        } else {
          original = objectFactory.create(type, constructorArgTypes, constructorArgs);
        }
        PropertyCopier.copyBeanProperties(type, enhanced, original);
        if (lazyLoader.size() > 0) {
          return new CglibSerialStateHolder(original, lazyLoader.getProperties(), objectFactory, constructorArgTypes, constructorArgs);
        } else {
          return original;
        }
      } else {
        if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
          if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
            lazyLoader.loadAll();
          } else if (PropertyNamer.isProperty(methodName)) {
            final String property = PropertyNamer.methodToProperty(methodName);
            if (lazyLoader.hasLoader(property)) {
              lazyLoader.load(property);
            }
          }
        }
      }
    }
    return methodProxy.invokeSuper(enhanced, args);
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:37,代码来源:CglibProxyFactory.java

示例11: invoke

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
  if (Object.class.equals(method.getDeclaringClass())) {
    try {
      return method.invoke(this, args);
    } catch (Throwable t) {
      throw ExceptionUtil.unwrapThrowable(t);
    }
  }
  final MapperMethod mapperMethod = cachedMapperMethod(method);
  return mapperMethod.execute(sqlSession, args);
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:13,代码来源:MapperProxy.java

示例12: invoke

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object invoke(Object enhanced, Method method, Method methodProxy, Object[] args) throws Throwable {
  final String methodName = method.getName();
  try {
    synchronized (lazyLoader) {
      if (WRITE_REPLACE_METHOD.equals(methodName)) {
        Object original = null;
        if (constructorArgTypes.isEmpty()) {
          original = objectFactory.create(type);
        } else {
          original = objectFactory.create(type, constructorArgTypes, constructorArgs);
        }
        PropertyCopier.copyBeanProperties(type, enhanced, original);
        if (lazyLoader.size() > 0) {
          return new JavassistSerialStateHolder(original, lazyLoader.getProperties(), objectFactory, constructorArgTypes, constructorArgs);
        } else {
          return original;
        }
      } else {
        if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
          if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
            lazyLoader.loadAll();
          } else if (PropertyNamer.isProperty(methodName)) {
            final String property = PropertyNamer.methodToProperty(methodName);
            if (lazyLoader.hasLoader(property)) {
              lazyLoader.load(property);
            }
          }
        }
      }
    }
    return methodProxy.invoke(enhanced, args);
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:37,代码来源:JavassistProxyFactory.java

示例13: intercept

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object intercept(Object enhanced, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
  final String methodName = method.getName();
  try {
    synchronized (lazyLoader) {
      if (WRITE_REPLACE_METHOD.equals(methodName)) {
        Object original = null;
        if (constructorArgTypes.isEmpty()) {
          original = objectFactory.create(type);
        } else {
          original = objectFactory.create(type, constructorArgTypes, constructorArgs);
        }
        PropertyCopier.copyBeanProperties(type, enhanced, original);
        if (lazyLoader.size() > 0) {
          return new CglibSerialStateHolder(original, lazyLoader.getProperties(), objectFactory, constructorArgTypes, constructorArgs);
        } else {
          return original;
        }
      } else {
        if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
          if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
            lazyLoader.loadAll();
          } else if (PropertyNamer.isProperty(methodName)) {
            final String property = PropertyNamer.methodToProperty(methodName);
            if (lazyLoader.hasLoader(property)) {
              lazyLoader.load(property);
            }
          }
        }
      }
    }
    return methodProxy.invokeSuper(enhanced, args);
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:37,代码来源:CglibProxyFactory.java

示例14: intercept

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
@Override
public Object intercept(Object enhanced, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
  final String methodName = method.getName();
  try {
    synchronized (lazyLoader) {
      if (WRITE_REPLACE_METHOD.equals(methodName)) {
        Object original = null;
        if (constructorArgTypes.isEmpty()) {
          original = objectFactory.create(type);
        } else {
          original = objectFactory.create(type, constructorArgTypes, constructorArgs);
        }
        PropertyCopier.copyBeanProperties(type, enhanced, original);
        if (lazyLoader.size() > 0) {
          return new CglibSerialStateHolder(original, lazyLoader.getProperties(), objectFactory, constructorArgTypes, constructorArgs);
        } else {
          return original;
        }
      } else {
    	//这里是关键,延迟加载就是调用ResultLoaderMap.loadAll()
        if (lazyLoader.size() > 0 && !FINALIZE_METHOD.equals(methodName)) {
          if (aggressive || lazyLoadTriggerMethods.contains(methodName)) {
            lazyLoader.loadAll();
          } else if (PropertyNamer.isProperty(methodName)) {
          	//或者调用ResultLoaderMap.load()
            final String property = PropertyNamer.methodToProperty(methodName);
            if (lazyLoader.hasLoader(property)) {
              lazyLoader.load(property);
            }
          }
        }
      }
    }
    return methodProxy.invokeSuper(enhanced, args);
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:39,代码来源:CglibProxyFactory.java

示例15: invoke

import org.apache.ibatis.reflection.ExceptionUtil; //导入依赖的package包/类
public final Object invoke(Object enhanced, Method method, Object[] args) throws Throwable {
  final String methodName = method.getName();
  try {
    if (WRITE_REPLACE_METHOD.equals(methodName)) {
      final Object original;
      if (constructorArgTypes.isEmpty()) {
        original = objectFactory.create(type);
      } else {
        original = objectFactory.create(type, constructorArgTypes, constructorArgs);
      }

      PropertyCopier.copyBeanProperties(type, enhanced, original);
      return this.newSerialStateHolder(original, unloadedProperties, objectFactory, constructorArgTypes, constructorArgs);
    } else {
      synchronized (this.reloadingPropertyLock) {
        if (!FINALIZE_METHOD.equals(methodName) && PropertyNamer.isProperty(methodName) && !reloadingProperty) {
          final String property = PropertyNamer.methodToProperty(methodName);
          final String propertyKey = property.toUpperCase(Locale.ENGLISH);
          if (unloadedProperties.containsKey(propertyKey)) {
            final ResultLoaderMap.LoadPair loadPair = unloadedProperties.remove(propertyKey);
            if (loadPair != null) {
              try {
                reloadingProperty = true;
                loadPair.load(enhanced);
              } finally {
                reloadingProperty = false;
              }
            } else {
              /* I'm not sure if this case can really happen or is just in tests -
               * we have an unread property but no loadPair to load it. */
              throw new ExecutorException("An attempt has been made to read a not loaded lazy property '"
                      + property + "' of a disconnected object");
            }
          }
        }

        return enhanced;
      }
    }
  } catch (Throwable t) {
    throw ExceptionUtil.unwrapThrowable(t);
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:44,代码来源:AbstractEnhancedDeserializationProxy.java


注:本文中的org.apache.ibatis.reflection.ExceptionUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。