package io.craft.armor;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author warden
 * @author mindwind
 * @version 1.0, Dec 18, 2014
 */
public class ArmorInvocationHandler implements InvocationHandler {
	
	
	private Object delegate;
	
	
	public ArmorInvocationHandler(Object delegate) {
		 this.delegate = delegate;
	}

	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		return method.invoke(delegate, args);
	}
	

}

@@ -29,43 +29,136 @@
 ort 
-java.lang.reflect.InvocationHandler
+io.craft.armor.api.ArmorService;%0A%0Aimport java.lang.reflect.InvocationHandler;%0Aimport java.lang.reflect.InvocationTargetException
 ;%0Aim
@@ -352,24 +352,30 @@
  Object 
+      
 delegate
 ;%0A%09%0A%09%0A%09p
@@ -366,16 +366,56 @@
 delegate
+    ;%0A%09private ArmorService armorService
 ;%0A%09%0A%09%0A%09p
@@ -599,50 +599,573 @@
 %7B%0A%09%09
-return method.invoke(delegate, args);%0A%09%7D%0A%09
+// Armor master switch is off%0A%09%09if (!armorService.isOn()) %7B %0A%09%09%09return rawInvoke(method, args);%0A%09%09%7D%0A%09%09%0A%09%09// Armor method swich is off%0A%09%09if (!armorService.isOn(delegate.getClass(), method.getName(), method.getParameterTypes())) %7B  %0A%09%09%09return rawInvoke(method, args);%0A%09%09%7D%0A%09%09%0A%09%09%0A%09%09// Armor context invoke%0A%09%09return armorInvoke(method, args);%0A%09%7D%0A%09%0A%09private Object rawInvoke(Method method, Object%5B%5D args) throws Throwable %7B%0A%09%09return method.invoke(delegate, args);%0A%09%7D%0A%09%0A%09private Object armorInvoke(Method method, Object%5B%5D args) throws Throwable %7B%0A%09%09return null; // TODO%0A%09%7D
 %0A%0A%7D%0A

improve - Armor invocation handler main logic flow