---
title: "AOP 作用 各种实现的优缺点"
author: "onlyor"
date: "2012-04-07T17:49:15Z"
tags: []
categories: ["企业架构"]
slug: "aop"
draft: false
lastmod: "2012-04-11T15:52:08Z"
id: 1478109
url: "https://onlyor.iteye.com/blog/1478109"
---

## AOP作用

　　Authentication 权限

　　Caching 缓存

　　Context passing 内容传递

　　Error handling 错误处理

　　Lazy loading 懒加载

　　Debugging 调试

　　logging, tracing, profiling and monitoring 记录跟踪 优化 校准

　　Performance optimization 性能优化

　　Persistence 持久化

　　Resource pooling 资源池

　　Synchronization 同步

　　Transactions 事务

 

ØSpring AOP（动态）：通过代理程序运行时织入

n优点：简单，易用

n缺点：性能略低，仅适用于方法调用，必须在Spring容器

ØAspect J（静态）：通过修改程序的字节码完成织入

n优点：性能好，功能强大，无需Spring容器

n缺点：修改需要重新编译，要引入Aspect J的编译器／织入器，复杂