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 "after returning" joinpoint kind on a "void method(stuff)" 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 <<a hr= ef=3D"mailto:[email protected]"> [email protected]</a>> 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= ;"> </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;"> </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;"> </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;"> </span></font></p> <p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam= ily: Arial;"> <!-- Aspect to capture username in trxns--><br> <aspect class=3D"GetUserAspect" deployment-model=3D"perInstance"><br> <pointcut name=3D"SetUser" expression=3D"execution(<b><span style=3D"f= ont-weight: bold;">public static void com.xxx.core.audit.Log.setUser(..)</s= pan></b>)"/><br> <advice name=3D"storeUserName(StaticJoinPoint jp)" type=3D"after returning" bind-to=3D"SetUser"/><br> <param name=3D"test" value=3D"i got loaded"/><br> </aspect></span></font></p> <p><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size: 12pt= ;"> </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= ;"> </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= ;"> </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> public static void setUser(String message)<br> {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= ;"> </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= ;"> </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= ;"> </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> private static ThreadLocal userName =3D new ThreadLocal();<br> private AspectContext myAspectContext =3D null;<br> <br> public NextgenGetUserAspect(AspectContext ac){<br> myAspectContext =3D ac;<br> System.out.println("test init->" + myAspectContext.getParameter("test"));<br> } </span></font></p> <p><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size: 12pt= ;"> </span></font></p> <p><font face=3D"Arial" size=3D"2"><span style=3D"font-size: 10pt; font-fam= ily: Arial;"> public static void setUserName(String name) {<br> userName.set(name);<br> }<br> public static String getUserName() {<br> return (String) userName.get();<br> }<br> public Object storeUserName(StaticJoinPoint joinPoint) throws Throwable {<br> System.out.println("NextgenMonitoring SET USERNAME ")= ;<br> return null;<br> }</span></font></p> <p><font face=3D"Times New Roman" size=3D"3"><span style=3D"font-size: 12pt= ;"> </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;"> </span></font></p> </div> </div> </blockquote></div><br> ------=_Part_23396_894658.1194557917258--