Aspect Oriented Programming(AOP) 介绍

什么是AOP?
:) = Aspect Oriented Programming

Business Rule             | (AOP)
Security Permission     |
Logging                     | --------------> Business Logic
Database Operations   |
Web Service               |

为什么AOP?
为了独立业务
怎样AOP?
举个例子
按照传统的写法写登陆业务

 

 1 ExpandedBlockStart.gif ContractedBlock.gif /**/ /* Traditional Way */
 2 None.gif bool  isAdministrator  =   false ;
 3 None.gif if (Users.ValidateUser(Context.User.UserName)  ==  UserRole.Admministrator)
 4 ExpandedBlockStart.gifContractedBlock.gif dot.gif {
 5InBlock.gif            isAdministrator = true;
 6ExpandedBlockEnd.gif}

 7 None.gif if ( ! isAdministrator)  throw   new  NoPermissionExpection();
 8 None.gif //  Bussiness Code
 9 ExpandedBlockStart.gifContractedBlock.gif /**/ /* -----------------------------------------------------------------
10InBlock.gif*   Aspect Oriented Programming
11InBlock.gif*   AOP指的是用面向方面的编程来解决面向方面的问题
12InBlock.gif*   一般包含: 1.切入点 2.方面问题的解决
13InBlock.gif*   在实现中一般加入了动态代理的成分反倒复杂了许多,包含了五个方面
14InBlock.gif*   1. 连接点 2. 接入点 3. 通知 4.方面 5. 引入
15ExpandedBlockEnd.gif------------------------------------------------------------------*/

16 None.gif if ( ! Memebership.User.HasPermission)  throw   new  NoPermissionExpection();

关于动态代理的部分
例如:

None.gif [Before(Memebership.User.HasPermission)]
None.gif
public   void  ExecuteLogic()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif        
// TODO:: Implement the business logic
ExpandedBlockEnd.gif
}

None.gif
public   class  ExecuteEngine
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif          
public void Run()
ExpandedSubBlockStart.gifContractedSubBlock.gif          
dot.gif{
InBlock.gif                  
// TODO:: Get the attribute to find out if there is a before attribute。
InBlock.gif                  
//        If there is, Run the Arrtibute Method First,  then run the ExecuteLogic
ExpandedSubBlockEnd.gif
          }

ExpandedBlockEnd.gif}

框架
Spring, Aspect# 等等

关于AOP更多描述:

http://www.jdon.com/AOPdesign/jdon-aop.htm
http://wayfarer.cnblogs.com/articles/241024.html

转载于:https://www.cnblogs.com/zhzkl/archive/2008/05/31/1211434.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值