Re: [aspectwerkz-user] trouble with static pointcuts 2.0

"Alexandre Vasseur" <[email protected]> Thu, 8 Nov 2007 22:38:37 +0100
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <[email protected]>
------=_Part_23396_894658.1194557917258
Content-Type: text/plain; charset=WINDOWS-1252
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

an "after returning" joinpoint kind on a "void method(stuff)" will likely
not match

use simply after perhaps


On Nov 7, 2007 10:36 PM, Michael Wyszinski <[email protected]> wrote=
:

>
>
> All, I have several aspects running correctly in weblogic but, having
> trouble advising a certain static method, I've tried several diff pointcu=
t
> definitions but it never works on this particular class. It has worked on=
 a
> similar non-static method=85.Any help to debug this would be appreciated
>
>
>
> Here are the details
>
>
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
>
> XML def
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
>
>
>
>        <!-- Aspect to capture username in trxns-->
>      <aspect class=3D"GetUserAspect" deployment-model=3D"perInstance">
>            <pointcut name=3D"SetUser" expression=3D"execution(*public sta=
tic
> void com.xxx.core.audit.Log.setUser(..)*)"/>
>            <advice name=3D"storeUserName(StaticJoinPoint jp)" type=3D"aft=
er
> returning" bind-to=3D"SetUser"/>
>            <param name=3D"test" value=3D"i got loaded"/>
>      </aspect>
>
>
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
>
> target
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
>
>
>
> package com.xxx.core.audit;
>
>
>
> public class Log
> {
>  public static void setUser(String message)
>  {stuff=85}
>
> }
>
>
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
>
> Aspect clas
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
>
>
>
> import org.codehaus.aspectwerkz.AspectContext;
> import org.codehaus.aspectwerkz.joinpoint.*;
>
>
>
>
> public class GetUserAspect{
>      private static ThreadLocal userName =3D new ThreadLocal();
>     private AspectContext myAspectContext =3D null;
>
>      public NextgenGetUserAspect(AspectContext ac){
>      myAspectContext =3D ac;
>     System.out.println("test init->" + myAspectContext.getParameter
> ("test"));
>      }
>
>
>
>   public static void setUserName(String name) {
>   userName.set(name);
>  }
>  public static String getUserName() {
>   return (String) userName.get();
>  }
>  public Object storeUserName(StaticJoinPoint  joinPoint) throws Throwable
> {
>   System.out.println("NextgenMonitoring SET USERNAME ");
>   return null;
>  }
>
>
>
> }
>
>
>

------=_Part_23396_894658.1194557917258
Content-Type: text/html; charset=WINDOWS-1252
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

<font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-family=
: Arial;">an &quot;after
returning&quot; joinpoint kind on a &quot;void method(stuff)&quot; will lik=
ely not match<br><br>use simply after perhaps<br><br></span></font><br><div=
 class=3D"gmail_quote">On Nov 7, 2007 10:36 PM, Michael Wyszinski &lt;<a hr=
ef=3D"mailto:[email protected]">
[email protected]</a>&gt; wrote:<br><blockquote class=3D"gmail_quote=
" style=3D"border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0=
.8ex; padding-left: 1ex;">








<div link=3D"blue" vlink=3D"purple" lang=3D"EN-US">

<div>

<p><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size: 12pt=
;">&nbsp;</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">All, I have several aspects running correctly in weblogic
but, having trouble advising a certain static method, I've tried several di=
ff
pointcut definitions but it never works on this particular class. It has wo=
rked
on a similar non-static method=85.Any help to debug this would be
appreciated</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">&nbsp;</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">Here are the details</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">&nbsp;</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">XML def</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">&nbsp;</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!-- Aspect to
capture username in trxns--&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;aspect class=3D&quot;GetUserAspect&quot;
deployment-model=3D&quot;perInstance&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;pointcut
name=3D&quot;SetUser&quot; expression=3D&quot;execution(<b><span style=3D"f=
ont-weight: bold;">public static void com.xxx.core.audit.Log.setUser(..)</s=
pan></b>)&quot;/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;advice
name=3D&quot;storeUserName(StaticJoinPoint jp)&quot; type=3D&quot;after
returning&quot; bind-to=3D&quot;SetUser&quot;/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;param
name=3D&quot;test&quot; value=3D&quot;i got loaded&quot;/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/aspect&gt;</span></font></p>

<p><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size: 12pt=
;">&nbsp;</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">target</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D</span></font></p>

<p><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size: 12pt=
;">&nbsp;</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">package com.xxx.core.audit;</span></font></p>

<p><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size: 12pt=
;">&nbsp;</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">public class Log<br>
{<br>
&nbsp;public static void setUser(String message)<br>
&nbsp;{stuff=85}</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">}</span></font></p>

<p><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size: 12pt=
;">&nbsp;</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">Aspect clas</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D</span></font></p>

<p><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size: 12pt=
;">&nbsp;</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">import org.codehaus.aspectwerkz.AspectContext;<br>
import org.codehaus.aspectwerkz.joinpoint.*;</span></font></p>

<p><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size: 12pt=
;">&nbsp;</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;"><br>
public class GetUserAspect{<br>
&nbsp;&nbsp;&nbsp;&nbsp; private static ThreadLocal userName =3D new
ThreadLocal();<br>
&nbsp;&nbsp;&nbsp; private AspectContext myAspectContext =3D null;<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp; public NextgenGetUserAspect(AspectContext ac){<br>
&nbsp;&nbsp;&nbsp;&nbsp; myAspectContext =3D ac;<br>
&nbsp;&nbsp;&nbsp; System.out.println(&quot;test init-&gt;&quot; +
myAspectContext.getParameter(&quot;test&quot;));<br>
&nbsp;&nbsp;&nbsp;&nbsp; }&nbsp; </span></font></p>

<p><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size: 12pt=
;">&nbsp;</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">&nbsp;&nbsp;public static void setUserName(String name) {<br>
&nbsp;&nbsp;userName.set(name);<br>
&nbsp;}<br>
&nbsp;public static String getUserName() {<br>
&nbsp;&nbsp;return (String) userName.get();<br>
&nbsp;}<br>
&nbsp;public Object storeUserName(StaticJoinPoint&nbsp; joinPoint) throws
Throwable {<br>
&nbsp;&nbsp;System.out.println(&quot;NextgenMonitoring SET USERNAME &quot;)=
;<br>
&nbsp;&nbsp;return null;<br>
&nbsp;}</span></font></p>

<p><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size: 12pt=
;">&nbsp;</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">}</span></font></p>

<p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam=
ily: Arial;">&nbsp;</span></font></p>

</div>

</div>


</blockquote></div><br>

------=_Part_23396_894658.1194557917258--