Announcement Announcement Module
No announcement yet.
property based pointcut? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • property based pointcut?

    have a weak memory of reading that property based pointcuts are possible....

    but can't find an example online. other than an article which is more geared to annotations ( where the author in "Selecting by annotation property" shows the "value" variable in the method equal to a "RequiredNew".

    want to do a similar thing whereby i define a pointcut to match not only the method and it's arguments (properties) but also a value of a argument (property). like the following:

    <aop: pointcut id="transitory" expression="execution(matrix.cmdb.pojo.Element ) and args(element)"/>


    <aop: pointcut id="transitory" expression="execution(matrix.cmdb.pojo.Element ment.type="environment")) and args(element)"/>

    mvh / matthew (28341)

  • #2
    You'll have to deal with that in advice itself, you can't create a pointcut that tests the value of the argument, just the type of the argument. but you can easily test the value inside the advice and only perform operation if your value matches what you expecting...


    • #3
      went that way

      exactly what i did. just had a vage memory of seeing an example where it was possible. must have mixed it up with something else.

      anyway i started wondering after i posted about how costly my AOP set-up is. basically i have an Element pojo that can have several types and depending on the type i use a specific composite ID (i.e. criteria) in the DAO to hunt for an pre-existing record (if the element already exists then updat otherwise insert).

      going to have lots of element types (upwards of 50/100). which means lots of pointcut-ref against the aforementioned pointcut ("transitory") to call a specific controller bean (before setElement is executed) for an element type. each controller bean will have to check the type, exit if not the excepted or continue if a match.

      how expensive is that set-up? every time setElement is called possibily 100 controller beans get called and only one actually does a persistance check. the other just return if the element type is a no-match. seems like i waste of calls. but maybe there is no other work-around?