Skip to content

Commit 391e4cc

Browse files
committed
Merge branch 'SentryMan-aspect2' into jakarta-master
2 parents 0602a5c + 9b32648 commit 391e4cc

File tree

5 files changed

+16
-32
lines changed

5 files changed

+16
-32
lines changed

inject-generator/src/main/java/io/avaje/inject/generator/AspectMethod.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ List<MethodReader.MethodParam> initParams(List<? extends VariableElement> parame
4141

4242
void addTargets(Set<String> targets) {
4343
for (AspectPair aspectPair : aspectPairs) {
44-
targets.add(aspectPair.target());
44+
targets.add(aspectPair.annotationShortName());
4545
}
4646
}
4747

@@ -123,8 +123,7 @@ void writeSetupForMethods(Append writer, String shortName) {
123123
}
124124
writer.append(");").eol();
125125
for (AspectPair aspect : aspectPairs) {
126-
String target = aspect.target();
127-
String name = aspectTargetShortName(target);
126+
String name = Util.initLower(aspect.annotationShortName());
128127
String sn = aspect.annotationShortName();
129128
writer.append(" %s%s = %s.interceptor(%s, %s.getAnnotation(%s.class));", localName, sn, name, localName, localName, sn).eol();
130129
}

inject-generator/src/main/java/io/avaje/inject/generator/AspectPair.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ String target() {
2121
}
2222

2323
void addImports(ImportTypeMap importTypes) {
24-
importTypes.add(target);
24+
importTypes.add("io.avaje.inject.aop.AspectProvider");
2525
importTypes.add(annotationFullName);
2626
}
2727

inject-generator/src/main/java/io/avaje/inject/generator/BeanAspects.java

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,51 +10,41 @@ final class BeanAspects {
1010
static final BeanAspects EMPTY = new BeanAspects();
1111

1212
private final List<AspectMethod> aspectMethods;
13-
private final Set<String> targets;
13+
private final Set<String> aspectNames;
1414

1515
private BeanAspects() {
1616
this.aspectMethods = Collections.emptyList();
17-
this.targets = Collections.emptySet();
17+
this.aspectNames = Collections.emptySet();
1818
}
1919

2020
BeanAspects(List<AspectMethod> aspectMethods) {
2121
this.aspectMethods = aspectMethods;
22-
this.targets = initTargets();
22+
this.aspectNames = initAspectNames();
2323
}
2424

2525
boolean hasAspects() {
2626
return !aspectMethods.isEmpty();
2727
}
2828

29-
Set<String> targets() {
30-
return targets;
29+
Set<String> aspectNames() {
30+
return aspectNames;
3131
}
3232

3333
void extraImports(ImportTypeMap importTypes) {
34-
for (AspectMethod aspectMethod : aspectMethods) {
34+
for (final AspectMethod aspectMethod : aspectMethods) {
3535
aspectMethod.addImports(importTypes);
3636
}
3737
}
3838

39-
Set<String> initTargets() {
40-
Set<String> targets = new LinkedHashSet<>();
41-
for (AspectMethod aspectMethod : aspectMethods) {
39+
Set<String> initAspectNames() {
40+
final Set<String> targets = new LinkedHashSet<>();
41+
for (final AspectMethod aspectMethod : aspectMethods) {
4242
aspectMethod.addTargets(targets);
4343
}
4444
return targets;
4545
}
4646

47-
void writeFields(Append writer) {
48-
for (String target : targets) {
49-
String type = Util.shortName(target);
50-
String name = Util.initLower(type);
51-
writer.append(" private final %s %s;", type, name).eol();
52-
}
53-
writer.eol();
54-
}
55-
5647
List<AspectMethod> methods() {
5748
return aspectMethods;
5849
}
59-
6050
}

inject-generator/src/main/java/io/avaje/inject/generator/SimpleBeanProxyWriter.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ private void writeMethods() {
4747
}
4848

4949
private void writeFields() {
50-
aspects.writeFields(writer);
5150
for (AspectMethod method : aspects.methods()) {
5251
method.writeSetupFields(writer);
5352
}
@@ -57,21 +56,17 @@ private void writeFields() {
5756
private void writeConstructor() {
5857
writer.append(" public %s%s(", shortName, suffix);
5958
int count = 0;
60-
for (String target : aspects.targets()) {
59+
for (final String aspectName : aspects.aspectNames()) {
6160
if (count++ > 0) {
6261
writer.append(", ");
6362
}
64-
final String type = Util.shortName(target);
65-
String name = Util.initLower(type);
63+
final var type = "AspectProvider<" + aspectName + ">";
64+
final var name = Util.initLower(aspectName);
6665
writer.append(type).append(" ").append(name);
6766
}
6867
beanReader.writeConstructorParams(writer);
6968
writer.append(") {").eol();
7069
beanReader.writeConstructorInit(writer);
71-
for (String target : aspects.targets()) {
72-
String name = AspectMethod.aspectTargetShortName(target);
73-
writer.append(" this.%s = %s;", name, name).eol();
74-
}
7570
writeSetupForMethods();
7671
writer.append(" }").eol();
7772
}

inject/src/main/java/io/avaje/inject/aop/Aspect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* Specify the {@link AspectProvider} for this aspect.
2222
*/
23-
Class<?> target();
23+
Class<? extends AspectProvider> target();
2424

2525
/**
2626
* Specify the priority ordering when multiple aspects are on a method.

0 commit comments

Comments
 (0)