RE: [aspectwerkz-user] defining a new aspect at run-time
[email protected] Tue, 21 Jun 2005 18:44:16 -0400
| Newsgroups | gmane.comp.java.aspectwerkz.user |
|---|---|
| Message-ID | <3E62A5A0B8058845984FFA345CE894F2060CBF15@NSTMC007PEX1.ubsgs.ubsgroup.net> |
Hi again, Is there any way of knowing whether a hot deployment worked? Deployer.deploy always returns a handle, but there is no way of knowing whether it actually did something, and this is very confusing. Also, after a call to Deployer.deploy, I try to obtain an instance of the aspect through calls to Aspects.aspectOf(...) and different version of this method return different aspect instances, none of which is actually weaved. And this makes things even more confusing. Obviously my aspect is not deployed correctly or not deployed at all, but I have no way of knowing why :( Thanks, Boris |-----Original Message----- |From: Alexandre Vasseur [mailto:[email protected]] |Sent: Monday, June 06, 2005 2:32 AM |To: [email protected] |Subject: Re: [aspectwerkz-user] defining a new aspect at run-time | | |You should definitely use a deployment scope. Your pointcut is very |generic "call( bsh stuff)" and hence it will be quite expensive if you |don't use one. | |I would f.e. use: |// in aop.xml visible from classloader "loader" used thereafter |<deployment-scope name="bsh" expression="within(.... place likely to |call stuff...)"/> | |// get tge deployment scope (systemID refers to your xml) |DeploymentScope scope = SystemDefinition.getDefinitionFor(loader, |systemId).getDeploymentScope("bsh"); | |// invoke: |Deployer.deploy(Class aspect, String xmlDef, DeploymentScope scope); | |Alex | |On 6/3/05, [email protected] <[email protected]> wrote: |> 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. |> |> | 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.