File tree Expand file tree Collapse file tree 3 files changed +66
-3
lines changed
inject/src/main/java/io/avaje/inject
inject-test/src/test/java/org/example/coffee/factory Expand file tree Collapse file tree 3 files changed +66
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import io .avaje .inject .Bean ;
4
4
import io .avaje .inject .Factory ;
5
+ import io .avaje .inject .PostConstruct ;
6
+ import io .avaje .inject .PreDestroy ;
5
7
import org .example .coffee .CoffeeMaker ;
6
8
7
- import javax .annotation .PostConstruct ;
8
- import javax .annotation .PreDestroy ;
9
9
import javax .inject .Inject ;
10
10
11
11
/**
@@ -41,7 +41,6 @@ BFact buildB(AFact afact, CoffeeMaker maker) {
41
41
return new BFact (afact , maker );
42
42
}
43
43
44
-
45
44
@ PostConstruct
46
45
void initFactory () {
47
46
countInit ++;
Original file line number Diff line number Diff line change
1
+ package io .avaje .inject ;
2
+
3
+ import java .lang .annotation .Documented ;
4
+ import java .lang .annotation .Retention ;
5
+ import java .lang .annotation .Target ;
6
+
7
+ import static java .lang .annotation .ElementType .METHOD ;
8
+ import static java .lang .annotation .RetentionPolicy .RUNTIME ;
9
+
10
+ /**
11
+ * The <code>PostConstruct</code> annotation is used on a method that needs to be executed
12
+ * after dependency injection is done to perform any initialization.
13
+ * <p>
14
+ * Note that we can equally use any <code>PostConstruct</code> annotation - so we can use
15
+ * the one from <code>javax.annotation</code>, <code>jakarta.annotation</code> or this one.
16
+ * </p>
17
+ * <p>
18
+ * Only one method in a given class can be annotated with this annotation.
19
+ * <p>
20
+ * The method on which the <code>PostConstruct</code> annotation is applied must fulfill
21
+ * the following criteria:
22
+ * <ul>
23
+ * <li>The method must not have any parameters.</li>
24
+ * <li>The method may be public, protected or package private.</li>
25
+ * <li>The method must not be static.</li>
26
+ * </ul>
27
+ */
28
+ @ Documented
29
+ @ Retention (RUNTIME )
30
+ @ Target (METHOD )
31
+ public @interface PostConstruct {
32
+ }
Original file line number Diff line number Diff line change
1
+ package io .avaje .inject ;
2
+
3
+ import java .lang .annotation .Documented ;
4
+ import java .lang .annotation .Retention ;
5
+ import java .lang .annotation .Target ;
6
+
7
+ import static java .lang .annotation .ElementType .METHOD ;
8
+ import static java .lang .annotation .RetentionPolicy .RUNTIME ;
9
+
10
+ /**
11
+ * The <code>PreDestroy</code> annotation is used on a method as a callback notification
12
+ * to signal that the instance is in the process of being removed by the container.
13
+ * <p>
14
+ * Note that we can equally use any <code>PreDestroy</code> annotation - so we can use
15
+ * the one from <code>javax.annotation</code>, <code>jakarta.annotation</code> or this one.
16
+ * <p>
17
+ * The method annotated with <code>PreDestroy</code> is typically used to release resources
18
+ * that it has been holding.
19
+ * <p>
20
+ * The method on which the <code>PreDestroy</code> annotation is applied must fulfill the
21
+ * following criteria:
22
+ * <ul>
23
+ * <li>The method must not have any parameters.</li>
24
+ * <li>The method may be public, protected or package private.</li>
25
+ * <li>The method must not be static.</li>
26
+ * </ul>
27
+ */
28
+ @ Documented
29
+ @ Retention (RUNTIME )
30
+ @ Target (METHOD )
31
+ public @interface PreDestroy {
32
+ }
You can’t perform that action at this time.
0 commit comments