Geeks With Blogs
Greg Young Greg.ToString()

Sorry for spamming but I have had a few posts stuck in my head for a few weeks and I am sitting at my desk in a position I have resigned waiting out my time. Obviously I will not be receiving any new projects and all old projects are on wait of other resources = Bored Greg.


Continuing with the dynamic proxy I created a DSL for runtime based aspect assignment.

One thing that I did which was a bit different than anything I had seen done before was that I allowed attributes to map aspects.


In the assignment language you can say

Assign to Attribute


Assign to Method Level Attribute


Assign to Class Level Attribute

The first statement will assign an aspect to any method that has the attribute defined at either it's method level or at the class level that contains it.

The second statement will assign an aspect to any method that specifically declares the attributte at it's method level

The last statement will assign an aspect to any method that has the attribute declared at the class level.

One can also add an optional Having clause where you can access the public properties of the attribute


i.e. Having RoleType=“Admin“ and UseSecurity=true

This simply allows you to filter the assignment.

This addition was invaluable to my dynamic proxy and IMHO really helps bridge the gap between aspect based code and attribute based code. The gives me the big pro of having a simple code based declarative method of defining a behavior and at the same time it keeps me from having to pay the penalty of going through reflections (and a special handling object) in order to process the attributes.

There are some pitfalls to this methodology, one of the largest is that since the metadata is defined as an attribute a re-compile is required to change it. I am at this point leaving it to the developer to decide when it is good to use the attribute and when it is bad :)

What is really nice about this is it allows me to define “Types“ of join points via the use of attributes. In other words this allows me to group method types which are similar points to simplify my aspect assignment (1 line instead of hundreds or thousands). It also allows me to go and refactor those places that were using attribute based programming to use aspects instead quite easily :D


Anyone else have any thoughts on this?



Posted on Tuesday, January 24, 2006 1:01 PM AOP | Back to top

Comments on this post: Dynamic Proxy and Attributes

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Greg Young | Powered by: