├── .gitignore ├── LICENSE ├── README.md ├── comenta-filme ├── .dockerignore ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ └── main │ ├── docker │ ├── Dockerfile.jvm │ └── Dockerfile.native │ ├── java │ └── org │ │ └── cimatech │ │ ├── Comentario.java │ │ ├── ComentarioResource.java │ │ ├── Filme.java │ │ └── FilmeResource.java │ └── resources │ ├── META-INF │ └── resources │ │ └── index.html │ └── application.properties ├── configurable-datasource ├── .dockerignore ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ └── main │ ├── docker │ ├── Dockerfile.jvm │ ├── Dockerfile.legacy-jar │ ├── Dockerfile.native │ └── Dockerfile.native-distroless │ ├── java │ └── org │ │ └── fxapps │ │ └── datasource │ │ ├── DataSourceLoader.java │ │ └── resource │ │ └── DataSourceResource.java │ └── resources │ ├── META-INF │ └── resources │ │ └── index.html │ └── application.properties ├── dev-register ├── .dockerignore ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ └── main │ ├── docker │ ├── Dockerfile.jvm │ ├── Dockerfile.legacy-jar │ ├── Dockerfile.native │ └── Dockerfile.native-micro │ ├── java │ └── org │ │ └── acme │ │ ├── Developer.java │ │ └── DeveloperResource.java │ └── resources │ ├── META-INF │ └── resources │ │ └── index.html │ └── application.properties ├── jug14-demos ├── .gitignore ├── README.md ├── quarkus-ola-mundo │ ├── .dockerignore │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── docker │ │ │ ├── Dockerfile.jvm │ │ │ └── Dockerfile.native │ │ ├── java │ │ │ └── org │ │ │ │ └── acme │ │ │ │ └── ExampleResource.java │ │ └── resources │ │ │ ├── META-INF │ │ │ └── resources │ │ │ │ └── index.html │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── org │ │ └── acme │ │ ├── ExampleResourceTest.java │ │ └── NativeExampleResourceIT.java ├── quarkus-persistencia │ ├── .dockerignore │ ├── .gitignore │ ├── .mvn │ │ └── wrapper │ │ │ ├── MavenWrapperDownloader.java │ │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ │ └── main │ │ ├── docker │ │ ├── Dockerfile.jvm │ │ └── Dockerfile.native │ │ ├── java │ │ └── org │ │ │ └── jugvale │ │ │ ├── model │ │ │ └── Evento.java │ │ │ └── rest │ │ │ └── EventoResource.java │ │ └── resources │ │ ├── META-INF │ │ └── resources │ │ │ ├── index.html │ │ │ └── index.js │ │ └── application.properties └── using-kogito │ ├── .dockerignore │ ├── .gitignore │ ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ └── maven-wrapper.properties │ ├── mvnw │ ├── mvnw.cmd │ ├── pom.xml │ └── src │ ├── main │ ├── docker │ │ ├── Dockerfile.jvm │ │ └── Dockerfile.native │ ├── java │ │ └── org │ │ │ └── acme │ │ │ └── kogito │ │ │ └── model │ │ │ └── Person.java │ └── resources │ │ ├── META-INF │ │ └── kmodule.xml │ │ └── org │ │ └── acme │ │ └── kogito │ │ ├── person-rules.drl │ │ └── persons.bpmn2 │ └── test │ └── java │ └── org │ └── acme │ └── kogito │ ├── PersonProcessInGraalIT.java │ └── PersonProcessTest.java ├── kie-soup-datasets-rest-test ├── .dockerignore ├── .gitignore ├── pom.xml └── src │ └── main │ ├── docker │ ├── Dockerfile.jvm │ └── Dockerfile.native │ ├── java │ └── org │ │ └── kie │ │ └── soup │ │ └── sql │ │ └── rest │ │ ├── DatasetResource.java │ │ └── DefaultDatasourceLocator.java │ └── resources │ ├── META-INF │ └── resources │ │ └── index.html │ └── application.properties ├── metrics-example ├── .dockerignore ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ └── main │ ├── docker │ ├── Dockerfile.jvm │ ├── Dockerfile.legacy-jar │ ├── Dockerfile.native │ └── Dockerfile.native-distroless │ ├── java │ └── org │ │ └── fxapps │ │ └── GreetingResource.java │ └── resources │ ├── META-INF │ └── resources │ │ └── index.html │ └── application.properties ├── quarkus-form-authentication ├── .dockerignore ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ └── main │ ├── docker │ ├── Dockerfile.jvm │ └── Dockerfile.native │ ├── java │ └── org │ │ └── fxapps │ │ └── SampleResource.java │ └── resources │ ├── META-INF │ └── resources │ │ ├── error.html │ │ ├── index.html │ │ ├── login.html │ │ └── secured │ │ └── index.html │ └── application.properties ├── quarkus-gradle-hello ├── .dockerignore ├── .gitignore ├── README.md ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ ├── java │ └── org │ │ └── giu │ │ ├── model │ │ └── Band.java │ │ ├── resources │ │ └── BandResource.java │ │ └── storage │ │ └── BandStorage.java │ └── resources │ ├── META-INF │ └── resources │ │ └── index.html │ └── application.properties ├── quarkus-microblog ├── .dockerignore ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ └── main │ ├── docker │ ├── Dockerfile.jvm │ └── Dockerfile.native │ ├── java │ └── org │ │ └── fxapps │ │ ├── MicropostResource.java │ │ └── model │ │ └── Micropost.java │ └── resources │ ├── META-INF │ └── resources │ │ └── index.html │ ├── application.properties │ └── templates │ └── postsTemplate.html ├── security-kogito ├── .dockerignore ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ └── maven-wrapper.properties ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ ├── main │ ├── docker │ │ ├── Dockerfile.jvm │ │ └── Dockerfile.native │ ├── java │ │ └── org │ │ │ └── acme │ │ │ └── kogito │ │ │ ├── SecurityFilter.java │ │ │ └── model │ │ │ └── Person.java │ └── resources │ │ ├── META-INF │ │ └── kmodule.xml │ │ ├── application.properties │ │ └── org │ │ └── acme │ │ └── kogito │ │ ├── person-rules.drl │ │ └── persons.bpmn2 │ └── test │ └── java │ └── org │ └── acme │ └── kogito │ ├── PersonProcessInGraalIT.java │ └── PersonProcessTest.java ├── serverless-workflow-greeting-quarkus-with-monitoring ├── Dockerfile ├── README.md ├── operator │ └── serverless-workflow-greeting-quarkus.yaml ├── pom.xml └── src │ ├── main │ └── resources │ │ ├── application.properties │ │ ├── jsongreet.sw.json │ │ └── yamlgreet.sw.yml │ └── test │ └── java │ └── org │ └── kie │ └── kogito │ └── examples │ └── GreetRestIT.java ├── static-resources ├── .dockerignore ├── .gitignore ├── .mvn │ └── wrapper │ │ ├── MavenWrapperDownloader.java │ │ └── maven-wrapper.properties ├── README.md ├── components │ └── mycomp │ │ ├── index.html │ │ └── index.js ├── mvnw ├── mvnw.cmd ├── pom.xml └── src │ └── main │ ├── docker │ ├── Dockerfile.jvm │ └── Dockerfile.native │ ├── java │ └── org │ │ └── fxapps │ │ ├── ComponentStaticFileService.java │ │ └── ComponentStaticResourcesResource.java │ └── resources │ ├── META-INF │ └── resources │ │ └── index.html │ └── application.properties ├── swf-greeting-persistence-monitoring ├── README.md ├── operator │ └── swf-greeting-persistence-monitoring.yaml ├── pom.xml └── src │ └── main │ └── resources │ ├── application.properties │ ├── jsongreet.sw.json │ └── yamlgreet.sw.yml └── test-javacpp ├── .dockerignore ├── .gitignore ├── pom.xml └── src └── main ├── docker ├── Dockerfile.jvm └── Dockerfile.native ├── java └── org │ └── fxapps │ └── cpp │ ├── lib │ ├── NativeLibrary.h │ └── NativeLibrary.java │ └── resource │ └── TestResource.java └── resources ├── META-INF └── resources │ └── index.html └── application.properties /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Package Files 4 | *.jar 5 | *.war 6 | *.ear 7 | 8 | # Maven Build 9 | target/ 10 | 11 | # Eclipse directories 12 | bin/ 13 | .settings 14 | .classpath 15 | .project 16 | 17 | # Forge file 18 | .forge_settings 19 | 20 | # Mac File 21 | *.DS_Store 22 | 23 | *~ 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # quarkus-examples 2 | Examples using Quarkus 3 | -------------------------------------------------------------------------------- /comenta-filme/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* -------------------------------------------------------------------------------- /comenta-filme/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | 19 | # OSX 20 | .DS_Store 21 | 22 | # Vim 23 | *.swp 24 | *.swo 25 | 26 | # patch 27 | *.orig 28 | *.rej 29 | 30 | # Maven 31 | target/ 32 | pom.xml.tag 33 | pom.xml.releaseBackup 34 | pom.xml.versionsBackup 35 | release.properties -------------------------------------------------------------------------------- /comenta-filme/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /comenta-filme/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 docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/comenta-filme-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/comenta-filme-jvm 15 | # 16 | ### 17 | FROM fabric8/java-alpine-openjdk8-jre 18 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 19 | ENV AB_ENABLED=jmx_exporter 20 | COPY target/lib/* /deployments/lib/ 21 | COPY target/*-runner.jar /deployments/app.jar 22 | EXPOSE 8080 23 | 24 | # run with user 1001 and be prepared for be running in OpenShift too 25 | RUN adduser -G root --no-create-home --disabled-password 1001 \ 26 | && chown -R 1001 /deployments \ 27 | && chmod -R "g+rwX" /deployments \ 28 | && chown -R 1001:root /deployments 29 | USER 1001 30 | 31 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /comenta-filme/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 docker image run: 5 | # 6 | # mvn package -Pnative -Dnative-image.docker-build=true 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/comenta-filme . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/comenta-filme 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal 18 | WORKDIR /work/ 19 | COPY target/*-runner /work/application 20 | RUN chmod 775 /work 21 | EXPOSE 8080 22 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /comenta-filme/src/main/java/org/cimatech/Comentario.java: -------------------------------------------------------------------------------- 1 | package org.cimatech; 2 | 3 | import javax.persistence.Entity; 4 | import io.quarkus.hibernate.orm.panache.PanacheEntity; 5 | 6 | @Entity 7 | public class Comentario extends PanacheEntity { 8 | 9 | public String usuario; 10 | public String comentario; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /comenta-filme/src/main/java/org/cimatech/ComentarioResource.java: -------------------------------------------------------------------------------- 1 | package org.cimatech; 2 | 3 | import javax.transaction.Transactional; 4 | import javax.ws.rs.DELETE; 5 | import javax.ws.rs.Path; 6 | import javax.ws.rs.PathParam; 7 | 8 | @Path("comentario") 9 | public class ComentarioResource { 10 | 11 | @DELETE 12 | @Path("{id}") 13 | @Transactional 14 | public void apagar(@PathParam("id") long id) { 15 | Comentario.delete("id", id); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /comenta-filme/src/main/java/org/cimatech/Filme.java: -------------------------------------------------------------------------------- 1 | package org.cimatech; 2 | 3 | import java.util.List; 4 | import javax.persistence.Entity; 5 | import javax.persistence.JoinColumn; 6 | import javax.persistence.OneToMany; 7 | import io.quarkus.hibernate.orm.panache.PanacheEntity; 8 | 9 | @Entity 10 | public class Filme extends PanacheEntity { 11 | 12 | public String nome; 13 | 14 | @OneToMany(orphanRemoval = true) 15 | @JoinColumn(name="filme_id") 16 | public List comentarios; 17 | 18 | } -------------------------------------------------------------------------------- /comenta-filme/src/main/java/org/cimatech/FilmeResource.java: -------------------------------------------------------------------------------- 1 | package org.cimatech; 2 | 3 | import java.util.List; 4 | import javax.transaction.Transactional; 5 | import javax.ws.rs.Consumes; 6 | import javax.ws.rs.DELETE; 7 | import javax.ws.rs.GET; 8 | import javax.ws.rs.POST; 9 | import javax.ws.rs.Path; 10 | import javax.ws.rs.PathParam; 11 | import javax.ws.rs.Produces; 12 | import javax.ws.rs.core.MediaType; 13 | import javax.ws.rs.core.Response; 14 | import javax.ws.rs.core.Response.Status; 15 | 16 | @Path("filmes") 17 | @Produces(MediaType.APPLICATION_JSON) 18 | @Consumes(MediaType.APPLICATION_JSON) 19 | public class FilmeResource { 20 | 21 | @GET 22 | public List filmes() { 23 | return Filme.listAll(); 24 | } 25 | 26 | @POST 27 | @Transactional 28 | public Filme novo(Filme filme) { 29 | Filme.persist(filme); 30 | return filme; 31 | } 32 | 33 | @DELETE 34 | @Transactional 35 | @Path("{id}") 36 | public void delete(@PathParam("id") long id) { 37 | Filme.delete("id", id); 38 | } 39 | 40 | @POST 41 | @Transactional 42 | @Path("{id}/comentario") 43 | public Response comentar(@PathParam("id") long id, 44 | Comentario comentario) { 45 | Filme filme = Filme.findById(id); 46 | if (filme == null) { 47 | return Response.status(Status.NOT_FOUND).build(); 48 | } 49 | comentario.persist(); 50 | filme.comentarios.add(comentario); 51 | filme.persist(); 52 | return Response.ok(filme).build(); 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /comenta-filme/src/main/resources/META-INF/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | comenta-filme - 1.0.0-SNAPSHOT 6 | 99 | 100 | 101 | 102 | 105 | 106 |
107 |
108 |

Congratulations, you have created a new Quarkus application.

109 | 110 |

Why do you see this?

111 | 112 |

This page is served by Quarkus. The source is in 113 | src/main/resources/META-INF/resources/index.html.

114 | 115 |

What can I do from here?

116 | 117 |

If not already done, run the application in dev mode using: mvn compile quarkus:dev. 118 |

119 |
    120 |
  • Add REST resources, Servlets, functions and other services in src/main/java.
  • 121 |
  • Your static assets are located in src/main/resources/META-INF/resources.
  • 122 |
  • Configure your application in src/main/resources/application.properties. 123 |
  • 124 |
125 | 126 |

How do I get rid of this page?

127 |

Just delete the src/main/resources/META-INF/resources/index.html file.

128 |
129 |
130 |
131 |

Application

132 |
    133 |
  • GroupId: org.cimatech
  • 134 |
  • ArtifactId: comenta-filme
  • 135 |
  • Version: 1.0.0-SNAPSHOT
  • 136 |
  • Quarkus Version: 0.25.0
  • 137 |
138 |
139 |
140 |

Next steps

