Hi Andrew, actually, i am writing a custom monitoring tool that monitor the EJB call. it is supposed to be used in several projects.
As a non-intrusive monitoring tool, is it possible to create a 'plug-and-play' solution? or is it possible to auto-generate those sub-aspect? thank you. ppkluk Andrew Eisenberg wrote: > > Here is my suggestion, which I posted to the newsgroup. Reposting it > here in order to reach the larger audience of the mailing list. > > ------------ > One thing that you can do is create an abstract aspect that defines the > advice and an abstract pointcut. People who want to use your aspect need > to > create a concrete aspect and instantiate the pointcut. > > Eg- > > abstract aspect AbstractSessionBeanAspect { > protected abstract pointcut sessionBeanMethods(); > > before() : sessionBeanMethods() { > // do something > > } > } > > > aspect MySessionBeanAspect extends AbstractSessionBeanAspect { > protected pointcut sessionBeanMethods() : execution( > SessionBeanInterface.*(..)); > } > > On Wed, Jul 29, 2009 at 12:31 PM, Andy Clement<andrew.clem...@gmail.com> > wrote: >> Well if you can't hardcode the interface name then the you can intercept >> all >> method executions and then the JoinPoint.StaticPart state to determine at >> runtime if you are interested in it. >> before(): execution(* *(..)) { >> System.out.println(thisJoinPointStaticPart); >> } >> that may match a lot of places though. If you can exploit the existence >> of >> annotations, that may help, something like this to indicate the declaring >> type must have the @Remote annotation. >> before(): execution(* (@Remote *).*(..)) { >> System.out.println(thisJoinPointStaticPart); >> } >> >> Andy >> >> 2009/7/28 ppkluk <imperfectluk-...@yahoo.com.hk> >>> >>> Hi all, >>> >>> i am new to aspectj and i am trying to write aspect to capture the >>> method >>> of all a session bean (EJB 3.0 syntax). >>> >>> the methods i want to captures are the 'business method' in the session >>> bean. >>> As EJB 3.0 session bean can be created in the following form: >>> >>> -------------------------------------------------------------- >>> //interface defining the session bean method >>> public interface SessionBeanInterface { >>> public void advicedMethod(); >>> } >>> -------------------------------------------------------------- >>> >>> @Stateless(name="MySessionBean") >>> @Remote(SessionBeanInterface.class) //indicate SesionBeanInterface is >>> the >>> remote bussinesss interface >>> public class SessionBean implements SessionBeanInterface { >>> >>> public void advicedMethod(){ >>> //this method to be captured by before execution(...) pointcut >>> >>> } >>> >>> public void nonAdvicedMethod() { >>> //this method is NOT to be captured >>> } >>> } >>> ------------------------------------------------------------------- >>> >>> in this situation, is this possible to write pointcut to capture only >>> the >>> methods declared >>> in the SessionBeanInterface interface?? >>> >>> *** i CANNOT HARDCODE the interface type in the aspect as i am now >>> writing >>> a >>> *** generic tool aims to capture all the method execution. >>> >>> thank you. >>> >>> ppkluk >>> -- >>> View this message in context: >>> http://www.nabble.com/how-to-capture-method-joinpoints-in-EJB3-session-bean-interface--tp24703854p24703854.html >>> Sent from the AspectJ - users mailing list archive at Nabble.com. >>> >>> _______________________________________________ >>> aspectj-users mailing list >>> aspectj-users@eclipse.org >>> https://dev.eclipse.org/mailman/listinfo/aspectj-users >> >> >> _______________________________________________ >> aspectj-users mailing list >> aspectj-users@eclipse.org >> https://dev.eclipse.org/mailman/listinfo/aspectj-users >> >> > _______________________________________________ > aspectj-users mailing list > aspectj-users@eclipse.org > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > -- View this message in context: http://www.nabble.com/how-to-capture-method-joinpoints-in-EJB3-session-bean-interface--tp24703854p24734494.html Sent from the AspectJ - users mailing list archive at Nabble.com. _______________________________________________ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users