Skip to content

Commit 6ea2da5

Browse files
authored
Update chapter05.adoc (#22)
1 parent c6a8d60 commit 6ea2da5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

chapter05/chapter05.adoc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,19 @@ classes and interfaces included in the MicroProfile Configuration API:
121121
- `Config` - the class that is the main entry point to the configuration API
122122
and provides access to configuration data. The Config class provides
123123
static methods that can be used to access configuration properties.
124+
124125
- `ConfigProvider` - a utility class for getting the Config instance. It
125126
allows retrieving the static instance of the Config object.
127+
126128
- `ConfigBuilder` - An interface used to create a Config instance manually.
127129
It can add default sources, converters, and configuration sources.
130+
128131
- `ConfigSource` - This class represents a source of configuration values.
129132
It reads configuration data from a specific source, such as system
130133
properties, environment variables, files, or data stores.
134+
131135
- `Property` - It represents a key/value pair in the configuration data.
136+
132137
- `Converter<T>` - This interface implements custom converters that convert
133138
configuration values from String to any desired type.
134139

@@ -329,10 +334,15 @@ In this example, we’re injecting a property named "product.maintenanceMessage"
329334
As we saw, the Config API makes it easy to inject configuration properties into an application. The Config API defines a contract for config implementations. A ConfigSource is used to read configuration data from a particular source. For example, we could create a ConfigSource that reads configuration data from a file.
330335

331336
`ConfigSource` interface has the following methods:
337+
332338
- `String getName()` : Returns the name of the ConfigSource.
339+
333340
- `int getOrdinal()` : Returns the ordinal of the ConfigSource. Ordinals are used to determine the precedence of ConfigSources. A higher ordinal means a higher precedence.
341+
334342
- `Map<String, String> getProperties()` : Returns a map of the properties in this ConfigSource. The keys in the map are the property names, and the values are the property values.
343+
335344
- `getValue(String propertyName)` : Returns the value of the given property. If the property is not found, this method returns null.
345+
336346
- `Set getPropertyNames()` : Returns a Set of the property names in this ConfigSource.
337347

338348
Let’s implement a feature in our MicroProfile e-Commerce application to integrate payment gateway configuration dynamically by creating a PaymentServiceConfigSource (a custom ConfigSource) which could fetch API keys and endpoints. This would ensure that payment service configurations are up-to-date and can be changed without redeploying the application.
@@ -469,7 +479,8 @@ public class PaymentService {
469479
}
470480
----
471481

472-
Explanation:
482+
**Explanation:**
483+
473484
- `@Path("/authorize")`: Defines the base URI for the RESTful service. This class will handle requests made to URIs that start with `/payment/api/authorize`.
474485
- `@RequestScoped`: Indicates that a new instance of `PaymentService` is created for each HTTP request.
475486
- `@POST`: Specifies that the `processPayment` method will respond to HTTP POST requests, which is appropriate for operations that change server state (in this case, processing a payment).

0 commit comments

Comments
 (0)