[aspectwerkz-user] defining a new aspect at run-time
[email protected] Fri, 3 Jun 2005 11:33:23 -0400
| Newsgroups | gmane.comp.java.aspectwerkz.user |
|---|---|
| Message-ID | <3E62A5A0B8058845984FFA345CE894F2060CBEEA@NSTMC007PEX1.ubsgs.ubsgroup.net> |
Hi all,
After spending some time evaluating aspectJ and aspectwerkz, I decided the latter was a better fit for my purpose because of its dynamic nature. I was able to set it up to use native hotswap etc.
Now I would like to introduce a new aspect at run-time:
xmlDef="<aspect class='test.com.ubs.firc.support.aspect.GenericMethodDecorator'> " +
"<pointcut name='allMethods' expression='call(* bsh.This.toString())'/>" +
"<advice name='decorate' type='around' bind-to='allMethods'/>" +
"</aspect>";
h = Deployer.deploy(GenericMethodDecorator.class, xmlDef);
Debugging through the AspectWerkz code, this seems impossible. One can only "change" the definition of an existing aspect, but not introduce a new one (because JoinPointFactory.COMPILATION_INFO_REPOSITORY is empty). I have no aop.xml, no aspects or aspect config files whatsoever are declared at startup. However, I'm sure it worked at some point. Why it worked I have no idea. After to two lines above, I started trying to get a hold on the aspect instance calling various 'aspectOf' methods in the Aspects class. The one that eventually gave me the correct aspect instance was
a = Aspects.aspectOf(bsh.This.class.getClassLoader(),
"test.com.ubs.firc.support.aspect.GenericMethodDecorator");
Anyway, is it in principle possible to do what I'm trying to do? I'm willing to hack into the AspectWerkz source code if need be....
Thanks,
Boris
Visit our website at http://www.ubs.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.