diff --git a/.gitignore b/.gitignore index 2de92df..c534fdf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,14 @@ build /.apt_generated/ -/.gradle/ -/bin/ +**/.project +**/.gradle/ **/.DS_Store .vscode -.classpath -.project -.settings/org.eclipse.jdt.core.prefs -.settings/org.eclipse.wst.common.component -.settings/org.eclipse.wst.common.project.facet.core.xml +/*/bin/ +/*/build/ +/*/.classpath +/*/.project +/*/.settings/org.eclipse.jdt.core.prefs +/*/.settings/org.eclipse.wst.common.component +/*/.settings/org.eclipse.wst.common.project.facet.core.xml +/*/.settings/org.eclipse.buildship.core.prefs diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs new file mode 100644 index 0000000..f44feba --- /dev/null +++ b/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,3 @@ +connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) +connection.project.dir=player-service +eclipse.preferences.version=1 diff --git a/game-service/.gitignore b/game-service/.gitignore deleted file mode 100644 index f547dc2..0000000 --- a/game-service/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.gradle/ -/bin/ diff --git a/game-service/.settings/org.eclipse.buildship.core.prefs b/game-service/.settings/org.eclipse.buildship.core.prefs index 03931c0..6ec81db 100644 --- a/game-service/.settings/org.eclipse.buildship.core.prefs +++ b/game-service/.settings/org.eclipse.buildship.core.prefs @@ -1,3 +1,3 @@ connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) -connection.project.dir= +connection.project.dir=../player-service eclipse.preferences.version=1 diff --git a/game-service/.settings/org.eclipse.jdt.ui.prefs b/game-service/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..81ecbd4 --- /dev/null +++ b/game-service/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,59 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.ondemandthreshold=99 +org.eclipse.jdt.ui.staticondemandthreshold=99 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=true +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/player-service/.settings/org.eclipse.jdt.ui.prefs b/player-service/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..81ecbd4 --- /dev/null +++ b/player-service/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,59 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.ondemandthreshold=99 +org.eclipse.jdt.ui.staticondemandthreshold=99 +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=true +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=true +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/player-service/.settings/org.eclipse.wst.common.component b/player-service/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..a2f4da7 --- /dev/null +++ b/player-service/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/player-service/.settings/org.eclipse.wst.common.project.facet.core.xml b/player-service/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..cea524a --- /dev/null +++ b/player-service/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/player-service/build.gradle b/player-service/build.gradle new file mode 100644 index 0000000..60e8045 --- /dev/null +++ b/player-service/build.gradle @@ -0,0 +1,22 @@ +ext { + httpPort = 8081 + httpsPort = 8444 +} + +liberty { + server { + name = 'player-service' + dropins = [war] + bootstrapProperties = ['httpPort': httpPort, 'httpsPort': httpsPort] + } +} + +libertyStart.doLast { + println "Application available at: http://localhost:${httpPort}/${project.name}" +} + +task open { + doLast { + java.awt.Desktop.desktop.browse "http://localhost:${httpPort}/${project.name}".toURI() + } +} diff --git a/player-service/src/main/java/org/libertybikes/player/service/Player.java b/player-service/src/main/java/org/libertybikes/player/service/Player.java new file mode 100644 index 0000000..775f31b --- /dev/null +++ b/player-service/src/main/java/org/libertybikes/player/service/Player.java @@ -0,0 +1,9 @@ +package org.libertybikes.player.service; + +public class Player { + + public String id; + + public String name; + +} diff --git a/player-service/src/main/java/org/libertybikes/player/service/PlayerApp.java b/player-service/src/main/java/org/libertybikes/player/service/PlayerApp.java new file mode 100644 index 0000000..0d62053 --- /dev/null +++ b/player-service/src/main/java/org/libertybikes/player/service/PlayerApp.java @@ -0,0 +1,9 @@ +package org.libertybikes.player.service; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +@ApplicationPath("/") +public class PlayerApp extends Application { + +} diff --git a/player-service/src/main/java/org/libertybikes/player/service/PlayerService.java b/player-service/src/main/java/org/libertybikes/player/service/PlayerService.java new file mode 100644 index 0000000..b2644c6 --- /dev/null +++ b/player-service/src/main/java/org/libertybikes/player/service/PlayerService.java @@ -0,0 +1,53 @@ +package org.libertybikes.player.service; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import javax.annotation.PostConstruct; +import javax.enterprise.context.ApplicationScoped; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Path("/") +@ApplicationScoped +public class PlayerService { + + Map allPlayers = new HashMap<>(); + + @PostConstruct + public void initPlayers() { + for (int i = 0; i < 10; i++) + createPlayer(); + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + public Collection getPlayers() { + return allPlayers.values(); + } + + @GET + @Path("/create") + @Consumes(MediaType.APPLICATION_JSON) + public String createPlayer() { + Player p = new Player(); + p.id = UUID.randomUUID().toString(); + p.name = "Bob"; + allPlayers.put(p.id, p); + return p.id; + } + + @GET + @Path("/{playerId}") + @Produces(MediaType.APPLICATION_JSON) + public Player getPlayerById(@PathParam("playerId") String id) { + return allPlayers.get(id); + } + +} diff --git a/player-service/src/main/liberty/config/server.xml b/player-service/src/main/liberty/config/server.xml new file mode 100644 index 0000000..3d2bc5d --- /dev/null +++ b/player-service/src/main/liberty/config/server.xml @@ -0,0 +1,9 @@ + + + microProfile-1.2 + + + + + + \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index cefbf9e..9d62ab8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,3 +17,4 @@ include 'services:webservice' rootProject.name = 'liberty-bikes' include 'game-service' +include 'player-service'