??????????Java???AOP
???????????? ???????[ 2015/3/27 14:43:51 ] ????????Java ??????? Spring JDK
????????????????????InvocationHandler??invoke()????????????????????????????????????????——???????????????е??????в???????????????Щ????????????????aop??before??after??around????hook??????????????????add multiple aops?????????Handler???Aspect???????????????????????????μ???軌?????????????????????????????????
??????????????????????aop??????????????
???????????BeforeHandler ?? AfterHandler??????aop????????????????????????????????????н?????????
?????????????????????е?aop handler??????????????????????????????hook??
???????????????????????????й????
???????????????????????????????proxy object????
?????????????
????????????????????????Σ?????????и????????????·?????????????????????
???????????handler???????
????public abstract class AbstractHandler implements InvocationHandler {
????private Object targetObject;
????public void setTargetObject(Object targetObject) {
????this.targetObject = targetObject;
????}
????}
???????????BeforeHandler??AfterHandler?????????????handler??????
????public abstract class BeforeHandler extends AbstractHandler {
????public abstract void handleBefore(Object proxy?? Method method?? Object[] args);
????public Object invoke(Object proxy?? Method method?? Object[] args) throws Throwable {
????handleBefore(proxy?? method?? args);
????return method.invoke(getTargetObject()?? args);
????public abstract class AfterHandler extends AbstractHandler {
????public abstract void handleAfter(Object proxy?? Method method?? Object[] args);
????public Object invoke(Object proxy?? Method method?? Object[] args) throws Throwable {
????Object result = method.invoke(getTargetObject()?? args);
????handleAfter(proxy?? method?? args);
????return result;
????}
????}
????????Proxy???????
????public class ProxyFactory {
????public static Object getProxy(Object targetObject??
????List handlers) {
????//Code to get the proxy
????return proxyObject;
????} else {
????return targetObject;
????}
????}
????}
????????????????
????CalculatorImpl calcImpl = new CalculatorImpl();
????BeforeHandler before = new BeforeHandlerImpl();
????AfterHandler after = new AfterHandlerImpl();
????List<AbstractHandler> handlers = new ArrayList<AbstractHandler>();
????handlers.add(before);
????handlers.add(after);
????Calculator proxy = (Calculator) ProxyFactory.getProxy(calcImpl??
????handlers);
????int result = proxy.calculate(20?? 10);
????????
??????????????μ?????????????AOP??????????structural implementation????????????????????????????????????????????ò???????????????????????л????????????????????Java???????????????????????е????????????Ч????
????https://github.com/debjava/aopusingjdkdynamicproxy
???????
???????????????й?AOP?????????????????????????????????????before??after????aop???????????????“Around”??“Throw”?????????????????ɡ?
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
Java???????????Щ???????????????Java????????????????Java?б???Map????????Java Web???????????????Java??????????????д?????Java????????7???????????????????????(java .net ?????)???Java??????????Python??????Java webdriver??λ????????′????е?????Java??д??????????????????Java???????????????JavaScript????????????Java?????????????????? Java???????10??????????????Java?м????????????????java???????ü???????????м???????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????