Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Can I use an annotation as a type-pattern when introducing annotations to the class type?

I'm trying to add JPA EntityListeners to my Entities via AspectJ.  However, I am either doing something wrong, or I am potentially running into an AJ bug.

I have the following aspect declaration:

public aspect AutoAuditEventAspect {

 declare parents : @Auditable * implements com.ia.persistence.AutoAuditable;

 declare @type : @Auditable : @EntityListeners(com.ia.persistence.AuditEventListener.class);

}


Where @Auditable is my own annotation

and AutoAuditable is an interface with a static Aspect Implementation.


However, when I try to compile my project I get the following error:

[ERROR] error at declare @type : @Auditable : @EntityListeners(com.ia.persistence.AuditEventListener.class);

[ERROR] ^^^^^^^^^^^^^^

[ERROR] webapp/src/main/java/com/ia/persistence/AutoAuditEventAspect.aj:9:0::0 The annotation @EntityListeners is disallowed for this location

[ERROR] error at declare @type : @Auditable : @EntityListeners(com.ia.persistence.AuditEventListener.class);

[ERROR] 

[ERROR] webapp/src/main/java/com/ia/persistence/AutoAuditEventAspect.aj:9:0::0 Syntax error on token ";", "name pattern" expected



If I try to remove the @Auditable as the <type-pattern> and replace with "com.ia.domain.*", then it compiles fine.

Am I not allowed to use an annotation as a type specifier when trying to introduce an annotation to the class type?

Thanks,

Eric



Back to the top