ublic interface ISomeService {
public void doSome(); public String dade();
}
public class SomeService implements ISomeService {
//核心业务
public void doSome(){
System.out.println("我们都要找到Java开发工作,薪资6,7,8,9,10K");
} public String dade() {
System.out.println("==================");
return "add";
} }
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*; /**
* Created by QiuShao on 2017/7/31.
*/
@Aspect
public class MyAspect {
/*前置增强*/
@Before(value = "execution(* *..spring17.*.*(..))")
public void before(){
System.out.println("前置增强");
} /*后置增强*/
@AfterReturning(value = "execution(* *..spring17.*.*(..))")
public void after(){
System.out.println("后置增强");
}
/*环绕增强*/
@Around(value = "execution(* *..spring17.*.*(..))")
public Object around(ProceedingJoinPoint proceed) throws Throwable {
System.out.println("环绕前");
Object result=proceed.proceed();
System.out.println("环绕后");
if(result!=null){
return result;
/*String str=(String)result;
return str.toUpperCase();*/
}else {
return null;
}
}
}

配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
">
<!--01.目标对象-->
<bean id="someService" class="cn.bdqn.spring17.SomeService"></bean> <!--02.增强 通知-->
<bean class="cn.bdqn.spring17.MyAspect"></bean> <aop:aspectj-autoproxy/> </beans>

单侧

 // aspectj 注解
@Test
public void test011(){
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContextspring15.xml");
ISomeService service = (ISomeService) ctx.getBean("someService");
service.doSome();
String aa= service.dade();
System.out.println(aa); }

最新文章

  1. Web jquery表格组件 JQGrid 的使用 - 7.查询数据、编辑数据、删除数据
  2. Freemark基本语法知识(转)
  3. cocos2dx游戏开发——微信打飞机学习笔记(二)——游戏框架
  4. paip.提升效率--批量变量赋值 “多元”赋值
  5. 3、使用Oracle Logminer同步Demo
  6. Linux系统如何查看CPU型号等
  7. SVN二次开发——让SVN、TSVN(TortoiseSVN)支持windows的访问控制模型、NTFS ADS(可选数据流、NTFS的安全属性)
  8. Map 根据value 排序
  9. 深入理解JVM(三)——配置参数
  10. Linux通配符应用详解
  11. 文本处理三剑客之awk(No.1)
  12. js代码跑马灯效果-----轮播图字效果!
  13. 前端入门5-CSS弹性布局flex
  14. frameset,iframe框架之间如何互相调用变量、函数
  15. win10 + VS2010 + OpenCV2.4.10重编译OpenCV开发环境搭建
  16. Kafka 0.10问题点滴
  17. Matlab、R向量与矩阵操作 z
  18. UnicodeDecodeError: &#39;ascii&#39; codec can&#39;t decode byte 0x9c in position 1: ordinal not in range(128)
  19. 把多个js函数绑定到onload时间处理函数上
  20. 基础笔记1(进制,浮点,递归,floor,round和ceil)

热门文章

  1. 1091 Acute Stroke (30)(30 分)
  2. Python连接Mysql数据库_20160928
  3. tcpdump抓包工具用法说明
  4. Jenkins安装和配置FindBugs、PMD、CheckStyle等插件
  5. struts2的使用知识点
  6. 算法导论笔记——第十八章 B树
  7. IoT:template
  8. Arduino 元件
  9. CF-839B
  10. eval解析字符串问题