James 7 年 前
コミット
3fb6814175
1 ファイル変更12 行追加4 行削除
  1. 12 4
      src/main/java/com/jfinal/aop/AopFactory.java

+ 12 - 4
src/main/java/com/jfinal/aop/AopFactory.java

@@ -23,15 +23,23 @@ public class AopFactory {
 	
 	public <T> T get(Class<T> targetClass) {
 		try {
-			return get(targetClass, injectDepth);
+			return doGet(targetClass, injectDepth);
+		} catch (ReflectiveOperationException e) {
+			throw new RuntimeException(e);
+		}
+	}
+	
+	public <T> T get(Class<T> targetClass, int injectDepth) {
+		try {
+			return doGet(targetClass, injectDepth);
 		} catch (ReflectiveOperationException e) {
 			throw new RuntimeException(e);
 		}
 	}
 	
 	@SuppressWarnings("unchecked")
-	protected <T> T get(Class<T> targetClass, int injectDepth) throws ReflectiveOperationException {
-		// Aop.get(obj.getClass()) 可以用 Aop.inject(obj),所以注掉下一行代码 
+	protected <T> T doGet(Class<T> targetClass, int injectDepth) throws ReflectiveOperationException {
+		// Aop.get(obj.getClass()) 可以用 Aop.inject(obj),所以注掉下一行代码
 		// targetClass = (Class<T>)getUsefulClass(targetClass);
 		
 		targetClass = (Class<T>)getMappingClass(targetClass);
@@ -107,7 +115,7 @@ public class AopFactory {
 				fieldInjectedClass = field.getType();
 			}
 			
-			Object fieldInjectedObject = get(fieldInjectedClass, injectDepth);
+			Object fieldInjectedObject = doGet(fieldInjectedClass, injectDepth);
 			field.setAccessible(true);
 			field.set(targetObject, fieldInjectedObject);
 		}