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的更多相关文章

  1. [Spring框架]Spring AOP基础入门总结二:Spring基于AspectJ的AOP的开发.

    前言: 在上一篇中: [Spring框架]Spring AOP基础入门总结一. 中 我们已经知道了一个Spring AOP程序是如何开发的, 在这里呢我们将基于AspectJ来进行AOP 的总结和学习 ...

  2. 11Spring_AOP编程(AspectJ)_概述

    AspectJ 是一个框架 (第三方AOP框架 ),提供切面编程 ,编写一个Aspect 支持多个Advice和多个PointCut .对比前一种提到的传统的Aop编程,AspctJ更加的常用.Asp ...

  3. Spring基于AspectJ的AOP的开发——注解

    源码:https://gitee.com/kszsa/dchart 一, AspectJ的概述: AspectJ是一个面向切面的框架,它扩展了Java语言.AspectJ定义了AOP语法所以它有一个专 ...

  4. spring中AspectJ的使用

    目录 AspectJ: AOP术语 通知的类型 切入点表达式 基于xml的AspectJ编程 导入jar包 定义切面类 引入约束 AOP配置 基于注解的AspectJ编程 AspectJ: 什么是AO ...

随机推荐

  1. BZOJ1251 序列终结者(Splay平衡树)(占位)

    网上有许多题,就是给定一个序列,要你支持几种操作:A.B.C.D.一看另一道题,又是一个序列 要支持几种操作:D.C.B.A.尤其是我们这里的某人,出模拟试题,居然还出了一道这样的,真是没技术含量…… ...

  2. MySQL多个条件以什么表当做主条件表_20161111周五

    前两天有事情 停了2天 数据需求:1.活动日期11.8-11.10订单2.单笔订单购买A类产品 B类产品满足68元.且连续3天下单的用户ID 首先第一个条件很简单,主要是第二个条件 第二个条件是 且 ...

  3. jdk安装图解--windows系统(第一次安装和第二次安装区别)

    第一次安装可参考 https://jingyan.baidu.com/article/22fe7cedc9b93e3003617f64.html 第二次安装,如已经配置好环境变量,cmd下执行java ...

  4. tyvj1124花店橱窗——有限制的DP

    题目:http://www.joyoi.cn/problem/tyvj-1124 此题首先注意一束花能往哪些花瓶中放置:原本应放在本位置,但因为有多余花瓶,故可以有些变动,范围在i~i+v-f间: 假 ...

  5. win32 UNICODE 支持

    #include <string> #ifdef _UNICODE #define tstring std::wstring #define __T(quote) L##quote #el ...

  6. opencv报错 error: (-215) size.width>0 && size.height>0 in function cv::imshow

    使用opencv读取摄像头并且显示事出现此问题: 后来发现是图像为空时的错误,加入: if(!frame.empty()) imshow("video",frame); 完整的代码 ...

  7. AR/VR-AR:AR

    ylbtech-AR/VR-AR:AR 增强现实技术(Augmented Reality,简称 AR),是一种实时地计算摄影机影像的位置及角度并加上相应图像.视频.3D模型的技术,这种技术的目标是在屏 ...

  8. 创建oracle数据库图示(一步一步教你安装oracle)

    123456 密码 版权声明:本文为博主原创文章,未经博主允许不得转载.

  9. fkmu

    杭州赛区J:考虑实质上是求解 (a,b) = 1 且 a*b<=n的数对个数,枚举a,对b容斥. trickgcd:考虑反向求解,即为ans[x] -= ans[t*x],注意到因为反向求所以余 ...

  10. vim跳转到文件的指定偏移位置

    :goto 偏移量 例如:偏移到文件的第100个字节处 :goto 100