Source Code Cross Referenced for WatchdogConfig.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » boot » 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 » EJB Server resin 3.1.5 » resin » com.caucho.boot 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         *
023:         *   Free Software Foundation, Inc.
024:         *   59 Temple Place, Suite 330
025:         *   Boston, MA 02111-1307  USA
026:         *
027:         * @author Scott Ferguson
028:         */
029:
030:        package com.caucho.boot;
031:
032:        import com.caucho.config.program.ConfigProgram;
033:        import com.caucho.config.ConfigException;
034:        import com.caucho.server.port.Port;
035:        import com.caucho.util.*;
036:        import com.caucho.vfs.Path;
037:        import com.caucho.vfs.Vfs;
038:
039:        import java.lang.reflect.*;
040:        import java.net.*;
041:        import java.util.ArrayList;
042:        import java.util.logging.Logger;
043:
044:        /**
045:         * Thread responsible for watching a backend server.
046:         */
047:        public class WatchdogConfig {
048:            private static final L10N L = new L10N(WatchdogConfig.class);
049:            private static final Logger log = Logger
050:                    .getLogger(WatchdogConfig.class.getName());
051:
052:            private static final int WATCHDOG_PORT_DEFAULT = 6600;
053:
054:            private String _id = "";
055:
056:            private WatchdogArgs _args;
057:
058:            private Path _javaHome;
059:            private Path _javaExe;
060:            private ArrayList<String> _jvmArgs = new ArrayList<String>();
061:            private ArrayList<String> _watchdogJvmArgs = new ArrayList<String>();
062:            private Path _resinHome;
063:            private Path _resinRoot;
064:            private Path _resinConf;
065:            private Path _logPath;
066:
067:            private boolean _is64bit;
068:            private boolean _hasXss;
069:            private boolean _hasXmx;
070:
071:            private Path _pwd;
072:            private int _watchdogPort;
073:
074:            private String _userName;
075:            private String _groupName;
076:
077:            private ArrayList<Port> _ports = new ArrayList<Port>();
078:
079:            private long _shutdownWaitTime = 60000L;
080:
081:            private boolean _isVerbose;
082:            private boolean _isWatchdog64bit;
083:            private boolean _hasWatchdogXss;
084:            private boolean _hasWatchdogXmx;
085:
086:            WatchdogConfig(WatchdogArgs args) {
087:                _args = args;
088:
089:                _pwd = Vfs.getPwd();
090:
091:                _is64bit = "64".equals(System
092:                        .getProperty("sun.arch.data.model"));
093:            }
094:
095:            public void setId(String id) {
096:                _id = id;
097:            }
098:
099:            public String getId() {
100:                return _id;
101:            }
102:
103:            String[] getArgv() {
104:                return _args.getArgv();
105:            }
106:
107:            public void setVerbose(boolean isVerbose) {
108:                _isVerbose = isVerbose;
109:            }
110:
111:            public void setJavaExe(Path javaExe) {
112:                _javaExe = javaExe;
113:            }
114:
115:            public void setJavaHome(Path javaHome) {
116:                _javaHome = javaHome;
117:            }
118:
119:            public Path getJavaHome() {
120:                if (_javaHome != null)
121:                    return _javaHome;
122:                else
123:                    return _args.getJavaHome();
124:            }
125:
126:            public void addJvmArg(String arg) {
127:                _jvmArgs.add(arg);
128:
129:                if (arg.equals("-d64"))
130:                    _is64bit = true;
131:                else if (arg.startsWith("-Xss"))
132:                    _hasXss = true;
133:                else if (arg.startsWith("-Xmx"))
134:                    _hasXmx = true;
135:            }
136:
137:            public ArrayList<String> getJvmArgs() {
138:                return _jvmArgs;
139:            }
140:
141:            public void addWatchdogJvmArg(String arg) {
142:                _watchdogJvmArgs.add(arg);
143:
144:                if (arg.equals("-d64"))
145:                    _isWatchdog64bit = true;
146:                else if (arg.startsWith("-Xss"))
147:                    _hasWatchdogXss = true;
148:                else if (arg.startsWith("-Xmx"))
149:                    _hasWatchdogXmx = true;
150:            }
151:
152:            public ArrayList<String> getWatchdogJvmArgs() {
153:                return _watchdogJvmArgs;
154:            }
155:
156:            /**
157:             * Adds a http.
158:             */
159:            public void addHttp(Port port) throws ConfigException {
160:                _ports.add(port);
161:            }
162:
163:            /**
164:             * Adds a custom-protocol port.
165:             */
166:            public void addProtocol(Port port) throws ConfigException {
167:                _ports.add(port);
168:            }
169:
170:            /**
171:             * Adds a watchdog managed port
172:             */
173:            public void addOpenPort(Port port) {
174:                _ports.add(port);
175:            }
176:
177:            public void setUserName(String user) {
178:                _userName = user;
179:            }
180:
181:            public String getUserName() {
182:                return _userName;
183:            }
184:
185:            public void setGroupName(String group) {
186:                _groupName = group;
187:            }
188:
189:            public String getGroupName() {
190:                return _groupName;
191:            }
192:
193:            public Path getLogPath() {
194:                if (_logPath != null)
195:                    return _logPath;
196:
197:                String name;
198:
199:                if ("".equals(_id))
200:                    name = "jvm-default.log";
201:                else
202:                    name = "jvm-" + _id + ".log";
203:
204:                return getLogDirectory().lookup(name);
205:            }
206:
207:            public Path getRootDirectory() {
208:                return _args.getRootDirectory();
209:            }
210:
211:            public Path getLogDirectory() {
212:                Path logDirectory = _args.getLogDirectory();
213:
214:                if (logDirectory != null)
215:                    return logDirectory;
216:                else
217:                    return getRootDirectory().lookup("log");
218:            }
219:
220:            public long getShutdownWaitTime() {
221:                return _shutdownWaitTime;
222:            }
223:
224:            public int getWatchdogPort() {
225:                if (_args.getWatchdogPort() > 0)
226:                    return _args.getWatchdogPort();
227:                else if (_watchdogPort > 0)
228:                    return _watchdogPort;
229:                else
230:                    return WATCHDOG_PORT_DEFAULT;
231:            }
232:
233:            public void setWatchdogPort(int port) {
234:                _watchdogPort = port;
235:            }
236:
237:            /**
238:             * Ignore items we can't understand.
239:             */
240:            public void addBuilderProgram(ConfigProgram program) {
241:            }
242:
243:            WatchdogArgs getArgs() {
244:                return _args;
245:            }
246:
247:            Iterable<Port> getPorts() {
248:                return _ports;
249:            }
250:
251:            Path getPwd() {
252:                return _pwd;
253:            }
254:
255:            Path getResinHome() {
256:                if (_resinHome != null)
257:                    return _resinHome;
258:                else
259:                    return _args.getResinHome();
260:            }
261:
262:            Path getResinRoot() {
263:                if (_resinRoot != null)
264:                    return _resinRoot;
265:                else
266:                    return _args.getRootDirectory();
267:            }
268:
269:            /**
270:             * Sets the resin.conf
271:             */
272:            public void setResinConf(Path resinConf) {
273:                _resinConf = resinConf;
274:            }
275:
276:            /**
277:             * Returns the resin.conf
278:             */
279:            public Path getResinConf() {
280:                if (_resinConf != null)
281:                    return _resinConf;
282:                else
283:                    return _args.getResinConf();
284:            }
285:
286:            boolean hasWatchdogXmx() {
287:                return _hasWatchdogXmx;
288:            }
289:
290:            boolean hasWatchdogXss() {
291:                return _hasWatchdogXss;
292:            }
293:
294:            boolean hasXmx() {
295:                return _hasXmx;
296:            }
297:
298:            boolean hasXss() {
299:                return _hasXss;
300:            }
301:
302:            boolean is64bit() {
303:                return _is64bit;
304:            }
305:
306:            boolean isVerbose() {
307:                if (_isVerbose)
308:                    return _isVerbose;
309:                else
310:                    return _args.isVerbose();
311:            }
312:
313:            String getJavaExe() {
314:                if (_javaExe != null)
315:                    return _javaExe.getNativePath();
316:
317:                Path javaHome = Vfs.lookup(System.getProperty("java.home"));
318:
319:                if (javaHome.getTail().equals("jre"))
320:                    javaHome = javaHome.getParent();
321:
322:                if (javaHome.lookup("bin/javaw.exe").canRead())
323:                    return javaHome.lookup("bin/javaw").getNativePath();
324:                else if (javaHome.lookup("bin/java.exe").canRead())
325:                    return javaHome.lookup("bin/java").getNativePath();
326:                else if (javaHome.lookup("bin/java").canRead())
327:                    return javaHome.lookup("bin/java").getNativePath();
328:
329:                javaHome = Vfs.lookup(System.getProperty("java.home"));
330:
331:                if (javaHome.lookup("bin/javaw.exe").canRead())
332:                    return javaHome.lookup("bin/javaw").getNativePath();
333:                else if (javaHome.lookup("bin/java.exe").canRead())
334:                    return javaHome.lookup("bin/java").getNativePath();
335:                else if (javaHome.lookup("bin/java").canRead())
336:                    return javaHome.lookup("bin/java").getNativePath();
337:
338:                return "java";
339:            }
340:
341:            @Override
342:            public String toString() {
343:                return getClass().getSimpleName() + "[" + getId() + "]";
344:            }
345:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.