Skip to content

Commit 8f599d7

Browse files
committed
Deprecate the use of @Aspect.target with the view to remove it
1 parent e7df0e4 commit 8f599d7

File tree

6 files changed

+8
-17
lines changed

6 files changed

+8
-17
lines changed

blackbox-aspect/src/main/java/org/example/external/aspect/MyExternalAspect.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package org.example.external.aspect;
22

33
import io.avaje.inject.aop.Aspect;
4-
import org.example.external.aspect.sub.MyAspectImplementation;
54

65
import java.lang.annotation.ElementType;
76
import java.lang.annotation.Retention;
87
import java.lang.annotation.RetentionPolicy;
98
import java.lang.annotation.Target;
109

11-
@Aspect(target = MyAspectImplementation.class)
10+
@Aspect
1211
@Target(ElementType.METHOD)
1312
@Retention(RetentionPolicy.RUNTIME)
1413
public @interface MyExternalAspect {

blackbox-aspect/src/main/java/org/example/external/aspect/sub/MyAspectImplementation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import java.util.Arrays;
1111

1212
@Component
13-
public class MyAspectImplementation implements AspectProvider<MyExternalAspect>, MethodInterceptor {
13+
class MyAspectImplementation implements AspectProvider<MyExternalAspect>, MethodInterceptor {
1414

1515
@Override
1616
public MethodInterceptor interceptor(Method method, MyExternalAspect aspectAnnotation) {

blackbox-test-inject/src/main/java/org/example/myapp/aspect/MyAround.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.lang.annotation.RetentionPolicy;
88
import java.lang.annotation.Target;
99

10-
@Aspect(target = MyAroundAspect.class)
10+
@Aspect
1111
@Target(ElementType.METHOD)
1212
@Retention(RetentionPolicy.RUNTIME)
1313
public @interface MyAround {

blackbox-test-inject/src/main/java/org/example/myapp/aspect/MyAroundAspect.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import java.util.List;
1212

1313
@Singleton
14-
//@Aspect(target = MyAround.class)
1514
public class MyAroundAspect implements AspectProvider<MyAround>, MethodInterceptor {
1615

1716
private final List<String> trace = new ArrayList<>();

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ private Meta readTarget(Element anElement) {
4444
Meta meta = new Meta();
4545
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotationMirror.getElementValues().entrySet()) {
4646
String key = entry.getKey().toString();
47-
if (key.equals("target()")) {
48-
meta.target(entry.getValue().getValue().toString());
49-
} else if (key.equals("ordering()")) {
47+
if (key.equals("ordering()")) {
5048
meta.ordering(Integer.parseInt(entry.getValue().getValue().toString()));
5149
}
5250
}
@@ -59,21 +57,15 @@ private Meta readTarget(Element anElement) {
5957

6058
private static class Meta {
6159

62-
String target;
63-
6460
int ordering = Constants.ORDERING_DEFAULT;
6561

66-
void target(String target) {
67-
this.target = target;
68-
}
69-
7062
void ordering(int ordering) {
7163
this.ordering = ordering;
7264
}
7365

7466
@Override
7567
public String toString() {
76-
return "Meta(target=" + target + ", ordering=" + ordering + ')';
68+
return "Meta(ordering=" + ordering + ')';
7769
}
7870
}
7971
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
public @interface Aspect {
1919

2020
/**
21-
* Specify the {@link AspectProvider} for this aspect.
21+
* Deprecated - the target() attribute is no longer required and should be removed.
2222
*/
23-
Class<? extends AspectProvider> target();
23+
@Deprecated
24+
Class<?> target() default Void.class;
2425

2526
/**
2627
* Specify the priority ordering when multiple aspects are on a method.

0 commit comments

Comments
 (0)