0

I'm trying to solve the following problem: I have an aspect defined like this:

public aspect ComponentAspect {
    declare @type : uk.co.xxx.* : @Component;
}

As expected it annotates everything in "uk.co.xxx" package, the thing is I don't need to annotate all classes in this package, only those matching certain pattern, for example I have classes ending with ...Client.java and only these I want to annotate. So I would expect code like this:

public aspect ComponentAspect {
    declare @type : uk.co.xxx.workflow.*Client : @Component;
}

but of cause it is only my wishful thinking.

Any ideas how I can achieve my result?

Thanks a lot for any idea, so far I spent 2 hours without progress at all :(

kriegaex
  • 63,017
  • 15
  • 111
  • 202
user2174470
  • 131
  • 1
  • 3
  • I know this one is old, but still listed as unanswered. Would you please accept and upvote my answer if it seems appropriate? Thanks. – kriegaex Jun 09 '14 at 12:20

1 Answers1

1

Why wishful thinking? It works as you expect. You just need to be careful which packages and/or subpackages you are targetting with your type pattern.

Maybe what you really want to do is target all classes with a certain name within all subpackages of a certain package. In this case you need the .. syntax, like so:

public aspect ComponentAspect {
    declare @type : uk.co.xxx.workflow..*Client : @Component;
}

I tried in one of my applications, it works like a charm.

kriegaex
  • 63,017
  • 15
  • 111
  • 202