Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] pointcuts from a properties file



Charlie,

Please see the Tracing examples in Chapter 3 of the Programming Guide
(http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/progguide/examples-development.html)
 to find out more about abstract pointcuts and library aspects. Several
chapters of our new book Eclipse AspectJ
(http://www.awprofessional.com/title/0321245873) go into more depth.

Wes is referring to the new AspectJ 5 load-time weaving support which is
configured using XML and allows you to define simple concrete aspects by
declaring pointcuts. Read more about it in the Developer's Notebook
(http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/ajdk15notebook/index.html).
 We are considering allowing this feature to be used for compile-time and
post-compile (binary) weaving too.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/

"Wes Isberg" <wes@xxxxxxxxxxxxxx>@eclipse.org on 26/01/2005 01:37:50

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:    aspectj-users-admin@xxxxxxxxxxx


To:    aspectj-users@xxxxxxxxxxx
cc:
Subject:    Re: [aspectj-users] pointcuts from a properties file



wrt this...
> I can't really find the javadoc that says whether
> "execution"
> (or "call" or any of the other methods) takes a String or not.

These are pointcuts, not methods, and can be considered to
exist only at compile/weave-time.  The documentation is in the
AspectJ programmers guide.

Matt's right about abstract aspects.  I suspect you want to say
"public method execution in any type below package
com.alloyinc.quiz.admin".  You could create a library aspect

  abstract aspect DoingThing {
     abstract pointcut withinTypes();
     pointcut publicMethodsWithinTypes() : withinTypes()
       && execution(public * *(..));
     before() : publicMethodsWithinTypes() { ... }
     // more advice
  }

then use it like this

  aspect DoingMyThing extends DoingThing {
     pointcut withinTypes() : within(com.alloyinc.quiz.admin..*);
  }

I believe Adrian, et al are working on a way to allow you to
configure a subaspect pointcut like this with config tools.
(Still more cool things coming out of those guys!)

Wes

> ------------Original Message------------
> From: "Charles N. Harvey III" <charlieh@xxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Tue, Jan-25-2005 2:51 PM
> Subject: [aspectj-users] pointcuts from a properties file
>
> Hello.
> I would like to write an aspect and put it in a jar file and have it
> be re-used a lot.  But, the classes that it will weave will change
> in each project.  So the pointcut statement has to change each time.
>
> Consider this example:
>
----------------------------------------------------------------------------

>     /**
>      * pointcut defining which Action classes to weave into.
>      */
>     public pointcut adminAuth( ActionMapping mapping,
>                                ActionForm form,
>                                HttpServletRequest request,
>                                HttpServletResponse response )
>         : ( execution( public * com.alloyinc.quiz.admin.*.*.execute(..)
> ) ||
>             execution( public * com.alloyinc.poll.admin.*.*.execute(..)
> ) )
>           && args( mapping, form, request, response );
>
>     /**
>      * Advice for <code>adminAuth</code> pointcut.
>      */
>     ActionForward around( ActionMapping mapping,
>                           ActionForm form,
>                           HttpServletRequest request,
>                           HttpServletResponse response )
>             : adminAuth( mapping, form, request, response )
>     {
>         // some stuff that checks for login
>     }
>
----------------------------------------------------------------------------

>
> I want to be able to switch the following with text from a properties
> file:
>         : ( execution( public * com.alloyinc.quiz.admin.*.*.execute(..)
> ) ||
>             execution( public * com.alloyinc.poll.admin.*.*.execute(..)
> ) )
>
> Can I do that?  I can't really find the javadoc that says whether
> "execution"
> (or "call" or any of the other methods) takes a String or not.  If it
> does,
> I would think that I could replace it with a property.  If not, well,
> then
> I guess not.
>
> Thanks in advance if anyone knows the answer to this.
>
>
> Charlie
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
>


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/aspectj-users




Back to the top