mirror of
https://github.com/OpenLiberty/liberty-bikes.git
synced 2024-11-27 01:20:01 +08:00
Initial copy of player-service
This commit is contained in:
parent
67985d39fc
commit
6f228ce0d2
17
.gitignore
vendored
17
.gitignore
vendored
@ -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
|
||||
|
3
.settings/org.eclipse.buildship.core.prefs
Normal file
3
.settings/org.eclipse.buildship.core.prefs
Normal file
@ -0,0 +1,3 @@
|
||||
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
||||
connection.project.dir=player-service
|
||||
eclipse.preferences.version=1
|
2
game-service/.gitignore
vendored
2
game-service/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
/.gradle/
|
||||
/bin/
|
@ -1,3 +1,3 @@
|
||||
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
|
||||
connection.project.dir=
|
||||
connection.project.dir=../player-service
|
||||
eclipse.preferences.version=1
|
||||
|
59
game-service/.settings/org.eclipse.jdt.ui.prefs
Normal file
59
game-service/.settings/org.eclipse.jdt.ui.prefs
Normal file
@ -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
|
59
player-service/.settings/org.eclipse.jdt.ui.prefs
Normal file
59
player-service/.settings/org.eclipse.jdt.ui.prefs
Normal file
@ -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
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-modules id="moduleCoreId" project-version="2.0">
|
||||
<wb-module deploy-name="player-service">
|
||||
<property name="context-root" value="player-service"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
|
||||
<wb-resource deploy-path="/" source-path="src/main/webapp"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<fixed facet="jst.java"/>
|
||||
<fixed facet="jst.web"/>
|
||||
<installed facet="jst.web" version="2.4"/>
|
||||
<installed facet="jst.java" version="1.8"/>
|
||||
</faceted-project>
|
22
player-service/build.gradle
Normal file
22
player-service/build.gradle
Normal file
@ -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()
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package org.libertybikes.player.service;
|
||||
|
||||
public class Player {
|
||||
|
||||
public String id;
|
||||
|
||||
public String name;
|
||||
|
||||
}
|
@ -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 {
|
||||
|
||||
}
|
@ -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<String, Player> allPlayers = new HashMap<>();
|
||||
|
||||
@PostConstruct
|
||||
public void initPlayers() {
|
||||
for (int i = 0; i < 10; i++)
|
||||
createPlayer();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Collection<Player> 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);
|
||||
}
|
||||
|
||||
}
|
9
player-service/src/main/liberty/config/server.xml
Normal file
9
player-service/src/main/liberty/config/server.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<server>
|
||||
<featureManager>
|
||||
<feature>microProfile-1.2</feature>
|
||||
</featureManager>
|
||||
|
||||
<httpEndpoint id="defaultHttpEndpoint" httpPort="${httpPort}" httpsPort="${httpsPort}" />
|
||||
|
||||
<applicationManager autoExpand="true"/>
|
||||
</server>
|
@ -17,3 +17,4 @@ include 'services:webservice'
|
||||
|
||||
rootProject.name = 'liberty-bikes'
|
||||
include 'game-service'
|
||||
include 'player-service'
|
||||
|
Loading…
Reference in New Issue
Block a user