- 浏览: 107410 次
- 性别:
- 来自: 北京
最新评论
-
nwpu7:
解决问题,感谢感谢
org.hibernate.hql.ast.HqlToken 错误weblogic异常 -
zhangna307:
如果已经有对应的hibernte-cfg.xml文件,还是报这 ...
Could not instantiate cache implementation异常处理 -
zzw118:
不错,解决了我的问题!
Could not instantiate cache implementation异常处理 -
flank.tai:
女孩的技术都这么牛!!顶。不过图片看不了呀!!!
深度技术 USB启动维护盘制作工具 -
supercode:
dell的服务器与自己diy的相同配置,价格高出多少左右
Dell PowerEdge 2800 服务器 Windows 2003安装手册
请先看代码
package aop; public interface SomeService { void someMethod(); void someInnerMethod(); }
package aop; import org.apache.log4j.Logger; import org.springframework.context.ApplicationContext; public class SomeServiceImpl implements SomeService { private static final Logger log = Logger.getLogger(SomeServiceImpl.class); protected static ApplicationContext ctx; public void someMethod() { someInnerMethod(); log.debug("someMethod"); } public void someInnerMethod() { log.debug("someInnerMethod"); } }
package aop; package com.gxlu.srm; import junit.framework.TestCase; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class SomeServiceTest extends TestCase { protected void setUp() throws Exception { String[] paths = { "classpath:applicationContext-aop.xml" }; ctx = new ClassPathXmlApplicationContext(paths); } public void testAop() { SomeService someService = (SomeService) ctx.getBean("someService"); someService.someMethod(); someService.someInnerMethod(); } }
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="debugInterceptor" class="org.springframework.aop.interceptor.DebugInterceptor"/> <bean id="someServiceTarget" class="aop.SomeServiceImpl"/> <bean id="someService" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"><value>aop.SomeService</value></property> <property name="target"><ref local="someServiceTarget"/></property> <property name="interceptorNames"> <list> <value>someAdvisor</value> </list> </property> </bean> <bean id="someAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"> <property name="advice"><ref local="debugInterceptor"/></property> <property name="patterns"> <list> <value>aop\.SomeService\.someMethod</value> <value>aop\.SomeService\.someInnerMethod</value> </list> </property> </bean> </beans>
log4j.logger.org.springframework.aop=DEBUG log4j.logger.aop=DEBUG
日志显示
[srm] 2006-12-24 23:06:16.953 < INFO> [main] org.springframework.aop.framework.DefaultAopProxyFactory.<clinit>(61) | CGLIB2 not available: proxyTargetClass feature disabled [srm] 2006-12-24 23:06:16.984 <DEBUG> [main] org.springframework.aop.framework.ProxyFactoryBean.addInterface(216) | Added new aspect interface: aop.SomeService [srm] 2006-12-24 23:06:17.015 <DEBUG> [main] org.springframework.aop.framework.ProxyFactoryBean.initializeAdvisorChain(420) | Configuring advisor or advice 'someAdvisor' [srm] 2006-12-24 23:06:17.015 <DEBUG> [main] org.springframework.aop.framework.ProxyFactoryBean.addAdvisorOnChainCreation(526) | Adding advisor or TargetSource [org.springframework.aop.support.RegexpMethodPointcutAdvisor: advice [org.springframework.aop.interceptor.DebugInterceptor@126804e], pointcut patterns {aop\.SomeService\.someMethod, aop\.SomeService\.someInnerMethod}] with name [someAdvisor] [srm] 2006-12-24 23:06:17.015 <DEBUG> [main] org.springframework.aop.framework.ProxyFactoryBean.addAdvisorOnChainCreation(535) | Adding advisor with name [someAdvisor] [srm] 2006-12-24 23:06:17.015 <DEBUG> [main] org.springframework.aop.framework.ProxyFactoryBean.freshTargetSource(549) | Not refreshing target: bean name not specified in interceptorNames [srm] 2006-12-24 23:06:17.015 <DEBUG> [main] org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(109) | Creating JDK dynamic proxy for [aop.SomeServiceImpl] [srm] 2006-12-24 23:06:17.062 <DEBUG> [main] org.springframework.aop.interceptor.DebugInterceptor.invokeUnderTrace(57) | Entering invocation: method 'someMethod', arguments []; target is of class [aop.SomeServiceImpl]; count=1 [srm] 2006-12-24 23:06:17.062 <DEBUG> [main] aop.SomeServiceImpl.someInnerMethod(17) | someInnerMethod [srm] 2006-12-24 23:06:17.078 <DEBUG> [main] aop.SomeServiceImpl.someMethod(13) | someMethod [srm] 2006-12-24 23:06:17.078 <DEBUG> [main] org.springframework.aop.interceptor.DebugInterceptor.invokeUnderTrace(60) | Exiting invocation: method 'someMethod', arguments []; target is of class [aop.SomeServiceImpl]; count=1[srm] 2006-12-24 23:06:17.078 <DEBUG> [main] org.springframework.aop.interceptor.DebugInterceptor.invokeUnderTrace(57) | Entering invocation: method 'someInnerMethod', arguments []; target is of class [aop.SomeServiceImpl]; count=2 [srm] 2006-12-24 23:06:17.078 <DEBUG> [main] aop.SomeServiceImpl.someInnerMethod(17) | someInnerMethod [srm] 2006-12-24 23:06:17.078 <DEBUG> [main] org.springframework.aop.interceptor.DebugInterceptor.invokeUnderTrace(60) | Exiting invocation: method 'someInnerMethod', arguments []; target is of class [aop.SomeServiceImpl]; count=2
单独进入'someInnerMethod'时 AOP起作用
但通过'someMethod'调用someInnerMethod时为什么没有出现Entering invocation: method 'someInnerMethod'的日志?
是否SpringAOP不支持嵌套?!
发表评论
-
求100以内的质数
2011-01-11 12:42 902题目:除了能被自身和1整除外,不能被其他数整除的数,为素数 ... -
整理开始
2010-03-15 16:49 770将近半年没来javaeye了,自己的知识没能及时梳理。从今天开 ... -
dddd
2009-09-16 17:11 795ddddddddd -
java文件上传下载
2009-09-16 17:07 5502文件上传在web应用中非常普遍,要在jsp环境中实现文件上传功 ... -
实现Ext表单对checkBoxGroup的统一管理
2009-08-11 13:21 13511 对于类型是checkboxgroup的数据,数据库中保存数 ... -
cvsnt 配置
2009-06-03 15:51 1086CvsNT设置1.安装CvsNT,并 ... -
发生算术溢出或其它算术异常。
2009-05-26 17:16 3686今天报了一个bug,sql在DB2执行的时候报“发生算术溢出或 ... -
回车代替点按钮提交
2009-05-22 16:46 1493输入框+按钮 完成的操作和 输入框+回车 完成一样的操作 & ... -
eclipse下修改代码重启tomcat的问题
2009-05-04 17:40 2255忍受了很久的eclipse下修改代码重启tomcat的问题,今 ... -
urlrewritefilter 例子
2009-04-17 17:31 1135我在tomcat下跑通了一个例子,关于urlRewritefi ... -
正则表达式
2009-03-20 17:35 820如果你曾经用过Perl或任何其他内建正则表达式支持的语言 ... -
正则表达式大全
2009-03-20 16:35 875常用正则表达式大全! ... -
Could not instantiate cache implementation异常处理
2009-03-06 14:34 7966今天遇到了一个很奇怪的问题 我照例增加了一套新功能,但一切就 ... -
整理分页
2009-02-24 16:28 846从今天开始打算整理一下分页、上传下载、程序里调用存储 ... -
Dell PowerEdge 2800 服务器 Windows 2003安装手册
2009-02-06 15:40 2218Dell PowerEdge 2800 服务器 W ... -
新年第一天的工作
2009-02-05 11:50 723初十一来上班了,工作安排是解决河北bug,但是公司服务器dow ... -
深度技术 USB启动维护盘制作工具
2009-02-05 11:27 5907前言 大容量的移动硬盘和U盘已经越来越普及,很多朋友希望将 ... -
Tomcat:IOException while loading persisted session
2009-01-05 10:20 854错误描述:....while loading persiste ... -
display tag
2008-12-29 10:19 4273DisplayTag Tutorial by DarrenWa ... -
eclipse快捷键大全
2008-12-17 17:11 583Ctrl+1 快速修复(最经典的快捷键,就不用多说了)Ctrl ...
相关推荐
spring aop jar 包
spring aop spring aop spring aop spring aop spring aop spring aop spring aop spring aop spring aop
描述一下Spring AOP? 在Spring AOP中关注点(concern)和横切关注点(cross-cutting concern)有什么不同? AOP有哪些可用的实现? Spring中有哪些不同的通知类型(advice types)? Spring AOP 代理是什么? 引介...
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-...
2、能够清楚的知道如何用spring aop实现自定义注解以及注解的逻辑实现 (需要知道原理的请看spring aop源码,此处不做赘述) 3、可在现有源码上快速进行功能扩展 4、spring boot,mybatis,druid,spring aop的使用
基于注解实现SpringAop基于注解实现SpringAop基于注解实现SpringAop
spring aop的demo spring aop的demo
springaop依赖的jar包,spring版本2.5.6,如果需要,可以下载使用,欢迎各位评论指出不足
死磕Spring之AOP篇 - Spring AOP两种代理对象的拦截处理(csdn)————程序
Spring框架的关键组件之一是面向方面编程(AOP)框架。 面向方面的编程需要将程序逻辑分解成不同的部分。 此教程将通过简单实用的方法来学习Spring框架提供的AOP/面向方面编程。
Spring AOP 几个不同使用方法的完整例子,使用Junit4c测试, 在我的博客上有不同配置组合的说明,可以参考
Spring aop Spring aop
spring aop切面拦截指定类和方法实现流程日志跟踪 一般情况下,在不侵入业务代码的情况下,需要做流程日志跟踪是比较合理的 采用springaop切面思想
开发工具 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...
AOP的意思就是面向切面编程。本文主要是通过梳理JDK中自带的反射机制,实现 AOP动态代理模式,这也是Spring AOP 的实现原理
spring aop
springAOP所需jar包 springAOP所需jar包 springAOP所需jar包 springAOP所需jar包 springAOP所需jar包
springAOP详解
Spring AOP简单demo 入门级的 advice
NULL 博文链接:https://306963591.iteye.com/blog/1129837