您的位置:首页 > 编程语言 > ASP

Aspect Oriented Programming(AOP) 介绍

2008-05-31 23:47 274 查看
什么是AOP?

:) = Aspect Oriented Programming


Business Rule | (AOP)

Security Permission |

Logging | --------------> Business Logic

Database Operations |

Web Service |


为什么AOP?

为了独立业务

怎样AOP?

举个例子

按照传统的写法写登陆业务

1bool isAdministrator = false;

3if(Users.ValidateUser(Context.User.UserName) == UserRole.Admministrator)

4if(!isAdministrator) throw new NoPermissionExpection();

8// Bussiness Code

9if(!Memebership.User.HasPermission) throw new NoPermissionExpection();

关于动态代理的部分

例如:

[Before(Memebership.User.HasPermission)]

public void ExecuteLogic()

public class ExecuteEngine

public void Run()

// TODO:: Get the attribute to find out if there is a before attribute。

// If there is, Run the Arrtibute Method First, then run the ExecuteLogic

}

}

框架

Spring, Aspect# 等等



关于AOP更多描述:


http://www.jdon.com/AOPdesign/jdon-aop.htm

http://wayfarer.cnblogs.com/articles/241024.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: