From 96f1fd7619daaace03bf665d70fb468c4dc50f68 Mon Sep 17 00:00:00 2001 From: Damian Pierzchalski Date: Mon, 3 Dec 2018 23:34:57 +0100 Subject: [PATCH] initial commit --- .gitignore | 50 ++++++++++ module-ear/pom.xml | 67 +++++++++++++ module-ejb/pom.xml | 21 +++++ .../java/pl/myboardgames/ExampleService.java | 12 +++ module-web/nb-configuration.xml | 18 ++++ module-web/pom.xml | 28 ++++++ .../pl/myboardgames/BoardGameController.java | 32 +++++++ .../java/pl/myboardgames/BoardGameEntity.java | 61 ++++++++++++ .../java/pl/myboardgames/JaxRsActivator.java | 18 ++++ .../main/java/pl/myboardgames/UserEntity.java | 14 +++ pom.xml | 94 +++++++++++++++++++ 11 files changed, 415 insertions(+) create mode 100644 .gitignore create mode 100644 module-ear/pom.xml create mode 100644 module-ejb/pom.xml create mode 100644 module-ejb/src/main/java/pl/myboardgames/ExampleService.java create mode 100644 module-web/nb-configuration.xml create mode 100644 module-web/pom.xml create mode 100644 module-web/src/main/java/pl/myboardgames/BoardGameController.java create mode 100644 module-web/src/main/java/pl/myboardgames/BoardGameEntity.java create mode 100644 module-web/src/main/java/pl/myboardgames/JaxRsActivator.java create mode 100644 module-web/src/main/java/pl/myboardgames/UserEntity.java create mode 100644 pom.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e2927d --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +.classpath +.project +.settings +~* +*.idea +*.iml +MANIFEST.MF + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + +# Logs and databases # +###################### +*.log +*.sqlite + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Directory # +############# +bin/ +out/ +target/ +.vscode/launch.json diff --git a/module-ear/pom.xml b/module-ear/pom.xml new file mode 100644 index 0000000..bd370fc --- /dev/null +++ b/module-ear/pom.xml @@ -0,0 +1,67 @@ + + + 4.0.0 + + + app + pl.myboardgames + 1.0-SNAPSHOT + + + module-ear + ear + + + + pl.myboardgames + module-web + war + + + pl.myboardgames + module-ejb + ejb + + + + + + + org.wildfly.plugins + wildfly-maven-plugin + 2.0.0.Final + + 127.0.0.1 + 9990 + admin + admin + myboardgames.ear + + + + + undeploy + clean + + undeploy + + + true + + + + + + deploy + install + + deploy + + + + + + + + diff --git a/module-ejb/pom.xml b/module-ejb/pom.xml new file mode 100644 index 0000000..712c355 --- /dev/null +++ b/module-ejb/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + + app + pl.myboardgames + 1.0-SNAPSHOT + + + module-ejb + ejb + + + + javax + javaee-api + + + diff --git a/module-ejb/src/main/java/pl/myboardgames/ExampleService.java b/module-ejb/src/main/java/pl/myboardgames/ExampleService.java new file mode 100644 index 0000000..4bc6876 --- /dev/null +++ b/module-ejb/src/main/java/pl/myboardgames/ExampleService.java @@ -0,0 +1,12 @@ +package pl.myboardgames; + +import javax.ejb.Stateless; + +@Stateless +public class ExampleService { + + public String whoAmI() { + return "i'm ExampleService"; + } + +} diff --git a/module-web/nb-configuration.xml b/module-web/nb-configuration.xml new file mode 100644 index 0000000..4da1f6c --- /dev/null +++ b/module-web/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + ide + + diff --git a/module-web/pom.xml b/module-web/pom.xml new file mode 100644 index 0000000..2269cdb --- /dev/null +++ b/module-web/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + + + app + pl.myboardgames + 1.0-SNAPSHOT + + module-web + war + module-web + + + + pl.myboardgames + module-ejb + ejb + provided + + + + javax + javaee-api + + + diff --git a/module-web/src/main/java/pl/myboardgames/BoardGameController.java b/module-web/src/main/java/pl/myboardgames/BoardGameController.java new file mode 100644 index 0000000..c6a2f8a --- /dev/null +++ b/module-web/src/main/java/pl/myboardgames/BoardGameController.java @@ -0,0 +1,32 @@ +package pl.myboardgames; + +import java.util.ArrayList; +import java.util.List; +import javax.enterprise.context.RequestScoped; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; + +@Path("/board") +@RequestScoped +public class BoardGameController { + +// @EJB +// ExampleService exampleService; + + @GET + @Produces("application/json; charset=UTF-8") + public Response getAllBoardGames() { + + BoardGameEntity board1 = new BoardGameEntity("Dominion"); + BoardGameEntity board2 = new BoardGameEntity("Agricola"); + + List ret = new ArrayList<>(); + + ret.add(board1); + ret.add(board2); + + return Response.status(200).entity(ret).build(); + } +} diff --git a/module-web/src/main/java/pl/myboardgames/BoardGameEntity.java b/module-web/src/main/java/pl/myboardgames/BoardGameEntity.java new file mode 100644 index 0000000..d8ae55e --- /dev/null +++ b/module-web/src/main/java/pl/myboardgames/BoardGameEntity.java @@ -0,0 +1,61 @@ +package pl.myboardgames; + +import java.util.List; + +public class BoardGameEntity { + private String name; + private Integer minPlayers; + private Integer maxPlayers; + private Integer playTime; + private String location; + private List categories; + + public BoardGameEntity(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public Integer getMinPlayers() { + return minPlayers; + } + + public Integer getMaxPlayers() { + return maxPlayers; + } + + public Integer getPlayTime() { + return playTime; + } + + public String getLocation() { + return location; + } + + public List getCategories() { + return categories; + } + + public void setMinPlayers(Integer minPlayers) { + this.minPlayers = minPlayers; + } + + public void setMaxPlayers(Integer maxPlayers) { + this.maxPlayers = maxPlayers; + } + + public void setPlayTime(Integer playTime) { + this.playTime = playTime; + } + + public void setLocation(String location) { + this.location = location; + } + + + + + +} diff --git a/module-web/src/main/java/pl/myboardgames/JaxRsActivator.java b/module-web/src/main/java/pl/myboardgames/JaxRsActivator.java new file mode 100644 index 0000000..5004261 --- /dev/null +++ b/module-web/src/main/java/pl/myboardgames/JaxRsActivator.java @@ -0,0 +1,18 @@ +package pl.myboardgames; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +/** + * A class extending {@link Application} and annotated with @ApplicationPath is the Java EE 6 + * "no XML" approach to activating JAX-RS. + * + *

