Spring Aspect实现AOP切面
百度搜索的大部分的文章(demo)都只是对简单的方法进行切面(例如:public String say(String name)),却未介绍在入参是不固定的时候改怎么处理,后来查到可以使用org.aspectj.lang.JoinPoint类获取到被代理类的信息和方法的入参信息。
参考BLOG: http://blog.csdn.net/wangyang1354/article/details/50896349
但是在对dubbo的类进行Aspect代理时会出现如下错误:(因为dubbo已经对此类代理过一次了,Aspect好像只能对纯类进行切面)
com.alibaba.dubbo.rpc.RpcException: Forbid consumer 10.20.1.222 access service com.hwy.huabus.api.payment.InstallmentPlanService from registry 192.168.18.191:2181 use dubbo version 2.5.3, Please check registry access list (whitelist/blacklist).
at com.alibaba.dubbo.registry.integration.RegistryDirectory.doList(RegistryDirectory.java:579)
at com.alibaba.dubbo.rpc.cluster.directory.AbstractDirectory.list(AbstractDirectory.java:73)
at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.list(AbstractClusterInvoker.java:260)
at com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:219)
at com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:72)
at com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52)
at com.alibaba.dubbo.common.bytecode.proxy0.createPlan(proxy0.java)
at com.hwy.huabus.service.InstallmentPlanServiceTest.testCreatePlan(InstallmentPlanServiceTest.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Spring Aspect实现AOP切面的更多相关文章
- spring boot使用AOP切面编程
		
spring boot使用AOP 1.在pom文件中添加依赖: <!--spring boot aop切面--> <dependency> <groupId>org ...
 - Spring MVC通过AOP切面编程 来拦截controller 实现日志的写入
		
首选需要参考的是:[参考]http://www.cnblogs.com/guokai870510826/p/5977948.html http://www.cnblogs.com/guokai8 ...
 - spring AOP 之五:Spring MVC通过AOP切面编程来拦截controller
		
示例1:通过包路径及类名规则为应用增加切面 该示例是通过拦截所有com.dxz.web.aop包下的以Controller结尾的所有类的所有方法,在方法执行前后打印和记录日志到数据库. 新建一个spr ...
 - 一文带你搞定AOP切面
		
摘要:AOP在spring中又叫"面向切面编程",是对传统我们面向对象编程的一个补充,主要操作对象就是"切面",可以简单的理解它是贯穿于方法之中,在方法执行前. ...
 - [Spring] Aspect Oriented Programming with Spring | AOP | 切面 | 切点
		
使用Spring面向切面编程 1.介绍 AOP是OOP的补充,提供了另一种关于程序结构的思路. OOP的模块化的关键单位是 类 . AOP的则是aspect切面. AOP 将程序的逻辑分成独立的块(叫 ...
 - 关于spring.net的面向切面编程 (Aspect Oriented Programming with Spring.NET)-使用工厂创建代理(Using the ProxyFactoryObject to create AOP proxies)
		
本文翻译自Spring.NET官方文档Version 1.3.2. 受限于个人知识水平,有些地方翻译可能不准确,但是我还是希望我的这些微薄的努力能为他人提供帮助. 侵删. 如果你正在为你的业务模型使用 ...
 - Spring学习4-面向切面(AOP)之aspectj注解方式
		
一.简介 1.AOP用在哪些方面:AOP能够将那些与业务无关,却为业务模块所共同调用的逻辑或责任,例如事务处理.日志管理.权限控制,异常处理等,封装起来,便于减少系统的重复代码,降低模块间的耦合 ...
 - Spring学习4-面向切面(AOP)之Spring接口方式
		
一.初识AOP 关于AOP的学习可以参看帮助文档:spring-3.2.0.M2\docs\reference\html目录下index.html的相关章节 1.AOP:Aspect ...
 - Spring @Aspect切面参数传递
		
Spring @Aspect切面参数传递: Xml: <?xml version="1.0" encoding="UTF-8"?> <bean ...
 
随机推荐
- [转]让Nginx支持ThinkPHP的URL重写和PATHINFO
			
From : http://www.jzxue.com/wangzhankaifa/php/201108/08-8396.html ThinkPHP支持通过PATHINFO和URL rewrite ...
 - jquery click()方法模拟点击事件对a标签不生效的解决办法
			
阅读数:8971 <a href="www.baidu.com"></a> 1 问题分析 点击A标签本身,并不会触发跳转到指定链接的事件,就是说,我们平时都 ...
 - 谈谈Enter回车键提交表单那些事 回车搜索 enter搜索
			
我们在做系统前端的时候,往往会用到form标签,采用jquery插件做表单验证.我们信誓旦旦的一位把一切都做好的时候,并且检查一遍又一遍的时候,意向不到的事情发生了,也许是出于一种意外,而这种意外我们 ...
 - C/C++ 关于 for循环 的第二个表达式右侧非常量的时候
			
废话不多说,直接看代码: #include<stdio.h> int main(){ ; ;z<zmax;z++){ printf("i=%d z=%d\n",i ...
 - Sicily 1388. Quicksum
			
http://soj.me/1388 又一道字符串的水题.... #include <iostream> #include <cstring> using namespace ...
 - webAR涉及的技术【转】
			
1.技术体系 1.1技术体系整理 其中绿色底色的代表Demo中表现出的能力比较成熟,可以直接应用. 脑图地址:http://naotu.baidu.com/file/3392a895a90397252 ...
 - [leetcode]Set Matrix Zeroes @ Python
			
原题地址:https://oj.leetcode.com/problems/set-matrix-zeroes/ 题意:Given a m x n matrix, if an element is 0 ...
 - maskrcnn_benchmark代码分析(3)
			
数据结构 数据加载 数据后处理
 - Remove Duplicates from Sorted Array II leetcode java
			
题目: Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For e ...
 - Permutations leetcode java
			
题目: Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the f ...