Skip to content

Commit 1c75c1e

Browse files
committed
chore: remove "Why this matters" section from README
1 parent b947a97 commit 1c75c1e

1 file changed

Lines changed: 0 additions & 57 deletions

File tree

README.adoc

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -17,63 +17,6 @@ TaxCalculator taxCalculator;
1717

1818
The application should not need a producer method, manual lookup, or conditional logic at the injection point. CDI should resolve the correct implementation based on the active deployment.
1919

20-
== Why this matters
21-
22-
CDI already provides powerful mechanisms such as qualifiers, alternatives, producers, portable extensions, and build-compatible extensions. However, these features do not directly express a common requirement:
23-
24-
[source,text]
25-
26-
```
27-
This bean should exist only when this condition is true.
28-
```
29-
30-
Without conditional bean activation, developers often move this decision into producer methods:
31-
32-
[source,java]
33-
34-
```
35-
@Produces
36-
TaxCalculator taxCalculator() {
37-
if ("BR".equals(System.getProperty("app.country"))) {
38-
return new BrazilTaxCalculator();
39-
}
40-
return new PortugalTaxCalculator();
41-
}
42-
```
43-
44-
This works, but it hides the activation rule away from the bean itself. The implementation classes no longer explain when they are active.
45-
46-
Conditional activation keeps the rule close to the bean:
47-
48-
[source,java]
49-
50-
```
51-
@RequiresSetting(name = "app.country", value = "BR")
52-
@ApplicationScoped
53-
public class BrazilTaxCalculator implements TaxCalculator {
54-
}
55-
```
56-
57-
[source,java]
58-
59-
```
60-
@RequiresSetting(name = "app.country", value = "PT")
61-
@ApplicationScoped
62-
public class PortugalTaxCalculator implements TaxCalculator {
63-
}
64-
```
65-
66-
Then the injection point remains clean:
67-
68-
[source,java]
69-
70-
```
71-
@Inject
72-
TaxCalculator taxCalculator;
73-
```
74-
75-
Only the matching bean participates in CDI typesafe resolution.
76-
7720
== API overview
7821

7922
The sample introduces two annotations and one contract:

0 commit comments

Comments
 (0)