Skip to content

Commit

Permalink
improving documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aludwiko committed Jan 17, 2025
1 parent 66eb1d3 commit 211170c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ You can use `ServiceSetup` to disable components by overriding `disabledComponen
include::example$doc-snippets/src/main/java/com/example/MyAppSetup.java[tag=disable-components]
----
<1> Override `disabledComponents`
<2> Provide a set of component classes to disable
<2> Provide a set of component classes to disable depending on the configuration


[#_dependency_injection]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
@Setup
public class MyAppSetup implements ServiceSetup {

// end::disable-components[]
private final Config appConfig;

public MyAppSetup(Config appConfig) {
this.appConfig = appConfig;
}

// end::disable-components[]

@Override
public DependencyProvider createDependencyProvider() { // <1>
final var myAppSettings =
Expand All @@ -40,7 +41,11 @@ public <T> T getDependency(Class<T> clazz) {
// tag::disable-components[]
@Override
public Set<Class<?>> disabledComponents() { // <1>
return Set.of(MyComponent.class); // <2>
if (appConfig.getString("my-app.environment").equals("prod")) {
return Set.of(MyComponent.class); // <2>
} else {
return Set.of(); // <2>
}
}
// tag::pojo-dependency-injection[]
}
Expand Down
1 change: 1 addition & 0 deletions samples/doc-snippets/src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
my-app {
some-feature-flag = true
environment = "test"
}

0 comments on commit 211170c

Please sign in to comment.