<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<bean id="userManager" class="com.jzg.spring.UserManagerImpl" />
<bean id="logHandler" class="com.jzg.spring.LogHandler" />
<aop:config>
<!-- 先声明一个aspect,这里logHandler为<bean id="logHandler">所指向的java类 -->
<!--securityHandler中有需要在被切入方法上执行的方法 -->
<aop:aspect id="logAspect" ref="logHandler">
<!-- 这里是匹配任意返回值的无参add前缀 的方法 -->
<!-- <aop:pointcut id="addAllMethod" expression="execution(* add*(..))"/> -->
<!-- execution(* com.jzg.spring.*.*(..)), 这里是匹配spring包下的所有方法 -->
<aop:pointcut id="AllMethod" expression="execution(* com.jzg.spring.*.*(..))" />
<!-- 按照AllMethod切入点的规定,在spring包下所有方法执行后都会执行一次 log() 方法 -->
<aop:after method="log" pointcut-ref="AllMethod" />
</aop:aspect>
</aop:config>
</beans>
package com.jzg.spring;
import org.aspectj.lang.JoinPoint;
public class LogHandler {
@SuppressWarnings("unused")
private void log(JoinPoint jp) {
Object o[] = jp.getArgs();
System.out.println(jp.getSignature());
System.out.println(o[0]);
System.out.println("-------log()----------");
}
}
分享到:
相关推荐
下面小编就为大家分享一篇Spring Aop之AspectJ注解配置实现日志管理的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
它实现了横切关注点的干净模块化,例如错误检查和处理、同步、上下文相关行为、性能优化、监控和日志记录、调试支持和多对象协议 为什么是方面? AOP 使我们能够轻松修改现有代码,并在不接触源代码本身的情况下添加...
uc_demouc_demo UC快速开发框架登录界面系统代码(数据字典)管理系统账号管理权限组管理系统日志查看Demo示范权限设置uc_demo项目是Union Componen项目中的一个用例。本用例是一个后台的全功能实现,包括以下功能:...
Spring AOP(面向切面编程)是Java高级编程中的重要组成部分,它允许程序员以声明的方式处理关注点(例如日志、事务管理等),而不是通过硬编码。本文深入分析了Spring AOP的实现机制,让读者能够更好地理解和应用这...
AOP实现的关键在于AOP框架自动创建的AOP代理,AOP代理主要分为静态代理和动态代理,静态代理的代表为AspectJ;而动态代理则以Spring AOP为代表。 何为切面? 一个和业务没有任何耦合相关的代码段,诸如:调用日志,...
AOP 采取横向抽取机制,取代了传统纵向继承体系的重复性代码,其应用主要体现在事务处理、日志管理、权限控制、异常处理等方面。 目前最流行的 AOP 框架有两个,分别为 Spring AOP 和 AspectJ。Spring AOP 使用纯 ...
APDPlat快速体验 ...24)、日志拦截使用AspectJ。 25)、上传备份文件到FTP使用Commons Net。 26)、JSON处理使用Jackson。 27)、分布式搜索和实时分析使用elasticsearch 标签:APDPlat Web框架
概念:面向切面编程,在不改变源码的情况下对方法进行增强,抽取横切关注点(日志处理,事务管理,安全检查,性能测试等等),使用AOP进行增强,使程序员只需要关注与业务逻辑编写. 专业术语 目标Target:需要增强的类 ...
(三) 搭建日志环境并配置显示DDL语句jar包 31 三、 Spring整合hibernate3事务 31 (一) Annotation注解方式配置事务管理 31 (二) Spring事务选项 35 (三) XML文件形式配置Spring事务管理 37 四、 HibernateTemplate ...
(三) 搭建日志环境并配置显示DDL语句jar包 31 三、 Spring整合hibernate3事务 31 (一) Annotation注解方式配置事务管理 31 (二) Spring事务选项 35 (三) XML文件形式配置Spring事务管理 37 四、 HibernateTemplate ...
Spring技术 Spring Ioc基础、Ioc注入技巧、对象高级装配(自动装配、模板装配、组件扫描特性、FactoryBean、对象生命周期)、Spring AOP原理、AspectJ、Spring JDBC支持、Spring事务及安全管理;Spring整合Hibernate...
11.9 日志 464 11.9.1 问题 464 11.9.2 解决方案 464 11.9.3 工作原理 464 11.10 运行单元和集成测试 466 11.10.1 问题 466 11.10.2 解决方案 467 11.10.3 工作原理 467 11.11 使用自定义布局和...
11.9 日志 464 11.9.1 问题 464 11.9.2 解决方案 464 11.9.3 工作原理 464 11.10 运行单元和集成测试 466 11.10.1 问题 466 11.10.2 解决方案 467 11.10.3 工作原理 467 11.11 使用自定义布局和...
提供了应用版本后台管理所需的API服务,使用HTML和ajax简单实现了应用版本管理界面。 使用了AOP对api请求进行动态日志记录。 实现通用的文件上传(包括多文件上传)和下载功能。 增加了请求流量以及请求权限的控制。...
通过Maven Profiles实现可移植性 11.2.1. 覆盖一个项目对象模型 11.3. 激活Profile 11.3.1. 激活配置 11.3.2. 通过属性缺失激活 11.4. 外部Profile 11.5. Settings Profile 11.5.1. 全局Settings ...