diff --git a/java/building-plugins.md b/java/building-plugins.md index 24f1d3443..4d8f4019d 100644 --- a/java/building-plugins.md +++ b/java/building-plugins.md @@ -31,7 +31,7 @@ Of course, it's up to your project / plugin how you call the corresponding Maven ## Share CDS Models via Maven Artifacts -Before the CAP Java 2.2 release CDS definitions had to be shared as node.js modules, also for Java projects. +Before the CAP Java 2.2 release CDS definitions had to be shared as Node.js modules, also for Java projects. Starting with the 2.2 release CDS models, CSV import data and i18n files can now be shared through Maven dependencies in addition to npm packages. This means you can now provide CDS models, CSV files, i18n files, and Java code (for example, event handlers) in a single Maven dependency. diff --git a/java/cds-data.md b/java/cds-data.md index fd861c1f3..61c4a2e22 100644 --- a/java/cds-data.md +++ b/java/cds-data.md @@ -432,7 +432,8 @@ book.put("ID", 97); book.put("title", "Dracula"); ``` -You can now either define an accessor interface or use a [generated accessor interface](#generated-accessor-interfaces). The accessor interface then looks like in the following example: +You can now either define an accessor interface or use a [generated accessor interface](#generated-accessor-interfaces). +If you define an interface yourself, it could look like the following example: ```java interface Book extends Map { diff --git a/java/developing-applications/building.md b/java/developing-applications/building.md index e6e04229f..9b3aecf60 100644 --- a/java/developing-applications/building.md +++ b/java/developing-applications/building.md @@ -70,7 +70,7 @@ CAP Java positions [Spring](https://spring.io) or more precisely [Spring Boot](h Spring comes as a rich set of industry-proven frameworks, libraries, and tools that greatly simplify custom development. Spring Boot also allows the creation of self-contained applications that are easy to configure and run. -As all other components in the different layers of the CAP Java stack are decoupled from the concrete application framework, thus you aren't obligated to build on Spring. +As all other components in the different layers of the CAP Java stack are decoupled from the concrete application framework, you aren't obligated to build on Spring. In some scenarios, it might be even preferable to run the (web) service with minimal resource consumption or with smallest possible usage of open source dependencies. In this case, a solution based on plain Java Servlets could be favorable. Lastly, in case you want to run your application on a 3rd party application framework, you're free to bundle it with CAP modules and provide the glue code, which is necessary for integration. @@ -141,7 +141,7 @@ Find a full list of standard plugins in [Standard Modules](#standard-modules). ### Module Dependencies All CAP Java modules are built as [Maven](https://maven.apache.org/) artifacts and are available on [Apache Maven Central Repository](https://search.maven.org/search?q=com.sap.cds). -They've `groupId` `com.sap.cds`. +They have `groupId` `com.sap.cds`. Beside the Java libraries (Jars) reflecting the modularized functionality, the group also contains a "bill of materials" (BOM) pom named `cds-services-bom`, which is recommended especially for multi-project builds. It basically helps to control the dependency versions of the artifacts and should be declared in dependency management of the parent `pom`: diff --git a/java/developing-applications/running.md b/java/developing-applications/running.md index e86b4f866..c5047038e 100644 --- a/java/developing-applications/running.md +++ b/java/developing-applications/running.md @@ -61,7 +61,7 @@ The `watch` goal uses the `spring-boot-maven-plugin` internally to start the app When you add the [Spring Boot Devtools](https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.devtools) to your project, the `watch` goal can take advantage of the reload mechanism. In case your application doesn't use the Spring Boot Devtools the `watch` goal performs a complete restart of the Spring Boot application after CDS model changes. As the application context reload is always faster than a complete restart the approach using the Spring Boot Devtools is the preferred approach. ::: warning -The `watch` goal only works on Windows if the Spring Boot Devtools are enabled. +On Windows, the `watch` goal only works if the Spring Boot Devtools are enabled. ::: ### CDS Auto-Build diff --git a/java/operating-applications/observability.md b/java/operating-applications/observability.md index 4b097907a..ebed90112 100644 --- a/java/operating-applications/observability.md +++ b/java/operating-applications/observability.md @@ -53,8 +53,8 @@ public void readAuthors(List orders) { Some remarks: -* [Logging Configuration](#logging-configuration) shows how to configure loggers individually to control the emitted log messages. -* The API is robust with regards to the passed parameters that means no exception is thrown on parameters mismatch or invalid parameters. +* [Spring Boot Logging](#logging-configuration) shows how to configure loggers individually to control the emitted log messages. +* The API is robust with regards to the passed parameters, which means no exception is thrown on parameters mismatch or invalid parameters. ::: tip Prefer *passing parameters* over *concatenating* the message. `logger.info("Consolidating order " + order)` creates the message `String` regardless the configured log level. This can have a negative impact on performance. @@ -72,7 +72,7 @@ In case your application runs on Spring Boot and you use the Spring starter pack Similarly, no specific log output configuration is required for local development, as per default, log messages are written to the console in human-readable form, which contains timestamp, thread, and logger component information. To customize the log output, for instance to add some application-specific information, you can create corresponding configuration files (such as `logback-spring.xml` for logback). Add them to the classpath and Spring picks them automatically. Consult the documentation of the dedicated logging framework to learn about the configuration file format. -All logs are written that have a log level greater or equal to the configured log level of the corresponding logger object. +All logs are written, that have a log level greater or equal to the configured log level of the corresponding logger object. The following log levels are available: | Level | Use case @@ -107,10 +107,10 @@ Note that loggers are organized in packages, for instance `org.springframework` #### At Runtime with Restart { #logging-configuration-restart} -You can overrule the given logging configuration with a corresponding environment variable. For instance, to set loggers in package `my.loggers.order` to `DEBUG` level add the following environment variable: +You can overrule the given logging configuration with a corresponding environment variable. For instance, to set loggers in package `my.loggers.order` to `DEBUG` level set the following environment variable: ```sh -LOGGING_LEVEL_MY_LOGGERS_ORDER = DEBUG +LOGGING_LEVEL_MY_LOGGERS_ORDER=DEBUG ``` and restart the application. @@ -128,15 +128,15 @@ If configured, you can use [Spring actuators](https://docs.spring.io/spring-boot ```sh # retrieve state of all loggers: -curl http:///actuator/loggers +curl https:///actuator/loggers # retrieve state of single logger: -curl http:///actuator/loggers/my.loggers.oder.consolidation - {"configuredLevel":null,"effectiveLevel":"INFO"} +curl https:///actuator/loggers/my.loggers.oder.consolidation +#> {"configuredLevel":null,"effectiveLevel":"INFO"} # Change logging level: -curl -X POST -H 'Content-Type: application/json' -d '{"configuredLevel": "DEBUG"}' - http:///actuator/loggers/my.loggers.oder.consolidation +curl -X POST -H 'Content-Type: application/json' -d '{"configuredLevel": "DEBUG"}' \ + https:///actuator/loggers/my.loggers.oder.consolidation ``` [Learn more about Spring actuators and security aspects in the section **Metrics**.](#spring-boot-actuators){ .learn-more} @@ -183,7 +183,7 @@ Establishing a connection is the same for both services: The application needs t By default, the library appends additional fields to the log output such as correlation id or Cloud Foundry space. To instrument incoming HTTP requests, a servlet filter needs to be created. See [Instrumenting Servlets](https://github.com/SAP/cf-java-logging-support/wiki/Instrumenting-Servlets) for more details. -During local development, you might want to stick to the (human-readable) standard log line format. This boils down to have different logger configurations for different Spring profiles. The following sample configuration outlines how you can achieve this. `cf-java-logging-support` is only active for profile `cloud`, since all other profiles are configured with the standard logback output format: +During local development, you might want to stick to the (human-readable) standard log line format. This boils down to having different logger configurations for different Spring profiles. The following sample configuration outlines how you can achieve this. `cf-java-logging-support` is only active for profile `cloud`, since all other profiles are configured with the standard logback output format: ::: code-group ```xml [srv/src/main/resources/logback-spring.xml] @@ -418,7 +418,8 @@ The following example produces an additional span when the `@After` handler is e @Component @ServiceName(CatalogService_.CDS_NAME) class CatalogServiceHandler implements EventHandler { - Tracer tracer = GlobalOpenTelemetry.getTracerProvider().tracerBuilder("RatingCalculator").build(); + Tracer tracer = GlobalOpenTelemetry.getTracerProvider() + .tracerBuilder("RatingCalculator").build(); @After(entity = Books_.CDS_NAME) public void afterAddReview(AddReviewContext context) { @@ -453,8 +454,11 @@ class CatalogServiceHandler implements EventHandler { public void afterAddReview(AddReviewContext context) { ratingCalculator.setBookRating(context.getResult().getBookId()); - LongCounter counter = meter.counterBuilder("reviewCounter").setDescription("Counts the number of reviews created per book").build(); - counter.add(1, Attributes.of(AttributeKey.stringKey("bookId"), context.getResult().getBookId())); + LongCounter counter = meter.counterBuilder("reviewCounter") + .setDescription("Counts the number of reviews created per book") + .build(); + counter.add(1, Attributes.of(AttributeKey.stringKey("bookId"), + context.getResult().getBookId())); } } ```