ASPCTJ
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); }

ASPCTJ的更多相关文章
- [Spring框架]Spring AOP基础入门总结二:Spring基于AspectJ的AOP的开发.
前言: 在上一篇中: [Spring框架]Spring AOP基础入门总结一. 中 我们已经知道了一个Spring AOP程序是如何开发的, 在这里呢我们将基于AspectJ来进行AOP 的总结和学习 ...
- 11Spring_AOP编程(AspectJ)_概述
AspectJ 是一个框架 (第三方AOP框架 ),提供切面编程 ,编写一个Aspect 支持多个Advice和多个PointCut .对比前一种提到的传统的Aop编程,AspctJ更加的常用.Asp ...
- Spring基于AspectJ的AOP的开发——注解
源码:https://gitee.com/kszsa/dchart 一, AspectJ的概述: AspectJ是一个面向切面的框架,它扩展了Java语言.AspectJ定义了AOP语法所以它有一个专 ...
- spring中AspectJ的使用
目录 AspectJ: AOP术语 通知的类型 切入点表达式 基于xml的AspectJ编程 导入jar包 定义切面类 引入约束 AOP配置 基于注解的AspectJ编程 AspectJ: 什么是AO ...
随机推荐
- hyperledger fabric学习(1)
第一部分 环境搭建 说明 本次环境搭建是是现在虚拟机中,采用ubuntu 16.04版本,安装多次成功. 首先安装一些常用的工具 sudo apt-get update sudo apt-get in ...
- MySQL业务-发放的优惠券 用户使用情况_20161028
运营部门给用户发放优惠券,如果想监控优惠券的使用效果 优惠券使用率是个反映效果的很好指标 下面sql就是针对某天对特定用户发放的优惠券在发放日期以后每天的使用情况 SELECT e.城市,e.用户ID ...
- ACM学习历程—HDU 1059 Dividing(dp && 多重背包)
Description Marsha and Bill own a collection of marbles. They want to split the collection among the ...
- asm 兼容性、asm 主要参数管理
一 ASM instance 与 Database instance 的版本兼容性说明 1. Oracle 11gR2 的ASM 支持11g和10g的数据库实例.但是在Oracle Clusterwa ...
- LWIP的底层结构(物理层)
LWIP的底层结构(物理层) 转自:http://bluefish.blog.51cto.com/214870/158418 我们前面讲到说是ip层的发送和接收都是直接调用了底层,也就是设备驱动层的函 ...
- [poj3107/poj2378]Godfather/Tree Cutting树形dp
题意:求树的重心(删除该点后子树最大的最小) 解题关键:想树的结构,删去某个点后只剩下它的子树和原树-此树所形成的数,然后第一次dp求每个子树的节点个数,第二次dp求解答案即可. 此题一开始一直T,后 ...
- [Makefile] Makefile 及其工作原理
转自:https://www.linuxidc.com/Linux/2018-09/154071.htm 当你需要在一些源文件改变后运行或更新一个任务时,通常会用到 make 工具.make 工具需要 ...
- POJ 3255 Roadblocks (次短路)
题意:给定一个图,求一条1-n的次短路. 析:次短路就是最短路再长一点呗,我们可以和求最短路一样,再多维护一个数组,来记录次短路. 代码如下: #pragma comment(linker, &quo ...
- Linux 基础命令(一)
Linux 基础: https://www.cnblogs.com/linhaifeng/articles/6045600.html Linux 比 Windows 更稳定做服务器,开发出来的软件需要 ...
- css样式也技巧
目录 关于iPhone的点击事件绑定无效的处理方法 https://blog.csdn.net/u014477038/article/details/52527194 去掉a.button.input ...