├── .gitignore
├── README.md
├── build-script-examples
├── Example5-1-build.xml
├── Example5-2-pom.xml
└── Example5-3-build.gradle
├── chapter01-devops-for-developers
└── README.md
├── chapter02-the-system-of-truth
└── README.md
├── chapter03-introduction-to-containers
└── README.md
├── chapter04-dissecting-the-monolith
├── README.md
├── helidon-demo
│ ├── .gitignore
│ ├── pom.xml
│ ├── readme.md
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── demo
│ │ │ ├── Greeting.java
│ │ │ └── GreetingResource.java
│ │ └── resources
│ │ ├── .gitkeep
│ │ ├── META-INF
│ │ ├── beans.xml
│ │ └── microprofile-config.properties
│ │ ├── WEB
│ │ └── index.html
│ │ ├── logging.properties
│ │ └── privateKey.pem
├── helidon.png
├── lambda
│ └── quarkus-lambda
│ │ ├── output.json
│ │ ├── payload.json
│ │ ├── pom.xml
│ │ ├── quarkus-lambda.iml
│ │ ├── src
│ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── demo
│ │ │ │ │ ├── GreetingLambda.java
│ │ │ │ │ ├── InputObject.java
│ │ │ │ │ ├── OutputObject.java
│ │ │ │ │ └── ProcessingService.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ └── test
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── demo
│ │ │ │ └── LambdaHandlerTest.java
│ │ │ └── resources
│ │ │ └── application.properties
│ │ └── trust-policy.json
├── micronaut-demo
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── MavenWrapperDownloader.java
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── README.md
│ ├── micronaut-cli.yml
│ ├── mvnw
│ ├── mvnw.bat
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── demo
│ │ │ ├── Application.java
│ │ │ ├── Greeting.java
│ │ │ └── GreetingController.java
│ │ └── resources
│ │ ├── application.yml
│ │ └── logback.xml
├── micronaut.png
├── quarkus-demo
│ ├── .dockerignore
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── MavenWrapperDownloader.java
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── README.md
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── docker
│ │ ├── Dockerfile.jvm
│ │ ├── Dockerfile.legacy-jar
│ │ ├── Dockerfile.native
│ │ └── Dockerfile.native-distroless
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── demo
│ │ │ ├── Greeting.java
│ │ │ └── GreetingResource.java
│ │ └── resources
│ │ ├── META-INF
│ │ └── resources
│ │ │ └── index.html
│ │ └── application.properties
├── quarkus.png
├── spring-boot-demo
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── MavenWrapperDownloader.java
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── demo
│ │ │ ├── DemoApplication.java
│ │ │ ├── Greeting.java
│ │ │ └── GreetingController.java
│ │ └── resources
│ │ └── application.properties
└── spring-boot.png
├── chapter05-continuous-integration
├── Example5-1-build.xml
├── Example5-2-pom.xml
├── Example5-3-build.gradle
└── README.md
├── chapter06-package-management
├── README.md
├── gradle-manifest
│ ├── build.gradle
│ └── settings.gradle
├── gradle-properties
│ ├── build.gradle
│ ├── settings.gradle
│ └── src
│ │ └── main
│ │ └── resources
│ │ └── META-INF
│ │ └── metadata.properties
├── maven-manifest
│ └── pom.xml
└── maven-properties
│ ├── pom.xml
│ └── src
│ └── main
│ └── resources
│ └── META-INF
│ └── metadata.properties
├── chapter07-securing-your-binaries
└── README.md
├── chapter08-deploying-for-developers
├── README.md
├── quarkus-demo
│ ├── .dockerignore
│ ├── .gitignore
│ ├── .mvn
│ │ └── wrapper
│ │ │ ├── MavenWrapperDownloader.java
│ │ │ ├── maven-wrapper.jar
│ │ │ └── maven-wrapper.properties
│ ├── README.md
│ ├── docker-compose.yaml
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── opentelemetry-collector-config.yaml
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── docker
│ │ ├── Dockerfile.jvm
│ │ ├── Dockerfile.legacy-jar
│ │ ├── Dockerfile.native
│ │ └── Dockerfile.native-distroless
│ │ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── demo
│ │ │ ├── Greeting.java
│ │ │ └── GreetingResource.java
│ │ └── resources
│ │ ├── META-INF
│ │ └── resources
│ │ │ └── index.html
│ │ └── application.properties
├── quarkus-lambda
│ ├── output.json
│ ├── payload.json
│ ├── pom.xml
│ ├── src
│ │ ├── main
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── demo
│ │ │ │ │ ├── GreetingLambda.java
│ │ │ │ │ ├── InputObject.java
│ │ │ │ │ ├── OutputObject.java
│ │ │ │ │ └── ProcessingService.java
│ │ │ └── resources
│ │ │ │ └── application.properties
│ │ └── test
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── demo
│ │ │ │ └── LambdaHandlerTest.java
│ │ │ └── resources
│ │ │ └── application.properties
│ └── trust-policy.json
└── spring-boot-demo
│ ├── .gitignore
│ ├── .mvn
│ └── wrapper
│ │ ├── MavenWrapperDownloader.java
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
│ ├── mvnw
│ ├── mvnw.cmd
│ ├── pom.xml
│ └── src
│ └── main
│ ├── java
│ └── com
│ │ └── example
│ │ └── demo
│ │ ├── DemoApplication.java
│ │ ├── Greeting.java
│ │ └── GreetingController.java
│ └── resources
│ └── application.properties
├── chapter09-mobile-workflows
└── README.md
└── chapter10-continous-deployment-patterns-and-antipatterns
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .idea
3 | .iml
4 | target/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # code-snippets
2 | DevOps Tools for Java Developers resources and examples
3 |
4 | Code snippets are organized by book chapter.
5 |
6 | ---
7 |
8 | ### DevOps Tools for Java Developers Visitor Log
9 |
10 | Add your own visitor comment below. Detailed exercise in Chapter 4.
11 |
12 |
13 | Stephen Chin ([@steveonjava](https://twitter.com/steveonjava)): Every developer should learn how to do DevOps!
14 |
15 | Overmellow (@notwitter): Seconded!
16 |
17 | Vishal Agrawal ([@vishalcool88](https://twitter.com/vishalagrawal_)): Learning DevOps tools for Java Developers
18 |
19 | Joseph TAMO ([@TamalJoseph](https://twitter.com/tamaljoseph)) : I'm learning how to do DevOps!
20 |
21 | Svippa: DevOps and beyond!
22 |
23 | Ahmed Aziz ([@AA_ziz](https://twitter.com/AA_ziz)): DevOps is just a fancy term for ownership
24 |
25 | Yuxh:(@no_twitter):My Visitor comment
26 |
27 | Alexander Frolov: I have managed to reach Chpater 2 out. Not every book can bring me so far. Thanks guys. Very appreciate your effort.
28 |
29 | Joseph : Every developer should learn how to do DevOps!
30 |
31 | MovieGoer (@SWETwitter) : Completed this exercise
32 |
33 | Etienne: Java certified since 2001, just checking out what the cool kids are up to ;)
34 |
35 | Super Zen: Great book!
36 |
37 | Lagom Peter: Many Devops tools for java developers!
38 |
39 | Aaron MAJAMBO (@majambo) : Added my own comments
40 |
41 | Shiva P B: Learning the foundation of DevOps!
42 |
43 | Víctor Orozco ([@tuxtor](https://twitter.com/tuxtor)): Great work team!, this is the most interesting book intro I've seen so far. I'll happily write my review when finished
44 |
45 | Marcin Napierala: just comment
46 |
47 | Dawit Wondim: Awesome Book! Thanks for helping me become a better software engineer.
48 |
49 | Henry Osei ([@henryosei](https://github.com/henryosei/)) : Devops tools for Java Developers, a good book for getting started for java developers in devops
50 |
51 | FullMoon: Started reading..
52 |
53 | RRVIber: Hello DevOps?
54 |
55 | BSL: ikasten!
56 |
57 | jinsungKim: Devops tools for java developers!
58 |
59 | Chanyoung (@notwitter) : devops! let's go!
60 |
61 | METAMI: HELLO DEVOPS!
62 |
63 | Drafighter ([@ChajeongYong](https://twitter.com/ChajeongYong)) : My First Exercise, Thank you for your help!
64 |
65 | JunHyeong Kim(instagram : @junhyeong_daily) : great book !!!
66 |
67 | Arron KIM (@notwitter): my own comments
68 |
69 | Jean-Paul: DevOps not only for Java, I hope!
70 |
71 | Billy Nader ([@Nabil Nader](https://www.linkedin.com/in/nabilnader/)): Backend developer
72 |
73 | Hyunjun KWON : This is a Great book for Java developers who want to learn how to do DevOps.
74 |
75 | Exercise done!
76 | Gaurav : Deveops Tools
77 |
78 | BLIGHTK: GREAKT BOOK
79 |
80 | jc : Add comment
81 |
82 | hankug (@none) : git request / exercise finish
83 |
84 | Ruxandra (@RPalmtag): readings on a rainy day
85 |
86 | AndyLee: DevOps great!
87 |
88 | Игор: Одлична књига!
89 |
90 | DaLei Sun ([@sundalei](https://twitter.com/sundalei)): Great book for Java Developers to learn DevOps best practice.
91 |
92 | Dan: Booyah!
93 |
94 | Vinayak Karigar: Ready to learn Devops tools
95 |
96 | Si Dunn (@grumblecore) : Very helpful book. Glad I found it. Thanks!
97 |
98 | Chandrakant: Great Book
99 |
100 | Good job!
101 |
102 | Virtoria Kazakova - haven't got twitter:(
103 | Thanks for book!
104 |
105 | Captain BAB: Make it so!
106 |
107 | Gaurav : Testing
108 | ---
109 | JINSU WI[@legolender]: comment;
110 |
--------------------------------------------------------------------------------
/build-script-examples/Example5-1-build.xml:
--------------------------------------------------------------------------------
1 | <1>
2 |
3 | <2>
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | <3>
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | <4>
21 |
22 |
27 |
28 |
29 |
30 |
31 |
36 |
37 |
38 | <5>
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | <6>
53 |
54 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/build-script-examples/Example5-2-pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 |
7 | com.mycompany.app <1>
8 | my-app
9 | 1.0-SNAPSHOT
10 |
11 | my-app
12 |
13 | http://www.example.com
14 |
15 | <2>
16 | UTF-8
17 | 11
18 |
19 |
20 | <3>
21 |
22 | junit
23 | junit
24 | 4.11
25 | test
26 |
27 |
28 |
29 | <4>
30 |
31 |
32 | <5>
33 | maven-compiler-plugin
34 | 3.8.0
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/build-script-examples/Example5-3-build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file was generated by the Gradle 'init' task.
3 | */
4 |
5 | plugins {
6 | id 'java' <1>
7 | id 'maven-publish'
8 | }
9 |
10 | repositories { <2>
11 | mavenLocal()
12 | maven {
13 | url = uri('https://repo.maven.apache.org/maven2')
14 | }
15 | }
16 |
17 | dependencies {
18 | testImplementation 'junit:junit:4.11' <3>
19 | }
20 |
21 | group = 'com.mycompany.app'
22 | version = '1.0-SNAPSHOT'
23 | description = 'my-app'
24 | sourceCompatibility = '11' <4>
25 |
26 | publishing {
27 | publications {
28 | maven(MavenPublication) {
29 | from(components.java)
30 | }
31 | }
32 | }
33 |
34 | tasks.withType(JavaCompile) { <5>
35 | options.encoding = 'UTF-8'
36 | }
37 |
--------------------------------------------------------------------------------
/chapter01-devops-for-developers/README.md:
--------------------------------------------------------------------------------
1 | Code Snippets and Examples for Chapter
2 |
--------------------------------------------------------------------------------
/chapter02-the-system-of-truth/README.md:
--------------------------------------------------------------------------------
1 | Code Snippets and Examples for Chapter
2 |
--------------------------------------------------------------------------------
/chapter03-introduction-to-containers/README.md:
--------------------------------------------------------------------------------
1 | Code Snippets and Examples for Chapter
2 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/README.md:
--------------------------------------------------------------------------------
1 | Code Snippets and Examples for Chapter
2 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/helidon-demo/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle/
2 | *.iml
3 | *.ipr
4 | *.iws
5 | .idea/
6 | build/
7 | out/
8 | target/
9 | .classpath
10 | .project
11 | tmp/
12 | .DS_Store
13 | .tmp
14 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/helidon-demo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | io.helidon.applications
8 | helidon-mp
9 | 2.3.0
10 |
11 | com.example
12 | demo
13 | 1.0-SNAPSHOT
14 |
15 |
16 |
17 | io.helidon.microprofile.bundles
18 | helidon-microprofile
19 |
20 |
21 | org.jboss
22 | jandex
23 | runtime
24 | true
25 |
26 |
27 | jakarta.activation
28 | jakarta.activation-api
29 | runtime
30 |
31 |
32 | org.junit.jupiter
33 | junit-jupiter-api
34 | test
35 |
36 |
37 |
38 |
39 |
40 |
41 | org.apache.maven.plugins
42 | maven-dependency-plugin
43 |
44 |
45 | copy-libs
46 |
47 |
48 |
49 |
50 | org.jboss.jandex
51 | jandex-maven-plugin
52 |
53 |
54 | make-index
55 |
56 |
57 |
58 |
59 | io.helidon.build-tools
60 | helidon-maven-plugin
61 |
62 |
63 | third-party-license-report
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/helidon-demo/readme.md:
--------------------------------------------------------------------------------
1 | # MicroProfile generated Application
2 |
3 | ## Introduction
4 |
5 | MicroProfile Starter has generated this MicroProfile application for you.
6 |
7 | The generation of the executable jar file can be performed by issuing the following command
8 |
9 | mvn clean package
10 |
11 | This will create an executable jar file **demo.jar** within the _target_ maven folder. This can be started by executing the following command
12 |
13 | java -jar target/demo.jar
14 |
15 |
16 |
17 | To launch the test page, open your browser at the following URL
18 |
19 | http://localhost:8080/index.html
20 |
21 |
22 |
23 | ## Specification examples
24 |
25 | By default, there is always the creation of a JAX-RS application class to define the path on which the JAX-RS endpoints are available.
26 |
27 | Also, a simple Hello world endpoint is created, have a look at the class **HelloController**.
28 |
29 | More information on MicroProfile can be found [here](https://microprofile.io/)
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/helidon-demo/src/main/java/com/example/demo/Greeting.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import io.helidon.common.Reflected;
4 |
5 | @Reflected
6 | public class Greeting {
7 | private final String content;
8 |
9 | public Greeting(String content) {
10 | this.content = content;
11 | }
12 |
13 | public String getContent() {
14 | return content;
15 | }
16 | }
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/helidon-demo/src/main/java/com/example/demo/GreetingResource.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import javax.ws.rs.DefaultValue;
4 | import javax.ws.rs.GET;
5 | import javax.ws.rs.Path;
6 | import javax.ws.rs.QueryParam;
7 |
8 | @Path("/greeting")
9 | public class GreetingResource {
10 | private static final String template = "Hello, %s!";
11 |
12 | @GET
13 | public Greeting greeting(@QueryParam("name") @DefaultValue("World") String name) {
14 | return new Greeting(String.format(template, name));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/helidon-demo/src/main/resources/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devops-tools-for-java-developers/code-snippets/19a9e77448ee1d7b428086c93a646473834a9b5f/chapter04-dissecting-the-monolith/helidon-demo/src/main/resources/.gitkeep
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/helidon-demo/src/main/resources/META-INF/beans.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/helidon-demo/src/main/resources/META-INF/microprofile-config.properties:
--------------------------------------------------------------------------------
1 |
2 | # Microprofile server properties
3 | server.port=8080
4 | server.host=0.0.0.0
5 |
6 | # src/main/resources/WEB in your source tree
7 | server.static.classpath.location=/WEB
8 | # default is index.html
9 | #server.static.classpath.welcome=index.html
10 |
11 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/helidon-demo/src/main/resources/WEB/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Eclipse MicroProfile demo
6 |
7 |
8 |
9 | MicroProfile
10 |
11 | Hello JAX-RS endpoint
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/helidon-demo/src/main/resources/logging.properties:
--------------------------------------------------------------------------------
1 | # Example Logging Configuration File
2 | # For more information see $JAVA_HOME/jre/lib/logging.properties
3 |
4 | # Send messages to the console
5 | handlers=java.util.logging.ConsoleHandler
6 |
7 | # Global default logging level. Can be overriden by specific handlers and loggers
8 | .level=INFO
9 |
10 | # Helidon Web Server has a custom log formatter that extends SimpleFormatter.
11 | # It replaces "!thread!" with the current thread name
12 | java.util.logging.ConsoleHandler.level=INFO
13 | java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter
14 | java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
15 |
16 | #Component specific log levels
17 | #io.helidon.webserver.level=INFO
18 | #io.helidon.config.level=INFO
19 | #io.helidon.security.level=INFO
20 | #io.helidon.microprofile.level=INFO
21 | #io.helidon.common.level=INFO
22 | #io.netty.level=INFO
23 | #org.glassfish.jersey.level=INFO
24 | #org.jboss.weld=INFO
25 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/helidon-demo/src/main/resources/privateKey.pem:
--------------------------------------------------------------------------------
1 | -----BEGIN PRIVATE KEY-----
2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDPAO3J/p486N/+
3 | gQslxfsC4Vct7cAVMi7v3I6mTXDizw+JrpMTRNVUcnVf0ymKIxGHktbnqtFJBfkf
4 | lIdLIxM5PwPB23J0ehklONNq8zGqjFZQI9TU1H3e12Jt7AUn4TKQaPXtBQalybb6
5 | ayT7RhiNNrUGGNzH+wL1ak8jVAEFpLuFcfojJwshF3myNfXInAqRIGCEeQBFyZrh
6 | 8RK+PxoGOiYmXJJgxDxtfr0cMVa7y0gdPuSqEDQND+vt8kVQk47cK8eGH1ypoPfk
7 | emeNOpjjDRaJIuoDgXEOCQxHVT1qN4OjWOfAYRZXtfvy6xrP+rS5o0gqg/1tZbF7
8 | XUmrm46vAgMBAAECggEBAMehqrFKF4rAPvzvsDN+ikPN08icZ8lJO1DhUMT7HCnv
9 | 7JkoPfiwQlgNhjqip4XrqgUoTI7hArK8yvN0x0FkEy77IYF8RBYmhkeKVQHohXZn
10 | nvnshF24i6cz6l395z79hEkWoE0zsqSCMy+v0tttT1Iod03o/kryPXk2TBnS8qVf
11 | 6nv/ohuu2S5KI0b4skxGSM60kA96h6ngCcq4pkwHEtnwJmF2xz4EO+zb558yOF5A
12 | OznjKxTbNH3RsCGG1bMWSvy4qIihdJRDUAeKKdtAZOeLgUrSFHUDxKwCLFIESde0
13 | JP9uXuUlAb8WOnsL4z0jbgx1+ctI0UOIKTJc8sErXrECgYEA+S8cSpgED416ydrt
14 | WWmETeW2sPUJsmDfQhQxUoxhSypDTDBGHGBZzvLSoWCxJBnuY8teiDzDAXh7nHMs
15 | SZA1vT9hZu+qWzgdU+0SK6r0FyY5RFBIHB468fO6S5mJm0wqmy1J94Voaeofij1q
16 | 1pE8/tniLKciP2BnkX7lu2F1E4cCgYEA1Kp0Kz0WwUcu2UnmKOOzqIsA9mwucKAF
17 | zmGA1c8q+Cx2dIgeHQjWtl3SWs0qVps74YEZUYbxmG/M9MHHGbRq7w8hwaSpeFt+
18 | DswiscELag4PuEHn6yGdJyPnXBoERnOvVPlkdDts6NPvLtfcBBkgPqhpvhObf9vf
19 | Cv+trWWExZkCgYAlmY86Tj/mnOGXTdqcsEhPfMcZYpApA2cM0IE0xIv1zJXFDE+3
20 | /m3uxUM1KKLyIJuRIWHNSuXd9fEpBVP8ca86NDMdVjKtewUp4c7pGe2lBJaFkVug
21 | KouYcL9+otdZwJ95NNdBazb7LGG/+U6Cu/2pMvVm6X1IdOKL2MsPgEArRwKBgQDA
22 | midfyZHENg2t6Qmz2pUpfcq/YrakdakMgq3F9jw6Szp0y5pKPWkH/Oy4I7vGeAzB
23 | bMRbW9WOcyKyQJVrKET4gUHXOKPrRyFhkWuShP0rbdS60aWTA/xqKFAuz7kzfS47
24 | zSo3QmKecuLaD9FJPOBBHxG1fdiE8cKNGYZX1etrcQKBgHhnkwmCTxXdimQTswE1
25 | nytAbdXEUSqLU2sZT3sQq497j6uOjcBlZekPtibOuyQLFmeKIMZMI1j0AARbu+ZJ
26 | T7SwLL4cjsws838VujJzXPGxvbp3twvWpZHsUvp2eX/8LiWexL5TPj4jkHkkholH
27 | H675T5VXIbt4N8LR1fHThOJB
28 | -----END PRIVATE KEY-----
29 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/helidon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devops-tools-for-java-developers/code-snippets/19a9e77448ee1d7b428086c93a646473834a9b5f/chapter04-dissecting-the-monolith/helidon.png
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/lambda/quarkus-lambda/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "Role": {
3 | "Path": "/",
4 | "RoleName": "lambda-ex",
5 | "RoleId": "AROAZEJV7ZLPCZ7CNYW6U",
6 | "Arn": "arn:aws:iam::627715328734:role/lambda-ex",
7 | "CreateDate": "2021-06-13T15:22:56+00:00",
8 | "AssumeRolePolicyDocument": {
9 | "Version": "2012-10-17",
10 | "Statement": [
11 | {
12 | "Effect": "Allow",
13 | "Principal": {
14 | "Service": "lambda.amazonaws.com"
15 | },
16 | "Action": "sts:AssumeRole"
17 | }
18 | ]
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/lambda/quarkus-lambda/payload.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Bill",
3 | "greeting": "hello"
4 | }
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/lambda/quarkus-lambda/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 | com.example.demo
7 | quarkus-lambda
8 | 1.0-SNAPSHOT
9 |
10 | 3.8.1
11 | true
12 | 11
13 | 11
14 | 11
15 | UTF-8
16 | UTF-8
17 | 2.5.0.Final
18 | quarkus-bom
19 | io.quarkus
20 | 2.5.0.Final
21 | 3.0.0-M5
22 |
23 |
24 |
25 |
26 | ${quarkus.platform.group-id}
27 | ${quarkus.platform.artifact-id}
28 | ${quarkus.platform.version}
29 | pom
30 | import
31 |
32 |
33 |
34 |
35 |
36 | io.quarkus
37 | quarkus-amazon-lambda
38 |
39 |
40 | io.quarkus
41 | quarkus-test-amazon-lambda
42 | test
43 |
44 |
45 | io.quarkus
46 | quarkus-junit5
47 | test
48 |
49 |
50 |
51 |
52 |
53 | io.quarkus
54 | quarkus-maven-plugin
55 | ${quarkus-plugin.version}
56 |
57 |
58 |
59 | build
60 |
61 |
62 |
63 |
64 |
65 | maven-compiler-plugin
66 | ${compiler-plugin.version}
67 |
68 |
69 | maven-surefire-plugin
70 | ${surefire-plugin.version}
71 |
72 |
73 | org.jboss.logmanager.LogManager
74 | ${maven.home}
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | native
83 |
84 |
85 | native
86 |
87 |
88 |
89 | native
90 |
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/lambda/quarkus-lambda/src/main/java/com/example/demo/GreetingLambda.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import com.amazonaws.services.lambda.runtime.Context;
4 | import com.amazonaws.services.lambda.runtime.RequestHandler;
5 |
6 | import javax.inject.Inject;
7 | import javax.inject.Named;
8 |
9 | @Named("greeting")
10 | public class GreetingLambda implements RequestHandler {
11 | @Inject
12 | ProcessingService service;
13 |
14 | @Override
15 | public OutputObject handleRequest(InputObject input, Context context) {
16 | OutputObject output = service.process(input);
17 | output.setRequestId(context.getAwsRequestId());
18 | return output;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/lambda/quarkus-lambda/src/main/java/com/example/demo/InputObject.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | public class InputObject {
4 | private String name;
5 | private String greeting;
6 |
7 | public String getName() {
8 | return name;
9 | }
10 |
11 | public void setName(String name) {
12 | this.name = name;
13 | }
14 |
15 | public String getGreeting() {
16 | return greeting;
17 | }
18 |
19 | public void setGreeting(String greeting) {
20 | this.greeting = greeting;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/lambda/quarkus-lambda/src/main/java/com/example/demo/OutputObject.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | public class OutputObject {
4 | private String result;
5 | private String requestId;
6 |
7 | public String getResult() {
8 | return result;
9 | }
10 |
11 | public void setResult(String result) {
12 | this.result = result;
13 | }
14 |
15 | public String getRequestId() {
16 | return requestId;
17 | }
18 |
19 | public void setRequestId(String requestId) {
20 | this.requestId = requestId;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/lambda/quarkus-lambda/src/main/java/com/example/demo/ProcessingService.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import javax.enterprise.context.ApplicationScoped;
4 |
5 | @ApplicationScoped
6 | public class ProcessingService {
7 | public OutputObject process(InputObject input) {
8 | OutputObject output = new OutputObject();
9 | output.setResult(input.getGreeting() + " " + input.getName());
10 | return output;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/lambda/quarkus-lambda/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | quarkus.lambda.handler=greeting
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/lambda/quarkus-lambda/src/test/java/com/example/demo/LambdaHandlerTest.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import io.quarkus.amazon.lambda.test.LambdaClient;
4 | import io.quarkus.test.junit.QuarkusTest;
5 | import org.junit.jupiter.api.Assertions;
6 | import org.junit.jupiter.api.Test;
7 |
8 | @QuarkusTest
9 | public class LambdaHandlerTest {
10 | @Test
11 | public void testSimpleLambdaSuccess() throws Exception {
12 | InputObject in = new InputObject();
13 | in.setGreeting("Hello");
14 | in.setName("serverless");
15 | OutputObject out = LambdaClient.invoke(OutputObject.class, in);
16 | Assertions.assertEquals("Hello serverless", out.getResult());
17 | Assertions.assertTrue(out.getRequestId().matches("aws-request-\\d"), "Expected requestId as 'aws-request-'");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/lambda/quarkus-lambda/src/test/resources/application.properties:
--------------------------------------------------------------------------------
1 | quarkus.lambda.handler=greeting
2 |
3 | quarkus.lambda.enable-polling-jvm-mode=true
4 |
5 |
6 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/lambda/quarkus-lambda/trust-policy.json:
--------------------------------------------------------------------------------
1 | {
2 | "Version": "2012-10-17",
3 | "Statement": [
4 | {
5 | "Effect": "Allow",
6 | "Principal": {
7 | "Service": "lambda.amazonaws.com"
8 | },
9 | "Action": "sts:AssumeRole"
10 | }
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/.gitignore:
--------------------------------------------------------------------------------
1 | Thumbs.db
2 | .DS_Store
3 | .gradle
4 | build/
5 | target/
6 | out/
7 | .idea
8 | *.iml
9 | *.ipr
10 | *.iws
11 | .project
12 | .settings
13 | .classpath
14 | .factorypath
15 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/.mvn/wrapper/MavenWrapperDownloader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007-present the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | import java.net.*;
17 | import java.io.*;
18 | import java.nio.channels.*;
19 | import java.util.Properties;
20 |
21 | public class MavenWrapperDownloader {
22 |
23 | private static final String WRAPPER_VERSION = "0.5.6";
24 | /**
25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26 | */
27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29 |
30 | /**
31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32 | * use instead of the default one.
33 | */
34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35 | ".mvn/wrapper/maven-wrapper.properties";
36 |
37 | /**
38 | * Path where the maven-wrapper.jar will be saved to.
39 | */
40 | private static final String MAVEN_WRAPPER_JAR_PATH =
41 | ".mvn/wrapper/maven-wrapper.jar";
42 |
43 | /**
44 | * Name of the property which should be used to override the default download url for the wrapper.
45 | */
46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47 |
48 | public static void main(String args[]) {
49 | System.out.println("- Downloader started");
50 | File baseDirectory = new File(args[0]);
51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52 |
53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom
54 | // wrapperUrl parameter.
55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56 | String url = DEFAULT_DOWNLOAD_URL;
57 | if(mavenWrapperPropertyFile.exists()) {
58 | FileInputStream mavenWrapperPropertyFileInputStream = null;
59 | try {
60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61 | Properties mavenWrapperProperties = new Properties();
62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64 | } catch (IOException e) {
65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66 | } finally {
67 | try {
68 | if(mavenWrapperPropertyFileInputStream != null) {
69 | mavenWrapperPropertyFileInputStream.close();
70 | }
71 | } catch (IOException e) {
72 | // Ignore ...
73 | }
74 | }
75 | }
76 | System.out.println("- Downloading from: " + url);
77 |
78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79 | if(!outputFile.getParentFile().exists()) {
80 | if(!outputFile.getParentFile().mkdirs()) {
81 | System.out.println(
82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83 | }
84 | }
85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86 | try {
87 | downloadFileFromURL(url, outputFile);
88 | System.out.println("Done");
89 | System.exit(0);
90 | } catch (Throwable e) {
91 | System.out.println("- Error downloading");
92 | e.printStackTrace();
93 | System.exit(1);
94 | }
95 | }
96 |
97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99 | String username = System.getenv("MVNW_USERNAME");
100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101 | Authenticator.setDefault(new Authenticator() {
102 | @Override
103 | protected PasswordAuthentication getPasswordAuthentication() {
104 | return new PasswordAuthentication(username, password);
105 | }
106 | });
107 | }
108 | URL website = new URL(urlString);
109 | ReadableByteChannel rbc;
110 | rbc = Channels.newChannel(website.openStream());
111 | FileOutputStream fos = new FileOutputStream(destination);
112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113 | fos.close();
114 | rbc.close();
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devops-tools-for-java-developers/code-snippets/19a9e77448ee1d7b428086c93a646473834a9b5f/chapter04-dissecting-the-monolith/micronaut-demo/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/README.md:
--------------------------------------------------------------------------------
1 | ## Micronaut 2.5.5 Documentation
2 |
3 | - [User Guide](https://docs.micronaut.io/2.5.5/guide/index.html)
4 | - [API Reference](https://docs.micronaut.io/2.5.5/api/index.html)
5 | - [Configuration Reference](https://docs.micronaut.io/2.5.5/guide/configurationreference.html)
6 | - [Micronaut Guides](https://guides.micronaut.io/index.html)
7 | ---
8 |
9 | ## Feature http-client documentation
10 |
11 | - [Micronaut HTTP Client documentation](https://docs.micronaut.io/latest/guide/index.html#httpClient)
12 |
13 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/micronaut-cli.yml:
--------------------------------------------------------------------------------
1 | applicationType: default
2 | defaultPackage: com.example.demo
3 | testFramework: junit
4 | sourceLanguage: java
5 | buildTool: maven
6 | features: [annotation-api, app-name, http-client, java, java-application, junit, logback, maven, netty-server, readme, shade, yaml]
7 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # https://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Mingw, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | fi
118 |
119 | if [ -z "$JAVA_HOME" ]; then
120 | javaExecutable="`which javac`"
121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
122 | # readlink(1) is not available as standard on Solaris 10.
123 | readLink=`which readlink`
124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
125 | if $darwin ; then
126 | javaHome="`dirname \"$javaExecutable\"`"
127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
128 | else
129 | javaExecutable="`readlink -f \"$javaExecutable\"`"
130 | fi
131 | javaHome="`dirname \"$javaExecutable\"`"
132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
133 | JAVA_HOME="$javaHome"
134 | export JAVA_HOME
135 | fi
136 | fi
137 | fi
138 |
139 | if [ -z "$JAVACMD" ] ; then
140 | if [ -n "$JAVA_HOME" ] ; then
141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
142 | # IBM's JDK on AIX uses strange locations for the executables
143 | JAVACMD="$JAVA_HOME/jre/sh/java"
144 | else
145 | JAVACMD="$JAVA_HOME/bin/java"
146 | fi
147 | else
148 | JAVACMD="`which java`"
149 | fi
150 | fi
151 |
152 | if [ ! -x "$JAVACMD" ] ; then
153 | echo "Error: JAVA_HOME is not defined correctly." >&2
154 | echo " We cannot execute $JAVACMD" >&2
155 | exit 1
156 | fi
157 |
158 | if [ -z "$JAVA_HOME" ] ; then
159 | echo "Warning: JAVA_HOME environment variable is not set."
160 | fi
161 |
162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
163 |
164 | # traverses directory structure from process work directory to filesystem root
165 | # first directory with .mvn subdirectory is considered project base directory
166 | find_maven_basedir() {
167 |
168 | if [ -z "$1" ]
169 | then
170 | echo "Path not specified to find_maven_basedir"
171 | return 1
172 | fi
173 |
174 | basedir="$1"
175 | wdir="$1"
176 | while [ "$wdir" != '/' ] ; do
177 | if [ -d "$wdir"/.mvn ] ; then
178 | basedir=$wdir
179 | break
180 | fi
181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
182 | if [ -d "${wdir}" ]; then
183 | wdir=`cd "$wdir/.."; pwd`
184 | fi
185 | # end of workaround
186 | done
187 | echo "${basedir}"
188 | }
189 |
190 | # concatenates all lines of a file
191 | concat_lines() {
192 | if [ -f "$1" ]; then
193 | echo "$(tr -s '\n' ' ' < "$1")"
194 | fi
195 | }
196 |
197 | BASE_DIR=`find_maven_basedir "$(pwd)"`
198 | if [ -z "$BASE_DIR" ]; then
199 | exit 1;
200 | fi
201 |
202 | ##########################################################################################
203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
204 | # This allows using the maven wrapper in projects that prohibit checking in binary data.
205 | ##########################################################################################
206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
207 | if [ "$MVNW_VERBOSE" = true ]; then
208 | echo "Found .mvn/wrapper/maven-wrapper.jar"
209 | fi
210 | else
211 | if [ "$MVNW_VERBOSE" = true ]; then
212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
213 | fi
214 | if [ -n "$MVNW_REPOURL" ]; then
215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
216 | else
217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
218 | fi
219 | while IFS="=" read key value; do
220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
221 | esac
222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
223 | if [ "$MVNW_VERBOSE" = true ]; then
224 | echo "Downloading from: $jarUrl"
225 | fi
226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
227 | if $cygwin; then
228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
229 | fi
230 |
231 | if command -v wget > /dev/null; then
232 | if [ "$MVNW_VERBOSE" = true ]; then
233 | echo "Found wget ... using wget"
234 | fi
235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
236 | wget "$jarUrl" -O "$wrapperJarPath"
237 | else
238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
239 | fi
240 | elif command -v curl > /dev/null; then
241 | if [ "$MVNW_VERBOSE" = true ]; then
242 | echo "Found curl ... using curl"
243 | fi
244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
245 | curl -o "$wrapperJarPath" "$jarUrl" -f
246 | else
247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
248 | fi
249 |
250 | else
251 | if [ "$MVNW_VERBOSE" = true ]; then
252 | echo "Falling back to using Java to download"
253 | fi
254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
255 | # For Cygwin, switch paths to Windows format before running javac
256 | if $cygwin; then
257 | javaClass=`cygpath --path --windows "$javaClass"`
258 | fi
259 | if [ -e "$javaClass" ]; then
260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
261 | if [ "$MVNW_VERBOSE" = true ]; then
262 | echo " - Compiling MavenWrapperDownloader.java ..."
263 | fi
264 | # Compiling the Java class
265 | ("$JAVA_HOME/bin/javac" "$javaClass")
266 | fi
267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
268 | # Running the downloader
269 | if [ "$MVNW_VERBOSE" = true ]; then
270 | echo " - Running MavenWrapperDownloader.java ..."
271 | fi
272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
273 | fi
274 | fi
275 | fi
276 | fi
277 | ##########################################################################################
278 | # End of extension
279 | ##########################################################################################
280 |
281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
282 | if [ "$MVNW_VERBOSE" = true ]; then
283 | echo $MAVEN_PROJECTBASEDIR
284 | fi
285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
286 |
287 | # For Cygwin, switch paths to Windows format before running java
288 | if $cygwin; then
289 | [ -n "$M2_HOME" ] &&
290 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
291 | [ -n "$JAVA_HOME" ] &&
292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
293 | [ -n "$CLASSPATH" ] &&
294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
295 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
297 | fi
298 |
299 | # Provide a "standardized" way to retrieve the CLI args that will
300 | # work with both Windows and non-Windows executions.
301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
302 | export MAVEN_CMD_LINE_ARGS
303 |
304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
305 |
306 | exec "$JAVACMD" \
307 | $MAVEN_OPTS \
308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
311 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/mvnw.bat:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
124 |
125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
162 | if ERRORLEVEL 1 goto error
163 | goto end
164 |
165 | :error
166 | set ERROR_CODE=1
167 |
168 | :end
169 | @endlocal & set ERROR_CODE=%ERROR_CODE%
170 |
171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
175 | :skipRcPost
176 |
177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
179 |
180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
181 |
182 | exit /B %ERROR_CODE%
183 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.example.demo
6 | demo
7 | 0.1
8 | ${packaging}
9 |
10 |
11 | io.micronaut
12 | micronaut-parent
13 | 2.5.5
14 |
15 |
16 |
17 | jar
18 | 11
19 | 11
20 | 2.5.5
21 | com.example.demo.Application
22 | netty
23 |
24 |
25 |
26 |
27 | central
28 | https://repo.maven.apache.org/maven2
29 |
30 |
31 |
32 |
33 |
34 | io.micronaut
35 | micronaut-inject
36 | compile
37 |
38 |
39 | io.micronaut
40 | micronaut-validation
41 | compile
42 |
43 |
44 | org.junit.jupiter
45 | junit-jupiter-api
46 | test
47 |
48 |
49 | org.junit.jupiter
50 | junit-jupiter-engine
51 | test
52 |
53 |
54 | io.micronaut.test
55 | micronaut-test-junit5
56 | test
57 |
58 |
59 | io.micronaut
60 | micronaut-http-client
61 | compile
62 |
63 |
64 | io.micronaut
65 | micronaut-http-server-netty
66 | compile
67 |
68 |
69 | io.micronaut
70 | micronaut-runtime
71 | compile
72 |
73 |
74 | javax.annotation
75 | javax.annotation-api
76 | compile
77 |
78 |
79 | ch.qos.logback
80 | logback-classic
81 | runtime
82 |
83 |
84 |
85 |
86 |
87 |
88 | io.micronaut.build
89 | micronaut-maven-plugin
90 |
91 |
92 |
93 | org.apache.maven.plugins
94 | maven-compiler-plugin
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 | -Amicronaut.processing.group=com.example.demo
103 | -Amicronaut.processing.module=demo
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/src/main/java/com/example/demo/Application.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import io.micronaut.runtime.Micronaut;
4 |
5 | public class Application {
6 |
7 | public static void main(String[] args) {
8 | Micronaut.run(Application.class, args);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/src/main/java/com/example/demo/Greeting.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import io.micronaut.core.annotation.Introspected;
4 |
5 | @Introspected
6 | public class Greeting {
7 | private final String content;
8 |
9 | public Greeting(String content) {
10 | this.content = content;
11 | }
12 |
13 | public String getContent() {
14 | return content;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/src/main/java/com/example/demo/GreetingController.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import io.micronaut.http.annotation.Controller;
4 | import io.micronaut.http.annotation.Get;
5 | import io.micronaut.http.annotation.QueryValue;
6 |
7 | @Controller("/")
8 | public class GreetingController {
9 | @Get(uri = "/greeting")
10 | public Greeting greeting(@QueryValue(value = "name", defaultValue = "World") String name) {
11 | return new Greeting("Hello, " + name + "!");
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | micronaut:
2 | server:
3 | port: 8081
4 | application:
5 | name: demo
6 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut-demo/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 |
7 |
8 | %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/micronaut.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devops-tools-for-java-developers/code-snippets/19a9e77448ee1d7b428086c93a646473834a9b5f/chapter04-dissecting-the-monolith/micronaut.png
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/.dockerignore:
--------------------------------------------------------------------------------
1 | *
2 | !target/*-runner
3 | !target/*-runner.jar
4 | !target/lib/*
5 | !target/quarkus-app/*
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/.gitignore:
--------------------------------------------------------------------------------
1 | #Maven
2 | target/
3 | pom.xml.tag
4 | pom.xml.releaseBackup
5 | pom.xml.versionsBackup
6 | release.properties
7 |
8 | # Eclipse
9 | .project
10 | .classpath
11 | .settings/
12 | bin/
13 |
14 | # IntelliJ
15 | .idea
16 | *.ipr
17 | *.iml
18 | *.iws
19 |
20 | # NetBeans
21 | nb-configuration.xml
22 |
23 | # Visual Studio Code
24 | .vscode
25 | .factorypath
26 |
27 | # OSX
28 | .DS_Store
29 |
30 | # Vim
31 | *.swp
32 | *.swo
33 |
34 | # patch
35 | *.orig
36 | *.rej
37 |
38 | # Local environment
39 | .env
40 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/.mvn/wrapper/MavenWrapperDownloader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007-present the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | import java.net.*;
17 | import java.io.*;
18 | import java.nio.channels.*;
19 | import java.util.Properties;
20 |
21 | public class MavenWrapperDownloader {
22 |
23 | private static final String WRAPPER_VERSION = "0.5.6";
24 | /**
25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26 | */
27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29 |
30 | /**
31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32 | * use instead of the default one.
33 | */
34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35 | ".mvn/wrapper/maven-wrapper.properties";
36 |
37 | /**
38 | * Path where the maven-wrapper.jar will be saved to.
39 | */
40 | private static final String MAVEN_WRAPPER_JAR_PATH =
41 | ".mvn/wrapper/maven-wrapper.jar";
42 |
43 | /**
44 | * Name of the property which should be used to override the default download url for the wrapper.
45 | */
46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47 |
48 | public static void main(String args[]) {
49 | System.out.println("- Downloader started");
50 | File baseDirectory = new File(args[0]);
51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52 |
53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom
54 | // wrapperUrl parameter.
55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56 | String url = DEFAULT_DOWNLOAD_URL;
57 | if(mavenWrapperPropertyFile.exists()) {
58 | FileInputStream mavenWrapperPropertyFileInputStream = null;
59 | try {
60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61 | Properties mavenWrapperProperties = new Properties();
62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64 | } catch (IOException e) {
65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66 | } finally {
67 | try {
68 | if(mavenWrapperPropertyFileInputStream != null) {
69 | mavenWrapperPropertyFileInputStream.close();
70 | }
71 | } catch (IOException e) {
72 | // Ignore ...
73 | }
74 | }
75 | }
76 | System.out.println("- Downloading from: " + url);
77 |
78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79 | if(!outputFile.getParentFile().exists()) {
80 | if(!outputFile.getParentFile().mkdirs()) {
81 | System.out.println(
82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83 | }
84 | }
85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86 | try {
87 | downloadFileFromURL(url, outputFile);
88 | System.out.println("Done");
89 | System.exit(0);
90 | } catch (Throwable e) {
91 | System.out.println("- Error downloading");
92 | e.printStackTrace();
93 | System.exit(1);
94 | }
95 | }
96 |
97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99 | String username = System.getenv("MVNW_USERNAME");
100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101 | Authenticator.setDefault(new Authenticator() {
102 | @Override
103 | protected PasswordAuthentication getPasswordAuthentication() {
104 | return new PasswordAuthentication(username, password);
105 | }
106 | });
107 | }
108 | URL website = new URL(urlString);
109 | ReadableByteChannel rbc;
110 | rbc = Channels.newChannel(website.openStream());
111 | FileOutputStream fos = new FileOutputStream(destination);
112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113 | fos.close();
114 | rbc.close();
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devops-tools-for-java-developers/code-snippets/19a9e77448ee1d7b428086c93a646473834a9b5f/chapter04-dissecting-the-monolith/quarkus-demo/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/README.md:
--------------------------------------------------------------------------------
1 | # demo project
2 |
3 | This project uses Quarkus, the Supersonic Subatomic Java Framework.
4 |
5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
6 |
7 | ## Running the application in dev mode
8 |
9 | You can run your application in dev mode that enables live coding using:
10 | ```shell script
11 | ./mvnw compile quarkus:dev
12 | ```
13 |
14 | > **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
15 |
16 | ## Packaging and running the application
17 |
18 | The application can be packaged using:
19 | ```shell script
20 | ./mvnw package
21 | ```
22 | It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
23 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.
24 |
25 | If you want to build an _über-jar_, execute the following command:
26 | ```shell script
27 | ./mvnw package -Dquarkus.package.type=uber-jar
28 | ```
29 |
30 | The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`.
31 |
32 | ## Creating a native executable
33 |
34 | You can create a native executable using:
35 | ```shell script
36 | ./mvnw package -Pnative
37 | ```
38 |
39 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
40 | ```shell script
41 | ./mvnw package -Pnative -Dquarkus.native.container-build=true
42 | ```
43 |
44 | You can then execute your native executable with: `./target/demo-1.0.0-SNAPSHOT-runner`
45 |
46 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html.
47 |
48 | ## Provided examples
49 |
50 | ### RESTEasy JAX-RS example
51 |
52 | REST is easy peasy with this Hello World RESTEasy resource.
53 |
54 | [Related guide section...](https://quarkus.io/guides/getting-started#the-jax-rs-resources)
55 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # https://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Mingw, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | fi
118 |
119 | if [ -z "$JAVA_HOME" ]; then
120 | javaExecutable="`which javac`"
121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
122 | # readlink(1) is not available as standard on Solaris 10.
123 | readLink=`which readlink`
124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
125 | if $darwin ; then
126 | javaHome="`dirname \"$javaExecutable\"`"
127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
128 | else
129 | javaExecutable="`readlink -f \"$javaExecutable\"`"
130 | fi
131 | javaHome="`dirname \"$javaExecutable\"`"
132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
133 | JAVA_HOME="$javaHome"
134 | export JAVA_HOME
135 | fi
136 | fi
137 | fi
138 |
139 | if [ -z "$JAVACMD" ] ; then
140 | if [ -n "$JAVA_HOME" ] ; then
141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
142 | # IBM's JDK on AIX uses strange locations for the executables
143 | JAVACMD="$JAVA_HOME/jre/sh/java"
144 | else
145 | JAVACMD="$JAVA_HOME/bin/java"
146 | fi
147 | else
148 | JAVACMD="`which java`"
149 | fi
150 | fi
151 |
152 | if [ ! -x "$JAVACMD" ] ; then
153 | echo "Error: JAVA_HOME is not defined correctly." >&2
154 | echo " We cannot execute $JAVACMD" >&2
155 | exit 1
156 | fi
157 |
158 | if [ -z "$JAVA_HOME" ] ; then
159 | echo "Warning: JAVA_HOME environment variable is not set."
160 | fi
161 |
162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
163 |
164 | # traverses directory structure from process work directory to filesystem root
165 | # first directory with .mvn subdirectory is considered project base directory
166 | find_maven_basedir() {
167 |
168 | if [ -z "$1" ]
169 | then
170 | echo "Path not specified to find_maven_basedir"
171 | return 1
172 | fi
173 |
174 | basedir="$1"
175 | wdir="$1"
176 | while [ "$wdir" != '/' ] ; do
177 | if [ -d "$wdir"/.mvn ] ; then
178 | basedir=$wdir
179 | break
180 | fi
181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
182 | if [ -d "${wdir}" ]; then
183 | wdir=`cd "$wdir/.."; pwd`
184 | fi
185 | # end of workaround
186 | done
187 | echo "${basedir}"
188 | }
189 |
190 | # concatenates all lines of a file
191 | concat_lines() {
192 | if [ -f "$1" ]; then
193 | echo "$(tr -s '\n' ' ' < "$1")"
194 | fi
195 | }
196 |
197 | BASE_DIR=`find_maven_basedir "$(pwd)"`
198 | if [ -z "$BASE_DIR" ]; then
199 | exit 1;
200 | fi
201 |
202 | ##########################################################################################
203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
204 | # This allows using the maven wrapper in projects that prohibit checking in binary data.
205 | ##########################################################################################
206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
207 | if [ "$MVNW_VERBOSE" = true ]; then
208 | echo "Found .mvn/wrapper/maven-wrapper.jar"
209 | fi
210 | else
211 | if [ "$MVNW_VERBOSE" = true ]; then
212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
213 | fi
214 | if [ -n "$MVNW_REPOURL" ]; then
215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
216 | else
217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
218 | fi
219 | while IFS="=" read key value; do
220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
221 | esac
222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
223 | if [ "$MVNW_VERBOSE" = true ]; then
224 | echo "Downloading from: $jarUrl"
225 | fi
226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
227 | if $cygwin; then
228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
229 | fi
230 |
231 | if command -v wget > /dev/null; then
232 | if [ "$MVNW_VERBOSE" = true ]; then
233 | echo "Found wget ... using wget"
234 | fi
235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
236 | wget "$jarUrl" -O "$wrapperJarPath"
237 | else
238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
239 | fi
240 | elif command -v curl > /dev/null; then
241 | if [ "$MVNW_VERBOSE" = true ]; then
242 | echo "Found curl ... using curl"
243 | fi
244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
245 | curl -o "$wrapperJarPath" "$jarUrl" -f
246 | else
247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
248 | fi
249 |
250 | else
251 | if [ "$MVNW_VERBOSE" = true ]; then
252 | echo "Falling back to using Java to download"
253 | fi
254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
255 | # For Cygwin, switch paths to Windows format before running javac
256 | if $cygwin; then
257 | javaClass=`cygpath --path --windows "$javaClass"`
258 | fi
259 | if [ -e "$javaClass" ]; then
260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
261 | if [ "$MVNW_VERBOSE" = true ]; then
262 | echo " - Compiling MavenWrapperDownloader.java ..."
263 | fi
264 | # Compiling the Java class
265 | ("$JAVA_HOME/bin/javac" "$javaClass")
266 | fi
267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
268 | # Running the downloader
269 | if [ "$MVNW_VERBOSE" = true ]; then
270 | echo " - Running MavenWrapperDownloader.java ..."
271 | fi
272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
273 | fi
274 | fi
275 | fi
276 | fi
277 | ##########################################################################################
278 | # End of extension
279 | ##########################################################################################
280 |
281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
282 | if [ "$MVNW_VERBOSE" = true ]; then
283 | echo $MAVEN_PROJECTBASEDIR
284 | fi
285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
286 |
287 | # For Cygwin, switch paths to Windows format before running java
288 | if $cygwin; then
289 | [ -n "$M2_HOME" ] &&
290 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
291 | [ -n "$JAVA_HOME" ] &&
292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
293 | [ -n "$CLASSPATH" ] &&
294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
295 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
297 | fi
298 |
299 | # Provide a "standardized" way to retrieve the CLI args that will
300 | # work with both Windows and non-Windows executions.
301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
302 | export MAVEN_CMD_LINE_ARGS
303 |
304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
305 |
306 | exec "$JAVACMD" \
307 | $MAVEN_OPTS \
308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
311 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
124 |
125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
162 | if ERRORLEVEL 1 goto error
163 | goto end
164 |
165 | :error
166 | set ERROR_CODE=1
167 |
168 | :end
169 | @endlocal & set ERROR_CODE=%ERROR_CODE%
170 |
171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
175 | :skipRcPost
176 |
177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
179 |
180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
181 |
182 | exit /B %ERROR_CODE%
183 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.example
6 | demo
7 | 1.0.0-SNAPSHOT
8 |
9 | 3.8.1
10 | true
11 | 11
12 | 11
13 | UTF-8
14 | UTF-8
15 | 2.5.0.Final
16 | quarkus-universe-bom
17 | io.quarkus
18 | 3.0.0-M5
19 |
20 |
21 |
22 |
23 | ${quarkus.platform.group-id}
24 | ${quarkus.platform.artifact-id}
25 | ${quarkus-plugin.version}
26 | pom
27 | import
28 |
29 |
30 |
31 |
32 |
33 | io.quarkus
34 | quarkus-arc
35 |
36 |
37 | io.quarkus
38 | quarkus-resteasy
39 |
40 |
41 | io.quarkus
42 | quarkus-resteasy-jackson
43 |
44 |
45 | io.quarkus
46 | quarkus-junit5
47 | test
48 |
49 |
50 | io.rest-assured
51 | rest-assured
52 | test
53 |
54 |
55 |
56 |
57 |
58 | io.quarkus
59 | quarkus-maven-plugin
60 | ${quarkus-plugin.version}
61 | true
62 |
63 |
64 |
65 | build
66 | generate-code
67 | generate-code-tests
68 |
69 |
70 |
71 |
72 |
73 | maven-compiler-plugin
74 | ${compiler-plugin.version}
75 |
76 | ${maven.compiler.parameters}
77 |
78 |
79 |
80 | maven-surefire-plugin
81 | ${surefire-plugin.version}
82 |
83 |
84 | org.jboss.logmanager.LogManager
85 | ${maven.home}
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 | native
94 |
95 |
96 | native
97 |
98 |
99 |
100 |
101 |
102 | maven-failsafe-plugin
103 | ${surefire-plugin.version}
104 |
105 |
106 |
107 | integration-test
108 | verify
109 |
110 |
111 |
112 | ${project.build.directory}/${project.build.finalName}-runner
113 | org.jboss.logmanager.LogManager
114 | ${maven.home}
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 | native
124 |
125 |
126 |
127 |
128 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/src/main/docker/Dockerfile.jvm:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/demo-jvm .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/demo-jvm
15 | #
16 | # If you want to include the debug port into your docker image
17 | # you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005
18 | #
19 | # Then run the container using :
20 | #
21 | # docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/demo-jvm
22 | #
23 | ###
24 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
25 |
26 | ARG JAVA_PACKAGE=java-11-openjdk-headless
27 | ARG RUN_JAVA_VERSION=1.3.8
28 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
29 | # Install java and the run-java script
30 | # Also set up permissions for user `1001`
31 | RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
32 | && microdnf update \
33 | && microdnf clean all \
34 | && mkdir /deployments \
35 | && chown 1001 /deployments \
36 | && chmod "g+rwX" /deployments \
37 | && chown 1001:root /deployments \
38 | && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
39 | && chown 1001 /deployments/run-java.sh \
40 | && chmod 540 /deployments/run-java.sh \
41 | && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security
42 |
43 | # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
44 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
45 | # We make four distinct layers so if there are application changes the library layers can be re-used
46 | COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/
47 | COPY --chown=1001 target/quarkus-app/*.jar /deployments/
48 | COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
49 | COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/
50 |
51 | EXPOSE 8080
52 | USER 1001
53 |
54 | ENTRYPOINT [ "/deployments/run-java.sh" ]
55 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/src/main/docker/Dockerfile.legacy-jar:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package -Dquarkus.package.type=legacy-jar
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/demo-legacy-jar .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/demo-legacy-jar
15 | #
16 | # If you want to include the debug port into your docker image
17 | # you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005
18 | #
19 | # Then run the container using :
20 | #
21 | # docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/demo-legacy-jar
22 | #
23 | ###
24 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
25 |
26 | ARG JAVA_PACKAGE=java-11-openjdk-headless
27 | ARG RUN_JAVA_VERSION=1.3.8
28 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
29 | # Install java and the run-java script
30 | # Also set up permissions for user `1001`
31 | RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
32 | && microdnf update \
33 | && microdnf clean all \
34 | && mkdir /deployments \
35 | && chown 1001 /deployments \
36 | && chmod "g+rwX" /deployments \
37 | && chown 1001:root /deployments \
38 | && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
39 | && chown 1001 /deployments/run-java.sh \
40 | && chmod 540 /deployments/run-java.sh \
41 | && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security
42 |
43 | # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
44 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
45 | COPY target/lib/* /deployments/lib/
46 | COPY target/*-runner.jar /deployments/app.jar
47 |
48 | EXPOSE 8080
49 | USER 1001
50 |
51 | ENTRYPOINT [ "/deployments/run-java.sh" ]
52 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/src/main/docker/Dockerfile.native:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package -Pnative
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/demo .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/demo
15 | #
16 | ###
17 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
18 | WORKDIR /work/
19 | RUN chown 1001 /work \
20 | && chmod "g+rwX" /work \
21 | && chown 1001:root /work
22 | COPY --chown=1001:root target/*-runner /work/application
23 |
24 | EXPOSE 8080
25 | USER 1001
26 |
27 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
28 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/src/main/docker/Dockerfile.native-distroless:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a distroless container that runs the Quarkus application in native (no JVM) mode
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package -Pnative
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.native-distroless -t quarkus/demo .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/demo
15 | #
16 | ###
17 | FROM quay.io/quarkus/quarkus-distroless-image:1.0
18 | COPY target/*-runner /application
19 |
20 | EXPOSE 8080
21 | USER nonroot
22 |
23 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
24 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/src/main/java/com/example/demo/Greeting.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | public class Greeting {
4 | private final String content;
5 |
6 | public Greeting(String content) {
7 | this.content = content;
8 | }
9 |
10 | public String getContent() {
11 | return content;
12 | }
13 | }
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/src/main/java/com/example/demo/GreetingResource.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import javax.ws.rs.DefaultValue;
4 | import javax.ws.rs.GET;
5 | import javax.ws.rs.Path;
6 | import javax.ws.rs.QueryParam;
7 |
8 | @Path("/greeting")
9 | public class GreetingResource {
10 | private static final String template = "Hello, %s!";
11 |
12 | @GET
13 | public Greeting greeting(@QueryParam("name") @DefaultValue("World") String name) {
14 | return new Greeting(String.format(template, name));
15 | }
16 | }
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/src/main/resources/META-INF/resources/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | demo - 1.0.0-SNAPSHOT
6 |
108 |
109 |
110 |
111 |
112 | Your new Cloud-Native application is ready!
113 |
114 |
115 |
116 |
117 |
Congratulations, you have created a new Quarkus cloud application.
118 |
119 |
What is this page?
120 |
121 |
This page is served by Quarkus. The source is in
122 | src/main/resources/META-INF/resources/index.html
.
123 |
124 |
What are your next steps?
125 |
126 |
If not already done, run the application in dev mode using: ./mvnw compile quarkus:dev
.
127 |
128 |
129 | - Your static assets are located in
src/main/resources/META-INF/resources
.
130 | - Configure your application in
src/main/resources/application.properties
.
131 | - Quarkus now ships with a Dev UI (available in dev mode only)
132 | - Play with the getting started example code located in
src/main/java
:
133 |
134 |
140 |
141 |
142 |
143 |
144 |
Application
145 |
146 | - GroupId:
com.example
147 | - ArtifactId:
demo
148 | - Version:
1.0.0-SNAPSHOT
149 | - Quarkus Version:
1.13.6.Final
150 |
151 |
152 |
153 |
Do you like Quarkus?
154 |
155 | - Go give it a star on GitHub.
156 |
157 |
158 |
159 |
More reading
160 |
166 |
167 |
168 |
169 |
170 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus-demo/src/main/resources/application.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devops-tools-for-java-developers/code-snippets/19a9e77448ee1d7b428086c93a646473834a9b5f/chapter04-dissecting-the-monolith/quarkus-demo/src/main/resources/application.properties
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/quarkus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devops-tools-for-java-developers/code-snippets/19a9e77448ee1d7b428086c93a646473834a9b5f/chapter04-dissecting-the-monolith/quarkus.png
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/spring-boot-demo/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/spring-boot-demo/.mvn/wrapper/MavenWrapperDownloader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007-present the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | import java.net.*;
17 | import java.io.*;
18 | import java.nio.channels.*;
19 | import java.util.Properties;
20 |
21 | public class MavenWrapperDownloader {
22 |
23 | private static final String WRAPPER_VERSION = "0.5.6";
24 | /**
25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26 | */
27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29 |
30 | /**
31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32 | * use instead of the default one.
33 | */
34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35 | ".mvn/wrapper/maven-wrapper.properties";
36 |
37 | /**
38 | * Path where the maven-wrapper.jar will be saved to.
39 | */
40 | private static final String MAVEN_WRAPPER_JAR_PATH =
41 | ".mvn/wrapper/maven-wrapper.jar";
42 |
43 | /**
44 | * Name of the property which should be used to override the default download url for the wrapper.
45 | */
46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47 |
48 | public static void main(String args[]) {
49 | System.out.println("- Downloader started");
50 | File baseDirectory = new File(args[0]);
51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52 |
53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom
54 | // wrapperUrl parameter.
55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56 | String url = DEFAULT_DOWNLOAD_URL;
57 | if(mavenWrapperPropertyFile.exists()) {
58 | FileInputStream mavenWrapperPropertyFileInputStream = null;
59 | try {
60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61 | Properties mavenWrapperProperties = new Properties();
62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64 | } catch (IOException e) {
65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66 | } finally {
67 | try {
68 | if(mavenWrapperPropertyFileInputStream != null) {
69 | mavenWrapperPropertyFileInputStream.close();
70 | }
71 | } catch (IOException e) {
72 | // Ignore ...
73 | }
74 | }
75 | }
76 | System.out.println("- Downloading from: " + url);
77 |
78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79 | if(!outputFile.getParentFile().exists()) {
80 | if(!outputFile.getParentFile().mkdirs()) {
81 | System.out.println(
82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83 | }
84 | }
85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86 | try {
87 | downloadFileFromURL(url, outputFile);
88 | System.out.println("Done");
89 | System.exit(0);
90 | } catch (Throwable e) {
91 | System.out.println("- Error downloading");
92 | e.printStackTrace();
93 | System.exit(1);
94 | }
95 | }
96 |
97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99 | String username = System.getenv("MVNW_USERNAME");
100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101 | Authenticator.setDefault(new Authenticator() {
102 | @Override
103 | protected PasswordAuthentication getPasswordAuthentication() {
104 | return new PasswordAuthentication(username, password);
105 | }
106 | });
107 | }
108 | URL website = new URL(urlString);
109 | ReadableByteChannel rbc;
110 | rbc = Channels.newChannel(website.openStream());
111 | FileOutputStream fos = new FileOutputStream(destination);
112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113 | fos.close();
114 | rbc.close();
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/spring-boot-demo/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devops-tools-for-java-developers/code-snippets/19a9e77448ee1d7b428086c93a646473834a9b5f/chapter04-dissecting-the-monolith/spring-boot-demo/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/spring-boot-demo/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/spring-boot-demo/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
124 |
125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
162 | if ERRORLEVEL 1 goto error
163 | goto end
164 |
165 | :error
166 | set ERROR_CODE=1
167 |
168 | :end
169 | @endlocal & set ERROR_CODE=%ERROR_CODE%
170 |
171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
175 | :skipRcPost
176 |
177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
179 |
180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
181 |
182 | exit /B %ERROR_CODE%
183 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/spring-boot-demo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.springframework.boot
7 | spring-boot-starter-parent
8 | 2.5.0
9 |
10 | com.example
11 | demo
12 | 0.0.1-SNAPSHOT
13 | demo
14 | Demo project for Spring Boot
15 |
16 | 11
17 | 0.10.5
18 |
19 |
20 |
21 | org.springframework.boot
22 | spring-boot-starter-web
23 |
24 |
25 | org.springframework.experimental
26 | spring-native
27 | ${spring-native.version}
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter-test
32 | test
33 |
34 |
35 |
36 |
37 |
38 |
39 | org.springframework.boot
40 | spring-boot-maven-plugin
41 |
42 | exec
43 |
44 |
45 |
46 | org.springframework.experimental
47 | spring-aot-maven-plugin
48 | ${spring-native.version}
49 |
50 |
51 | test-generate
52 |
53 | test-generate
54 |
55 |
56 |
57 | generate
58 |
59 | generate
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | spring-release
69 | Spring release
70 | https://repo.spring.io/release
71 |
72 |
73 |
74 |
75 | spring-release
76 | Spring release
77 | https://repo.spring.io/release
78 |
79 |
80 |
81 |
82 |
83 | native-image
84 |
85 |
86 |
87 | org.graalvm.nativeimage
88 | native-image-maven-plugin
89 | 21.1.0
90 |
91 | com.example.demo.DemoApplication
92 |
93 |
94 |
95 |
96 | native-image
97 |
98 | package
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/spring-boot-demo/src/main/java/com/example/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class DemoApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(DemoApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/spring-boot-demo/src/main/java/com/example/demo/Greeting.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | public class Greeting {
4 | private final String content;
5 |
6 | public Greeting(String content) {
7 | this.content = content;
8 | }
9 |
10 | public String getContent() {
11 | return content;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/spring-boot-demo/src/main/java/com/example/demo/GreetingController.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.springframework.web.bind.annotation.GetMapping;
4 | import org.springframework.web.bind.annotation.RequestParam;
5 | import org.springframework.web.bind.annotation.RestController;
6 |
7 | @RestController
8 | public class GreetingController {
9 | private static final String template = "Hello, %s!";
10 |
11 | @GetMapping("/greeting")
12 | public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
13 | return new Greeting(String.format(template, name));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/spring-boot-demo/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/chapter04-dissecting-the-monolith/spring-boot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devops-tools-for-java-developers/code-snippets/19a9e77448ee1d7b428086c93a646473834a9b5f/chapter04-dissecting-the-monolith/spring-boot.png
--------------------------------------------------------------------------------
/chapter05-continuous-integration/Example5-1-build.xml:
--------------------------------------------------------------------------------
1 | <1>
2 |
3 | <2>
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | <3>
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | <4>
21 |
22 |
27 |
28 |
29 |
30 |
31 |
36 |
37 |
38 | <5>
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | <6>
53 |
54 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/chapter05-continuous-integration/Example5-2-pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 |
7 | com.mycompany.app <1>
8 | my-app
9 | 1.0-SNAPSHOT
10 |
11 | my-app
12 |
13 | http://www.example.com
14 |
15 | <2>
16 | UTF-8
17 | 11
18 |
19 |
20 | <3>
21 |
22 | junit
23 | junit
24 | 4.11
25 | test
26 |
27 |
28 |
29 | <4>
30 |
31 |
32 | <5>
33 | maven-compiler-plugin
34 | 3.8.0
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/chapter05-continuous-integration/Example5-3-build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * This file was generated by the Gradle 'init' task.
3 | */
4 |
5 | plugins {
6 | id 'java' <1>
7 | id 'maven-publish'
8 | }
9 |
10 | repositories { <2>
11 | mavenLocal()
12 | maven {
13 | url = uri('https://repo.maven.apache.org/maven2')
14 | }
15 | }
16 |
17 | dependencies {
18 | testImplementation 'junit:junit:4.11' <3>
19 | }
20 |
21 | group = 'com.mycompany.app'
22 | version = '1.0-SNAPSHOT'
23 | description = 'my-app'
24 | sourceCompatibility = '11' <4>
25 |
26 | publishing {
27 | publications {
28 | maven(MavenPublication) {
29 | from(components.java)
30 | }
31 | }
32 | }
33 |
34 | tasks.withType(JavaCompile) { <5>
35 | options.encoding = 'UTF-8'
36 | }
37 |
--------------------------------------------------------------------------------
/chapter05-continuous-integration/README.md:
--------------------------------------------------------------------------------
1 | Code Snippets and Examples for Chapter
2 |
--------------------------------------------------------------------------------
/chapter06-package-management/README.md:
--------------------------------------------------------------------------------
1 | Code Snippets and Examples for Chapter
2 |
--------------------------------------------------------------------------------
/chapter06-package-management/gradle-manifest/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java-library'
3 | id 'net.nemerosa.versioning' version '2.14.0'
4 | }
5 |
6 | version = '1.0.0-SNAPSHOT'
7 |
8 | ext {
9 | buildJdk = [
10 | System.properties['java.version'],
11 | '(' + System.properties['java.vendor'],
12 | System.properties['java.vm.version'] + ')'
13 | ].join(' ')
14 | buildOs = [
15 | System.properties['os.name'],
16 | System.properties['os.arch'],
17 | System.properties['os.version']
18 | ].join(' ')
19 | buildRevision = project.extensions.versioning.info.commit
20 | buildTimestamp = new Date().format("yyyy-MM-dd'T'HH:mm:ssXXX")
21 | }
22 |
23 | jar {
24 | manifest {
25 | attributes(
26 | 'Build-Jdk' : project.buildJdk,
27 | 'Build-OS' : project.buildOs,
28 | 'Build-Revision' : project.buildRevision,
29 | 'Build-Timestamp': project.buildTimestamp
30 | )
31 | }
32 | }
--------------------------------------------------------------------------------
/chapter06-package-management/gradle-manifest/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'example'
--------------------------------------------------------------------------------
/chapter06-package-management/gradle-properties/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java-library'
3 | id 'net.nemerosa.versioning' version '2.14.0'
4 | }
5 |
6 | version = '1.0.0-SNAPSHOT'
7 |
8 | ext {
9 | buildJdk = [
10 | System.properties['java.version'],
11 | '(' + System.properties['java.vendor'],
12 | System.properties['java.vm.version'] + ')'
13 | ].join(' ')
14 | buildOs = [
15 | System.properties['os.name'],
16 | System.properties['os.arch'],
17 | System.properties['os.version']
18 | ].join(' ')
19 | buildRevision = project.extensions.versioning.info.commit
20 | buildTimestamp = new Date().format("yyyy-MM-dd'T'HH:mm:ssXXX")
21 | }
22 |
23 | processResources {
24 | expand(
25 | 'build_jdk' : project.buildJdk,
26 | 'build_os' : project.buildOs,
27 | 'build_revision' : project.buildRevision,
28 | 'build_timestamp': project.buildTimestamp
29 | )
30 | }
--------------------------------------------------------------------------------
/chapter06-package-management/gradle-properties/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'example'
--------------------------------------------------------------------------------
/chapter06-package-management/gradle-properties/src/main/resources/META-INF/metadata.properties:
--------------------------------------------------------------------------------
1 | build.jdk = ${build_jdk}
2 | build.os = ${build_os}
3 | build.revision = ${build_revision}
4 | build.timestamp = ${build_timestamp}
5 |
--------------------------------------------------------------------------------
/chapter06-package-management/maven-manifest/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | com.acme
6 | example
7 | 1.0.0-SNAPSHOT
8 |
9 |
10 | UTF-8
11 | ${java.version} (${java.vendor} ${java.vm.version})
12 | ${os.name} ${os.arch} ${os.version}
13 | ${git.commit.id}
14 | ${git.build.time}
15 |
16 |
17 |
18 |
19 |
20 | pl.project13.maven
21 | git-commit-id-plugin
22 | 4.0.3
23 |
24 |
25 | resolve-git-pproperties
26 |
27 | revision
28 |
29 |
30 |
31 |
32 | false
33 | false
34 | true
35 | ${project.build.directory}/git.properties
36 |
37 | yyyy-MM-dd'T'HH:mm:ssXXX
38 |
39 |
40 |
41 | org.apache.maven.plugins
42 | maven-jar-plugin
43 | 3.2.0
44 |
45 |
46 |
47 | ${build.jdk}
48 | ${build.os}
49 | ${build.revision}
50 | ${build.timestamp}
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/chapter06-package-management/maven-properties/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | com.acme
6 | example
7 | 1.0.0-SNAPSHOT
8 |
9 |
10 | UTF-8
11 | ${java.version} (${java.vendor} ${java.vm.version})
12 | ${os.name} ${os.arch} ${os.version}
13 | ${git.commit.id}
14 | ${git.build.time}
15 |
16 |
17 |
18 |
19 |
20 | pl.project13.maven
21 | git-commit-id-plugin
22 | 4.0.3
23 |
24 |
25 | resolve-git-pproperties
26 |
27 | revision
28 |
29 |
30 |
31 |
32 | false
33 | false
34 | true
35 | ${project.build.directory}/git.properties
36 |
37 | yyyy-MM-dd'T'HH:mm:ssXXX
38 |
39 |
40 |
41 |
42 |
43 | src/main/resources
44 | true
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/chapter06-package-management/maven-properties/src/main/resources/META-INF/metadata.properties:
--------------------------------------------------------------------------------
1 | build.jdk = ${build.jdk}
2 | build.os = ${build.os}
3 | build.revision = ${build.revision}
4 | build.timestamp = ${build.timestamp}
5 |
--------------------------------------------------------------------------------
/chapter07-securing-your-binaries/README.md:
--------------------------------------------------------------------------------
1 | Code Snippets and Examples for Chapter
2 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/README.md:
--------------------------------------------------------------------------------
1 | Code Snippets and Examples for Chapter
2 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/.dockerignore:
--------------------------------------------------------------------------------
1 | *
2 | !target/*-runner
3 | !target/*-runner.jar
4 | !target/lib/*
5 | !target/quarkus-app/*
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/.gitignore:
--------------------------------------------------------------------------------
1 | #Maven
2 | target/
3 | pom.xml.tag
4 | pom.xml.releaseBackup
5 | pom.xml.versionsBackup
6 | release.properties
7 |
8 | # Eclipse
9 | .project
10 | .classpath
11 | .settings/
12 | bin/
13 |
14 | # IntelliJ
15 | .idea
16 | *.ipr
17 | *.iml
18 | *.iws
19 |
20 | # NetBeans
21 | nb-configuration.xml
22 |
23 | # Visual Studio Code
24 | .vscode
25 | .factorypath
26 |
27 | # OSX
28 | .DS_Store
29 |
30 | # Vim
31 | *.swp
32 | *.swo
33 |
34 | # patch
35 | *.orig
36 | *.rej
37 |
38 | # Local environment
39 | .env
40 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/.mvn/wrapper/MavenWrapperDownloader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007-present the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | import java.net.*;
17 | import java.io.*;
18 | import java.nio.channels.*;
19 | import java.util.Properties;
20 |
21 | public class MavenWrapperDownloader {
22 |
23 | private static final String WRAPPER_VERSION = "0.5.6";
24 | /**
25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26 | */
27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29 |
30 | /**
31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32 | * use instead of the default one.
33 | */
34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35 | ".mvn/wrapper/maven-wrapper.properties";
36 |
37 | /**
38 | * Path where the maven-wrapper.jar will be saved to.
39 | */
40 | private static final String MAVEN_WRAPPER_JAR_PATH =
41 | ".mvn/wrapper/maven-wrapper.jar";
42 |
43 | /**
44 | * Name of the property which should be used to override the default download url for the wrapper.
45 | */
46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47 |
48 | public static void main(String args[]) {
49 | System.out.println("- Downloader started");
50 | File baseDirectory = new File(args[0]);
51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52 |
53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom
54 | // wrapperUrl parameter.
55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56 | String url = DEFAULT_DOWNLOAD_URL;
57 | if(mavenWrapperPropertyFile.exists()) {
58 | FileInputStream mavenWrapperPropertyFileInputStream = null;
59 | try {
60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61 | Properties mavenWrapperProperties = new Properties();
62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64 | } catch (IOException e) {
65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66 | } finally {
67 | try {
68 | if(mavenWrapperPropertyFileInputStream != null) {
69 | mavenWrapperPropertyFileInputStream.close();
70 | }
71 | } catch (IOException e) {
72 | // Ignore ...
73 | }
74 | }
75 | }
76 | System.out.println("- Downloading from: " + url);
77 |
78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79 | if(!outputFile.getParentFile().exists()) {
80 | if(!outputFile.getParentFile().mkdirs()) {
81 | System.out.println(
82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83 | }
84 | }
85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86 | try {
87 | downloadFileFromURL(url, outputFile);
88 | System.out.println("Done");
89 | System.exit(0);
90 | } catch (Throwable e) {
91 | System.out.println("- Error downloading");
92 | e.printStackTrace();
93 | System.exit(1);
94 | }
95 | }
96 |
97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99 | String username = System.getenv("MVNW_USERNAME");
100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101 | Authenticator.setDefault(new Authenticator() {
102 | @Override
103 | protected PasswordAuthentication getPasswordAuthentication() {
104 | return new PasswordAuthentication(username, password);
105 | }
106 | });
107 | }
108 | URL website = new URL(urlString);
109 | ReadableByteChannel rbc;
110 | rbc = Channels.newChannel(website.openStream());
111 | FileOutputStream fos = new FileOutputStream(destination);
112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113 | fos.close();
114 | rbc.close();
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devops-tools-for-java-developers/code-snippets/19a9e77448ee1d7b428086c93a646473834a9b5f/chapter08-deploying-for-developers/quarkus-demo/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/README.md:
--------------------------------------------------------------------------------
1 | # demo project
2 |
3 | This project uses Quarkus, the Supersonic Subatomic Java Framework.
4 |
5 | If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ .
6 |
7 | ## Running the application in dev mode
8 |
9 | You can run your application in dev mode that enables live coding using:
10 | ```shell script
11 | ./mvnw compile quarkus:dev
12 | ```
13 |
14 | > **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
15 |
16 | ## Packaging and running the application
17 |
18 | The application can be packaged using:
19 | ```shell script
20 | ./mvnw package
21 | ```
22 | It produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
23 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.
24 |
25 | If you want to build an _über-jar_, execute the following command:
26 | ```shell script
27 | ./mvnw package -Dquarkus.package.type=uber-jar
28 | ```
29 |
30 | The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`.
31 |
32 | ## Creating a native executable
33 |
34 | You can create a native executable using:
35 | ```shell script
36 | ./mvnw package -Pnative
37 | ```
38 |
39 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
40 | ```shell script
41 | ./mvnw package -Pnative -Dquarkus.native.container-build=true
42 | ```
43 |
44 | You can then execute your native executable with: `./target/demo-1.0.0-SNAPSHOT-runner`
45 |
46 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html.
47 |
48 | ## Provided examples
49 |
50 | ### RESTEasy JAX-RS example
51 |
52 | REST is easy peasy with this Hello World RESTEasy resource.
53 |
54 | [Related guide section...](https://quarkus.io/guides/getting-started#the-jax-rs-resources)
55 |
56 |
57 | ## Setup Jaeger locally with Docker Compose
58 |
59 | You can have an instance of Jaeger running locally by running the following command:
60 |
61 | ```shell script
62 | docker-compose --env-file=opentelemetry-collector-config.yaml up
63 | ```
64 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/docker-compose.yaml:
--------------------------------------------------------------------------------
1 | version: "2"
2 | services:
3 |
4 | # Jaeger
5 | jaeger-all-in-one:
6 | image: jaegertracing/all-in-one:latest
7 | ports:
8 | - "16686:16686"
9 | - "14268"
10 | - "14250"
11 | # Collector
12 | otel-collector:
13 | image: otel/opentelemetry-collector:latest
14 | command: ["--config=/etc/otel-collector-config.yaml"]
15 | volumes:
16 | - ./opentelemetry-collector-config.yaml:/etc/otel-collector-config.yaml
17 | ports:
18 | - "13133:13133" # Health_check extension
19 | - "4317:4317" # OTLP gRPC receiver
20 | - "55680:55680" # OTLP gRPC receiver alternative port
21 | depends_on:
22 | - jaeger-all-in-one
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
124 |
125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
162 | if ERRORLEVEL 1 goto error
163 | goto end
164 |
165 | :error
166 | set ERROR_CODE=1
167 |
168 | :end
169 | @endlocal & set ERROR_CODE=%ERROR_CODE%
170 |
171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
175 | :skipRcPost
176 |
177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
179 |
180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
181 |
182 | exit /B %ERROR_CODE%
183 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/opentelemetry-collector-config.yaml:
--------------------------------------------------------------------------------
1 | receivers:
2 | otlp:
3 | protocols:
4 | grpc:
5 |
6 | exporters:
7 | logging:
8 |
9 | jaeger:
10 | endpoint: jaeger-all-in-one:14250
11 | insecure: true
12 |
13 | processors:
14 | batch:
15 |
16 | extensions:
17 | health_check:
18 |
19 | service:
20 | extensions: [health_check]
21 | pipelines:
22 | traces:
23 | receivers: [otlp]
24 | processors: [batch]
25 | exporters: [jaeger]
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.example.demo
6 | demo
7 | 1.0-SNAPSHOT
8 | demo
9 |
10 | 3.8.1
11 | NodePort
12 | ${quarkus.container-image.registry}/${quarkus.container-image.group}/${quarkus.container-image.name}:${quarkus.container-image.tag}
13 | 1.5.1
14 | true
15 | 11
16 | 11
17 | UTF-8
18 | 2.5.0.Final
19 | quarkus-bom
20 | io.quarkus
21 | 2.5.0.Final
22 | 3.0.0-M5
23 |
24 |
25 |
26 |
27 | ${quarkus.platform.group-id}
28 | ${quarkus.platform.artifact-id}
29 | ${quarkus.platform.version}
30 | pom
31 | import
32 |
33 |
34 |
35 |
36 |
37 | io.quarkus
38 | quarkus-micrometer-registry-prometheus
39 |
40 |
41 | io.quarkus
42 | quarkus-kubernetes
43 |
44 |
45 | io.quarkus
46 | quarkus-resteasy
47 |
48 |
49 | io.quarkus
50 | quarkus-resteasy-jackson
51 |
52 |
53 | io.quarkus
54 | quarkus-container-image-jib
55 |
56 |
57 | io.quarkus
58 | quarkus-opentelemetry-exporter-otlp
59 |
60 |
61 | io.quarkus
62 | quarkus-smallrye-health
63 |
64 |
65 | io.rest-assured
66 | rest-assured
67 | test
68 |
69 |
70 | io.quarkus
71 | quarkus-junit5
72 | test
73 |
74 |
75 |
76 |
77 |
78 | org.eclipse.jkube
79 | kubernetes-maven-plugin
80 | ${jkube.version}
81 |
82 | jib
83 |
84 |
85 |
86 | io.quarkus
87 | quarkus-maven-plugin
88 | ${quarkus-plugin.version}
89 |
90 |
91 |
92 | build
93 |
94 |
95 |
96 |
97 |
98 | maven-compiler-plugin
99 | ${compiler-plugin.version}
100 |
101 |
102 | maven-surefire-plugin
103 | ${surefire-plugin.version}
104 |
105 |
106 | org.jboss.logmanager.LogManager
107 | ${maven.home}
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 | native
116 |
117 |
118 | native
119 |
120 |
121 |
122 |
123 |
124 | maven-failsafe-plugin
125 | ${surefire-plugin.version}
126 |
127 |
128 |
129 | integration-test
130 | verify
131 |
132 |
133 |
134 | ${project.build.directory}/${project.build.finalName}-runner
135 | org.jboss.logmanager.LogManager
136 | ${maven.home}
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 | native
146 |
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/src/main/docker/Dockerfile.jvm:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/demo-jvm .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/demo-jvm
15 | #
16 | # If you want to include the debug port into your docker image
17 | # you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005
18 | #
19 | # Then run the container using :
20 | #
21 | # docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/demo-jvm
22 | #
23 | ###
24 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
25 |
26 | ARG JAVA_PACKAGE=java-11-openjdk-headless
27 | ARG RUN_JAVA_VERSION=1.3.8
28 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
29 | # Install java and the run-java script
30 | # Also set up permissions for user `1001`
31 | RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
32 | && microdnf update \
33 | && microdnf clean all \
34 | && mkdir /deployments \
35 | && chown 1001 /deployments \
36 | && chmod "g+rwX" /deployments \
37 | && chown 1001:root /deployments \
38 | && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
39 | && chown 1001 /deployments/run-java.sh \
40 | && chmod 540 /deployments/run-java.sh \
41 | && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security
42 |
43 | # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
44 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
45 | # We make four distinct layers so if there are application changes the library layers can be re-used
46 | COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/
47 | COPY --chown=1001 target/quarkus-app/*.jar /deployments/
48 | COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
49 | COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/
50 |
51 | EXPOSE 8080
52 | USER 1001
53 |
54 | ENTRYPOINT [ "/deployments/run-java.sh" ]
55 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/src/main/docker/Dockerfile.legacy-jar:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package -Dquarkus.package.type=legacy-jar
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/demo-legacy-jar .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/demo-legacy-jar
15 | #
16 | # If you want to include the debug port into your docker image
17 | # you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005
18 | #
19 | # Then run the container using :
20 | #
21 | # docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/demo-legacy-jar
22 | #
23 | ###
24 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
25 |
26 | ARG JAVA_PACKAGE=java-11-openjdk-headless
27 | ARG RUN_JAVA_VERSION=1.3.8
28 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
29 | # Install java and the run-java script
30 | # Also set up permissions for user `1001`
31 | RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
32 | && microdnf update \
33 | && microdnf clean all \
34 | && mkdir /deployments \
35 | && chown 1001 /deployments \
36 | && chmod "g+rwX" /deployments \
37 | && chown 1001:root /deployments \
38 | && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
39 | && chown 1001 /deployments/run-java.sh \
40 | && chmod 540 /deployments/run-java.sh \
41 | && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security
42 |
43 | # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
44 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
45 | COPY target/lib/* /deployments/lib/
46 | COPY target/*-runner.jar /deployments/app.jar
47 |
48 | EXPOSE 8080
49 | USER 1001
50 |
51 | ENTRYPOINT [ "/deployments/run-java.sh" ]
52 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/src/main/docker/Dockerfile.native:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package -Pnative
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/demo .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/demo
15 | #
16 | ###
17 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
18 | WORKDIR /work/
19 | RUN chown 1001 /work \
20 | && chmod "g+rwX" /work \
21 | && chown 1001:root /work
22 | COPY --chown=1001:root target/*-runner /work/application
23 |
24 | EXPOSE 8080
25 | USER 1001
26 |
27 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
28 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/src/main/docker/Dockerfile.native-distroless:
--------------------------------------------------------------------------------
1 | ####
2 | # This Dockerfile is used in order to build a distroless container that runs the Quarkus application in native (no JVM) mode
3 | #
4 | # Before building the container image run:
5 | #
6 | # ./mvnw package -Pnative
7 | #
8 | # Then, build the image with:
9 | #
10 | # docker build -f src/main/docker/Dockerfile.native-distroless -t quarkus/demo .
11 | #
12 | # Then run the container using:
13 | #
14 | # docker run -i --rm -p 8080:8080 quarkus/demo
15 | #
16 | ###
17 | FROM quay.io/quarkus/quarkus-distroless-image:1.0
18 | COPY target/*-runner /application
19 |
20 | EXPOSE 8080
21 | USER nonroot
22 |
23 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
24 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/src/main/java/com/example/demo/Greeting.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | public class Greeting {
4 | private final String content;
5 |
6 | public Greeting(String content) {
7 | this.content = content;
8 | }
9 |
10 | public String getContent() {
11 | return content;
12 | }
13 | }
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/src/main/java/com/example/demo/GreetingResource.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 |
4 | import io.micrometer.core.annotation.Timed;
5 | import io.opentelemetry.api.trace.*;
6 | import io.opentelemetry.context.Context;
7 |
8 | import javax.ws.rs.*;
9 | import java.util.logging.Logger;
10 | import javax.ws.rs.core.MediaType;
11 |
12 | @Path("/greeting")
13 | public class GreetingResource {
14 | private static final String template = "Hello, %s!";
15 |
16 | private final static Logger log;
17 |
18 | static {
19 | log = Logger.getLogger(GreetingResource.class.getName());
20 | }
21 |
22 | @GET
23 | @Produces(MediaType.APPLICATION_JSON)
24 | @Timed(value="custom")
25 | public Greeting greeting(@QueryParam("name") String name) {
26 | pause();
27 | return new Greeting(String.format(template, name));
28 | }
29 |
30 | private void pause() {
31 | Span span = Span.fromContext(Context.current())
32 | .setAttribute("pause", "start");
33 | try {
34 | Thread.sleep(2000);
35 | } catch (InterruptedException e) {
36 | span.setStatus(StatusCode.ERROR, "Execution was interrupted");
37 | span.setAttribute("unexpected.pause", "exception");
38 | span.recordException(e);
39 | log.severe("Thread interrupted");
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/src/main/resources/META-INF/resources/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | demo - 1.0.0-SNAPSHOT
6 |
108 |
109 |
110 |
111 |
112 | Your new Cloud-Native application is ready!
113 |
114 |
115 |
116 |
117 |
Congratulations, you have created a new Quarkus cloud application.
118 |
119 |
What is this page?
120 |
121 |
This page is served by Quarkus. The source is in
122 | src/main/resources/META-INF/resources/index.html
.
123 |
124 |
What are your next steps?
125 |
126 |
If not already done, run the application in dev mode using: ./mvnw compile quarkus:dev
.
127 |
128 |
129 | - Your static assets are located in
src/main/resources/META-INF/resources
.
130 | - Configure your application in
src/main/resources/application.properties
.
131 | - Quarkus now ships with a Dev UI (available in dev mode only)
132 | - Play with the getting started example code located in
src/main/java
:
133 |
134 |
140 |
141 |
142 |
143 |
144 |
Application
145 |
146 | - GroupId:
com.example
147 | - ArtifactId:
demo
148 | - Version:
1.0.0-SNAPSHOT
149 | - Quarkus Version:
2.5.0.Final
150 |
151 |
152 |
153 |
Do you like Quarkus?
154 |
155 | - Go give it a star on GitHub.
156 |
157 |
158 |
159 |
More reading
160 |
166 |
167 |
168 |
169 |
170 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-demo/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | quarkus.container-image.builder=jib
2 |
3 | quarkus.container-image.registry=quay.io
4 | quarkus.container-image.group=myrepo
5 | quarkus.container-image.name=demo
6 | quarkus.container-image.tag=1.0.0-SNAPSHOT
7 |
8 | quarkus.kubernetes.resources.limits.cpu=200m
9 | quarkus.kubernetes.resources.limits.memory=230Mi
10 | quarkus.kubernetes.resources.requests.cpu=100m
11 | quarkus.kubernetes.resources.requests.memory=115Mi
12 | custom.host = ${exporter.host:localhost}
13 | quarkus.kubernetes.env.vars.otlp-exporter=${custom.host:localhost}
14 | quarkus.opentelemetry.tracer.exporter.otlp.endpoint=http://${custom.host}:4317
15 |
16 | quarkus.log.console.format=%d{HH:mm:ss} %-5p traceId=%X{traceId}, spanId=%X{spanId}, sampled=%X{sampled} [%c{2.}] (%t) %s%e%n
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-lambda/output.json:
--------------------------------------------------------------------------------
1 | {
2 | "Role": {
3 | "Path": "/",
4 | "RoleName": "lambda-ex",
5 | "RoleId": "AROAZEJV7ZLPCZ7CNYW6U",
6 | "Arn": "arn:aws:iam::627715328734:role/lambda-ex",
7 | "CreateDate": "2021-06-13T15:22:56+00:00",
8 | "AssumeRolePolicyDocument": {
9 | "Version": "2012-10-17",
10 | "Statement": [
11 | {
12 | "Effect": "Allow",
13 | "Principal": {
14 | "Service": "lambda.amazonaws.com"
15 | },
16 | "Action": "sts:AssumeRole"
17 | }
18 | ]
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-lambda/payload.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Bill",
3 | "greeting": "hello"
4 | }
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-lambda/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 | com.example.demo
7 | quarkus-lambda
8 | 1.0-SNAPSHOT
9 |
10 | 3.8.1
11 | true
12 | 11
13 | 11
14 | 11
15 | UTF-8
16 | UTF-8
17 | 2.5.0.Final
18 | quarkus-bom
19 | io.quarkus
20 | 2.5.0.Final
21 | 3.0.0-M5
22 | NodePort
23 | 1.5.1
24 |
25 | ${quarkus.container-image.registry}/${quarkus.container-image.group}
26 | /${quarkus.container-image.name}:${quarkus.container-image.tag}
27 |
28 |
29 |
30 |
31 |
32 | ${quarkus.platform.group-id}
33 | ${quarkus.platform.artifact-id}
34 | ${quarkus.platform.version}
35 | pom
36 | import
37 |
38 |
39 |
40 |
41 |
42 | io.quarkus
43 | quarkus-kubernetes
44 |
45 |
46 | io.quarkus
47 | quarkus-container-image-jib
48 |
49 |
50 | io.quarkus
51 | quarkus-amazon-lambda
52 |
53 |
54 | io.quarkus
55 | quarkus-test-amazon-lambda
56 | test
57 |
58 |
59 | io.quarkus
60 | quarkus-junit5
61 | test
62 |
63 |
64 |
65 |
66 |
67 | org.eclipse.jkube
68 | kubernetes-maven-plugin
69 | ${jkube.version}
70 |
71 | jib
72 |
73 |
74 |
75 | io.quarkus
76 | quarkus-maven-plugin
77 | ${quarkus-plugin.version}
78 |
79 |
80 |
81 | build
82 |
83 |
84 |
85 |
86 |
87 | maven-compiler-plugin
88 | ${compiler-plugin.version}
89 |
90 |
91 | maven-surefire-plugin
92 | ${surefire-plugin.version}
93 |
94 |
95 | org.jboss.logmanager.LogManager
96 | ${maven.home}
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 | native
105 |
106 |
107 | native
108 |
109 |
110 |
111 | native
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-lambda/src/main/java/com/example/demo/GreetingLambda.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import com.amazonaws.services.lambda.runtime.Context;
4 | import com.amazonaws.services.lambda.runtime.RequestHandler;
5 |
6 | import javax.inject.Inject;
7 | import javax.inject.Named;
8 |
9 | @Named("greeting")
10 | public class GreetingLambda implements RequestHandler {
11 | @Inject
12 | ProcessingService service;
13 |
14 | @Override
15 | public OutputObject handleRequest(InputObject input, Context context) {
16 | OutputObject output = service.process(input);
17 | output.setRequestId(context.getAwsRequestId());
18 | return output;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-lambda/src/main/java/com/example/demo/InputObject.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | public class InputObject {
4 | private String name;
5 | private String greeting;
6 |
7 | public String getName() {
8 | return name;
9 | }
10 |
11 | public void setName(String name) {
12 | this.name = name;
13 | }
14 |
15 | public String getGreeting() {
16 | return greeting;
17 | }
18 |
19 | public void setGreeting(String greeting) {
20 | this.greeting = greeting;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-lambda/src/main/java/com/example/demo/OutputObject.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | public class OutputObject {
4 | private String result;
5 | private String requestId;
6 |
7 | public String getResult() {
8 | return result;
9 | }
10 |
11 | public void setResult(String result) {
12 | this.result = result;
13 | }
14 |
15 | public String getRequestId() {
16 | return requestId;
17 | }
18 |
19 | public void setRequestId(String requestId) {
20 | this.requestId = requestId;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-lambda/src/main/java/com/example/demo/ProcessingService.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import javax.enterprise.context.ApplicationScoped;
4 |
5 | @ApplicationScoped
6 | public class ProcessingService {
7 | public OutputObject process(InputObject input) {
8 | OutputObject output = new OutputObject();
9 | output.setResult(input.getGreeting() + " " + input.getName());
10 | return output;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-lambda/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | quarkus.lambda.handler=greeting
2 |
3 | quarkus.container-image.builder=jib
4 |
5 | quarkus.container-image.registry=quay.io
6 | quarkus.container-image.group=myrepo
7 | quarkus.container-image.name=demo
8 | quarkus.container-image.tag=1.0.0-SNAPSHOT
9 |
10 | quarkus.kubernetes.resources.limits.cpu=200m
11 | quarkus.kubernetes.resources.limits.memory=230Mi
12 | quarkus.kubernetes.resources.requests.cpu=100m
13 | quarkus.kubernetes.resources.requests.memory=115Mi
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-lambda/src/test/java/com/example/demo/LambdaHandlerTest.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import io.quarkus.amazon.lambda.test.LambdaClient;
4 | import io.quarkus.test.junit.QuarkusTest;
5 | import org.junit.jupiter.api.Assertions;
6 | import org.junit.jupiter.api.Test;
7 |
8 | @QuarkusTest
9 | public class LambdaHandlerTest {
10 | @Test
11 | public void testSimpleLambdaSuccess() throws Exception {
12 | InputObject in = new InputObject();
13 | in.setGreeting("Hello");
14 | in.setName("serverless");
15 | OutputObject out = LambdaClient.invoke(OutputObject.class, in);
16 | Assertions.assertEquals("Hello serverless", out.getResult());
17 | Assertions.assertTrue(out.getRequestId().matches("aws-request-\\d"), "Expected requestId as 'aws-request-'");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-lambda/src/test/resources/application.properties:
--------------------------------------------------------------------------------
1 | quarkus.lambda.handler=greeting
2 |
3 | quarkus.lambda.enable-polling-jvm-mode=true
4 |
5 |
6 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/quarkus-lambda/trust-policy.json:
--------------------------------------------------------------------------------
1 | {
2 | "Version": "2012-10-17",
3 | "Statement": [
4 | {
5 | "Effect": "Allow",
6 | "Principal": {
7 | "Service": "lambda.amazonaws.com"
8 | },
9 | "Action": "sts:AssumeRole"
10 | }
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/spring-boot-demo/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 |
7 | ### STS ###
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | .sts4-cache
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 |
22 | ### NetBeans ###
23 | /nbproject/private/
24 | /nbbuild/
25 | /dist/
26 | /nbdist/
27 | /.nb-gradle/
28 | build/
29 | !**/src/main/**/build/
30 | !**/src/test/**/build/
31 |
32 | ### VS Code ###
33 | .vscode/
34 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/spring-boot-demo/.mvn/wrapper/MavenWrapperDownloader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007-present the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | import java.net.*;
17 | import java.io.*;
18 | import java.nio.channels.*;
19 | import java.util.Properties;
20 |
21 | public class MavenWrapperDownloader {
22 |
23 | private static final String WRAPPER_VERSION = "0.5.6";
24 | /**
25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
26 | */
27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
29 |
30 | /**
31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
32 | * use instead of the default one.
33 | */
34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
35 | ".mvn/wrapper/maven-wrapper.properties";
36 |
37 | /**
38 | * Path where the maven-wrapper.jar will be saved to.
39 | */
40 | private static final String MAVEN_WRAPPER_JAR_PATH =
41 | ".mvn/wrapper/maven-wrapper.jar";
42 |
43 | /**
44 | * Name of the property which should be used to override the default download url for the wrapper.
45 | */
46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
47 |
48 | public static void main(String args[]) {
49 | System.out.println("- Downloader started");
50 | File baseDirectory = new File(args[0]);
51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
52 |
53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom
54 | // wrapperUrl parameter.
55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
56 | String url = DEFAULT_DOWNLOAD_URL;
57 | if(mavenWrapperPropertyFile.exists()) {
58 | FileInputStream mavenWrapperPropertyFileInputStream = null;
59 | try {
60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
61 | Properties mavenWrapperProperties = new Properties();
62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
64 | } catch (IOException e) {
65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
66 | } finally {
67 | try {
68 | if(mavenWrapperPropertyFileInputStream != null) {
69 | mavenWrapperPropertyFileInputStream.close();
70 | }
71 | } catch (IOException e) {
72 | // Ignore ...
73 | }
74 | }
75 | }
76 | System.out.println("- Downloading from: " + url);
77 |
78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
79 | if(!outputFile.getParentFile().exists()) {
80 | if(!outputFile.getParentFile().mkdirs()) {
81 | System.out.println(
82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83 | }
84 | }
85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
86 | try {
87 | downloadFileFromURL(url, outputFile);
88 | System.out.println("Done");
89 | System.exit(0);
90 | } catch (Throwable e) {
91 | System.out.println("- Error downloading");
92 | e.printStackTrace();
93 | System.exit(1);
94 | }
95 | }
96 |
97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception {
98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
99 | String username = System.getenv("MVNW_USERNAME");
100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
101 | Authenticator.setDefault(new Authenticator() {
102 | @Override
103 | protected PasswordAuthentication getPasswordAuthentication() {
104 | return new PasswordAuthentication(username, password);
105 | }
106 | });
107 | }
108 | URL website = new URL(urlString);
109 | ReadableByteChannel rbc;
110 | rbc = Channels.newChannel(website.openStream());
111 | FileOutputStream fos = new FileOutputStream(destination);
112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
113 | fos.close();
114 | rbc.close();
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/spring-boot-demo/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/devops-tools-for-java-developers/code-snippets/19a9e77448ee1d7b428086c93a646473834a9b5f/chapter08-deploying-for-developers/spring-boot-demo/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/spring-boot-demo/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip
2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
3 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/spring-boot-demo/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM https://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM set title of command window
39 | title %0
40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
42 |
43 | @REM set %HOME% to equivalent of $HOME
44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45 |
46 | @REM Execute a user defined script before this one
47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
51 | :skipRcPre
52 |
53 | @setlocal
54 |
55 | set ERROR_CODE=0
56 |
57 | @REM To isolate internal variables from possible post scripts, we use another setlocal
58 | @setlocal
59 |
60 | @REM ==== START VALIDATION ====
61 | if not "%JAVA_HOME%" == "" goto OkJHome
62 |
63 | echo.
64 | echo Error: JAVA_HOME not found in your environment. >&2
65 | echo Please set the JAVA_HOME variable in your environment to match the >&2
66 | echo location of your Java installation. >&2
67 | echo.
68 | goto error
69 |
70 | :OkJHome
71 | if exist "%JAVA_HOME%\bin\java.exe" goto init
72 |
73 | echo.
74 | echo Error: JAVA_HOME is set to an invalid directory. >&2
75 | echo JAVA_HOME = "%JAVA_HOME%" >&2
76 | echo Please set the JAVA_HOME variable in your environment to match the >&2
77 | echo location of your Java installation. >&2
78 | echo.
79 | goto error
80 |
81 | @REM ==== END VALIDATION ====
82 |
83 | :init
84 |
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86 | @REM Fallback to current working directory if not found.
87 |
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90 |
91 | set EXEC_DIR=%CD%
92 | set WDIR=%EXEC_DIR%
93 | :findBaseDir
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
95 | cd ..
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
97 | set WDIR=%CD%
98 | goto findBaseDir
99 |
100 | :baseDirFound
101 | set MAVEN_PROJECTBASEDIR=%WDIR%
102 | cd "%EXEC_DIR%"
103 | goto endDetectBaseDir
104 |
105 | :baseDirNotFound
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107 | cd "%EXEC_DIR%"
108 |
109 | :endDetectBaseDir
110 |
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112 |
113 | @setlocal EnableExtensions EnableDelayedExpansion
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116 |
117 | :endReadAdditionalConfig
118 |
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122 |
123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
124 |
125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127 | )
128 |
129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131 | if exist %WRAPPER_JAR% (
132 | if "%MVNW_VERBOSE%" == "true" (
133 | echo Found %WRAPPER_JAR%
134 | )
135 | ) else (
136 | if not "%MVNW_REPOURL%" == "" (
137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
138 | )
139 | if "%MVNW_VERBOSE%" == "true" (
140 | echo Couldn't find %WRAPPER_JAR%, downloading it ...
141 | echo Downloading from: %DOWNLOAD_URL%
142 | )
143 |
144 | powershell -Command "&{"^
145 | "$webclient = new-object System.Net.WebClient;"^
146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148 | "}"^
149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150 | "}"
151 | if "%MVNW_VERBOSE%" == "true" (
152 | echo Finished downloading %WRAPPER_JAR%
153 | )
154 | )
155 | @REM End of extension
156 |
157 | @REM Provide a "standardized" way to retrieve the CLI args that will
158 | @REM work with both Windows and non-Windows executions.
159 | set MAVEN_CMD_LINE_ARGS=%*
160 |
161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
162 | if ERRORLEVEL 1 goto error
163 | goto end
164 |
165 | :error
166 | set ERROR_CODE=1
167 |
168 | :end
169 | @endlocal & set ERROR_CODE=%ERROR_CODE%
170 |
171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
175 | :skipRcPost
176 |
177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
179 |
180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
181 |
182 | exit /B %ERROR_CODE%
183 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/spring-boot-demo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | 4.0.0
7 |
8 | org.springframework.boot
9 | spring-boot-starter-parent
10 | 2.5.0
11 |
12 | com.example
13 | demo
14 | 0.0.1-SNAPSHOT
15 | demo
16 | Demo project for Spring Boot
17 |
18 | 11
19 | 0.10.5
20 | 1.5.1
21 | registry.hub.docker.com
22 | myuser
23 | ${project.version}
24 |
25 |
26 | ${jkube.docker.registry}/${repository}/${project.name}:${tag.version}
27 |
28 | 2.7.0
29 | 9884
30 |
31 |
32 |
33 | io.dekorate
34 | kubernetes-spring-starter
35 | ${kubernetes-spring-starter.version}
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-actuator
40 |
41 |
42 | org.springframework.boot
43 | spring-boot-starter-web
44 |
45 |
46 | org.springframework.experimental
47 | spring-native
48 | ${spring-native.version}
49 |
50 |
51 | io.micrometer
52 | micrometer-registry-prometheus
53 | runtime
54 |
55 |
56 | org.springframework.boot
57 | spring-boot-starter-test
58 | test
59 |
60 |
61 |
62 |
63 |
64 |
65 | org.eclipse.jkube
66 | kubernetes-maven-plugin
67 | ${jkube.version}
68 |
69 |
70 | resources
71 | process-resources
72 |
73 | resource
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | ${prometheusPort}
82 |
83 |
84 |
85 |
86 |
87 |
88 | ${prometheusPort}
89 |
90 |
91 |
92 |
93 |
94 |
95 | org.springframework.boot
96 | spring-boot-maven-plugin
97 |
98 | exec
99 |
100 |
101 |
102 | org.springframework.experimental
103 | spring-aot-maven-plugin
104 | ${spring-native.version}
105 |
106 |
107 | test-generate
108 |
109 | test-generate
110 |
111 |
112 |
113 | generate
114 |
115 | generate
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 | spring-release
125 | Spring release
126 | https://repo.spring.io/release
127 |
128 |
129 |
130 |
131 | spring-release
132 | Spring release
133 | https://repo.spring.io/release
134 |
135 |
136 |
137 |
138 |
139 | native-image
140 |
141 |
142 |
143 | org.graalvm.nativeimage
144 | native-image-maven-plugin
145 | 21.1.0
146 |
147 |
148 | com.example.demo.DemoApplication
149 |
150 |
151 |
152 |
153 |
154 | native-image
155 |
156 | package
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/spring-boot-demo/src/main/java/com/example/demo/DemoApplication.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | @SpringBootApplication
7 | public class DemoApplication {
8 |
9 | public static void main(String[] args) {
10 | SpringApplication.run(DemoApplication.class, args);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/spring-boot-demo/src/main/java/com/example/demo/Greeting.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | public class Greeting {
4 | private final String content;
5 |
6 | public Greeting(String content) {
7 | this.content = content;
8 | }
9 |
10 | public String getContent() {
11 | return content;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/spring-boot-demo/src/main/java/com/example/demo/GreetingController.java:
--------------------------------------------------------------------------------
1 | package com.example.demo;
2 |
3 | import org.springframework.web.bind.annotation.GetMapping;
4 | import org.springframework.web.bind.annotation.RequestParam;
5 | import org.springframework.web.bind.annotation.RestController;
6 |
7 | @RestController
8 | public class GreetingController {
9 | private static final String template = "Hello, %s!";
10 |
11 | @GetMapping("/greeting")
12 | public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) {
13 | return new Greeting(String.format(template, name));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/chapter08-deploying-for-developers/spring-boot-demo/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | dekorate.kubernetes.serviceType=LoadBalancer
2 | management.endpoints.web.exposure.include=health,info,prometheus
3 |
4 |
--------------------------------------------------------------------------------
/chapter09-mobile-workflows/README.md:
--------------------------------------------------------------------------------
1 | Code Snippets and Examples for Chapter
2 |
--------------------------------------------------------------------------------
/chapter10-continous-deployment-patterns-and-antipatterns/README.md:
--------------------------------------------------------------------------------
1 | Code Snippets and Examples for Chapter
2 |
--------------------------------------------------------------------------------