Source Code Cross Referenced for Poker.java in  » J2EE » Enhydra-Demos » poker » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Enhydra Demos » poker 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Larry and Daryl's EnhyDraw! Poker
003:         * A sample Enhydra Application
004:         *
005:         * EnhyDraw!, beta 4, 5/21/99
006:         *
007:         * Copyright 1999, Larry Wolcot & Daryl Tempesta
008:         * ALL rights reserved. Not for commercial use
009:         * without written permission from both authors.
010:         *
011:         *
012:         */
013:
014:        package poker;
015:
016:        import java.io.*;
017:        import java.math.BigDecimal;
018:        import java.util.Enumeration;
019:        import com.lutris.util.*;
020:        import com.lutris.logging.Logger;
021:        import com.lutris.logging.LogChannel;
022:        import com.lutris.appserver.server.session.*;
023:        import com.lutris.appserver.server.user.*;
024:        import com.lutris.appserver.server.*;
025:        import com.lutris.appserver.server.httpPresentation.*;
026:
027:        import poker.spec.*;
028:
029:        import com.lutris.util.Config;
030:
031:        import javax.servlet.http.Cookie;
032:
033:        /**
034:         * This is the main application object
035:         * that handles the appication wide data,
036:         * like the GameManager.
037:         */
038:        public class Poker extends StandardApplication implements 
039:                java.io.Serializable {
040:
041:            private static GameManager gameManager = null;
042:
043:            private static FortuneManager fortuneManager = null;
044:
045:            // This is where you should enable the use of DODS_Objects
046:            // instead of Vector Objects for persistance
047:            private boolean useDB = false;
048:
049:            //    private boolean useDB = true;
050:
051:            public void startup(Config appConfig) throws ApplicationException {
052:
053:                try {
054:                    // This is where you should enable the use of DODS_Objects
055:                    // instead of Vector Objects for persistance
056:                    useDB = appConfig.getBoolean("EnhyDrawApplication.useDB",
057:                            false);
058:                } catch (ConfigException e) {
059:                    logChannel.write(Logger.INFO, "poker.conf errror:"
060:                            + e.toString());
061:                }
062:
063:                super .startup(appConfig);
064:
065:                //Yea, this needs to be finished
066:                try {
067:                    fortuneManager = FortuneManagerFactory
068:                            .getFortuneManager("poker.business.FortuneManagerImpl");
069:                    gameManager = GameManagerFactory
070:                            .getGameManager("poker.business.GameManagerImpl");
071:
072:                    fortuneManager.addFortune("Who's there?!");
073:                    fortuneManager.addFortune("What do you want?!");
074:                    fortuneManager
075:                            .addFortune("Don't come in here with loco motives!");
076:                    fortuneManager.addFortune("Whats the secret knock?!");
077:                    fortuneManager.addFortune("I don't like your looks?!");
078:                    fortuneManager
079:                            .addFortune("Come to play poker or tiddly winks?");
080:                    fortuneManager
081:                            .addFortune("BEA sure your app runs this nice!");
082:                    fortuneManager.addFortune("Watch your step, pal...");
083:                    fortuneManager.addFortune("Are you talking to me?");
084:                    fortuneManager
085:                            .addFortune("I'll J-Run your ass right outta town!");
086:                    fortuneManager.addFortune("Feeling lucky?    I hope so..");
087:                } catch (Exception e) {
088:
089:                }
090:                //This is tells the gameManager to use the DB instead of memory.
091:                //FIX: Still need to add the useDB key into the
092:                // Poker.conf configuration file..
093:
094:                try {
095:                    gameManager.setUseDB(useDB);
096:                } catch (Exception e) {
097:                    logChannel.write(Logger.INFO, "EnhyDraw! DB errror:"
098:                            + e.toString());
099:                    //There was a problem with the DB init
100:                }
101:
102:                if (logChannel != null)
103:                    logChannel.write(Logger.INFO,
104:                            "EnhyDraw Poker now starting!");
105:                state = RUNNING;
106:            }
107:
108:            /**
109:             * This is an optional function, used only by the Multiserver's graphical
110:             * administration. This bit of HTML appears in the status page for this
111:             * application. In this case, it displays the House Statistics
112:             * which include total earnings, total players, etc.
113:             *
114:             * @return HTML that is displayed in the status page of the Multiserver.
115:             */
116:            public String toHtml() {
117:
118:                GameManager g = GameManagerFactory
119:                        .getGameManager("poker.business.GameManagerImpl");
120:
121:                String n = new Integer(gameManager.getCount()).toString();
122:                String m = "Welcome to Larry and Daryl's EnhyDraw Poker!<br>";
123:                m += "<table border=\"1\" cellpadding=\"3\" cellspacing=\"0\"";
124:                m += "width=\"271\"><tr><td width=\"171\">Total Players Cataloged";
125:                m += "</td><td width=\"84\">" + g.getTotalPlayers()
126:                        + "</td></tr><tr>";
127:                m += "<td width=\"171\">Total Hands Dealt</td>";
128:                m += "<td width=\"84\">" + g.getTotalHandsDealt()
129:                        + "</td></tr><tr>";
130:                m += "<td width=\"171\">Total Hands Won</td>";
131:                m += "<td width=\"84\">" + g.getTotalHandsWon()
132:                        + "</td></tr><tr>";
133:                m += "<td width=\"171\">Total Hands Lost</td>";
134:                m += "<td width=\"84\">" + g.getTotalHandsLost()
135:                        + "</td></tr><tr>";
136:                m += "<td width=\"171\">Total Server Profit</td>";
137:                m += "<td width=\"84\">" + g.getHouseProfit()
138:                        + "</td></tr><tr>";
139:                m += "<td width=\"171\">Total Players Bankrupt</td>";
140:                m += "<td width=\"84\">" + g.getTotalBankrupt()
141:                        + "</td></tr></table>";
142:                m += "</div>";
143:                return m;
144:            }
145:
146:            /**
147:             * Return the game manager for this application.
148:             */
149:            public GameManager getGameManager() {
150:                return gameManager;
151:            }
152:
153:            public FortuneManager getFortuneManager() {
154:                return fortuneManager;
155:            }
156:
157:            /**
158:             * Shutdown the application.
159:             */
160:            public void shutdown() {
161:                super .shutdown();
162:            }
163:
164:            /**
165:             * This method pre processes all requests
166:             */
167:            public boolean requestPreprocessor(HttpPresentationComms comms)
168:                    throws Exception {
169:                super .requestPreprocessor(comms);
170:
171:                if (!(comms.request.getRequestURI().toLowerCase().endsWith(
172:                        ".gif") || comms.request.getRequestURI().toLowerCase()
173:                        .endsWith(".jpg")))
174:                    comms.session.getSessionData().set("app", this );
175:                String pp = comms.request.getApplicationPath();
176:                if (!pp.endsWith("/"))
177:                    pp += "/";
178:                String loginDir = pp + "login/";
179:                String mediaDir = pp + "media/";
180:                String page = comms.request.getRequestURI();
181:                if (page.startsWith(loginDir) || page.startsWith(mediaDir)) {
182:                    /*
183:                     * Let them go to the login and logout areas whether or not
184:                     * they are logged in.  Also let them get media on welcomepage.
185:                     */
186:                    return false;
187:                } else {
188:
189:                    //We need  to allow poker_pres to be dynamic , so if the requested url is poker_pres user dont need to be logged
190:                    String uri = comms.request.getRequestURI();
191:                    boolean is = uri.startsWith("/poker_pres");
192:
193:                    /*
194:                     * All other pages require the user to be logged in.
195:                     */
196:                    if (is)
197:
198:                        return false;
199:
200:                    else {
201:                        if (comms.session.getUser() != null)
202:                            // It's ok, they are logged in already.
203:                            return false;
204:                        else {
205:                            // They are not logged in! Redirect to login page.
206:                            String url = pp + "login/StartPresentation.po";
207:                            throw new ClientPageRedirectException(url);
208:                        }
209:                    }
210:                }
211:            }
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.