141 | 146 |
147 |
148 |
149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /comenta-filme/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.datasource.driver=org.h2.Driver 2 | quarkus.datasource.url=jdbc:h2:mem:default 3 | quarkus.datasource.username=sa 4 | quarkus.hibernate-orm.log.sql=true 5 | quarkus.hibernate-orm.database.generation=create-drop -------------------------------------------------------------------------------- /configurable-datasource/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* 5 | !target/quarkus-app/* -------------------------------------------------------------------------------- /configurable-datasource/.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 | -------------------------------------------------------------------------------- /configurable-datasource/.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 | -------------------------------------------------------------------------------- /configurable-datasource/README.md: -------------------------------------------------------------------------------- 1 | # configurable-datasource 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/configurable-datasource-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 | ## Related guides 49 | 50 | 51 | ## Provided examples 52 | 53 | ### RESTEasy JSON serialisation using Jackson 54 | 55 | This example demonstrate RESTEasy JSON serialisation by letting you list, add and remove quark types from a list. Quarked! 56 | 57 | [Related guide section...](https://quarkus.io/guides/rest-json#creating-your-first-json-rest-service) 58 | -------------------------------------------------------------------------------- /configurable-datasource/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/configurable-datasource-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/configurable-datasource-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/configurable-datasource-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 | -------------------------------------------------------------------------------- /configurable-datasource/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/configurable-datasource-legacy-jar . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/configurable-datasource-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/configurable-datasource-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 | -------------------------------------------------------------------------------- /configurable-datasource/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/configurable-datasource . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/configurable-datasource 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 | -------------------------------------------------------------------------------- /configurable-datasource/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/configurable-datasource . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/configurable-datasource 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 | -------------------------------------------------------------------------------- /configurable-datasource/src/main/java/org/fxapps/datasource/DataSourceLoader.java: -------------------------------------------------------------------------------- 1 | package org.fxapps.datasource; 2 | 3 | import java.sql.SQLException; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | import java.util.Optional; 8 | import java.util.Set; 9 | import java.util.stream.StreamSupport; 10 | 11 | import javax.enterprise.context.ApplicationScoped; 12 | import javax.enterprise.event.Observes; 13 | import javax.inject.Inject; 14 | import javax.sql.DataSource; 15 | 16 | import io.agroal.api.AgroalDataSource; 17 | import io.agroal.api.configuration.supplier.AgroalPropertiesReader; 18 | import io.quarkus.runtime.StartupEvent; 19 | import org.eclipse.microprofile.config.Config; 20 | import org.eclipse.microprofile.config.inject.ConfigProperty; 21 | 22 | @ApplicationScoped 23 | public class DataSourceLoader { 24 | 25 | private static final String DATASOURCES = "datasources"; 26 | private static final String DATASOURCE = "datasource"; 27 | private static final String PREFIX_TEMPLATE = DATASOURCE + ".%s."; 28 | 29 | @Inject 30 | Config config; 31 | 32 | @ConfigProperty(name = DATASOURCES, defaultValue = "") 33 | Optional> datasourcesProp; 34 | 35 | Map registeredDataSources; 36 | 37 | void load(@Observes StartupEvent startup) throws SQLException { 38 | var allProps = new HashMap(); 39 | var datasources = datasourcesProp.orElse(List.of()); 40 | 41 | registeredDataSources = new HashMap<>(); 42 | 43 | StreamSupport.stream(config.getPropertyNames().spliterator(), false) 44 | .filter(p -> p.startsWith(DATASOURCE)) 45 | .forEach(k -> allProps.put(k, config.getValue(k, String.class))); 46 | 47 | for (String ds : datasources) { 48 | var prefix = PREFIX_TEMPLATE.formatted(ds, AgroalPropertiesReader.JDBC_URL); 49 | var agroalProps = new AgroalPropertiesReader(prefix); 50 | agroalProps.readProperties(allProps); 51 | registeredDataSources.put(ds, AgroalDataSource.from(agroalProps.get())); 52 | } 53 | 54 | } 55 | 56 | public Optional getDataSource(String name) { 57 | return Optional.ofNullable(registeredDataSources.get(name)); 58 | } 59 | 60 | public Set datasources() { 61 | return registeredDataSources.keySet(); 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /configurable-datasource/src/main/java/org/fxapps/datasource/resource/DataSourceResource.java: -------------------------------------------------------------------------------- 1 | package org.fxapps.datasource.resource; 2 | 3 | import java.sql.Connection; 4 | import java.sql.SQLException; 5 | import java.util.ArrayList; 6 | import java.util.Collection; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | 10 | import javax.inject.Inject; 11 | import javax.ws.rs.GET; 12 | import javax.ws.rs.POST; 13 | import javax.ws.rs.Path; 14 | import javax.ws.rs.PathParam; 15 | import javax.ws.rs.Produces; 16 | import javax.ws.rs.core.MediaType; 17 | import javax.ws.rs.core.Response; 18 | import javax.ws.rs.core.Response.Status; 19 | 20 | import org.fxapps.datasource.DataSourceLoader; 21 | 22 | @Path("datasource") 23 | @Produces(MediaType.APPLICATION_JSON) 24 | public class DataSourceResource { 25 | 26 | @Inject 27 | DataSourceLoader loader; 28 | 29 | @GET 30 | public Collection list() { 31 | return loader.datasources(); 32 | } 33 | 34 | @POST 35 | @Path("{dsName}/query") 36 | public Response executeQuery(@PathParam("dsName") String dsName, String query) throws SQLException { 37 | var dataSourceOp = loader.getDataSource(dsName); 38 | 39 | if (dataSourceOp.isEmpty()) { 40 | return Response.status(Status.NOT_FOUND).build(); 41 | } 42 | 43 | var ds = dataSourceOp.get(); 44 | var connection = ds.getConnection(); 45 | var result = extractResult(query, connection); 46 | connection.close(); 47 | 48 | return Response.ok(result).build(); 49 | } 50 | 51 | private HashMap> extractResult(String query, Connection connection) throws SQLException { 52 | var result = new HashMap>(); 53 | try (var stmt = connection.createStatement()) { 54 | var rs = stmt.executeQuery(query); 55 | var meta = rs.getMetaData(); 56 | var nColumns = meta.getColumnCount(); 57 | while (rs.next()) { 58 | for (int i = 1; i <= nColumns; i++) { 59 | var column = meta.getColumnName(i); 60 | var value = rs.getString(i); 61 | 62 | result.putIfAbsent(column, new ArrayList()); 63 | result.get(column).add(value); 64 | } 65 | } 66 | } 67 | return result; 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /configurable-datasource/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.package.type=uber-jar 2 | datasources=ds1,ds2 3 | datasource.ds1.jdbcUrl=jdbc:mariadb://localhost:3306/jbpmdb 4 | datasource.ds1.providerClassName=org.mariadb.jdbc.Driver 5 | datasource.ds1.maxSize=10 6 | datasource.ds1.principal=jbpm 7 | datasource.ds1.credential=jbpm 8 | 9 | 10 | datasource.ds2.jdbcUrl=jdbc:mariadb://localhost:3306/test 11 | datasource.ds2.providerClassName=org.mariadb.jdbc.Driver 12 | datasource.ds2.maxSize=10 13 | datasource.ds2.principal=repasse 14 | datasource.ds2.credential=repasse -------------------------------------------------------------------------------- /dev-register/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* 5 | !target/quarkus-app/* -------------------------------------------------------------------------------- /dev-register/.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 | -------------------------------------------------------------------------------- /dev-register/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip 18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar 19 | -------------------------------------------------------------------------------- /dev-register/README.md: -------------------------------------------------------------------------------- 1 | # dev-register 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 | The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`. 26 | 27 | If you want to build an _über-jar_, execute the following command: 28 | ```shell script 29 | ./mvnw package -Dquarkus.package.type=uber-jar 30 | ``` 31 | 32 | The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`. 33 | 34 | ## Creating a native executable 35 | 36 | You can create a native executable using: 37 | ```shell script 38 | ./mvnw package -Pnative 39 | ``` 40 | 41 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: 42 | ```shell script 43 | ./mvnw package -Pnative -Dquarkus.native.container-build=true 44 | ``` 45 | 46 | You can then execute your native executable with: `./target/dev-register-1.0.0-SNAPSHOT-runner` 47 | 48 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling. 49 | 50 | ## Provided Code 51 | 52 | ### RESTEasy JAX-RS 53 | 54 | Easily start your RESTful Web Services 55 | 56 | [Related guide section...](https://quarkus.io/guides/getting-started#the-jax-rs-resources) 57 | -------------------------------------------------------------------------------- /dev-register/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.acme 6 | dev-register 7 | 1.0.0-SNAPSHOT 8 | 9 | 3.8.1 10 | false 11 | 11 12 | UTF-8 13 | UTF-8 14 | quarkus-bom 15 | io.quarkus.platform 16 | 2.7.3.Final 17 | 3.0.0-M5 18 | 19 | 20 | 21 | 22 | ${quarkus.platform.group-id} 23 | ${quarkus.platform.artifact-id} 24 | ${quarkus.platform.version} 25 | pom 26 | import 27 | 28 | 29 | 30 | 31 | 32 | io.quarkus 33 | quarkus-resteasy-jackson 34 | 35 | 36 | io.quarkus 37 | quarkus-arc 38 | 39 | 40 | io.quarkus 41 | quarkus-resteasy 42 | 43 | 44 | io.quarkus 45 | quarkus-junit5 46 | test 47 | 48 | 49 | io.rest-assured 50 | rest-assured 51 | test 52 | 53 | 54 | 55 | 56 | 57 | ${quarkus.platform.group-id} 58 | quarkus-maven-plugin 59 | ${quarkus.platform.version} 60 | true 61 | 62 | 63 | 64 | build 65 | generate-code 66 | generate-code-tests 67 | 68 | 69 | 70 | 71 | 72 | maven-compiler-plugin 73 | ${compiler-plugin.version} 74 | 75 | 76 | -parameters 77 | 78 | 79 | 80 | 81 | maven-surefire-plugin 82 | ${surefire-plugin.version} 83 | 84 | 85 | org.jboss.logmanager.LogManager 86 | ${maven.home} 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | native 95 | 96 | 97 | native 98 | 99 | 100 | 101 | 102 | 103 | maven-failsafe-plugin 104 | ${surefire-plugin.version} 105 | 106 | 107 | 108 | integration-test 109 | verify 110 | 111 | 112 | 113 | ${project.build.directory}/${project.build.finalName}-runner 114 | org.jboss.logmanager.LogManager 115 | ${maven.home} 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | native 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /dev-register/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/dev-register . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/dev-register 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5 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 | -------------------------------------------------------------------------------- /dev-register/src/main/docker/Dockerfile.native-micro: -------------------------------------------------------------------------------- 1 | #### 2 | # This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. 3 | # It uses a micro base image, tuned for Quarkus native executables. 4 | # It reduces the size of the resulting container image. 5 | # Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image. 6 | # 7 | # Before building the container image run: 8 | # 9 | # ./mvnw package -Pnative 10 | # 11 | # Then, build the image with: 12 | # 13 | # docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/dev-register . 14 | # 15 | # Then run the container using: 16 | # 17 | # docker run -i --rm -p 8080:8080 quarkus/dev-register 18 | # 19 | ### 20 | FROM quay.io/quarkus/quarkus-micro-image:1.0 21 | WORKDIR /work/ 22 | RUN chown 1001 /work \ 23 | && chmod "g+rwX" /work \ 24 | && chown 1001:root /work 25 | COPY --chown=1001:root target/*-runner /work/application 26 | 27 | EXPOSE 8080 28 | USER 1001 29 | 30 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] 31 | -------------------------------------------------------------------------------- /dev-register/src/main/java/org/acme/Developer.java: -------------------------------------------------------------------------------- 1 | package org.acme; 2 | 3 | 4 | public class Developer { 5 | public String name; 6 | public String language; 7 | public int workingYears; 8 | 9 | public Developer() { 10 | } 11 | 12 | public Developer(String name, String language, int workingYears) { 13 | this.name = name; 14 | this.language = language; 15 | this.workingYears = workingYears; 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /dev-register/src/main/java/org/acme/DeveloperResource.java: -------------------------------------------------------------------------------- 1 | package org.acme; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.annotation.PostConstruct; 7 | import javax.enterprise.context.ApplicationScoped; 8 | import javax.ws.rs.GET; 9 | import javax.ws.rs.POST; 10 | import javax.ws.rs.Path; 11 | import javax.ws.rs.Produces; 12 | import javax.ws.rs.core.MediaType; 13 | 14 | @Path("developers") 15 | @ApplicationScoped 16 | public class DeveloperResource { 17 | 18 | List developers; 19 | 20 | @PostConstruct 21 | public void init() { 22 | developers = new ArrayList<>(); 23 | developers.add(new Developer("Duke", "JAVA", 12)); 24 | developers.add(new Developer("John", "PYTHON", 4)); 25 | developers.add(new Developer("Mark", "JAVASCRIPT", 10)); 26 | } 27 | 28 | @GET 29 | @Produces(MediaType.APPLICATION_JSON) 30 | public List list() { 31 | return developers; 32 | } 33 | 34 | @POST 35 | public void store(Developer dev) { 36 | dev.language = dev.language.toUpperCase(); 37 | developers.add(dev); 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /dev-register/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.http.cors=true -------------------------------------------------------------------------------- /jug14-demos/.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Package Files 4 | *.jar 5 | *.war 6 | *.ear 7 | 8 | # Maven Build 9 | target/ 10 | 11 | # Eclipse directories 12 | bin/ 13 | .settings 14 | .classpath 15 | .project 16 | 17 | # Forge file 18 | .forge_settings 19 | 20 | # Mac File 21 | *.DS_Store 22 | 23 | *~ 24 | -------------------------------------------------------------------------------- /jug14-demos/README.md: -------------------------------------------------------------------------------- 1 | JUG 14 Demos 2 | -- 3 | 4 | Demos application for our JUG 14 meeting 5 | 6 | - Olá Mundo - very simple Hello World to show the joy of programming with Quarkus 7 | - Persistência - JPA, JSON-B, Maria DB and REST in action 8 | - Negócios: Kogito in Action 9 | -------------------------------------------------------------------------------- /jug14-demos/quarkus-ola-mundo/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* -------------------------------------------------------------------------------- /jug14-demos/quarkus-ola-mundo/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | 19 | # OSX 20 | .DS_Store 21 | 22 | # Vim 23 | *.swp 24 | *.swo 25 | 26 | # patch 27 | *.orig 28 | *.rej 29 | 30 | # Maven 31 | target/ 32 | pom.xml.tag 33 | pom.xml.releaseBackup 34 | pom.xml.versionsBackup 35 | release.properties -------------------------------------------------------------------------------- /jug14-demos/quarkus-ola-mundo/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /jug14-demos/quarkus-ola-mundo/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.jugvale.jug14 6 | quarkus-ola-mundo 7 | 1.0.0-SNAPSHOT 8 | 9 | UTF-8 10 | 2.22.0 11 | 0.21.2 12 | UTF-8 13 | 1.8 14 | 1.8 15 | 16 | 17 | 18 | 19 | io.quarkus 20 | quarkus-bom 21 | ${quarkus.version} 22 | pom 23 | import 24 | 25 | 26 | 27 | 28 | 29 | io.quarkus 30 | quarkus-resteasy 31 | 32 | 33 | io.quarkus 34 | quarkus-junit5 35 | test 36 | 37 | 38 | io.rest-assured 39 | rest-assured 40 | test 41 | 42 | 43 | io.quarkus 44 | quarkus-arc 45 | 46 | 47 | 48 | 49 | 50 | io.quarkus 51 | quarkus-maven-plugin 52 | ${quarkus.version} 53 | 54 | 55 | 56 | build 57 | 58 | 59 | 60 | 61 | 62 | maven-surefire-plugin 63 | ${surefire-plugin.version} 64 | 65 | 66 | org.jboss.logmanager.LogManager 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | native 75 | 76 | 77 | native 78 | 79 | 80 | 81 | 82 | 83 | io.quarkus 84 | quarkus-maven-plugin 85 | ${quarkus.version} 86 | 87 | 88 | 89 | native-image 90 | 91 | 92 | true 93 | 94 | 95 | 96 | 97 | 98 | maven-failsafe-plugin 99 | ${surefire-plugin.version} 100 | 101 | 102 | 103 | integration-test 104 | verify 105 | 106 | 107 | 108 | ${project.build.directory}/${project.build.finalName}-runner 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /jug14-demos/quarkus-ola-mundo/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 docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/quarkus-ola-mundo-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-ola-mundo-jvm 15 | # 16 | ### 17 | FROM fabric8/java-alpine-openjdk8-jre 18 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 19 | ENV AB_ENABLED=jmx_exporter 20 | COPY target/lib/* /deployments/lib/ 21 | COPY target/*-runner.jar /deployments/app.jar 22 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /jug14-demos/quarkus-ola-mundo/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 docker image run: 5 | # 6 | # mvn package -Pnative -Dnative-image.docker-build=true 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-ola-mundo . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-ola-mundo 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal 18 | WORKDIR /work/ 19 | COPY target/*-runner /work/application 20 | RUN chmod 775 /work 21 | EXPOSE 8080 22 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /jug14-demos/quarkus-ola-mundo/src/main/java/org/acme/ExampleResource.java: -------------------------------------------------------------------------------- 1 | package org.acme; 2 | 3 | import javax.inject.Inject; 4 | import javax.ws.rs.GET; 5 | import javax.ws.rs.Path; 6 | import javax.ws.rs.Produces; 7 | import javax.ws.rs.core.MediaType; 8 | 9 | import org.eclipse.microprofile.config.inject.ConfigProperty; 10 | 11 | @Path("/hello") 12 | public class ExampleResource { 13 | 14 | @Inject 15 | @ConfigProperty(name="nome") 16 | String nome; 17 | 18 | @GET 19 | @Produces(MediaType.TEXT_PLAIN) 20 | public String hello() { 21 | return "hello world, my name is " + nome; 22 | } 23 | } -------------------------------------------------------------------------------- /jug14-demos/quarkus-ola-mundo/src/main/resources/META-INF/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | quarkus-ola-mundo - 1.0.0-SNAPSHOT 6 | 99 | 100 | 101 | 102 | 105 | 106 |
107 |
108 |

Congratulations, you have created a new Quarkus application.

109 | 110 |

Why do you see this?

111 | 112 |

This page is served by Quarkus. The source is in 113 | src/main/resources/META-INF/resources/index.html.

114 | 115 |

What can I do from here?

116 | 117 |

If not already done, run the application in dev mode using: mvn compile quarkus:dev. 118 |

119 |
    120 |
  • Add REST resources, Servlets, functions and other services in src/main/java.
  • 121 |
  • Your static assets are located in src/main/resources/META-INF/resources.
  • 122 |
  • Configure your application in src/main/resources/application.properties. 123 |
  • 124 |
125 | 126 |

How do I get rid of this page?

127 |

Just delete the src/main/resources/META-INF/resources/index.html file.

128 |
129 |
130 |
131 |

Application

132 |
    133 |
  • GroupId: org.jugvale.jug14
  • 134 |
  • ArtifactId: quarkus-ola-mundo
  • 135 |
  • Version: 1.0.0-SNAPSHOT
  • 136 |
  • Quarkus Version: 0.21.2
  • 137 |
138 |
139 |
140 |

Next steps

141 | 146 |
147 |
148 |
149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /jug14-demos/quarkus-ola-mundo/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Configuration file 2 | # key = value 3 | nome=William Antônio -------------------------------------------------------------------------------- /jug14-demos/quarkus-ola-mundo/src/test/java/org/acme/ExampleResourceTest.java: -------------------------------------------------------------------------------- 1 | package org.acme; 2 | 3 | import io.quarkus.test.junit.QuarkusTest; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static io.restassured.RestAssured.given; 7 | import static org.hamcrest.CoreMatchers.is; 8 | 9 | @QuarkusTest 10 | public class ExampleResourceTest { 11 | 12 | @Test 13 | public void testHelloEndpoint() { 14 | given() 15 | .when().get("/hello") 16 | .then() 17 | .statusCode(200) 18 | .body(is("hello")); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /jug14-demos/quarkus-ola-mundo/src/test/java/org/acme/NativeExampleResourceIT.java: -------------------------------------------------------------------------------- 1 | package org.acme; 2 | 3 | import io.quarkus.test.junit.SubstrateTest; 4 | 5 | @SubstrateTest 6 | public class NativeExampleResourceIT extends ExampleResourceTest { 7 | 8 | // Execute the same tests but in native mode. 9 | } -------------------------------------------------------------------------------- /jug14-demos/quarkus-persistencia/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* -------------------------------------------------------------------------------- /jug14-demos/quarkus-persistencia/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | 19 | # OSX 20 | .DS_Store 21 | 22 | # Vim 23 | *.swp 24 | *.swo 25 | 26 | # patch 27 | *.orig 28 | *.rej 29 | 30 | # Maven 31 | target/ 32 | pom.xml.tag 33 | pom.xml.releaseBackup 34 | pom.xml.versionsBackup 35 | release.properties -------------------------------------------------------------------------------- /jug14-demos/quarkus-persistencia/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /jug14-demos/quarkus-persistencia/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.jugvale.jug14 6 | quarkus-persistencia 7 | 1.0.0-SNAPSHOT 8 | 9 | UTF-8 10 | 2.22.0 11 | 0.21.2 12 | UTF-8 13 | 1.8 14 | 1.8 15 | 16 | 17 | 18 | 19 | io.quarkus 20 | quarkus-bom 21 | ${quarkus.version} 22 | pom 23 | import 24 | 25 | 26 | 27 | 28 | 29 | io.quarkus 30 | quarkus-resteasy 31 | 32 | 33 | io.quarkus 34 | quarkus-junit5 35 | test 36 | 37 | 38 | io.rest-assured 39 | rest-assured 40 | test 41 | 42 | 43 | io.quarkus 44 | quarkus-resteasy-jsonb 45 | 46 | 47 | io.quarkus 48 | quarkus-jdbc-mariadb 49 | 50 | 51 | io.quarkus 52 | quarkus-hibernate-orm-panache 53 | 54 | 55 | io.quarkus 56 | quarkus-arc 57 | 58 | 59 | 60 | 61 | 62 | io.quarkus 63 | quarkus-maven-plugin 64 | ${quarkus.version} 65 | 66 | 67 | 68 | build 69 | 70 | 71 | 72 | 73 | 74 | maven-surefire-plugin 75 | ${surefire-plugin.version} 76 | 77 | 78 | org.jboss.logmanager.LogManager 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | native 87 | 88 | 89 | native 90 | 91 | 92 | 93 | 94 | 95 | io.quarkus 96 | quarkus-maven-plugin 97 | ${quarkus.version} 98 | 99 | 100 | 101 | native-image 102 | 103 | 104 | true 105 | 106 | 107 | 108 | 109 | 110 | maven-failsafe-plugin 111 | ${surefire-plugin.version} 112 | 113 | 114 | 115 | integration-test 116 | verify 117 | 118 | 119 | 120 | ${project.build.directory}/${project.build.finalName}-runner 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /jug14-demos/quarkus-persistencia/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 docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/quarkus-persistencia-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-persistencia-jvm 15 | # 16 | ### 17 | FROM fabric8/java-alpine-openjdk8-jre 18 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 19 | ENV AB_ENABLED=jmx_exporter 20 | COPY target/lib/* /deployments/lib/ 21 | COPY target/*-runner.jar /deployments/app.jar 22 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /jug14-demos/quarkus-persistencia/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 docker image run: 5 | # 6 | # mvn package -Pnative -Dnative-image.docker-build=true 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-persistencia . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-persistencia 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal 18 | WORKDIR /work/ 19 | COPY target/*-runner /work/application 20 | RUN chmod 775 /work 21 | EXPOSE 8080 22 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /jug14-demos/quarkus-persistencia/src/main/java/org/jugvale/model/Evento.java: -------------------------------------------------------------------------------- 1 | package org.jugvale.model; 2 | 3 | import javax.persistence.Entity; 4 | 5 | import io.quarkus.hibernate.orm.panache.PanacheEntity; 6 | 7 | @Entity 8 | public class Evento extends PanacheEntity { 9 | 10 | 11 | public String nome; 12 | 13 | public String local; 14 | 15 | } -------------------------------------------------------------------------------- /jug14-demos/quarkus-persistencia/src/main/java/org/jugvale/rest/EventoResource.java: -------------------------------------------------------------------------------- 1 | package org.jugvale.rest; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | import javax.transaction.Transactional; 7 | import javax.ws.rs.Consumes; 8 | import javax.ws.rs.DELETE; 9 | import javax.ws.rs.GET; 10 | import javax.ws.rs.PUT; 11 | import javax.ws.rs.Path; 12 | import javax.ws.rs.PathParam; 13 | import javax.ws.rs.Produces; 14 | 15 | import org.jugvale.model.Evento; 16 | 17 | /** 18 | * EventoResource 19 | */ 20 | @Path("evento") 21 | public class EventoResource { 22 | 23 | 24 | @GET 25 | @Produces("application/json") 26 | public List todos() { 27 | return Evento.listAll(); 28 | } 29 | 30 | 31 | @PUT 32 | @Consumes("application/json") 33 | @Transactional 34 | public void cria(Evento evento) { 35 | Evento.persist(evento); 36 | } 37 | 38 | @DELETE 39 | @Path("{id}") 40 | @Transactional 41 | public void apaga(@PathParam("id") long id) { 42 | Evento.delete("id", id); 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /jug14-demos/quarkus-persistencia/src/main/resources/META-INF/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Eventos

4 | 5 |

Adiciona evento

6 | Nome: 7 |
8 | 9 |

Eventos adicionados

10 | 11 |
    12 | 13 | 14 |
15 | 16 | 17 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /jug14-demos/quarkus-persistencia/src/main/resources/META-INF/resources/index.js: -------------------------------------------------------------------------------- 1 | function apaga(id) { 2 | $.ajax({ 3 | url: '/evento/' + id, 4 | type: 'DELETE', 5 | success: function(result) { 6 | carregaEventos(); 7 | } 8 | }); 9 | } 10 | 11 | function adiciona() { 12 | var evento = { 13 | nome: $("#nome").val() 14 | }; 15 | $("#nome").val(""); 16 | $.ajax({ 17 | url: '/evento', 18 | type: 'PUT', 19 | headers: { 20 | "Content-type": "application/json" 21 | }, 22 | data: JSON.stringify(evento), 23 | success: function(result) { 24 | carregaEventos(); 25 | } 26 | }); 27 | } 28 | 29 | function carregaEventos() { 30 | $.get("/evento", function(data, status){ 31 | var listaEvt = document.getElementById("eventos"); 32 | listaEvt.innerHTML = ""; 33 | $.each(data, function(i, evento){ 34 | var evtEl = document.createElement("li"); 35 | var evtApagar =document.createElement("button"); 36 | evtApagar.textContent = "X"; 37 | evtApagar.onclick = function() { 38 | apaga(evento.id); 39 | } 40 | evtEl.textContent = evento.id + ": " + evento.nome; 41 | evtEl.appendChild(evtApagar); 42 | listaEvt.appendChild(evtEl); 43 | }); 44 | }); 45 | } 46 | 47 | $(document).ready(function() { 48 | carregaEventos(); 49 | }); -------------------------------------------------------------------------------- /jug14-demos/quarkus-persistencia/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Configuration file 2 | # key = value 3 | 4 | quarkus.datasource.driver=org.mariadb.jdbc.Driver 5 | quarkus.datasource.url=jdbc:mysql://localhost:3306/jug14 6 | quarkus.datasource.username=root 7 | quarkus.hibernate-orm.log.sql=true 8 | quarkus.hibernate-orm.database.generation=create-drop -------------------------------------------------------------------------------- /jug14-demos/using-kogito/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* -------------------------------------------------------------------------------- /jug14-demos/using-kogito/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | 19 | # OSX 20 | .DS_Store 21 | 22 | # Vim 23 | *.swp 24 | *.swo 25 | 26 | # patch 27 | *.orig 28 | *.rej 29 | 30 | # Maven 31 | target/ 32 | pom.xml.tag 33 | pom.xml.releaseBackup 34 | pom.xml.versionsBackup 35 | release.properties -------------------------------------------------------------------------------- /jug14-demos/using-kogito/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /jug14-demos/using-kogito/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.acme 6 | using-kogito 7 | 1.0-SNAPSHOT 8 | 9 | 2.22.0 10 | 1.8 11 | 1.8 12 | 0.21.2 13 | UTF-8 14 | UTF-8 15 | 16 | 17 | 18 | 19 | io.quarkus 20 | quarkus-bom 21 | ${quarkus.version} 22 | pom 23 | import 24 | 25 | 26 | 27 | 28 | 29 | io.quarkus 30 | quarkus-resteasy 31 | 32 | 33 | io.quarkus 34 | quarkus-kogito 35 | 36 | 37 | io.quarkus 38 | quarkus-junit5 39 | test 40 | 41 | 42 | io.rest-assured 43 | rest-assured 44 | test 45 | 46 | 47 | 48 | 49 | 50 | io.quarkus 51 | quarkus-maven-plugin 52 | ${quarkus.version} 53 | 54 | 55 | 56 | build 57 | 58 | 59 | 60 | 61 | 62 | maven-surefire-plugin 63 | ${surefire-plugin.version} 64 | 65 | 66 | org.jboss.logmanager.LogManager 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | native 75 | 76 | 77 | native 78 | 79 | 80 | 81 | 82 | 83 | io.quarkus 84 | quarkus-maven-plugin 85 | ${quarkus.version} 86 | 87 | 88 | 89 | native-image 90 | 91 | 92 | true 93 | 94 | 95 | 96 | 97 | 98 | maven-failsafe-plugin 99 | ${surefire-plugin.version} 100 | 101 | 102 | 103 | integration-test 104 | verify 105 | 106 | 107 | 108 | ${project.build.directory}/${project.build.finalName}-runner 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /jug14-demos/using-kogito/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 docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/using-kogito-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/using-kogito-jvm 15 | # 16 | ### 17 | FROM fabric8/java-alpine-openjdk8-jre 18 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 19 | ENV AB_ENABLED=jmx_exporter 20 | COPY target/lib/* /deployments/lib/ 21 | COPY target/*-runner.jar /deployments/app.jar 22 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /jug14-demos/using-kogito/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 docker image run: 5 | # 6 | # mvn package -Pnative -Dnative-image.docker-build=true 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/using-kogito . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/using-kogito 15 | # 16 | ### 17 | FROM registry.fedoraproject.org/fedora-minimal 18 | WORKDIR /work/ 19 | COPY target/*-runner /work/application 20 | RUN chmod 775 /work 21 | EXPOSE 8080 22 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /jug14-demos/using-kogito/src/main/java/org/acme/kogito/model/Person.java: -------------------------------------------------------------------------------- 1 | package org.acme.kogito.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Person implements Serializable { 6 | 7 | private static final long serialVersionUID = -571683427125356701L; 8 | 9 | private String name; 10 | private int age; 11 | private boolean adult; 12 | 13 | public String getName() { 14 | return name; 15 | } 16 | 17 | public void setName(String name) { 18 | this.name = name; 19 | } 20 | 21 | public int getAge() { 22 | return age; 23 | } 24 | 25 | public void setAge(int age) { 26 | this.age = age; 27 | } 28 | 29 | public boolean isAdult() { 30 | return adult; 31 | } 32 | 33 | public void setAdult(boolean adult) { 34 | this.adult = adult; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return "Person [name=" + name + ", age=" + age + ", adult=" + adult + "]"; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /jug14-demos/using-kogito/src/main/resources/META-INF/kmodule.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /jug14-demos/using-kogito/src/main/resources/org/acme/kogito/person-rules.drl: -------------------------------------------------------------------------------- 1 | package org.acme.kogito 2 | 3 | import org.acme.kogito.model.Person; 4 | 5 | 6 | rule "Is adult" ruleflow-group "person" 7 | 8 | when 9 | $person: Person(age > 18) 10 | then 11 | modify($person) { 12 | setAdult(true) 13 | }; 14 | end 15 | -------------------------------------------------------------------------------- /jug14-demos/using-kogito/src/test/java/org/acme/kogito/PersonProcessInGraalIT.java: -------------------------------------------------------------------------------- 1 | package org.acme.kogito; 2 | 3 | import io.quarkus.test.junit.SubstrateTest; 4 | 5 | @SubstrateTest 6 | public class PersonProcessInGraalIT extends PersonProcessTest { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /jug14-demos/using-kogito/src/test/java/org/acme/kogito/PersonProcessTest.java: -------------------------------------------------------------------------------- 1 | package org.acme.kogito; 2 | 3 | import static io.restassured.RestAssured.given; 4 | import static org.hamcrest.core.Is.is; 5 | 6 | import javax.inject.Inject; 7 | 8 | import org.junit.jupiter.api.Test; 9 | import org.kie.kogito.Application; 10 | 11 | import io.quarkus.test.junit.QuarkusTest; 12 | import io.restassured.http.ContentType; 13 | 14 | @QuarkusTest 15 | public class PersonProcessTest { 16 | 17 | @Inject 18 | Application application; 19 | 20 | @Test 21 | public void testAdult() { 22 | given() 23 | .body("{\"person\": {\"name\":\"John Quark\", \"age\": 20}}") 24 | .contentType(ContentType.JSON) 25 | .when() 26 | .post("/persons") 27 | .then() 28 | .statusCode(200) 29 | .body("person.adult", is(true)); 30 | } 31 | 32 | @Test 33 | public void testChild() { 34 | given() 35 | .body("{\"person\": {\"name\":\"Jenny Quark\", \"age\": 15}}") 36 | .contentType(ContentType.JSON) 37 | .when() 38 | .post("/persons") 39 | .then() 40 | .statusCode(200) 41 | .body("person.adult", is(false)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /kie-soup-datasets-rest-test/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* -------------------------------------------------------------------------------- /kie-soup-datasets-rest-test/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | 19 | # OSX 20 | .DS_Store 21 | 22 | # Vim 23 | *.swp 24 | *.swo 25 | 26 | # patch 27 | *.orig 28 | *.rej 29 | 30 | # Maven 31 | target/ 32 | pom.xml.tag 33 | pom.xml.releaseBackup 34 | pom.xml.versionsBackup 35 | release.properties -------------------------------------------------------------------------------- /kie-soup-datasets-rest-test/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | org.kie 8 | kie-soup-datasets-rest-test 9 | 1.0-SNAPSHOT 10 | 11 | UTF-8 12 | 2.22.0 13 | 0.21.1 14 | UTF-8 15 | 1.8 16 | 1.8 17 | 7.26.0-SNAPSHOT 18 | 19 | 20 | 21 | 22 | io.quarkus 23 | quarkus-bom 24 | ${quarkus.version} 25 | pom 26 | import 27 | 28 | 29 | 30 | 31 | 32 | io.quarkus 33 | quarkus-resteasy 34 | 35 | 36 | io.quarkus 37 | quarkus-junit5 38 | test 39 | 40 | 41 | io.rest-assured 42 | rest-assured 43 | test 44 | 45 | 46 | io.quarkus 47 | quarkus-resteasy-jsonb 48 | 49 | 50 | io.quarkus 51 | quarkus-agroal 52 | 53 | 54 | io.quarkus 55 | quarkus-jdbc-mariadb 56 | 57 | 58 | org.kie.soup 59 | kie-soup-dataset-sql 60 | ${kie.soup.version} 61 | 62 | 63 | 64 | 65 | 66 | io.quarkus 67 | quarkus-maven-plugin 68 | ${quarkus.version} 69 | 70 | 71 | 72 | build 73 | 74 | 75 | 76 | 77 | 78 | maven-surefire-plugin 79 | ${surefire-plugin.version} 80 | 81 | 82 | org.jboss.logmanager.LogManager 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | native 91 | 92 | 93 | native 94 | 95 | 96 | 97 | 98 | 99 | io.quarkus 100 | quarkus-maven-plugin 101 | ${quarkus.version} 102 | 103 | 104 | 105 | native-image 106 | 107 | 108 | true 109 | 110 | 111 | 112 | 113 | 114 | maven-failsafe-plugin 115 | ${surefire-plugin.version} 116 | 117 | 118 | 119 | integration-test 120 | verify 121 | 122 | 123 | 124 | ${project.build.directory}/${project.build.finalName}-runner 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /kie-soup-datasets-rest-test/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 docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/kie-soup-datasets-rest-test-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/kie-soup-datasets-rest-test-jvm 15 | # 16 | ### 17 | FROM fabric8/java-alpine-openjdk8-jre 18 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 19 | ENV AB_ENABLED=jmx_exporter 20 | COPY target/lib/* /deployments/lib/ 21 | COPY target/*-runner.jar /deployments/app.jar 22 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /kie-soup-datasets-rest-test/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 docker image run: 5 | # 6 | # mvn package -Pnative -Dnative-image.docker-build=true 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/kie-soup-datasets-rest-test . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/kie-soup-datasets-rest-test 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal 18 | WORKDIR /work/ 19 | COPY target/*-runner /work/application 20 | RUN chmod 775 /work 21 | EXPOSE 8080 22 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /kie-soup-datasets-rest-test/src/main/java/org/kie/soup/sql/rest/DatasetResource.java: -------------------------------------------------------------------------------- 1 | package org.kie.soup.sql.rest; 2 | 3 | import java.util.stream.Stream; 4 | 5 | import javax.annotation.PostConstruct; 6 | import javax.inject.Inject; 7 | import javax.ws.rs.GET; 8 | import javax.ws.rs.Path; 9 | import javax.ws.rs.Produces; 10 | import javax.ws.rs.core.MediaType; 11 | 12 | import org.dashbuilder.DataSetCore; 13 | import org.dashbuilder.dataprovider.DataSetProviderRegistry; 14 | import org.dashbuilder.dataprovider.sql.SQLDataSetProvider; 15 | import org.dashbuilder.dataset.DataSet; 16 | import org.dashbuilder.dataset.def.DataSetDefRegistry; 17 | import org.dashbuilder.dataset.def.SQLDataSetDef; 18 | 19 | @Path("/datasets") 20 | public class DatasetResource { 21 | 22 | @Inject 23 | DefaultDatasourceLocator dataSourceLocator; 24 | private DataSet theDataSet; 25 | 26 | @PostConstruct 27 | public void buildDataSet() throws Exception { 28 | DataSetDefRegistry dataSetDefRegistry = DataSetCore.get().getDataSetDefRegistry(); 29 | SQLDataSetProvider sqlDataSetProvider = SQLDataSetProvider.get(); 30 | 31 | sqlDataSetProvider.setDataSourceLocator(dataSourceLocator); 32 | 33 | // Add SQL data sets support 34 | DataSetProviderRegistry dataSetProviderRegistry = DataSetCore.get().getDataSetProviderRegistry(); 35 | dataSetProviderRegistry.registerDataProvider(sqlDataSetProvider); 36 | 37 | // Register the SQL data set 38 | SQLDataSetDef def = new SQLDataSetDef(); 39 | def.setDbTable("PERSON"); 40 | def.setDbSQL("select * from PERSON"); 41 | 42 | def.setUUID("TEST_DS"); 43 | def.setDataSource("TEST"); 44 | dataSetDefRegistry.registerDataSetDef(def); 45 | 46 | theDataSet = sqlDataSetProvider.lookupDataSet(def, null); 47 | } 48 | 49 | @GET 50 | @Produces(MediaType.APPLICATION_JSON) 51 | public Object hello() { 52 | return theDataSet.getValueAt(0, 0); 53 | } 54 | } -------------------------------------------------------------------------------- /kie-soup-datasets-rest-test/src/main/java/org/kie/soup/sql/rest/DefaultDatasourceLocator.java: -------------------------------------------------------------------------------- 1 | package org.kie.soup.sql.rest; 2 | 3 | import javax.enterprise.context.ApplicationScoped; 4 | import javax.inject.Inject; 5 | import javax.sql.DataSource; 6 | 7 | import org.dashbuilder.dataprovider.sql.SQLDataSourceLocator; 8 | import org.dashbuilder.dataset.def.SQLDataSetDef; 9 | 10 | import io.agroal.api.AgroalDataSource; 11 | 12 | @ApplicationScoped 13 | public class DefaultDatasourceLocator implements SQLDataSourceLocator { 14 | 15 | @Inject 16 | @io.quarkus.agroal.DataSource("contacts") 17 | AgroalDataSource datasource; 18 | 19 | @Override 20 | public DataSource lookup(SQLDataSetDef def) throws Exception { 21 | 22 | return datasource; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /kie-soup-datasets-rest-test/src/main/resources/META-INF/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | kie-soup-datasets-rest-test - 1.0-SNAPSHOT 6 | 99 | 100 | 101 | 102 | 105 | 106 |
107 |
108 |

Congratulations, you have created a new Quarkus application.

109 | 110 |

Why do you see this?

111 | 112 |

This page is served by Quarkus. The source is in 113 | src/main/resources/META-INF/resources/index.html.

114 | 115 |

What can I do from here?

116 | 117 |

If not already done, run the application in dev mode using: mvn compile quarkus:dev. 118 |

119 |
    120 |
  • Add REST resources, Servlets, functions and other services in src/main/java.
  • 121 |
  • Your static assets are located in src/main/resources/META-INF/resources.
  • 122 |
  • Configure your application in src/main/resources/application.properties. 123 |
  • 124 |
125 | 126 |

How do I get rid of this page?

127 |

Just delete the src/main/resources/META-INF/resources/index.html file.

128 |
129 |
130 |
131 |

Application

132 |
    133 |
  • GroupId: org.kie
  • 134 |
  • ArtifactId: kie-soup-datasets-rest-test
  • 135 |
  • Version: 1.0-SNAPSHOT
  • 136 |
  • Quarkus Version: 0.21.1
  • 137 |
138 |
139 |
140 |

Next steps

141 | 146 |
147 |
148 |
149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /kie-soup-datasets-rest-test/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.datasource.contacts.driver=org.mariadb.jdbc.Driver 2 | quarkus.datasource.contacts.url=jdbc:mysql://localhost:3306/test 3 | quarkus.datasource.contacts.username = root -------------------------------------------------------------------------------- /metrics-example/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* 5 | !target/quarkus-app/* -------------------------------------------------------------------------------- /metrics-example/.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 | -------------------------------------------------------------------------------- /metrics-example/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /metrics-example/README.md: -------------------------------------------------------------------------------- 1 | # metrics-example 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 | The application is now runnable using `java -jar target/quarkus-app/quarkus-run.jar`. 26 | 27 | If you want to build an _über-jar_, execute the following command: 28 | ```shell script 29 | ./mvnw package -Dquarkus.package.type=uber-jar 30 | ``` 31 | 32 | The application, packaged as an _über-jar_, is now runnable using `java -jar target/*-runner.jar`. 33 | 34 | ## Creating a native executable 35 | 36 | You can create a native executable using: 37 | ```shell script 38 | ./mvnw package -Pnative 39 | ``` 40 | 41 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: 42 | ```shell script 43 | ./mvnw package -Pnative -Dquarkus.native.container-build=true 44 | ``` 45 | 46 | You can then execute your native executable with: `./target/metrics-example-1.0.0-SNAPSHOT-runner` 47 | 48 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling. 49 | 50 | ## Provided Code 51 | 52 | ### RESTEasy JAX-RS 53 | 54 | Easily start your RESTful Web Services 55 | 56 | [Related guide section...](https://quarkus.io/guides/getting-started#the-jax-rs-resources) 57 | -------------------------------------------------------------------------------- /metrics-example/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.fxapps 6 | metrics-example 7 | 1.0.0-SNAPSHOT 8 | 9 | 3.8.1 10 | 11 11 | UTF-8 12 | UTF-8 13 | quarkus-bom 14 | io.quarkus.platform 15 | 2.6.1.Final 16 | 3.0.0-M5 17 | 18 | 19 | 20 | 21 | ${quarkus.platform.group-id} 22 | ${quarkus.platform.artifact-id} 23 | ${quarkus.platform.version} 24 | pom 25 | import 26 | 27 | 28 | 29 | 30 | 31 | io.quarkus 32 | quarkus-micrometer-registry-prometheus 33 | 34 | 35 | io.quarkus 36 | quarkus-arc 37 | 38 | 39 | io.quarkus 40 | quarkus-resteasy 41 | 42 | 43 | io.quarkus 44 | quarkus-junit5 45 | test 46 | 47 | 48 | io.rest-assured 49 | rest-assured 50 | test 51 | 52 | 53 | 54 | 55 | 56 | ${quarkus.platform.group-id} 57 | quarkus-maven-plugin 58 | ${quarkus.platform.version} 59 | true 60 | 61 | 62 | 63 | build 64 | generate-code 65 | generate-code-tests 66 | 67 | 68 | 69 | 70 | 71 | maven-compiler-plugin 72 | ${compiler-plugin.version} 73 | 74 | 75 | -parameters 76 | 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 | -------------------------------------------------------------------------------- /metrics-example/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/metrics-example-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/metrics-example-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 quarkus/metrics-example-jvm 22 | # 23 | ### 24 | FROM registry.access.redhat.com/ubi8/openjdk-11-runtime:1.10 25 | 26 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' 27 | 28 | # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. 29 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 30 | 31 | # We make four distinct layers so if there are application changes the library layers can be re-used 32 | COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ 33 | COPY --chown=185 target/quarkus-app/*.jar /deployments/ 34 | COPY --chown=185 target/quarkus-app/app/ /deployments/app/ 35 | COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ 36 | 37 | EXPOSE 8080 38 | USER 185 39 | 40 | ENTRYPOINT [ "java", "-jar", "/deployments/quarkus-run.jar" ] 41 | 42 | -------------------------------------------------------------------------------- /metrics-example/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/metrics-example-legacy-jar . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/metrics-example-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 quarkus/metrics-example-legacy-jar 22 | # 23 | ### 24 | FROM registry.access.redhat.com/ubi8/openjdk-11-runtime:1.10 25 | 26 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' 27 | 28 | # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. 29 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 30 | 31 | COPY target/lib/* /deployments/lib/ 32 | COPY target/*-runner.jar /deployments/quarkus-run.jar 33 | 34 | EXPOSE 8080 35 | USER 185 36 | 37 | ENTRYPOINT [ "java", "-jar", "/deployments/quarkus-run.jar" ] 38 | -------------------------------------------------------------------------------- /metrics-example/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/metrics-example . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/metrics-example 15 | # 16 | ### 17 | FROM quay.io/quarkus/quarkus-micro-image:1.0 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 | -------------------------------------------------------------------------------- /metrics-example/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/metrics-example . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/metrics-example 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 | -------------------------------------------------------------------------------- /metrics-example/src/main/java/org/fxapps/GreetingResource.java: -------------------------------------------------------------------------------- 1 | package org.fxapps; 2 | 3 | import javax.ws.rs.GET; 4 | import javax.ws.rs.Path; 5 | import javax.ws.rs.Produces; 6 | import javax.ws.rs.core.MediaType; 7 | 8 | @Path("/hello") 9 | public class GreetingResource { 10 | 11 | @GET 12 | @Produces(MediaType.TEXT_PLAIN) 13 | public String hello() { 14 | return "Hello RESTEasy"; 15 | } 16 | } -------------------------------------------------------------------------------- /metrics-example/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jesuino/quarkus-examples/15d6e2926a7253d7cd61ac11f3977121f5a8ccd6/metrics-example/src/main/resources/application.properties -------------------------------------------------------------------------------- /quarkus-form-authentication/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* -------------------------------------------------------------------------------- /quarkus-form-authentication/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | 19 | # OSX 20 | .DS_Store 21 | 22 | # Vim 23 | *.swp 24 | *.swo 25 | 26 | # patch 27 | *.orig 28 | *.rej 29 | 30 | # Maven 31 | target/ 32 | pom.xml.tag 33 | pom.xml.releaseBackup 34 | pom.xml.versionsBackup 35 | release.properties -------------------------------------------------------------------------------- /quarkus-form-authentication/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /quarkus-form-authentication/README.md: -------------------------------------------------------------------------------- 1 | # quarkus-form-authentication 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 | ``` 11 | ./mvnw quarkus:dev 12 | ``` 13 | 14 | ## Packaging and running the application 15 | 16 | The application is packageable using `./mvnw package`. 17 | It produces the executable `quarkus-form-authentication-1.0.0-SNAPSHOT-runner.jar` file in `/target` directory. 18 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/lib` directory. 19 | 20 | The application is now runnable using `java -jar target/quarkus-form-authentication-1.0.0-SNAPSHOT-runner.jar`. 21 | 22 | ## Creating a native executable 23 | 24 | You can create a native executable using: `./mvnw package -Pnative`. 25 | 26 | Or you can use Docker to build the native executable using: `./mvnw package -Pnative -Dquarkus.native.container-build=true`. 27 | 28 | You can then execute your binary: `./target/quarkus-form-authentication-1.0.0-SNAPSHOT-runner` 29 | 30 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/building-native-image-guide . -------------------------------------------------------------------------------- /quarkus-form-authentication/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.fxapps 6 | quarkus-form-authentication 7 | 1.0.0-SNAPSHOT 8 | 9 | 3.8.1 10 | true 11 | 1.8 12 | 1.8 13 | UTF-8 14 | UTF-8 15 | 1.1.0.Final 16 | quarkus-universe-bom 17 | io.quarkus 18 | 1.1.0.Final 19 | 2.22.1 20 | 21 | 22 | 23 | 24 | ${quarkus.platform.group-id} 25 | ${quarkus.platform.artifact-id} 26 | ${quarkus.platform.version} 27 | pom 28 | import 29 | 30 | 31 | 32 | 33 | 34 | io.quarkus 35 | quarkus-resteasy 36 | 37 | 38 | io.quarkus 39 | quarkus-junit5 40 | test 41 | 42 | 43 | io.rest-assured 44 | rest-assured 45 | test 46 | 47 | 48 | io.quarkus 49 | quarkus-jdbc-mariadb 50 | 51 | 52 | io.quarkus 53 | quarkus-elytron-security-jdbc 54 | 55 | 56 | 57 | 58 | 59 | io.quarkus 60 | quarkus-maven-plugin 61 | ${quarkus-plugin.version} 62 | 63 | 64 | 65 | build 66 | 67 | 68 | 69 | 70 | 71 | maven-compiler-plugin 72 | ${compiler-plugin.version} 73 | 74 | 75 | maven-surefire-plugin 76 | ${surefire-plugin.version} 77 | 78 | 79 | org.jboss.logmanager.LogManager 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | native 88 | 89 | 90 | native 91 | 92 | 93 | 94 | 95 | 96 | maven-failsafe-plugin 97 | ${surefire-plugin.version} 98 | 99 | 100 | 101 | integration-test 102 | verify 103 | 104 | 105 | 106 | ${project.build.directory}/${project.build.finalName}-runner 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | native 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /quarkus-form-authentication/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 docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/quarkus-form-authentication-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-form-authentication-jvm 15 | # 16 | ### 17 | FROM fabric8/java-alpine-openjdk8-jre:1.6.5 18 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 19 | ENV AB_ENABLED=jmx_exporter 20 | 21 | # Be prepared for running in OpenShift too 22 | RUN adduser -G root --no-create-home --disabled-password 1001 \ 23 | && chown -R 1001 /deployments \ 24 | && chmod -R "g+rwX" /deployments \ 25 | && chown -R 1001:root /deployments 26 | 27 | COPY target/lib/* /deployments/lib/ 28 | COPY target/*-runner.jar /deployments/app.jar 29 | EXPOSE 8080 30 | 31 | # run with user 1001 32 | USER 1001 33 | 34 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /quarkus-form-authentication/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 docker image run: 5 | # 6 | # mvn package -Pnative -Dquarkus.native.container-build=true 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-form-authentication . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-form-authentication 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal 18 | WORKDIR /work/ 19 | COPY target/*-runner /work/application 20 | RUN chmod 775 /work 21 | EXPOSE 8080 22 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /quarkus-form-authentication/src/main/java/org/fxapps/SampleResource.java: -------------------------------------------------------------------------------- 1 | package org.fxapps; 2 | 3 | import java.security.Principal; 4 | 5 | import javax.annotation.security.PermitAll; 6 | import javax.annotation.security.RolesAllowed; 7 | import javax.ws.rs.GET; 8 | import javax.ws.rs.Path; 9 | import javax.ws.rs.Produces; 10 | import javax.ws.rs.core.Context; 11 | import javax.ws.rs.core.MediaType; 12 | import javax.ws.rs.core.SecurityContext; 13 | 14 | @Path("/sample") 15 | public class SampleResource { 16 | 17 | final static String MANAGER_ROLE = "manager"; 18 | final static String USER_ROLE = "user"; 19 | 20 | @GET 21 | @Path("info") 22 | @PermitAll 23 | public String userInfo(@Context SecurityContext securityContext) { 24 | Principal userPrincipal = securityContext.getUserPrincipal(); 25 | if (userPrincipal != null) { 26 | return userPrincipal.getName(); 27 | } 28 | // translates to "no content" response 29 | return null; 30 | 31 | } 32 | 33 | @GET 34 | @PermitAll 35 | @Path("public") 36 | @Produces(MediaType.TEXT_PLAIN) 37 | public String freeForAll() { 38 | return "Everyone can access this!"; 39 | } 40 | 41 | @GET 42 | @Path("user_managers") 43 | @Produces(MediaType.TEXT_PLAIN) 44 | @RolesAllowed({ USER_ROLE, MANAGER_ROLE }) 45 | public String contentForUsersAndManagers() { 46 | return "Only users and managers can see this!"; 47 | } 48 | 49 | @GET 50 | @Path("managers") 51 | @Produces(MediaType.TEXT_PLAIN) 52 | @RolesAllowed({ MANAGER_ROLE }) 53 | public String contentManagers() { 54 | return "Only MANAGERS can see this!"; 55 | } 56 | } -------------------------------------------------------------------------------- /quarkus-form-authentication/src/main/resources/META-INF/resources/error.html: -------------------------------------------------------------------------------- 1 |

Authentication Error! Verify your credentials and try again.

2 | 3 | Login Page -------------------------------------------------------------------------------- /quarkus-form-authentication/src/main/resources/META-INF/resources/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 54 | 55 | 56 | 57 | 58 |

LOGIN!

59 |
60 |
61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 |
70 |
71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /quarkus-form-authentication/src/main/resources/META-INF/resources/secured/index.html: -------------------------------------------------------------------------------- 1 |

This is a Secured page! If you can see it you are authenticated

2 | 3 | Go back to home page -------------------------------------------------------------------------------- /quarkus-form-authentication/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | ### DATASOURCE CONFIGURATION ### 2 | quarkus.datasource.url=jdbc:mysql://localhost:3306/quarkus_form_example 3 | quarkus.datasource.driver=org.mariadb.jdbc.Driver 4 | quarkus.datasource.username=root 5 | 6 | ### SECURITY CONFIGURATION ### 7 | quarkus.http.auth.form.enabled=true 8 | quarkus.security.jdbc.enabled=true 9 | quarkus.security.jdbc.principal-query.sql=select u.password, r.name from user u, user_role ur,role r where u.id = ur.user_id AND r.id = ur.role_id and u.username = ? group by u.password; 10 | quarkus.security.jdbc.principal-query.clear-password-mapper.enabled=true 11 | quarkus.security.jdbc.principal-query.clear-password-mapper.password-index=1 12 | quarkus.security.jdbc.principal-query.attribute-mappings.0.index=2 13 | quarkus.security.jdbc.principal-query.attribute-mappings.0.to=groups 14 | 15 | ### SECURITY URIS MAPPING ### 16 | quarkus.http.auth.permission.permit1.paths=/secured/* 17 | quarkus.http.auth.permission.permit1.policy=authenticated -------------------------------------------------------------------------------- /quarkus-gradle-hello/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !build/*-runner 3 | !build/*-runner.jar 4 | !build/lib/* -------------------------------------------------------------------------------- /quarkus-gradle-hello/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | .factorypath 19 | 20 | # OSX 21 | .DS_Store 22 | 23 | # Vim 24 | *.swp 25 | *.swo 26 | 27 | # patch 28 | *.orig 29 | *.rej 30 | 31 | # Gradle 32 | .gradle/ 33 | build/ -------------------------------------------------------------------------------- /quarkus-gradle-hello/README.md: -------------------------------------------------------------------------------- 1 | # Quarkus + Gradle 2 | 3 | Simple Rock Band REST API using Gradle and Quarkus. 4 | 5 | ## Requirements 6 | 7 | * Java JDK 11 8 | 9 | ## Developing 10 | 11 | Import the project in your favorite IDE. 12 | In the project root dir use `./gradlew quarkusDev` to start quarkus in dev mode. Start developing... 13 | 14 | In development mode you can access and invoke endpoints using `localhost:8080/swagger-ui` 15 | 16 | ## Building 17 | 18 | Run `./gradle quarkusBuild` and the built JARs will be found in `build` directory. 19 | 20 | ## Learning 21 | 22 | This project has three classes: 23 | 24 | * Band: Hold Bands information 25 | * BandStorage: In memory storage for bands information 26 | * BandResource: REST Endpoints 27 | 28 | #### Band class 29 | 30 | This class hold information about the band. It was build in a conservative way, using get/set for all attributes, but you could use public attributes because it would also work with Panache (service to map and store objects in a database) 31 | 32 | #### BandStorage 33 | 34 | A class that uses a Map structure to store bands by ID. It also generate IDs for all bands added to the storage. 35 | 36 | Notice that the class has an annotation `@ApplicationScoped`. This special annotation tells Quarkus that the class should be created (instance) once. After using this annotation Quarkus will be aware of this class and will make easy to use it in other classes. 37 | 38 | Since the class is controlled by Quarkus, we can ask it to run some methods. This is what happens on method *init*. It has the annotation `@PostConstruct`, which tells quarkus that it should run this method after it creates the class instance. In this method we create some initial band data. 39 | 40 | The most complex methods are searchByName and searchByYear, which uses the private filterBands methods to filter all stored bands by a Predicate, which is a way to filter bands. It also uses Java Lambda. 41 | 42 | 43 | #### BandResource 44 | 45 | This is where we expose the storage funtionality to be accessed outside our computer, via HTTP specifically. HTTP means that we could have a client application running in a browser using Javascript to access the app functionalities. 46 | 47 | To expose the apps functionalities we use JAX-RS, which is an API that help us to write Java code that will later be mapped to HTTP verbs and URIs. For example, the annotation `@Path` describes which URI (for example in *google.com/search* - *search* is the URI) all the methods of the class will be invoked. `@GET` is the HTTP verb, which means that the method *all* is invoked when we do a GET to `localhost:8080/band` in our application. 48 | 49 | Notice also the annotations `@Produces` and `@Consumes` to tell which format of data is used to exchange information between the server and the client. In our case we use the popular JSON format. 50 | 51 | The class has a single attribute storage. Notice the annotation `@Inject` on top of it. This annotation is used by Quarkus so it knows that our class should be created by it and then injected inside BandResource. 52 | 53 | In method *remove* we use the verb `@DELETE` and it requires a parameter. So to invoke it you must pass some number in the URL (*/band/123*). This number is passed as a parameter to the method and Quarkus knows that it should take it from the URL because we use the annotation `@PathParam` before the parameter. This is also done in `searchByName` and `searchByYear` methods. 54 | 55 | -------------------------------------------------------------------------------- /quarkus-gradle-hello/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | id 'io.quarkus' 4 | } 5 | 6 | repositories { 7 | mavenLocal() 8 | mavenCentral() 9 | } 10 | 11 | dependencies { 12 | implementation 'io.quarkus:quarkus-smallrye-openapi' 13 | implementation 'io.quarkus:quarkus-resteasy-jsonb' 14 | implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") 15 | implementation 'io.quarkus:quarkus-resteasy' 16 | 17 | testImplementation 'io.quarkus:quarkus-junit5' 18 | testImplementation 'io.rest-assured:rest-assured' 19 | } 20 | 21 | group 'org.giu' 22 | version '1.0.0-SNAPSHOT' 23 | 24 | compileJava { 25 | options.encoding = 'UTF-8' 26 | options.compilerArgs << '-parameters' 27 | } 28 | 29 | compileTestJava { 30 | options.encoding = 'UTF-8' 31 | } 32 | 33 | java { 34 | sourceCompatibility = JavaVersion.VERSION_11 35 | targetCompatibility = JavaVersion.VERSION_11 36 | } 37 | 38 | test { 39 | systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager" 40 | } 41 | -------------------------------------------------------------------------------- /quarkus-gradle-hello/gradle.properties: -------------------------------------------------------------------------------- 1 | #Gradle properties 2 | #Sat Jun 20 23:24:19 BRT 2020 3 | quarkusPluginVersion=1.5.2.Final 4 | quarkusPlatformArtifactId=quarkus-universe-bom 5 | quarkusPlatformGroupId=io.quarkus 6 | quarkusPlatformVersion=1.5.2.Final 7 | -------------------------------------------------------------------------------- /quarkus-gradle-hello/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /quarkus-gradle-hello/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /quarkus-gradle-hello/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | mavenLocal() 4 | mavenCentral() 5 | gradlePluginPortal() 6 | } 7 | plugins { 8 | id 'io.quarkus' version "${quarkusPluginVersion}" 9 | } 10 | } 11 | rootProject.name='quarkus-gradle-hello' -------------------------------------------------------------------------------- /quarkus-gradle-hello/src/main/java/org/giu/model/Band.java: -------------------------------------------------------------------------------- 1 | package org.giu.model; 2 | 3 | /** 4 | * Class that holds Band information 5 | */ 6 | public class Band { 7 | 8 | /** 9 | * Band unique ID; 10 | */ 11 | private int id; 12 | 13 | /** 14 | * Band Name 15 | */ 16 | private String name; 17 | 18 | /** 19 | * Band debut year 20 | */ 21 | private int debutYear; 22 | 23 | 24 | public Band() { 25 | } 26 | 27 | public static Band of(String name, int debutYear) { 28 | var band = new Band(); 29 | band.name = name; 30 | band.debutYear = debutYear; 31 | return band; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public int getDebutYear() { 43 | return debutYear; 44 | } 45 | 46 | public void setDebutYear(int debutYear) { 47 | this.debutYear = debutYear; 48 | } 49 | 50 | public int getId() { 51 | return id; 52 | } 53 | 54 | public void setId(int id) { 55 | this.id = id; 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /quarkus-gradle-hello/src/main/java/org/giu/resources/BandResource.java: -------------------------------------------------------------------------------- 1 | package org.giu.resources; 2 | 3 | import java.util.Collection; 4 | import java.util.List; 5 | 6 | import javax.inject.Inject; 7 | import javax.ws.rs.Consumes; 8 | import javax.ws.rs.DELETE; 9 | import javax.ws.rs.GET; 10 | import javax.ws.rs.PUT; 11 | import javax.ws.rs.Path; 12 | import javax.ws.rs.PathParam; 13 | import javax.ws.rs.Produces; 14 | import javax.ws.rs.QueryParam; 15 | import javax.ws.rs.core.Response; 16 | 17 | import org.giu.model.Band; 18 | import org.giu.storage.BandStorage; 19 | 20 | import static javax.ws.rs.core.MediaType.APPLICATION_JSON; 21 | import static javax.ws.rs.core.Response.Status.CREATED; 22 | import static javax.ws.rs.core.Response.Status.NOT_FOUND; 23 | 24 | /** 25 | * REST Service for Bands 26 | */ 27 | @Path("band") 28 | @Produces(APPLICATION_JSON) 29 | @Consumes(APPLICATION_JSON) 30 | public class BandResource { 31 | 32 | @Inject 33 | private BandStorage storage; 34 | 35 | @GET 36 | public Collection all() { 37 | return storage.all(); 38 | } 39 | 40 | @PUT 41 | public Response store(Band band) { 42 | storage.store(band); 43 | return Response.status(CREATED).build(); 44 | } 45 | 46 | @DELETE 47 | @Path("/{id}") 48 | public Response remove(@PathParam("id") int id) { 49 | Response response = Response.status(NOT_FOUND).build(); 50 | boolean wasRemoved = storage.remove(id); 51 | if (wasRemoved) { 52 | response = Response.noContent().build(); 53 | } 54 | return response; 55 | } 56 | 57 | @GET 58 | @Path("search/name/{name}") 59 | public List searchByName(@QueryParam("name") String name) { 60 | return storage.searchByName(name); 61 | } 62 | 63 | @GET 64 | @Path("search/year/{year}") 65 | public List searchByYear(@QueryParam("year") int year) { 66 | return storage.searchByYear(year); 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /quarkus-gradle-hello/src/main/java/org/giu/storage/BandStorage.java: -------------------------------------------------------------------------------- 1 | package org.giu.storage; 2 | 3 | import java.util.Collection; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | import java.util.concurrent.atomic.AtomicInteger; 8 | import java.util.function.Predicate; 9 | 10 | import javax.annotation.PostConstruct; 11 | import javax.enterprise.context.ApplicationScoped; 12 | 13 | import org.giu.model.Band; 14 | import org.slf4j.Logger; 15 | import org.slf4j.LoggerFactory; 16 | 17 | import static java.util.stream.Collectors.toList; 18 | 19 | /** 20 | * In Memory storage for Band objects. 21 | */ 22 | @ApplicationScoped 23 | public class BandStorage { 24 | 25 | private static final AtomicInteger idGenerator = new AtomicInteger(0); 26 | 27 | private static Map storage = new HashMap<>(); 28 | 29 | Logger logger = LoggerFactory.getLogger(BandStorage.class); 30 | 31 | /** 32 | * Internal method that adds some base data 33 | */ 34 | @PostConstruct 35 | public void init() { 36 | logger.info("Adding initial data to the storage"); 37 | List.of( 38 | Band.of("The Beatles", 1957), 39 | Band.of("Rolling Stones", 1962), 40 | Band.of("Pink Floyd", 1965), 41 | Band.of("The Doors", 1965), 42 | Band.of("Black Sabbath", 1968), 43 | Band.of("Led Zeppelin", 1968), 44 | Band.of("Queen", 1970)) 45 | .forEach(this::store); 46 | 47 | } 48 | 49 | /** 50 | * Store bands 51 | * @param band 52 | * The band object. The id is always overwritten. 53 | */ 54 | public void store(Band band) { 55 | band.setId(idGenerator.incrementAndGet()); 56 | storage.put(band.getId(), band); 57 | } 58 | 59 | /** 60 | * 61 | * Access all stored bands 62 | * @return 63 | * The list of all stored bands. 64 | */ 65 | public Collection all() { 66 | return storage.values(); 67 | } 68 | 69 | /** 70 | * 71 | * Remove a band from storage. 72 | * @param id 73 | * The band ID to be returned. 74 | * @return 75 | * true if a band was found and returned, false otherwise. 76 | */ 77 | public boolean remove(int id) { 78 | return storage.remove(id) != null; 79 | } 80 | 81 | /** 82 | * Search bands by name. 83 | * @param bandName 84 | * a band name or part of the band name 85 | * @return 86 | * The list of bands found in the storage; 87 | */ 88 | public List searchByName(String bandName) { 89 | return filterBands(band -> band.getName() 90 | .toLowerCase() 91 | .contains(bandName)); 92 | } 93 | 94 | /** 95 | * Search bands by debug year. 96 | * @param year 97 | * The band debug year 98 | * @return 99 | * The list of bands found in the storage; 100 | */ 101 | public List searchByYear(int year) { 102 | return filterBands(band -> band.getDebutYear() == year); 103 | } 104 | 105 | /** 106 | * 107 | * Filter bands in the storage. 108 | * @param filter 109 | * The filter to the applied to all bands in the storage. 110 | * @return 111 | * The list of bands found according to the filter. 112 | */ 113 | private List filterBands(Predicate filter) { 114 | return storage.values().stream() 115 | .filter(filter) 116 | .collect(toList()); 117 | } 118 | 119 | } -------------------------------------------------------------------------------- /quarkus-gradle-hello/src/main/resources/META-INF/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | quarkus-gradle-hello - 1.0.0-SNAPSHOT 6 | 99 | 100 | 101 | 102 | 105 | 106 |
107 |
108 |

Congratulations, you have created a new Quarkus application.

109 | 110 |

Why do you see this?

111 | 112 |

This page is served by Quarkus. The source is in 113 | src/main/resources/META-INF/resources/index.html.

114 | 115 |

What can I do from here?

116 | 117 |

If not already done, run the application in dev mode using: mvn compile quarkus:dev. 118 |

119 |
    120 |
  • Add REST resources, Servlets, functions and other services in src/main/java.
  • 121 |
  • Your static assets are located in src/main/resources/META-INF/resources.
  • 122 |
  • Configure your application in src/main/resources/application.properties. 123 |
  • 124 |
125 | 126 |

Do you like Quarkus?

127 |

Go give it a star on GitHub.

128 | 129 |

How do I get rid of this page?

130 |

Just delete the src/main/resources/META-INF/resources/index.html file.

131 |
132 |
133 |
134 |

Application

135 |
    136 |
  • GroupId: org.giu
  • 137 |
  • ArtifactId: quarkus-gradle-hello
  • 138 |
  • Version: 1.0.0-SNAPSHOT
  • 139 |
  • Quarkus Version: 1.5.2.Final
  • 140 |
141 |
142 |
143 |

Next steps

144 | 149 |
150 |
151 |
152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /quarkus-gradle-hello/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Configuration file 2 | # key = value -------------------------------------------------------------------------------- /quarkus-microblog/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* -------------------------------------------------------------------------------- /quarkus-microblog/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | 19 | # OSX 20 | .DS_Store 21 | 22 | # Vim 23 | *.swp 24 | *.swo 25 | 26 | # patch 27 | *.orig 28 | *.rej 29 | 30 | # Maven 31 | target/ 32 | pom.xml.tag 33 | pom.xml.releaseBackup 34 | pom.xml.versionsBackup 35 | release.properties -------------------------------------------------------------------------------- /quarkus-microblog/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /quarkus-microblog/README.md: -------------------------------------------------------------------------------- 1 | # quarkus-microblog 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 | ``` 11 | ./mvnw quarkus:dev 12 | ``` 13 | 14 | ## Packaging and running the application 15 | 16 | The application is packageable using `./mvnw package`. 17 | It produces the executable `quarkus-microblog-1.0.0-SNAPSHOT-runner.jar` file in `/target` directory. 18 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/lib` directory. 19 | 20 | The application is now runnable using `java -jar target/quarkus-microblog-1.0.0-SNAPSHOT-runner.jar`. 21 | 22 | ## Creating a native executable 23 | 24 | You can create a native executable using: `./mvnw package -Pnative`. 25 | 26 | Or you can use Docker to build the native executable using: `./mvnw package -Pnative -Dquarkus.native.container-build=true`. 27 | 28 | You can then execute your binary: `./target/quarkus-microblog-1.0.0-SNAPSHOT-runner` 29 | 30 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/building-native-image-guide . -------------------------------------------------------------------------------- /quarkus-microblog/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.fxapps 6 | quarkus-microblog 7 | 1.0.0-SNAPSHOT 8 | 9 | 3.8.1 10 | true 11 | 1.8 12 | 1.8 13 | UTF-8 14 | UTF-8 15 | 1.1.0.Final 16 | quarkus-universe-bom 17 | io.quarkus 18 | 1.1.0.Final 19 | 2.22.1 20 | 21 | 22 | 23 | 24 | ${quarkus.platform.group-id} 25 | ${quarkus.platform.artifact-id} 26 | ${quarkus.platform.version} 27 | pom 28 | import 29 | 30 | 31 | 32 | 33 | 34 | io.quarkus 35 | quarkus-resteasy 36 | 37 | 38 | io.quarkus 39 | quarkus-hibernate-orm-panache 40 | 41 | 42 | io.quarkus 43 | quarkus-resteasy-qute 44 | 45 | 46 | io.quarkus 47 | quarkus-jdbc-h2 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 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | native 82 | 83 | 84 | native 85 | 86 | 87 | 88 | 89 | 90 | maven-failsafe-plugin 91 | ${surefire-plugin.version} 92 | 93 | 94 | 95 | integration-test 96 | verify 97 | 98 | 99 | 100 | ${project.build.directory}/${project.build.finalName}-runner 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | native 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /quarkus-microblog/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 docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/quarkus-microblog-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-microblog-jvm 15 | # 16 | ### 17 | FROM fabric8/java-alpine-openjdk8-jre:1.6.5 18 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 19 | ENV AB_ENABLED=jmx_exporter 20 | 21 | # Be prepared for running in OpenShift too 22 | RUN adduser -G root --no-create-home --disabled-password 1001 \ 23 | && chown -R 1001 /deployments \ 24 | && chmod -R "g+rwX" /deployments \ 25 | && chown -R 1001:root /deployments 26 | 27 | COPY target/lib/* /deployments/lib/ 28 | COPY target/*-runner.jar /deployments/app.jar 29 | EXPOSE 8080 30 | 31 | # run with user 1001 32 | USER 1001 33 | 34 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /quarkus-microblog/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 docker image run: 5 | # 6 | # mvn package -Pnative -Dquarkus.native.container-build=true 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-microblog . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/quarkus-microblog 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal 18 | WORKDIR /work/ 19 | COPY target/*-runner /work/application 20 | RUN chmod 775 /work 21 | EXPOSE 8080 22 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /quarkus-microblog/src/main/java/org/fxapps/MicropostResource.java: -------------------------------------------------------------------------------- 1 | package org.fxapps; 2 | 3 | import java.util.List; 4 | 5 | import javax.annotation.PostConstruct; 6 | import javax.enterprise.context.ApplicationScoped; 7 | import javax.inject.Inject; 8 | import javax.transaction.Transactional; 9 | import javax.ws.rs.*; 10 | import javax.ws.rs.core.MediaType; 11 | import org.fxapps.model.Micropost; 12 | import io.quarkus.panache.common.Sort; 13 | import io.quarkus.qute.Template; 14 | import io.quarkus.qute.TemplateInstance; 15 | 16 | @Path("/micropost") 17 | @ApplicationScoped 18 | public class MicropostResource { 19 | 20 | @Inject 21 | Template postsTemplate; 22 | 23 | @PostConstruct 24 | @Transactional 25 | public void start() { 26 | Micropost.persist(new Micropost[] { Micropost.create("Antonio", "I love playing with my Legos"), 27 | Micropost.create("Luana", "I like Painting and I should do it more often"), 28 | Micropost.create("William", "I love Java") }); 29 | } 30 | 31 | @GET 32 | @Produces(MediaType.TEXT_HTML) 33 | public TemplateInstance getPostsHtml() { 34 | final List posts = Micropost.findAll(Sort.descending("date")).list(); 35 | return postsTemplate.data("posts", posts); 36 | } 37 | 38 | @POST 39 | @Transactional 40 | public void create(@FormParam("author") String author, @FormParam("content") String content) { 41 | Micropost.create(author, content).persist(); 42 | 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /quarkus-microblog/src/main/java/org/fxapps/model/Micropost.java: -------------------------------------------------------------------------------- 1 | package org.fxapps.model; 2 | 3 | import java.util.Date; 4 | 5 | import javax.persistence.Entity; 6 | 7 | import io.quarkus.hibernate.orm.panache.PanacheEntity; 8 | 9 | /** 10 | * Micropost 11 | */ 12 | @Entity 13 | public class Micropost extends PanacheEntity { 14 | 15 | public String author; 16 | public String content; 17 | public Date date; 18 | 19 | public static Micropost create(String author, String content) { 20 | Micropost post = new Micropost(); 21 | post.author = author; 22 | post.content = content; 23 | post.date = new Date(); 24 | return post; 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /quarkus-microblog/src/main/resources/META-INF/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 28 | 29 | 30 | 31 | 32 | 33 |

Microblog

34 |
35 |

New post

36 |
37 |
38 |

40 | 41 |
42 | 43 |
44 |

Posts

45 |
46 | 47 |
48 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /quarkus-microblog/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.datasource.url=jdbc:h2:mem:default 2 | quarkus.datasource.driver=org.h2.Driver 3 | quarkus.datasource.username=ha 4 | quarkus.hibernate-orm.database.generation=create-drop -------------------------------------------------------------------------------- /quarkus-microblog/src/main/resources/templates/postsTemplate.html: -------------------------------------------------------------------------------- 1 | {#for post in posts} 2 |
3 | {post.author} said: 4 |

5 |

{post.content}
6 |

7 | {post.date} 8 |
9 | {/for} -------------------------------------------------------------------------------- /security-kogito/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* -------------------------------------------------------------------------------- /security-kogito/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | 19 | # OSX 20 | .DS_Store 21 | 22 | # Vim 23 | *.swp 24 | *.swo 25 | 26 | # patch 27 | *.orig 28 | *.rej 29 | 30 | # Maven 31 | target/ 32 | pom.xml.tag 33 | pom.xml.releaseBackup 34 | pom.xml.versionsBackup 35 | release.properties -------------------------------------------------------------------------------- /security-kogito/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /security-kogito/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.acme 6 | securing-kogito 7 | 1.0-SNAPSHOT 8 | 9 | UTF-8 10 | 2.22.0 11 | 0.22.0 12 | UTF-8 13 | 1.8 14 | 1.8 15 | 16 | 17 | 18 | 19 | io.quarkus 20 | quarkus-bom 21 | ${quarkus.version} 22 | pom 23 | import 24 | 25 | 26 | 27 | 28 | 29 | io.quarkus 30 | quarkus-resteasy 31 | 32 | 33 | io.quarkus 34 | quarkus-kogito 35 | 36 | 37 | io.quarkus 38 | quarkus-junit5 39 | test 40 | 41 | 42 | io.rest-assured 43 | rest-assured 44 | test 45 | 46 | 47 | io.quarkus 48 | quarkus-elytron-security 49 | 50 | 51 | 52 | 53 | 54 | io.quarkus 55 | quarkus-maven-plugin 56 | ${quarkus.version} 57 | 58 | 59 | 60 | build 61 | 62 | 63 | 64 | 65 | 66 | maven-surefire-plugin 67 | ${surefire-plugin.version} 68 | 69 | 70 | org.jboss.logmanager.LogManager 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | native 79 | 80 | 81 | native 82 | 83 | 84 | 85 | 86 | 87 | io.quarkus 88 | quarkus-maven-plugin 89 | ${quarkus.version} 90 | 91 | 92 | 93 | native-image 94 | 95 | 96 | true 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 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /security-kogito/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 docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/using-kogito-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/using-kogito-jvm 15 | # 16 | ### 17 | FROM fabric8/java-alpine-openjdk8-jre 18 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 19 | ENV AB_ENABLED=jmx_exporter 20 | COPY target/lib/* /deployments/lib/ 21 | COPY target/*-runner.jar /deployments/app.jar 22 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /security-kogito/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 docker image run: 5 | # 6 | # mvn package -Pnative -Dnative-image.docker-build=true 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/using-kogito . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/using-kogito 15 | # 16 | ### 17 | FROM registry.fedoraproject.org/fedora-minimal 18 | WORKDIR /work/ 19 | COPY target/*-runner /work/application 20 | RUN chmod 775 /work 21 | EXPOSE 8080 22 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /security-kogito/src/main/java/org/acme/kogito/SecurityFilter.java: -------------------------------------------------------------------------------- 1 | package org.acme.kogito; 2 | 3 | import java.io.IOException; 4 | import javax.ws.rs.WebApplicationException; 5 | import javax.ws.rs.container.ContainerRequestContext; 6 | import javax.ws.rs.container.ContainerRequestFilter; 7 | import javax.ws.rs.core.Context; 8 | import javax.ws.rs.core.Response; 9 | import javax.ws.rs.core.SecurityContext; 10 | import javax.ws.rs.ext.Provider; 11 | 12 | /** 13 | * SecurityFilter 14 | */ 15 | @Provider 16 | public class SecurityFilter implements ContainerRequestFilter { 17 | 18 | final String ADM_ROLE = "admin"; 19 | 20 | @Context 21 | SecurityContext securityContext; 22 | 23 | @Override 24 | public void filter(ContainerRequestContext requestContext) throws IOException { 25 | if ("POST".equals(requestContext.getMethod()) && ! securityContext.isUserInRole(ADM_ROLE)) { 26 | throw new WebApplicationException(Response.status(403).entity("User not autorized to start processes").build()); 27 | } 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /security-kogito/src/main/java/org/acme/kogito/model/Person.java: -------------------------------------------------------------------------------- 1 | package org.acme.kogito.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class Person { 6 | 7 | private String name; 8 | private int age; 9 | private boolean adult; 10 | 11 | public String getName() { 12 | return name; 13 | } 14 | 15 | public void setName(String name) { 16 | this.name = name; 17 | } 18 | 19 | public int getAge() { 20 | return age; 21 | } 22 | 23 | public void setAge(int age) { 24 | this.age = age; 25 | } 26 | 27 | public boolean isAdult() { 28 | return adult; 29 | } 30 | 31 | public void setAdult(boolean adult) { 32 | this.adult = adult; 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "Person [name=" + name + ", age=" + age + ", adult=" + adult + "]"; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /security-kogito/src/main/resources/META-INF/kmodule.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /security-kogito/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | quarkus.security.embedded.enabled=true 2 | quarkus.security.embedded.users.usr=usr 3 | quarkus.security.embedded.roles.usr=user 4 | quarkus.security.embedded.users.adm=adm 5 | quarkus.security.embedded.roles.adm=user,admin 6 | quarkus.security.embedded.auth-mechanism=BASIC -------------------------------------------------------------------------------- /security-kogito/src/main/resources/org/acme/kogito/person-rules.drl: -------------------------------------------------------------------------------- 1 | package org.acme.kogito 2 | 3 | import org.acme.kogito.model.Person; 4 | 5 | 6 | rule "Is adult" ruleflow-group "person" 7 | 8 | when 9 | $person: Person(age > 18) 10 | then 11 | modify($person) { 12 | setAdult(true) 13 | }; 14 | end 15 | -------------------------------------------------------------------------------- /security-kogito/src/test/java/org/acme/kogito/PersonProcessInGraalIT.java: -------------------------------------------------------------------------------- 1 | package org.acme.kogito; 2 | 3 | import io.quarkus.test.junit.SubstrateTest; 4 | 5 | @SubstrateTest 6 | public class PersonProcessInGraalIT extends PersonProcessTest { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /security-kogito/src/test/java/org/acme/kogito/PersonProcessTest.java: -------------------------------------------------------------------------------- 1 | package org.acme.kogito; 2 | 3 | import static io.restassured.RestAssured.given; 4 | import static org.hamcrest.core.Is.is; 5 | 6 | import javax.inject.Inject; 7 | 8 | import org.junit.jupiter.api.Test; 9 | import org.kie.kogito.Application; 10 | 11 | import io.quarkus.test.junit.QuarkusTest; 12 | import io.restassured.http.ContentType; 13 | 14 | @QuarkusTest 15 | public class PersonProcessTest { 16 | 17 | @Inject 18 | Application application; 19 | 20 | @Test 21 | public void testAdult() { 22 | given() 23 | .body("{\"person\": {\"name\":\"John Quark\", \"age\": 20}}") 24 | .contentType(ContentType.JSON) 25 | .when() 26 | .post("/persons") 27 | .then() 28 | .statusCode(200) 29 | .body("person.adult", is(true)); 30 | } 31 | 32 | @Test 33 | public void testChild() { 34 | given() 35 | .body("{\"person\": {\"name\":\"Jenny Quark\", \"age\": 15}}") 36 | .contentType(ContentType.JSON) 37 | .when() 38 | .post("/persons") 39 | .then() 40 | .statusCode(200) 41 | .body("person.adult", is(false)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /serverless-workflow-greeting-quarkus-with-monitoring/Dockerfile: -------------------------------------------------------------------------------- 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/metrics-example-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/metrics-example-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 quarkus/metrics-example-jvm 22 | # 23 | ### 24 | FROM registry.access.redhat.com/ubi8/openjdk-11-runtime:1.10 25 | 26 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' 27 | 28 | # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. 29 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 30 | 31 | # We make four distinct layers so if there are application changes the library layers can be re-used 32 | COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ 33 | COPY --chown=185 target/quarkus-app/*.jar /deployments/ 34 | COPY --chown=185 target/quarkus-app/app/ /deployments/app/ 35 | COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ 36 | 37 | EXPOSE 8080 38 | USER 185 39 | 40 | ENTRYPOINT [ "java", "-jar", "/deployments/quarkus-run.jar" ] 41 | 42 | -------------------------------------------------------------------------------- /serverless-workflow-greeting-quarkus-with-monitoring/operator/serverless-workflow-greeting-quarkus.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: app.kiegroup.org/v1beta1 2 | kind: KogitoBuild 3 | metadata: 4 | name: serverless-workflow-greeting-quarkus 5 | spec: 6 | type: RemoteSource 7 | #env: 8 | # env can be used to set variables during build 9 | #- name: MY_CUSTOM_ENV 10 | # value: "my value" 11 | gitSource: 12 | contextDir: serverless-workflow-greeting-quarkus 13 | uri: 'https://github.com/kiegroup/kogito-examples' 14 | # set your maven nexus repository to speed up the build time 15 | #mavenMirrorURL: 16 | --- 17 | apiVersion: app.kiegroup.org/v1beta1 18 | kind: KogitoRuntime 19 | metadata: 20 | name: serverless-workflow-greeting-quarkus -------------------------------------------------------------------------------- /serverless-workflow-greeting-quarkus-with-monitoring/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.kie.kogito.examples 6 | 7 | serverless-workflow-greeting-quarkus 8 | Kogito Example :: Serverless Workflow Greeting :: Quarkus 9 | Kogito Serverless Workflow Example - Quarkus 10 | 1.0 11 | 12 | 11 13 | 11 14 | 2.6.0.Final 15 | quarkus-bom 16 | io.quarkus 17 | 2.6.0.Final 18 | 1.15.0.Final 19 | 20 | 21 | 22 | 23 | ${quarkus.platform.group-id} 24 | ${quarkus.platform.artifact-id} 25 | ${quarkus.platform.version} 26 | pom 27 | import 28 | 29 | 30 | 31 | 32 | 33 | org.kie.kogito 34 | kogito-quarkus-serverless-workflow 35 | ${kogito.version} 36 | 37 | 38 | org.kie.kogito 39 | kogito-addons-quarkus-monitoring-prometheus 40 | ${kogito.version} 41 | 42 | 43 | io.quarkus 44 | quarkus-resteasy 45 | 46 | 47 | io.quarkus 48 | quarkus-resteasy-jackson 49 | 50 | 51 | io.quarkus 52 | quarkus-jsonp 53 | 54 | 55 | io.quarkus 56 | quarkus-smallrye-openapi 57 | 58 | 59 | io.quarkus 60 | quarkus-junit5 61 | test 62 | 63 | 64 | io.rest-assured 65 | rest-assured 66 | test 67 | 68 | 69 | io.quarkus 70 | quarkus-smallrye-health 71 | 72 | 73 | 74 | ${project.artifactId} 75 | 76 | 77 | io.quarkus 78 | quarkus-maven-plugin 79 | ${quarkus-plugin.version} 80 | 81 | 82 | 83 | build 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | native 93 | 94 | **/*IT.java 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /serverless-workflow-greeting-quarkus-with-monitoring/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Packaging 2 | # quarkus.package.type=fast-jar 3 | #quarkus.infinispan-client.server-list=localhost:11222 4 | #quarkus.infinispan-client.auth-username=admin 5 | #quarkus.infinispan-client.auth-password=changeme 6 | #enable.resource.infinispan=true 7 | -------------------------------------------------------------------------------- /serverless-workflow-greeting-quarkus-with-monitoring/src/main/resources/jsongreet.sw.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "jsongreet", 3 | "version": "1.0", 4 | "name": "Greeting workflow", 5 | "expressionLang": "jsonpath", 6 | "description": "JSON based greeting workflow", 7 | "start": "ChooseOnLanguage", 8 | "functions": [ 9 | { 10 | "name": "greetFunction", 11 | "metadata": { 12 | "type": "sysout" 13 | } 14 | } 15 | ], 16 | "states": [ 17 | { 18 | "name": "ChooseOnLanguage", 19 | "type": "switch", 20 | "dataConditions": [ 21 | { 22 | "condition": "{{ $.[?(@.language == 'English')] }}", 23 | "transition": "GreetInEnglish" 24 | }, 25 | { 26 | "condition": "{{ $.[?(@.language == 'Spanish')] }}", 27 | "transition": "GreetInSpanish" 28 | } 29 | ], 30 | "default": { 31 | "transition": "GreetInEnglish" 32 | } 33 | }, 34 | { 35 | "name": "GreetInEnglish", 36 | "type": "inject", 37 | "data": { 38 | "greeting": "Hello from JSON Workflow, " 39 | }, 40 | "transition": "GreetPerson" 41 | }, 42 | { 43 | "name": "GreetInSpanish", 44 | "type": "inject", 45 | "data": { 46 | "greeting": "Saludos desde JSON Workflow, " 47 | }, 48 | "transition": "GreetPerson" 49 | }, 50 | { 51 | "name": "GreetPerson", 52 | "type": "operation", 53 | "actions": [ 54 | { 55 | "name": "greetAction", 56 | "functionRef": { 57 | "refName": "greetFunction", 58 | "arguments": { 59 | "message": "$.greeting $.name" 60 | } 61 | } 62 | } 63 | ], 64 | "end": { 65 | "terminate": "true" 66 | } 67 | } 68 | ] 69 | } -------------------------------------------------------------------------------- /serverless-workflow-greeting-quarkus-with-monitoring/src/main/resources/yamlgreet.sw.yml: -------------------------------------------------------------------------------- 1 | id: yamlgreet 2 | version: '1.0' 3 | name: Greeting workflow 4 | description: YAML based greeting workflow 5 | expressionLang: jsonpath 6 | start: ChooseOnLanguage 7 | functions: 8 | - name: greetFunction 9 | metadata: 10 | type: sysout 11 | states: 12 | - name: ChooseOnLanguage 13 | type: switch 14 | dataConditions: 15 | - condition: "{{ $.[?(@.language == 'English')] }}" 16 | transition: GreetInEnglish 17 | - condition: "{{ $.[?(@.language == 'Spanish')] }}" 18 | transition: GreetInSpanish 19 | default: 20 | transition: GreetInEnglish 21 | - name: GreetInEnglish 22 | type: inject 23 | data: 24 | greeting: 'Hello from YAML Workflow, ' 25 | transition: GreetPerson 26 | - name: GreetInSpanish 27 | type: inject 28 | data: 29 | greeting: 'Saludos desde YAML Workflow, ' 30 | transition: GreetPerson 31 | - name: GreetPerson 32 | type: operation 33 | actions: 34 | - name: greetAction 35 | functionRef: 36 | refName: greetFunction 37 | arguments: 38 | message: "$.greeting $.name" 39 | end: 40 | terminate: true 41 | -------------------------------------------------------------------------------- /serverless-workflow-greeting-quarkus-with-monitoring/src/test/java/org/kie/kogito/examples/GreetRestIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Red Hat, Inc. and/or its affiliates. 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 | * http://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 | package org.kie.kogito.examples; 17 | 18 | import org.junit.jupiter.api.Test; 19 | 20 | import io.quarkus.test.junit.QuarkusIntegrationTest; 21 | import io.restassured.http.ContentType; 22 | 23 | import static io.restassured.RestAssured.given; 24 | import static org.hamcrest.CoreMatchers.containsString; 25 | 26 | @QuarkusIntegrationTest 27 | class GreetRestIT { 28 | 29 | @Test 30 | void testGreetRest() { 31 | given() 32 | .contentType(ContentType.JSON) 33 | .accept(ContentType.JSON) 34 | .body("{\"workflowdata\" : {\"name\" : \"John\", \"language\":\"English\"}}").when() 35 | .post("/jsongreet") 36 | .then() 37 | .statusCode(201) 38 | .body("workflowdata.greeting", containsString("Hello")); 39 | 40 | given() 41 | .contentType(ContentType.JSON) 42 | .accept(ContentType.JSON) 43 | .body("{\"workflowdata\" : {\"name\" : \"Javierito\", \"language\":\"Spanish\"}}").when() 44 | .post("/jsongreet") 45 | .then() 46 | .statusCode(201) 47 | .body("workflowdata.greeting", containsString("Saludos")); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /static-resources/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* -------------------------------------------------------------------------------- /static-resources/.gitignore: -------------------------------------------------------------------------------- 1 | # Eclipse 2 | .project 3 | .classpath 4 | .settings/ 5 | bin/ 6 | 7 | # IntelliJ 8 | .idea 9 | *.ipr 10 | *.iml 11 | *.iws 12 | 13 | # NetBeans 14 | nb-configuration.xml 15 | 16 | # Visual Studio Code 17 | .vscode 18 | .factorypath 19 | 20 | # OSX 21 | .DS_Store 22 | 23 | # Vim 24 | *.swp 25 | *.swo 26 | 27 | # patch 28 | *.orig 29 | *.rej 30 | 31 | # Maven 32 | target/ 33 | pom.xml.tag 34 | pom.xml.releaseBackup 35 | pom.xml.versionsBackup 36 | release.properties -------------------------------------------------------------------------------- /static-resources/.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 | -------------------------------------------------------------------------------- /static-resources/README.md: -------------------------------------------------------------------------------- 1 | # static-resources 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 | ``` 11 | ./mvnw quarkus:dev 12 | ``` 13 | 14 | ## Packaging and running the application 15 | 16 | The application can be packaged using `./mvnw package`. 17 | It produces the `static-resources-1.0.0-SNAPSHOT-runner.jar` file in the `/target` directory. 18 | Be aware that it’s not an _über-jar_ as the dependencies are copied into the `target/lib` directory. 19 | 20 | The application is now runnable using `java -jar target/static-resources-1.0.0-SNAPSHOT-runner.jar`. 21 | 22 | ## Creating a native executable 23 | 24 | You can create a native executable using: `./mvnw package -Pnative`. 25 | 26 | Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./mvnw package -Pnative -Dquarkus.native.container-build=true`. 27 | 28 | You can then execute your native executable with: `./target/static-resources-1.0.0-SNAPSHOT-runner` 29 | 30 | If you want to learn more about building native executables, please consult https://quarkus.io/guides/building-native-image. -------------------------------------------------------------------------------- /static-resources/components/mycomp/index.html: -------------------------------------------------------------------------------- 1 |

Hello World!

2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /static-resources/components/mycomp/index.js: -------------------------------------------------------------------------------- 1 | function sayHello() { 2 | alert("Hello!"); 3 | } 4 | -------------------------------------------------------------------------------- /static-resources/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | org.fxapps 6 | static-resources 7 | 1.0.0-SNAPSHOT 8 | 9 | 3.8.1 10 | true 11 | 11 12 | 11 13 | UTF-8 14 | UTF-8 15 | 1.5.2.Final 16 | quarkus-universe-bom 17 | io.quarkus 18 | 1.5.2.Final 19 | 2.22.1 20 | 21 | 22 | 23 | 24 | ${quarkus.platform.group-id} 25 | ${quarkus.platform.artifact-id} 26 | ${quarkus.platform.version} 27 | pom 28 | import 29 | 30 | 31 | 32 | 33 | 34 | io.quarkus 35 | quarkus-resteasy 36 | 37 | 38 | io.quarkus 39 | quarkus-junit5 40 | test 41 | 42 | 43 | io.rest-assured 44 | rest-assured 45 | test 46 | 47 | 48 | 49 | 50 | 51 | io.quarkus 52 | quarkus-maven-plugin 53 | ${quarkus-plugin.version} 54 | 55 | 56 | 57 | build 58 | 59 | 60 | 61 | 62 | 63 | maven-compiler-plugin 64 | ${compiler-plugin.version} 65 | 66 | 67 | maven-surefire-plugin 68 | ${surefire-plugin.version} 69 | 70 | 71 | org.jboss.logmanager.LogManager 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | native 80 | 81 | 82 | native 83 | 84 | 85 | 86 | 87 | 88 | maven-failsafe-plugin 89 | ${surefire-plugin.version} 90 | 91 | 92 | 93 | integration-test 94 | verify 95 | 96 | 97 | 98 | ${project.build.directory}/${project.build.finalName}-runner 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | native 108 | 109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /static-resources/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 docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/static-resources-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/static-resources-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 5050 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/static-resources-jvm 22 | # 23 | ### 24 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1 25 | 26 | ARG JAVA_PACKAGE=java-11-openjdk-headless 27 | ARG RUN_JAVA_VERSION=1.3.8 28 | 29 | ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' 30 | 31 | # Install java and the run-java script 32 | # Also set up permissions for user `1001` 33 | RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ 34 | && microdnf update \ 35 | && microdnf clean all \ 36 | && mkdir /deployments \ 37 | && chown 1001 /deployments \ 38 | && chmod "g+rwX" /deployments \ 39 | && chown 1001:root /deployments \ 40 | && 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 \ 41 | && chown 1001 /deployments/run-java.sh \ 42 | && chmod 540 /deployments/run-java.sh \ 43 | && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security 44 | 45 | # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. 46 | ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" 47 | 48 | COPY target/lib/* /deployments/lib/ 49 | COPY target/*-runner.jar /deployments/app.jar 50 | 51 | EXPOSE 8080 52 | USER 1001 53 | 54 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /static-resources/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 docker image run: 5 | # 6 | # mvn package -Pnative -Dquarkus.native.container-build=true 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/static-resources . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/static-resources 15 | # 16 | ### 17 | FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1 18 | WORKDIR /work/ 19 | COPY --chown=1001:root target/*-runner /work/application 20 | 21 | EXPOSE 8080 22 | USER 1001 23 | 24 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /static-resources/src/main/java/org/fxapps/ComponentStaticFileService.java: -------------------------------------------------------------------------------- 1 | package org.fxapps; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.FileNotFoundException; 5 | import java.io.InputStream; 6 | import java.nio.file.Path; 7 | import java.nio.file.Paths; 8 | 9 | import javax.enterprise.context.ApplicationScoped; 10 | import javax.inject.Inject; 11 | 12 | import org.eclipse.microprofile.config.inject.ConfigProperty; 13 | 14 | @ApplicationScoped 15 | public class ComponentStaticFileService { 16 | 17 | @Inject 18 | @ConfigProperty(name = "components.dir", defaultValue = "/tmp/components") 19 | String baseDir; 20 | 21 | public InputStream getComponentFile(String componentId, String fileName) throws FileNotFoundException { 22 | Path path = Paths.get(baseDir, componentId, fileName); 23 | return new FileInputStream(path.toFile()); 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /static-resources/src/main/java/org/fxapps/ComponentStaticResourcesResource.java: -------------------------------------------------------------------------------- 1 | package org.fxapps; 2 | 3 | import java.io.FileNotFoundException; 4 | import java.io.InputStream; 5 | 6 | import javax.inject.Inject; 7 | import javax.ws.rs.GET; 8 | import javax.ws.rs.Path; 9 | import javax.ws.rs.PathParam; 10 | import javax.ws.rs.core.Response; 11 | import javax.ws.rs.core.Response.Status; 12 | 13 | @Path("/dashbuilder-external-server/") 14 | public class ComponentStaticResourcesResource { 15 | 16 | @Inject 17 | ComponentStaticFileService componentStaticFileService; 18 | 19 | @GET 20 | @Path("component/{componentId}/{fileName: .*}") 21 | public Response hello(@PathParam("componentId") String componentId, 22 | @PathParam("fileName") String fileName) { 23 | 24 | // TODO: Add cache to never expires in prod 25 | try { 26 | InputStream fileStream = componentStaticFileService.getComponentFile(componentId, 27 | fileName); 28 | return Response.ok(fileStream).build(); 29 | } catch (FileNotFoundException e) { 30 | return Response.status(Status.NOT_FOUND).build(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /static-resources/src/main/resources/META-INF/resources/index.html: -------------------------------------------------------------------------------- 1 |

Resources for Component mycomp

2 |
3 | 4 | -------------------------------------------------------------------------------- /static-resources/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Configuration file 2 | # key = value -------------------------------------------------------------------------------- /swf-greeting-persistence-monitoring/README.md: -------------------------------------------------------------------------------- 1 | Kogito Serverless Workflow but requires Kafka and Infinispan 2 | -------------------------------------------------------------------------------- /swf-greeting-persistence-monitoring/operator/swf-greeting-persistence-monitoring.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: app.kiegroup.org/v1beta1 2 | kind: KogitoBuild 3 | metadata: 4 | name: swf-greeting-persistence-monitoring 5 | spec: 6 | type: RemoteSource 7 | #env: 8 | # env can be used to set variables during build 9 | #- name: MY_CUSTOM_ENV 10 | # value: "my value" 11 | gitSource: 12 | contextDir: swf-greeting-persistence-monitoring 13 | uri: 'https://github.com/jesuino/quarkus-examples' 14 | # set your maven nexus repository to speed up the build time 15 | #mavenMirrorURL: 16 | --- 17 | apiVersion: app.kiegroup.org/v1beta1 18 | kind: KogitoRuntime 19 | metadata: 20 | name: swf-greeting-persistence-monitoring 21 | infra: 22 | - kogito-infinispan-infra 23 | - kogito-kafka-infra 24 | 25 | -------------------------------------------------------------------------------- /swf-greeting-persistence-monitoring/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | swf-greeting-persistence-monitoring 6 | org.kie.kogito.examples 7 | 1.0 8 | 9 | 2.7.0.Final 10 | quarkus-bom 11 | io.quarkus 12 | 2.7.0.Final 13 | 1.17.0.Final 14 | 11 15 | 11 16 | 11 17 | 18 | 19 | 20 | 21 | org.kie.kogito 22 | kogito-bom 23 | ${kogito.version} 24 | pom 25 | import 26 | 27 | 28 | ${quarkus.platform.group-id} 29 | ${quarkus.platform.artifact-id} 30 | ${quarkus.platform.version} 31 | pom 32 | import 33 | 34 | 35 | 36 | 37 | 38 | org.kie.kogito 39 | kogito-quarkus-serverless-workflow 40 | 41 | 42 | io.quarkus 43 | quarkus-resteasy 44 | 45 | 46 | io.quarkus 47 | quarkus-resteasy-jackson 48 | 49 | 50 | io.quarkus 51 | quarkus-jsonp 52 | 53 | 54 | io.quarkus 55 | quarkus-smallrye-reactive-messaging-kafka 56 | 57 | 58 | org.kie.kogito 59 | kogito-addons-quarkus-events-process 60 | 61 | 62 | io.quarkus 63 | quarkus-smallrye-openapi 64 | 65 | 66 | org.kie.kogito 67 | kogito-addons-quarkus-monitoring-prometheus 68 | 69 | 70 | io.quarkus 71 | quarkus-junit5 72 | test 73 | 74 | 75 | io.rest-assured 76 | rest-assured 77 | test 78 | 79 | 80 | io.quarkus 81 | quarkus-smallrye-health 82 | 83 | 84 | 85 | ${project.artifactId} 86 | 87 | 88 | io.quarkus 89 | quarkus-maven-plugin 90 | ${quarkus-plugin.version} 91 | 92 | 93 | 94 | build 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | native 104 | 105 | **/*IT.java 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /swf-greeting-persistence-monitoring/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Packaging 2 | # quarkus.package.type=fast-jar 3 | quarkus.http.cors=true 4 | 5 | kafka.bootstrap.servers=localhost:9092 6 | 7 | mp.messaging.outgoing.kogito-processinstances-events.connector=smallrye-kafka 8 | mp.messaging.outgoing.kogito-processinstances-events.topic=kogito-processinstances-events 9 | mp.messaging.outgoing.kogito-processinstances-events.value.serializer=org.apache.kafka.common.serialization.StringSerializer 10 | 11 | mp.messaging.outgoing.kogito-usertaskinstances-events.connector=smallrye-kafka 12 | mp.messaging.outgoing.kogito-usertaskinstances-events.topic=kogito-usertaskinstances-events 13 | mp.messaging.outgoing.kogito-usertaskinstances-events.value.serializer=org.apache.kafka.common.serialization.StringSerializer 14 | 15 | mp.messaging.outgoing.kogito-variables-events.connector=smallrye-kafka 16 | mp.messaging.outgoing.kogito-variables-events.topic=kogito-variables-events 17 | mp.messaging.outgoing.kogito-variables-events.value.serializer=org.apache.kafka.common.serialization.StringSerializer 18 | 19 | kogito.persistence.type=infinispan 20 | quarkus.infinispan-client.server-list=localhost:11222 21 | quarkus.infinispan-client.use-auth=false 22 | quarkus.kogito.devservices.enabled=false 23 | ~ 24 | -------------------------------------------------------------------------------- /swf-greeting-persistence-monitoring/src/main/resources/jsongreet.sw.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "jsongreet", 3 | "version": "1.0", 4 | "name": "Greeting workflow", 5 | "expressionLang": "jsonpath", 6 | "description": "JSON based greeting workflow", 7 | "start": "ChooseOnLanguage", 8 | "functions": [ 9 | { 10 | "name": "greetFunction", 11 | "type": "custom", 12 | "operation": "sysout" 13 | } 14 | ], 15 | "states": [ 16 | { 17 | "name": "ChooseOnLanguage", 18 | "type": "switch", 19 | "dataConditions": [ 20 | { 21 | "condition": "{{ $.[?(@.language == 'English')] }}", 22 | "transition": "GreetInEnglish" 23 | }, 24 | { 25 | "condition": "{{ $.[?(@.language == 'Spanish')] }}", 26 | "transition": "GreetInSpanish" 27 | } 28 | ], 29 | "defaultCondition": { 30 | "transition": "GreetInEnglish" 31 | } 32 | }, 33 | { 34 | "name": "GreetInEnglish", 35 | "type": "inject", 36 | "data": { 37 | "greeting": "Hello from JSON Workflow, " 38 | }, 39 | "transition": "GreetPerson" 40 | }, 41 | { 42 | "name": "GreetInSpanish", 43 | "type": "inject", 44 | "data": { 45 | "greeting": "Saludos desde JSON Workflow, " 46 | }, 47 | "transition": "GreetPerson" 48 | }, 49 | { 50 | "name": "GreetPerson", 51 | "type": "operation", 52 | "actions": [ 53 | { 54 | "name": "greetAction", 55 | "functionRef": { 56 | "refName": "greetFunction", 57 | "arguments": { 58 | "message": "$.greeting $.name" 59 | } 60 | } 61 | } 62 | ], 63 | "end": { 64 | "terminate": "true" 65 | } 66 | } 67 | ] 68 | } -------------------------------------------------------------------------------- /swf-greeting-persistence-monitoring/src/main/resources/yamlgreet.sw.yml: -------------------------------------------------------------------------------- 1 | id: yamlgreet 2 | version: '1.0' 3 | name: Greeting workflow 4 | description: YAML based greeting workflow 5 | expressionLang: jsonpath 6 | start: ChooseOnLanguage 7 | functions: 8 | - name: greetFunction 9 | type: custom 10 | operation: sysout 11 | states: 12 | - name: ChooseOnLanguage 13 | type: switch 14 | dataConditions: 15 | - condition: "{{ $.[?(@.language == 'English')] }}" 16 | transition: GreetInEnglish 17 | - condition: "{{ $.[?(@.language == 'Spanish')] }}" 18 | transition: GreetInSpanish 19 | defaultCondition: 20 | transition: GreetInEnglish 21 | - name: GreetInEnglish 22 | type: inject 23 | data: 24 | greeting: 'Hello from YAML Workflow, ' 25 | transition: GreetPerson 26 | - name: GreetInSpanish 27 | type: inject 28 | data: 29 | greeting: 'Saludos desde YAML Workflow, ' 30 | transition: GreetPerson 31 | - name: GreetPerson 32 | type: operation 33 | actions: 34 | - name: greetAction 35 | functionRef: 36 | refName: greetFunction 37 | arguments: 38 | message: "$.greeting $.name" 39 | end: 40 | terminate: true 41 | -------------------------------------------------------------------------------- /test-javacpp/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !target/*-runner 3 | !target/*-runner.jar 4 | !target/lib/* -------------------------------------------------------------------------------- /test-javacpp/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.jar 15 | *.war 16 | *.nar 17 | *.ear 18 | *.zip 19 | *.tar.gz 20 | *.rar 21 | 22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 23 | hs_err_pid* 24 | 25 | /target/* 26 | 27 | .settings/* 28 | -------------------------------------------------------------------------------- /test-javacpp/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 4.0.0 7 | org.fxapps.cpp 8 | test-javacpp 9 | 1.0-SNAPSHOT 10 | 11 | 2.22.0 12 | 0.12.0 13 | 1.8 14 | UTF-8 15 | 1.8 16 | 17 | 18 | 19 | 20 | io.quarkus 21 | quarkus-bom 22 | ${quarkus.version} 23 | pom 24 | import 25 | 26 | 27 | 28 | 29 | 30 | io.quarkus 31 | quarkus-resteasy 32 | 33 | 34 | org.bytedeco 35 | javacpp 36 | 1.4.4 37 | 38 | 39 | 40 | 41 | 42 | io.quarkus 43 | quarkus-maven-plugin 44 | ${quarkus.version} 45 | 46 | 47 | 48 | build 49 | 50 | 51 | 52 | 53 | 54 | maven-surefire-plugin 55 | ${surefire-plugin.version} 56 | 57 | 58 | org.jboss.logmanager.LogManager 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | native 67 | 68 | 69 | native 70 | 71 | 72 | 73 | 74 | 75 | io.quarkus 76 | quarkus-maven-plugin 77 | ${quarkus.version} 78 | 79 | 80 | 81 | native-image 82 | 83 | 84 | true 85 | 86 | 87 | 88 | 89 | 90 | maven-failsafe-plugin 91 | ${surefire-plugin.version} 92 | 93 | 94 | 95 | integration-test 96 | verify 97 | 98 | 99 | 100 | ${project.build.directory}/${project.build.finalName}-runner 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /test-javacpp/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 docker image run: 5 | # 6 | # mvn package 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/test-javacpp-jvm . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/test-javacpp-jvm 15 | # 16 | ### 17 | FROM fabric8/java-jboss-openjdk8-jdk 18 | ENV JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0 19 | COPY target/lib/* /deployments/lib/ 20 | COPY target/*-runner.jar /deployments/app.jar 21 | ENTRYPOINT [ "/deployments/run-java.sh" ] -------------------------------------------------------------------------------- /test-javacpp/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 docker image run: 5 | # 6 | # mvn package -Pnative -Dnative-image.docker-build=true 7 | # 8 | # Then, build the image with: 9 | # 10 | # docker build -f src/main/docker/Dockerfile.native -t quarkus/test-javacpp . 11 | # 12 | # Then run the container using: 13 | # 14 | # docker run -i --rm -p 8080:8080 quarkus/test-javacpp 15 | # 16 | ### 17 | FROM registry.fedoraproject.org/fedora-minimal 18 | WORKDIR /work/ 19 | COPY target/*-runner /work/application 20 | RUN chmod 775 /work 21 | EXPOSE 8080 22 | CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] -------------------------------------------------------------------------------- /test-javacpp/src/main/java/org/fxapps/cpp/lib/NativeLibrary.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace NativeLibrary { 4 | class NativeClass { 5 | public: 6 | const std::string& get_property() { return property; } 7 | void set_property(const std::string& property) { this->property = property; } 8 | std::string property; 9 | }; 10 | } -------------------------------------------------------------------------------- /test-javacpp/src/main/java/org/fxapps/cpp/lib/NativeLibrary.java: -------------------------------------------------------------------------------- 1 | package org.fxapps.cpp.lib; 2 | 3 | import org.bytedeco.javacpp.*; 4 | import org.bytedeco.javacpp.annotation.*; 5 | 6 | @Platform(include="NativeLibrary.h") 7 | @Namespace("NativeLibrary") 8 | public class NativeLibrary { 9 | public static class NativeClass extends Pointer { 10 | static { Loader.load(); } 11 | public NativeClass() { allocate(); } 12 | private native void allocate(); 13 | 14 | // to call the getter and setter functions 15 | public native @StdString String get_property(); public native void set_property(String property); 16 | 17 | // to access the member variable directly 18 | public native @StdString String property(); public native void property(String property); 19 | } 20 | } -------------------------------------------------------------------------------- /test-javacpp/src/main/java/org/fxapps/cpp/resource/TestResource.java: -------------------------------------------------------------------------------- 1 | package org.fxapps.cpp.resource; 2 | 3 | import javax.ws.rs.GET; 4 | import javax.ws.rs.Path; 5 | import javax.ws.rs.Produces; 6 | import javax.ws.rs.core.MediaType; 7 | 8 | import org.bytedeco.javacpp.IntPointer; 9 | import org.bytedeco.javacpp.Loader;; 10 | 11 | @Path("/test") 12 | public class TestResource { 13 | 14 | @GET 15 | @Produces(MediaType.TEXT_PLAIN) 16 | public String hello() { 17 | Loader.load(); 18 | IntPointer intPointer = new IntPointer(123); 19 | int v = intPointer.get(); 20 | intPointer.close(); 21 | return "Native Value is " + v; 22 | 23 | } 24 | } -------------------------------------------------------------------------------- /test-javacpp/src/main/resources/META-INF/resources/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | test-javacpp - 1.0-SNAPSHOT 6 | 99 | 100 | 101 | 102 | 105 | 106 |
107 |
108 |

Congratulations, you have created a new Quarkus application.

109 | 110 |

Why do you see this?

111 | 112 |

This page is served by Quarkus. The source is in 113 | src/main/resources/META-INF/resources/index.html.

114 | 115 |

What can I do from here?

116 | 117 |

If not already done, run the application in dev mode using: mvn compile quarkus:dev. 118 |

119 |
    120 |
  • Add REST resources, Servlets, functions and other services in src/main/java.
  • 121 |
  • Your static assets are located in src/main/resources/META-INF/resources.
  • 122 |
  • Configure your application in src/main/resources/application.properties. 123 |
  • 124 |
125 | 126 |

How do I get rid of this page?

127 |

Just delete the src/main/resources/META-INF/resources/index.html file.

128 |
129 |
130 |
131 |

Application

132 |
    133 |
  • GroupId: org.fxapps.cpp
  • 134 |
  • ArtifactId: test-javacpp
  • 135 |
  • Version: 1.0-SNAPSHOT
  • 136 |
  • Quarkus Version: 0.12.0
  • 137 |
138 |
139 |
140 |

Next steps

141 | 146 |
147 |
148 |
149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /test-javacpp/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Configuration file 2 | # key = value 3 | --------------------------------------------------------------------------------