博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SpringPython之AOP
阅读量:4919 次
发布时间:2019-06-11

本文共 1911 字,大约阅读时间需要 6 分钟。

#-*- coding: UTF-8 -*-#-------------------------------------------------------------------------------# Name:        ģ��1# Purpose:## Author:      Administrator## Created:     07-11-2012# Copyright:   (c) Administrator 2012# Licence:     
#-------------------------------------------------------------------------------from springpython.context import ApplicationContextfrom springpython.config import PythonConfigfrom springpython.aop import *import timeclass PerformanceInterceptor(MethodInterceptor): def invoke(self, invocation): start = time.time() results = invocation.proceed() stop = time.time() print "Method took %2f seconds" % (stop - start) return resultsclass WikiService: def AddWhileInt(self, a, b): result = a+b total = 10000000 while(total): total-=1 result+=1 return result def AddWhileTrue(self, a, b): result = a+b total = 10000000 while(total>0): total-=1 result+=1 return resultclass IocPythonContainer(PythonConfig): def __init__(self): super(IocPythonContainer, self).__init__() def PerformanceAdvisor(self): return RegexpMethodPointcutAdvisor( advice = [PerformanceInterceptor()], patterns = [".*.*"] ) def WikiService(self): return ProxyFactoryObject( target = WikiService(), interceptors =[self.PerformanceAdvisor()] ) def main(): container = IocPythonContainer() service = container.WikiService() result = service.AddWhileInt(100, 20) print result result = service.AddWhileTrue(100, 20) print resultif __name__ == '__main__': main()

转载于:https://www.cnblogs.com/ankier/archive/2012/11/08/2759780.html

你可能感兴趣的文章
Android中关于JNI 的学习(一)对于JNIEnv的一些认识
查看>>
BMP、GIF、JPEG、PNG以及其它图片格式简单介绍
查看>>
C语言学习之控制语句
查看>>
AtCoder - 2061 Tree Restoring
查看>>
C#位运算讲解与示例
查看>>
Delphi XE5教程11:Tokens
查看>>
python学习笔记-day9-1【发送邮件模块 yagmail】
查看>>
git错误:fatal: Not a git repository (or any of the parent directories): .git
查看>>
centos7安装openresty
查看>>
C艹 预备知识
查看>>
存储过程与函数的区别
查看>>
关于MYSQL group by 分组按时间取最大值的实现方法!
查看>>
aspx页面加载时清掉缓存
查看>>
跟bWAPP学WEB安全(PHP代码)--邮件头和LDAP注入
查看>>
eclipse中tomcat的安装或者集成,
查看>>
终端log保存
查看>>
LeetCode Wiggle Sort
查看>>
关于链表的基本操作包括内容
查看>>
combox下拉框获取项目list的name显示
查看>>
pl/sql下载
查看>>