With the new release of the Enterprise Library of Microsoft patterns & practices team, it seems like AOP makes a great
and sudden come back in the .NET community. The latest release comes indeed with the
Policy
Injection Application Block, which is a kind of AOP framework that allows to "inject" the other Enterprise Library
application blocks (logging, exception handling, ...) into user code, and using a configuration file.
The implementation use remoting proxies to intercept method calls and inject policies, which has the major drawbacks to:
- Be limited to methods derived from MarshalByRefObject or exposing their semantics on an interface.
- Require instances to be created through a factory.
- Matching is performed at compile-time, so that runtime execution is faster.
- Policy Injection configuration does not have to be deployed.
- As with anything in PostSharp, remoting proxies and factories are not necessary.
- There is no CPU-expensive runtime matching.
- In some scenarios, make it easier to specify which policies should apply to methods (more flexible than the 'Tag' approach of EntLib).
- As with anything in PostSharp, remoting proxies and factories are not necessary.
- no need for factories,
- not limited to MarshalByRefObject,
- works also with static methods.
- A compile-time part whose principal role is to detect which methods needs to be 'interceptable', and adds kinds of 'event handlers' (OnMethodInvocation in our case) on these methods.
- A runtime part which is basically the implementation of the event handlers.