[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-dev] Runtime processing
|
We have a use case for weaving aspects at runtime, and to that end I
modified the AjBuildManager with an additional method:
byte[] weaveClassBytes(String className, byte[] classBytes)
In the current case, our system does this:
1) Calls the BuildManager with a normal batchBuild() call that only
includes the aspects that we are going to add.
2) When our custom classloader loads a new class it calls
weaveClassBytes() to add in the aspects defined.
Does anyone know if there is a problem with this? It seems to work
quite well and I can see that it would be possible to make a simple
launcher that runs programs this way so you could straightforwardly
instrument a non-aspect aware application with a set of aspects.
As an aside, we have also found that there is a need for resuable
advice. Is there a mechanism in AspectJ that I am missing? For
instance, I would like to define a pointcut and an advice separately
and then bind them in a 3rd place, i.e.:
pointcut method() : execution(public void Foo.bar());
advice timeMethod() = Object around() {
long start = System.currentTimeMillis();
Object result = proceed();
System.out.println(System.currentTimeMillis() - start);
return result;
}
bind timeMethod() : method();
Is there a better way that I am missing?
Sam