blob: e669c0e01f6a473d6e7a09e9d533a2b5f644d859 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
@interface Secured {
String value();
}
interface DemoService {
@Secured("READ")
void secureMethod();
}
class DemoServiceImpl implements DemoService {
public void secureMethod() { }
}
aspect X {
// None of these match, the subject at execution(secureMethod()) does not have the annotation
// see https://github.com/eclipse-aspectj/aspectj/blob/master/docs/adk15notebook/joinpointsignatures.adoc#join-point-modifiers
before(): execution(@Secured * *Service+.*(..)) { }
before(): execution(@Secured * *Service.*(..)) { }
before(): execution(@Secured * DemoService.*(..)) { }
}
public class Asp {
public static void main(String[] args) {
new DemoServiceImpl().secureMethod();
}
}
|