<?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/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd ">
<bean id="greetingService"
class="com.jesse.spring.simple.service.impl.GreetingServiceImpl">
<property name="string" value="Hello, Jesse!" />
</bean>
<bean id="point" class="com.jesse.spring.simple.service.Point">
</bean>
<aop:config>
<aop:aspect ref="point"> <!-- 创建切面 -->
<aop:pointcut id="greetPointcut" expression="execution(* *.greet(..))"/> <!-- 创建切入点并绑定greet方法 -->
<aop:before method="greetBefore" pointcut-ref="greetPointcut"/>
<aop:after method="greetAfter" pointcut-ref="greetPointcut"/>
</aop:aspect>
</aop:config>
</beans>
package com.jesse.spring.simple.service.impl;
import org.apache.log4j.Logger;
import com.jesse.spring.simple.service.GreetingService;
public class GreetingServiceImpl implements GreetingService {
private static final Logger logger = Logger
.getLogger(GreetingServiceImpl.class);
private String string;
@Override
public void greet() {
logger.info(this);
logger.info(string);
}
public String getString() {
return string;
}
public void setString(String string) {
this.string = string;
}
}
package com.jesse.spring.simple.service;
import org.apache.log4j.Logger;
public class Point {
private static final Logger logger = Logger.getLogger(Point.class);
public void greetBefore() {
logger.info("this is before method.....");
}
public void greetAfter() {
logger.info("this is after method.....");
}
}
[2013-10-26 03:32:05] INFO (Point.java:10) -this is before method.....
[2013-10-26 03:32:05] INFO (GreetingServiceImpl.java:15) -com.jesse.spring.simple.service.impl.GreetingServiceImpl@170eb6d
[2013-10-26 03:32:05] INFO (GreetingServiceImpl.java:16) -Hello, Jesse!
[2013-10-26 03:32:05] INFO (Point.java:14) -this is after method.....
[2013-10-26 03:32:05] INFO (Point.java:10) -this is before method.....
[2013-10-26 03:32:05] INFO (GreetingServiceImpl.java:15) -com.jesse.spring.simple.service.impl.GreetingServiceImpl@170eb6d
[2013-10-26 03:32:05] INFO (GreetingServiceImpl.java:16) -Hello, Jesse!
[2013-10-26 03:32:05] INFO (Point.java:14) -this is after method.....
分享到:
相关推荐
NULL 博文链接:https://306963591.iteye.com/blog/1129837
spring aop spring aop spring aop spring aop spring aop spring aop spring aop spring aop spring aop
spring aop jar 包
spring-aop-1.1.1.jar spring-aop-1.2.6.jar spring-aop-1.2.9.jar spring-aop-2.0.2.jar spring-aop-2.0.6.jar spring-aop-2.0.7.jar spring-aop-2.0.8.jar spring-aop-2.0.jar spring-aop-2.5.1.jar spring-aop-...
描述一下Spring AOP? 在Spring AOP中关注点(concern)和横切关注点(cross-cutting concern)有什么不同? AOP有哪些可用的实现? Spring中有哪些不同的通知类型(advice types)? Spring AOP 代理是什么? 引介...
3、对spring aop认识模糊的,不清楚如何实现Java 自定义注解的 4、想看spring aop 注解实现记录系统日志并入库等 二、能学到什么 1、收获可用源码 2、能够清楚的知道如何用spring aop实现自定义注解以及注解的逻辑...
基于注解实现SpringAop基于注解实现SpringAop基于注解实现SpringAop
Spring框架的关键组件之一是面向方面编程(AOP)框架。 面向方面的编程需要将程序逻辑分解成不同的部分。 此教程将通过简单实用的方法来学习Spring框架提供的AOP/面向方面编程。
Spring AOP简单demo 入门级的 advice
springaop依赖的jar包,spring版本2.5.6,如果需要,可以下载使用,欢迎各位评论指出不足
死磕Spring之AOP篇 - Spring AOP两种代理对象的拦截处理(csdn)————程序
spring aop的demo spring aop的demo
一个基于配置文件的Spring AOP的实现。实现了前置通知,后置通知,以及拦截器的功能,配置中有详细的注释。
Spring AOP 几个不同使用方法的完整例子,使用Junit4c测试, 在我的博客上有不同配置组合的说明,可以参考
AOP流程源码分析-SpringAOP中定义的类图AOP流程源码分析-SpringAOP中定义的类图AOP流程源码分析-SpringAOP中定义的类图AOP流程源码分析-SpringAOP中定义的类图AOP流程源码分析-SpringAOP中定义的类图AOP流程源码分析...
spring aop切面拦截指定类和方法实现流程日志跟踪 一般情况下,在不侵入业务代码的情况下,需要做流程日志跟踪是比较合理的 采用springaop切面思想
Spring aop Spring aop
AOP的意思就是面向切面编程。本文主要是通过梳理JDK中自带的反射机制,实现 AOP动态代理模式,这也是Spring AOP 的实现原理
开发工具 spring-aop-4.3.6.RELEASE开发工具 spring-aop-4.3.6.RELEASE开发工具 spring-aop-4.3.6.RELEASE开发工具 spring-aop-4.3.6.RELEASE开发工具 spring-aop-4.3.6.RELEASE开发工具 spring-aop-4.3.6.RELEASE...
springAOP所需jar包 springAOP所需jar包 springAOP所需jar包 springAOP所需jar包 springAOP所需jar包