Source Code Cross Referenced for SharkWebClient.java in  » Workflow-Engines » shark » org » enhydra » shark » webclient » 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 » Workflow Engines » shark » org.enhydra.shark.webclient 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.shark.webclient;
002:
003:        import java.io.File;
004:        import java.util.ArrayList;
005:        import java.util.List;
006:
007:        import javax.transaction.UserTransaction;
008:
009:        import org.enhydra.shark.client.utilities.LimitStruct;
010:        import org.enhydra.shark.client.utilities.SharkInterfaceWrapper;
011:        import org.enhydra.shark.utilities.MiscUtilities;
012:        import org.enhydra.shark.webclient.business.DeadlineCheckerWrapper;
013:        import org.enhydra.shark.webclient.business.LimitCheckerWrapper;
014:        import org.enhydra.shark.webclient.business.QuartzInitializer;
015:        import org.enhydra.shark.webclient.business.SharkUtils;
016:
017:        import com.lutris.appserver.server.ApplicationException;
018:        import com.lutris.appserver.server.Enhydra;
019:        import com.lutris.appserver.server.StandardApplication;
020:        import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
021:        import com.lutris.logging.Logger;
022:        import com.lutris.util.Config;
023:
024:        /**
025:         * The application object. Application-wide data would go here.
026:         */
027:        public class SharkWebClient extends StandardApplication {
028:
029:            public static SharkWebClient me;
030:
031:            /**
032:             * Shark config file
033:             */
034:            protected static String SHARK_CONFIG_FILE = "";
035:
036:            protected DeadlineCheckerWrapper deadlineChecker = null;
037:
038:            protected LimitCheckerWrapper limitChecker = null;
039:
040:            protected boolean doProfile = false;
041:
042:            /**
043:             * Request pre-processing profiling level Negative - profile everything Zero - profile
044:             * nothing Positive - profile only processing that lasted longer than specified number
045:             * of milliseconds
046:             */
047:            protected int profileLevel = 0;
048:
049:            /*
050:             * A few methods you might want to add to. See StandardApplication for more details.
051:             */
052:
053:            public void startup(Config appConfig) throws ApplicationException {
054:                super .startup(appConfig);
055:                try {
056:                    Enhydra.register(this );
057:                    // Here is where you would read application-specific settings from
058:                    // your config file.
059:
060:                    // Profiling Initialization
061:                    try {
062:                        SharkWebClient.SHARK_CONFIG_FILE = appConfig.getString(
063:                                "SharkWebClient.Shark.confFile", "");
064:                        profileLevel = appConfig.getInt("TimeProfiler", 0);
065:                        if (profileLevel != 0) {
066:                            doProfile = true;
067:                        }
068:
069:                    } catch (Exception ex) {
070:                    }
071:
072:                    try {
073:
074:                        if (SHARK_CONFIG_FILE != null
075:                                && !SHARK_CONFIG_FILE.equals("")) {
076:                            File cFile = new File(SHARK_CONFIG_FILE);
077:                            // if file don't exist, try to resolve relative path
078:                            if (!cFile.exists()) {
079:                                cFile = new File(appConfig.getConfigFile()
080:                                        .getFile().getParentFile()
081:                                        .getParentFile().getCanonicalPath()
082:                                        + "/" + SHARK_CONFIG_FILE);
083:                            }
084:
085:                            if (!cFile.exists())
086:                                throw new ApplicationException(
087:                                        "Configuration file does not exist:"
088:                                                + cFile);
089:
090:                            String cfp = cFile.getAbsolutePath();
091:                            SharkInterfaceWrapper.setProperties(cfp, false);
092:                            SharkInterfaceWrapper.getShark();
093:
094:                        } else {
095:
096:                            throw new ApplicationException(
097:                                    "Shark configuration file is not defined");
098:                        }
099:
100:                        UserTransaction ut = SharkInterfaceWrapper
101:                                .getUserTransaction();
102:                        ut.begin();
103:                        SharkUtils.uploadPackage(appConfig);
104:                        ut.commit();
105:
106:                        if (appConfig.getBoolean(
107:                                "SharkWebClient.StartDeadlineChecker", false)) {
108:                            double dcTime = appConfig.getDouble(
109:                                    "SharkWebClient.DeadlinePollingTime", 5);
110:                            long dt = (int) (dcTime * 60000);
111:                            int dcipt = appConfig
112:                                    .getInt(
113:                                            "SharkWebClient.DeadlineCheck.InstancesPerTransaction",
114:                                            100);
115:                            int dcfti = appConfig
116:                                    .getInt(
117:                                            "SharkWebClient.DeadlineCheck.FailuresToIgnore",
118:                                            10);
119:                            String[] lcStructs = appConfig
120:                                    .getStrings("SharkWebClient.DeadlineStruct");
121:                            List lcStrLst = new ArrayList();
122:                            if (lcStructs != null) {
123:                                for (int i = 0; i < lcStructs.length; i++) {
124:                                    String lcstruct = lcStructs[i];
125:                                    try {
126:                                        String[] hma = MiscUtilities.tokenize(
127:                                                lcstruct, ":");
128:                                        String h = hma[0];
129:                                        String m = hma[1];
130:                                        String a = hma[2];
131:                                        lcStrLst.add(new LimitStruct(Integer
132:                                                .parseInt(h), Integer
133:                                                .parseInt(m), Integer
134:                                                .parseInt(a)));
135:                                    } catch (Exception ex) {
136:                                        logChannel
137:                                                .write(
138:                                                        Logger.ERROR,
139:                                                        "Deadline struct parameter "
140:                                                                + lcstruct
141:                                                                + " is invalid - it won't be evaluated!",
142:                                                        ex);
143:                                    }
144:                                }
145:                            }
146:
147:                            deadlineChecker = new DeadlineCheckerWrapper(this ,
148:                                    SharkInterfaceWrapper.getDefaultUser(),
149:                                    lcStrLst, dt, dcipt, dcfti, true);
150:                        }
151:
152:                        if (appConfig.getBoolean(
153:                                "SharkWebClient.StartLimitChecker", false)) {
154:                            double dcTime = appConfig.getDouble(
155:                                    "SharkWebClient.LimitPollingTime", 5);
156:                            long dt = (int) (dcTime * 60000);
157:                            int dcipt = appConfig
158:                                    .getInt(
159:                                            "SharkWebClient.LimitCheck.InstancesPerTransaction",
160:                                            100);
161:                            int dcfti = appConfig
162:                                    .getInt(
163:                                            "SharkWebClient.LimitCheck.FailuresToIgnore",
164:                                            10);
165:                            String[] lcStructs = appConfig
166:                                    .getStrings("SharkWebClient.LimitStruct");
167:                            List lcStrLst = new ArrayList();
168:                            if (lcStructs != null) {
169:                                for (int i = 0; i < lcStructs.length; i++) {
170:                                    String lcstruct = lcStructs[i];
171:                                    try {
172:                                        String[] hma = MiscUtilities.tokenize(
173:                                                lcstruct, ":");
174:                                        String h = hma[0];
175:                                        String m = hma[1];
176:                                        String a = hma[2];
177:                                        lcStrLst.add(new LimitStruct(Integer
178:                                                .parseInt(h), Integer
179:                                                .parseInt(m), Integer
180:                                                .parseInt(a)));
181:                                    } catch (Exception ex) {
182:                                        logChannel
183:                                                .write(
184:                                                        Logger.ERROR,
185:                                                        "Limit struct parameter "
186:                                                                + lcstruct
187:                                                                + " is invalid - it won't be evaluated!",
188:                                                        ex);
189:                                    }
190:                                }
191:                            }
192:                            limitChecker = new LimitCheckerWrapper(this ,
193:                                    SharkInterfaceWrapper.getDefaultUser(),
194:                                    lcStrLst, dt, dcipt, dcfti, true);
195:                        }
196:
197:                        SharkUtils.init(appConfig);
198:
199:                        me = this ;
200:
201:                        try {
202:                            if (appConfig.getBoolean("startQuartz")) {
203:                                QuartzInitializer
204:                                        .startQuartzScheduler(appConfig
205:                                                .getString("SharkWebClient.quartzConfPath"));
206:                            }
207:                        } catch (Exception ex) {
208:                        }
209:
210:                    } catch (Exception ex) {
211:                        throw new ApplicationException(
212:                                "Shark initialization failed!", ex);
213:                    }
214:
215:                } finally {
216:                    Enhydra.unRegister();
217:                }
218:
219:            }
220:
221:            public void shutdown() {
222:                super .shutdown();
223:                if (deadlineChecker != null) {
224:                    deadlineChecker.stopChecker();
225:                }
226:                if (limitChecker != null) {
227:                    limitChecker.stopChecker();
228:                }
229:
230:                QuartzInitializer.stopQuartzScheduler();
231:            }
232:
233:            public boolean requestPreprocessor(HttpPresentationComms comms)
234:                    throws Exception {
235:                return super .requestPreprocessor(comms);
236:            }
237:
238:            /**
239:             * This is an optional function, used only by the Multiserver's graphical
240:             * administration. This bit of HTML appears in the status page for this application.
241:             * You could add extra status info, for example a list of currently logged in users.
242:             * 
243:             * @return HTML that is displayed in the status page of the Multiserver.
244:             */
245:            public String toHtml() {
246:                return "This is <I>SharkWebClient</I>";
247:            }
248:
249:            public boolean isProfilingTurnedOn() {
250:                return doProfile;
251:            }
252:
253:            public int getProfileLevel() {
254:                return profileLevel;
255:            }
256:
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.