[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[ews.eclipse.technology.aspectj] QUESTION: Class wrapping at runtime FEATURE
|
Hi,
I want to ask if this should be possible:
In VM is a class named "SessionImpl" which implements interface Session.
For example we say tha Session interface has only one method called "open".
I want to wrap SessionImpl this way: that before calling to this method
something happens and after also.
So I want to change this method byte code, which is loaded in VM.
so I specify something like this to achieve that:
RuntimeAspect extends SessionImpl implementing Session {
/* Here is an empty param list, but other methods can have*/
before: public void open() {
System.out.println("before call of open() on each object of type
SessionImpl");
}
/* Here is an empty param list, but other methods can have*/
after: public void open() {
System.out.println("after call of open() on each object of type
SessionImpl");
}
}
This wrapping can be done programmatically directly from code.
Example:
if (obj iswrapped by RuntimeAspect) {
wrap(obj, RuntimeAspect.class);
} else {
System.out.println("obj is already wrapped :-)");
}
// END
Wrapping could be applied on an specific interface. Wrapping can have
limited namespace. etc...
Is something like this alredy present in AspectJ? If not should it be a plan
to do this in a future?
Thanks John