Announcement Announcement Module
Collapse
No announcement yet.
pointcut to intercept "instanceof" instruction ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • pointcut to intercept "instanceof" instruction ?

    Hello,

    I'd like to define an Aspect to detect use of "instanceOf" instruction in my business domain code.

    As I'm using Hibernate, the abstract @Entity class "Pet" cannot be casted to its child "Cat" due to Hibernate proxies :

    Code:
    Pet felix = ....;
    if (felix instanceOf Cat) { // will always be false
        Cat cat = (Cat) felix;  // will fail anyway
    }
    To avoid such error in code, I'd like to create an aspect to detect use of instanceOf with a class that is annotated with @Entity.

    As I'm not an aspectJ pointcut expression guru, I'd welcome any help ;-)
Working...
X