|
|
@ -4,6 +4,9 @@ import de.fd.fh.server.access.AccessContextEventListener; |
|
|
|
import de.fd.fh.server.access.AccessRepository; |
|
|
|
import de.fd.fh.server.access.AccessService; |
|
|
|
import de.fd.fh.server.access.web.AccessController; |
|
|
|
import de.fd.fh.server.game.GameRepository; |
|
|
|
import de.fd.fh.server.game.GameService; |
|
|
|
import de.fd.fh.server.game.web.GameController; |
|
|
|
import de.fd.fh.server.user.UserContextEventListener; |
|
|
|
import de.fd.fh.server.user.web.UserController; |
|
|
|
import de.fd.fh.server.user.UserRepository; |
|
|
@ -21,9 +24,11 @@ public class ServerApp |
|
|
|
{ |
|
|
|
private static AccessRepository accessRepository; |
|
|
|
private static UserRepository userRepository; |
|
|
|
private static GameRepository gameRepository; |
|
|
|
|
|
|
|
private static AccessController accessController; |
|
|
|
private static UserController userController; |
|
|
|
private static GameController gameController; |
|
|
|
|
|
|
|
private static final Set<Observer> listeners = new HashSet<>(); |
|
|
|
|
|
|
@ -38,6 +43,7 @@ public class ServerApp |
|
|
|
addListeners(new AccessService(accessRepository))); |
|
|
|
userController = new UserController((UserService) |
|
|
|
addListeners(new UserService(userRepository))); |
|
|
|
gameController = new GameController(new GameService(gameRepository)); |
|
|
|
} |
|
|
|
|
|
|
|
before("/*", (req, res) -> accessController.before(req)); |
|
|
@ -50,17 +56,21 @@ public class ServerApp |
|
|
|
get("/users", userController::getCompleteUser); |
|
|
|
get("/users/:user_id", userController::getUser); |
|
|
|
|
|
|
|
post("/games", gameController::createGame); |
|
|
|
|
|
|
|
get("/hello", (req, res) -> "Hello World"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public static void initController( |
|
|
|
final AccessController accessController, |
|
|
|
final UserController userController |
|
|
|
final UserController userController, |
|
|
|
final GameController gameController |
|
|
|
) |
|
|
|
{ |
|
|
|
ServerApp.userController = userController; |
|
|
|
ServerApp.accessController = accessController; |
|
|
|
ServerApp.gameController = gameController; |
|
|
|
} |
|
|
|
|
|
|
|
private static Object addListeners(Observable service) |
|
|
@ -80,5 +90,6 @@ public class ServerApp |
|
|
|
{ |
|
|
|
accessRepository = new AccessRepository(); |
|
|
|
userRepository = new UserRepository(); |
|
|
|
gameRepository = new GameRepository(); |
|
|
|
} |
|
|
|
} |