I have recently been playing around with a layered Jave/J2EE framework called Spring. I came over a package called ‘aop’. That package really drew my attention on it. Thus I looked into a few classes that seemed to be the core one’s. It seems that they have built an AOP framework based on an open source project called AOP Alliance that provides the basic AOP constructs without the need of a special AOP language like AspectJ. They have done it using the Reflection API Java provides.
Given a similar API in Flash it would probably be possible to create a similar AOP framework for it. But that’s something I’m presently just dreaming about.
They have written a ‘little’ chapter on the aop framework called: Aspect Oriented Programming with Spring. I’d suggest you to refer to this article if you wanna learn more about it.
Archive for May, 2004
AOP: Spring Framework
AOP: Kinded Pointcuts
We have already worked with kinded pointcuts in the examples of the previous posts. But I haven’t explicitly explained what different types of kinded pointcuts exist and which join points they exactly capture. Here’s a list of the kinded pointcuts AspectJ provides:
> execution(MethodSignature/ConstructorSignature):
As you have probably already imagined this will capture the method or constructor execution matching the signature.
> call(MethodSignature/ConstructorSignature):
Such a pointcut captures the calls to methods matching the signature.
> get(FieldSignature):
This pointcut will capture the retrieval of the value of a field matching the signature.
> set(FieldSignature):
This will capture the write access to a field matching the signature.
> handler(TypeSignature):
This will capture executions of exception handlers.
Examples:
call(public * MyClass.*())
This would capture all calls to all public methods in the class MyClass that do not take any arguments.
set(private float MyClass.myField)
This would capture write access to the private field myField of the class MyClass.
These are the most common pointcuts. There do also exist pointcuts to capture the Object initialization and pre-initialization and so forth. But I won’t show them here.
Cross-Referencing
While refactoring the reflection part of the as2lib I came across an issue related to cross-referencing of static vars in Flash. Suddenly one of my static vars was undefined and I couldn’t guess why. I have minimized the code to only the core parts but it nevertheless enfolds three classes. Thus read on to hear what went wrong.
(more…)
