[Meinds-developers] Aspect oriented framework, first go
Brought to you by:
emcs,
rickardoberg
|
From: Rickard <ri...@xp...> - 2001-11-28 14:27:49
|
Hey I have now finished the first working version of an Aspect Oriented Programming (AOP) framework. It is very simple, yet extremely powerful. I should be very useful as the base for the object model of Meinds. The main features: * You can add behaviour to any object. This will allow the object to be casted to the interface of the new behaviour, and the methods in the additional interface are invokable. The methods are routed to aspects instead of the original object. * You can add interceptors to any object, including behaviour aspects. This will allow you to do custom things on each call to the object. The behaviour itself may be a composite object, but I haven't begun thinking about what weird possibilities that will bring :-) The example I have created contains two main object types: Individuals and UserGroups. Individuals have the ACL, Member, and User aspects attached to them. The basic object itself that these are attached to is a simple string (the id). Hence, the object itself does not provide much functionality, except toString(), hashCode(), and equals() implementations (from java.lang.String). UserGroups have the ACL, Member, and Group aspects attached to them. The basic object itself is again a string. The ACL, Member, and Group aspects have the CallLog and ACLCheck interceptors on top of them, so any call to them will log the call to System.out, and do an ACLCheck against the ACL of the same object. The ACLCheck implementation is fairly advanced, and allows for inherited ACL's both on the user and resource side. For example, if John is a member of the Admin UserGroup, and Admin may access the Sara Individual, then John may access Sara because of the transitive ACL check logic. The code are in four parts(/packages): * The main objects and object builders (for Individuals and UserGroups). * The aspects and their factories. * The interceptors and their factories. * The framework classes. There's also a fairly interesting test class that tests various uses of the example, mainly doing ACL-checks in complex ways. That should be all that's needed to allow you to look in the code and understand what's going on. I have uploaded a zip with both source and compiled code to SourceForge (check out the "aspects" release). run from /build/result with "java aspects.test.Test". A bunch of ACL tests will be executed. Most of the test messages are from the interceptors, and some are from behaviours. What you'll want to take a look at is the test source code, how the different behaviour aspects are coded, and well, how it fits together. Shouldn't be that hard to trace (especially if you're an IntelliJ user ;-). Play around. /Rickard -- Rickard Öberg |