package test;
/**
* QQ:1448376744
* @author 花间岛
*
*/
//控制器
public class Control {
//服务器
public static void main(String[] args) throws Exception {
boolean result = Handle.process(()->new Control().login("admin", "1024"));
System.out.println(result);
}
//Action
public boolean login(String username,String password) {
if("admin".equals(username)&&"1024".equals(password))
return true;
return false;
}
}
//委托接口
interface Action<TResult>{
public TResult inwork();
}
//通用处理器:AOP
class Handle{
public static <T> T process(Action<T> action) {
T value=null;
try {
//1:系统及业务逻辑
value = action.inwork();//2:主业务逻辑
//3:系统及业务逻辑
} catch(Exception e){
//1:异常处理业务逻辑
//2:日志记录
}
return value;
}
}