AOP Introductions(Extensions)
bill.burke Apr 15, 2003 12:15 PMWhat I had originally named Extensions has a real name in AOP I am told. Introductions.
Introductions are adding interfaces, methods, fields, constructors to an object or class:
POJO pojo = ...;
Cached cachedObj = (Cached)pojo;
cachedObj.flush();
where flush() is either delegated to an instance of an "introduced" class, or handled by an interceptor.
We will only support adding Interfaces. Either on a per class level, or a per instance level. Let's discuss per class first.
Class Introduction:
org.some.interface
org.some.other
This is the simplest to implement. The methods defined in the given interfaces will be added to the class and simple invoke down the interceptor chain. An interceptor is expected to handle the method invocation.
The next is:
org.some.interface
org.some.other
<delegate-class>org.some.delegate</delegate-class>
Introduced interface invocations will be delegated to an instantiation of the delegate-class. The delegate-class will be required to implement an empty constructor for the 1st iteration. If the extension class is advised, then a reference to the extended object will be placed within its metadata for reference.
Also there will be a configurable way to specify what interceptor chain should be traversed. The extended class's, the delegate-class's, and/or both.
The main problem I see with this is Serializable. Currently all AOP attached data and fields are not serialized across the wire. This is done on purpose because we want to support clients that are not using JBoss AOP. There are 2 things we can do for this. One, optionally provide a flag to make AOP fields non-transient, or use ClassProxy. AOP ClassProxy's are dynamically created classes that inherit from a base class and implement every public method of the base class to provide interceptor chains. They are used to provide interception for non-advised objects in AOP Remoting. They are serializable across the wire and retain their metadata. Actually. This ClassProxy construct is how will will support per instance introduction.
PER INSTANCE INTRODUCTIONS:
Per instanc introductions will be implemented using ClassProxy described above. Per instance introductions will be API driven. Meaning there will be no pre-XML config for this type of stuff.
Well that's it for now. That's my current brain dump. Implementation will follow later.
Bill