How to Choose an AOP Framework?
2005-09-13 15:07
344 查看
Return to Contents
4. How to Choose an AOP Framework?
4.1 DynamicProxy or IL Level Weaving
Generally, the AOP frameworks mentioned in last chapter can be divided into two categories: DynamicProxy and IL Level Weaving.
4.1.1 DynamicProxy
An AOP framework based on DynamicProxy, like Aspect#, dynamically (at runtime) constructs and builds sub classes of classes wanted to be intercepted with advices according to the configurations. Because it depends on inheritance, there come some implicit constraints: classes wanted to be intercepted must be un-sealed (inheritable); methods or properties of classes wanted to be intercepted must be virtual (overridable). In fact, an AOP framework of this kind is an extension of the DynamicProxy Pattern, including a set of configuration language and helper and factory classes for creating proxy objects or doing advising and introducing. For more about DynamicProxy Pattern, see Castle Project/DynamicProxy.
4.1.2 IL Level Weaving
Different from DynamicProxy, IL Level Weaving has less limitation. In essence, an AOP framework of this kind directly accesses/modifies the compiled IL code format assemblies, so in theory, any kinds of modifications and controlling to existing assemblies (unobfuscated) are possible. So through it, it becomes easy to do any AOP operations to existing assemblies, such as advising and introducing. But mostly this kind of processing can be done only at static time or build time. (Another so called load-time weaving is only the composition use of System.Assembly.Load and static-time or build-time processing.) And of course, specific IL Level Weaving framework must have its specific additional limitations.
4.2 Different Configuration Methods
Each AOP framework must have its specific configuration language. Although the format of a configuration language may mot affect much of the performance and implementing essence of the framework, it is the user interface of the framework and it represents how easy it is for users to use the AOP framework. There are four most common configuration methods:
Custom script like configuration language, e.g. Aspect#.
Xml based configuration, e.g. AspectDNG.
Custom Attribute Classes based Configuration, e.g. PapierLoom.Net (Dynamic Part of Loom.Net)
AspectJ like specific programming language extension with extended compiler, e.g. Eos.
4.3 Suggestion
How to choose the most suitable AOP framework for your project depends on the facts of your project.
If your project is a completely new one from design, which means your project doesn't depend on lots of existing codes, then all mentioned frameworks are suitable. So you should just choose the most familiar and the most stable one. And I suggest Aspect# and AspectDNG.
If your new project based on lots of existing code that expensive to change or based on existing assemblies without source code, AOP frameworks based on IL level weaving become the only choice. And I suggest AspectDNG.
Briefly, If you are not sure which one to choose, choose an IL level weaving based framework will not be too worse. And I suggest AspectDNG.
相关文章推荐
- How to Choose an AOP Framework?
- MSMQ&Com+ Service: How to create an Com+ Service in .NetFramework
- 1. Introduce how to import the Spring Framework sourcecode into an eclipse project 【analyze spring framework source 】
- How to map an Entity framework model to a table name dynamically
- How to choose an in-circuit emulator
- All-In-One Code Framework(AIO): 如何使用C#编写进程外的COM组件 (How to write an out-of-proc COM server in C#)
- HOW to Use QP_PREQ_PUB.PRICE_REQUEST API to Price an Item
- Javascript: How to enumerate property of an object ?
- HOWTO Build an RT-application
- zstu 2428 How to be An ACMan
- How to Copy an Assembly From the GAC to the File System
- How to create an RMI system
- How to format strings in an array in ruby?
- Stealing the Network: How to Own an Identity
- How to Make an Exe File
- How to sign an IIS SSL certificate request using OpenSSL
- How to Choose the Best Way to Pass Multiple Models in ASP.NET MVC
- An instance of “(null)” is already running. Choose “Stop” to terminate and launch a new instance.
- How to Distinguish a Physical Disk Device from an Event Message
- <<How to setup an iSCSI target using tgtadm>>