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. 如何将 Python 程序打包成 .exe 文件?

    有不少订阅本公众号的朋友都不是玩 Python,甚至都不是计算机相关专业的,当我给他们一个 Python 程序时,他们是完全不知道该怎么运行的. 于是我想是不是可以将我的程序打包成可执行文件,直接运行 ...

  2. The current .NET SDK does not support targeting .NET Core 2.2

    The current .NET SDK does not support targeting .NET Core 2.2 1. 奇怪的错误 最近遇到了一件奇怪的事, The current .NET ...

  3. ReSIProcate源码目录下功能说明

    1.basicCall,basicMessage,basicRegister,resip_test测试用的 2.db_static Sleepy Cat开发的Berkeley DB 3.dum为Dia ...

  4. 使用superobject 解析Json数据

    接口数据有如下规范{"error": 0, "msg": "", "data": ...} 其中数据data类型不确定. ...

  5. .Net锦囊-C#,.Net发送邮件三种方法…

    最近公司由于一个R&I项目的需要,用户要求在购买产品或出货等一些环节,需要发送邮件提醒或者说每周一让系统自动采集数据发送一封E-mail,因此我也就找来相关资料,写了一个Demo分享给大家,大 ...

  6. 实验楼之Linux快捷、用户及文件权限、文件查看

    实验二 知识点1:通常不是直接与系统打交道,而是通过一个叫做Shell的中间程序. shell即是用户交互的界面,又是控制系统的脚本语言.常用的有bash. zsh, ksh, csh, 命令行模式: ...

  7. 卡内操作系统COS

    https://wenku.baidu.com/view/dbaa94916bec0975f465e2e8.html 智能卡与cos技术简析: http://www.360doc.com/conten ...

  8. array mysql_fetch_row(resource result)

    array mysql_fetch_row(resource result) 函数返回从结果集result中取得的行生成的数组,若到了最后一行之后则返回false,每个结果的列存储在一个数组的单元中 ...

  9. Linux 97个常用命令

    ls [选项] [目录名 | 列出相关目录下的所有目录和文件 -a 列出包括.a开头的隐藏文件的所有文件 -A 通-a,但不列出"."和".." -l 列出文件 ...

  10. To the max(求最大子矩阵和)

    To the Max Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 47985   Accepted: 25387 Desc ...