Skip to main content

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

I think what you mean on the declare @type is the following.  I don't have an IDE in front of me right now, but I think you're missing the rest of the type pattern.  Notice the missing * (highlighted).

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




On Tue, Mar 11, 2014 at 11:27 AM, Eric B <ebenzacar@xxxxxxxxx> wrote:
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



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




--
mailto:matthew@xxxxxxxxxxxxxxx 

Back to the top