2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
5506
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
2
|
24 |
*/
|
|
25 |
|
|
26 |
package sun.net.httpserver;
|
|
27 |
|
|
28 |
import com.sun.net.httpserver.*;
|
|
29 |
import com.sun.net.httpserver.spi.*;
|
|
30 |
|
|
31 |
/**
|
|
32 |
* Parameters that users will not likely need to set
|
|
33 |
* but are useful for debugging
|
|
34 |
*/
|
|
35 |
|
|
36 |
class ServerConfig {
|
|
37 |
|
|
38 |
static int clockTick;
|
|
39 |
|
|
40 |
static int defaultClockTick = 10000 ; // 10 sec.
|
|
41 |
|
|
42 |
/* These values must be a reasonable multiple of clockTick */
|
|
43 |
static long defaultReadTimeout = 20 ; // 20 sec.
|
|
44 |
static long defaultWriteTimeout = 60 ; // 60 sec.
|
|
45 |
static long defaultIdleInterval = 300 ; // 5 min
|
|
46 |
static long defaultSelCacheTimeout = 120 ; // seconds
|
|
47 |
static int defaultMaxIdleConnections = 200 ;
|
|
48 |
|
|
49 |
static long defaultDrainAmount = 64 * 1024;
|
|
50 |
|
|
51 |
static long readTimeout;
|
|
52 |
static long writeTimeout;
|
|
53 |
static long idleInterval;
|
|
54 |
static long selCacheTimeout;
|
|
55 |
static long drainAmount; // max # of bytes to drain from an inputstream
|
|
56 |
static int maxIdleConnections;
|
|
57 |
static boolean debug = false;
|
|
58 |
|
|
59 |
static {
|
|
60 |
|
|
61 |
idleInterval = ((Long)java.security.AccessController.doPrivileged(
|
|
62 |
new sun.security.action.GetLongAction(
|
|
63 |
"sun.net.httpserver.idleInterval",
|
|
64 |
defaultIdleInterval))).longValue() * 1000;
|
|
65 |
|
|
66 |
clockTick = ((Integer)java.security.AccessController.doPrivileged(
|
|
67 |
new sun.security.action.GetIntegerAction(
|
|
68 |
"sun.net.httpserver.clockTick",
|
|
69 |
defaultClockTick))).intValue();
|
|
70 |
|
|
71 |
maxIdleConnections = ((Integer)java.security.AccessController.doPrivileged(
|
|
72 |
new sun.security.action.GetIntegerAction(
|
|
73 |
"sun.net.httpserver.maxIdleConnections",
|
|
74 |
defaultMaxIdleConnections))).intValue();
|
|
75 |
|
|
76 |
readTimeout = ((Long)java.security.AccessController.doPrivileged(
|
|
77 |
new sun.security.action.GetLongAction(
|
|
78 |
"sun.net.httpserver.readTimeout",
|
|
79 |
defaultReadTimeout))).longValue()* 1000;
|
|
80 |
|
|
81 |
selCacheTimeout = ((Long)java.security.AccessController.doPrivileged(
|
|
82 |
new sun.security.action.GetLongAction(
|
|
83 |
"sun.net.httpserver.selCacheTimeout",
|
|
84 |
defaultSelCacheTimeout))).longValue()* 1000;
|
|
85 |
|
|
86 |
writeTimeout = ((Long)java.security.AccessController.doPrivileged(
|
|
87 |
new sun.security.action.GetLongAction(
|
|
88 |
"sun.net.httpserver.writeTimeout",
|
|
89 |
defaultWriteTimeout))).longValue()* 1000;
|
|
90 |
|
|
91 |
drainAmount = ((Long)java.security.AccessController.doPrivileged(
|
|
92 |
new sun.security.action.GetLongAction(
|
|
93 |
"sun.net.httpserver.drainAmount",
|
|
94 |
defaultDrainAmount))).longValue();
|
|
95 |
|
|
96 |
debug = ((Boolean)java.security.AccessController.doPrivileged(
|
|
97 |
new sun.security.action.GetBooleanAction(
|
|
98 |
"sun.net.httpserver.debug"))).booleanValue();
|
|
99 |
}
|
|
100 |
|
|
101 |
static long getReadTimeout () {
|
|
102 |
return readTimeout;
|
|
103 |
}
|
|
104 |
|
|
105 |
static long getSelCacheTimeout () {
|
|
106 |
return selCacheTimeout;
|
|
107 |
}
|
|
108 |
|
|
109 |
static boolean debugEnabled () {
|
|
110 |
return debug;
|
|
111 |
}
|
|
112 |
|
|
113 |
static long getIdleInterval () {
|
|
114 |
return idleInterval;
|
|
115 |
}
|
|
116 |
|
|
117 |
static int getClockTick () {
|
|
118 |
return clockTick;
|
|
119 |
}
|
|
120 |
|
|
121 |
static int getMaxIdleConnections () {
|
|
122 |
return maxIdleConnections;
|
|
123 |
}
|
|
124 |
|
|
125 |
static long getWriteTimeout () {
|
|
126 |
return writeTimeout;
|
|
127 |
}
|
|
128 |
|
|
129 |
static long getDrainAmount () {
|
|
130 |
return drainAmount;
|
|
131 |
}
|
|
132 |
}
|