+ * Resources are served relative to the servlet path specified in the {@link ApplicationPath} + * annotation. + *

+ */ +@ApplicationPath("/api/v1") +public class JaxRsActivator extends Application { + /* class body intentionally left blank */ +} diff --git a/module-web/src/main/java/pl/myboardgames/UserEntity.java b/module-web/src/main/java/pl/myboardgames/UserEntity.java new file mode 100644 index 0000000..700fa19 --- /dev/null +++ b/module-web/src/main/java/pl/myboardgames/UserEntity.java @@ -0,0 +1,14 @@ +package pl.myboardgames; + +import java.util.List; + +public class UserEntity { + private String name; + private List boardgames; + + public void addBoard(BoardGameEntity board) { + this.boardgames.add(board); + } +} + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..ec3c1f3 --- /dev/null +++ b/pom.xml @@ -0,0 +1,94 @@ + + + 4.0.0 + pl.myboardgames + app + 1.0-SNAPSHOT + pom + + + module-ejb + module-web + module-ear + + + + UTF-8 + + + + + + pl.myboardgames + module-ejb + 1.0-SNAPSHOT + ejb + + + + pl.myboardgames + module-web + 1.0-SNAPSHOT + war + compile + + + + javax + javaee-api + 7.0 + provided + + + + + + + + + + maven-compiler-plugin + 3.3 + + 1.8 + 1.8 + + + + + maven-ejb-plugin + 3.0.1 + + 3.1 + + + + + maven-war-plugin + 3.2.2 + + false + + + + + org.apache.maven.plugins + maven-ear-plugin + 3.0.1 + + 7 + + + + + + + + + + + + + app +