01: /*
02: * Poker
03: *
04: * Enhydra super-servlet presentation object
05: *
06: */
07:
08: package poker.presentation.main;
09:
10: // Enhydra SuperServlet imports
11: import com.lutris.appserver.server.httpPresentation.HttpPresentation;
12: import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
13: import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
14: import com.lutris.util.KeywordValueException;
15: import com.lutris.appserver.server.session.SessionException;
16:
17: import poker.Poker;
18: import poker.spec.PokerGame;
19: import poker.spec.GameManager;
20:
21: public class QuitPresentation implements HttpPresentation {
22:
23: public void run(HttpPresentationComms comms)
24: throws HttpPresentationException, SessionException,
25: KeywordValueException {
26:
27: QuitHTML quit;
28: quit = (QuitHTML) comms.xmlcFactory.create(QuitHTML.class);
29:
30: Poker mainApp = (Poker) comms.session.getSessionData().get(
31: "app");
32: GameManager gameManager = mainApp.getGameManager();
33: PokerGame game = (PokerGame) comms.session.getSessionData()
34: .get("game");
35:
36: /*
37: * Catch Null pointer exception ( we canot make a instances of classes from business layer when we run poker_pres )
38: * We need to allow poker_pres to be dynamic , so if the requested url is /poker_pres/..... the response
39: * will be default HTML page
40: */
41: try {
42: String name = game.getName();
43: quit.setTextName(name);
44:
45: comms.session.setUser(null);
46: if (game.getCash() < 1) {
47: gameManager.removeGame(name);
48: }
49: } catch (NullPointerException e) {
50: }
51: comms.response.writeDOM(quit);
52: }
53:
54: }
|