KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > web > connector > grizzly > Constants


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 /*
24  * Copyright 1999-2004 The Apache Software Foundation
25  *
26  * Licensed under the Apache License, Version 2.0 (the "License");
27  * you may not use this file except in compliance with the License.
28  * You may obtain a copy of the License at
29  *
30  * http://www.apache.org/licenses/LICENSE-2.0
31  *
32  * Unless required by applicable law or agreed to in writing, software
33  * distributed under the License is distributed on an "AS IS" BASIS,
34  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35  * See the License for the specific language governing permissions and
36  * limitations under the License.
37  */

38
39 package com.sun.enterprise.web.connector.grizzly;
40
41 import org.apache.tomcat.util.buf.ByteChunk;
42
43 /**
44  * Constants. Inspired from class org.apache.coyote.http11.Constants
45  *
46  * @author Jean-Francois Arcand
47  */

48 public final class Constants {
49
50
51     /**
52      * Package name.
53      */

54     public static final String JavaDoc Package =
55                                     "com.sun.enterprise.web.connector.grizzly";
56
57     public static final int DEFAULT_CONNECTION_LINGER = -1;
58     public static int DEFAULT_CONNECTION_TIMEOUT = 60000;
59     public static final int DEFAULT_CONNECTION_UPLOAD_TIMEOUT = 300000;
60     public static final int DEFAULT_SERVER_SOCKET_TIMEOUT = 0;
61     public static final boolean DEFAULT_TCP_NO_DELAY = true;
62
63     /**
64      * Default socket timeout
65      */

66     public final static int DEFAULT_TIMEOUT = 30;
67     
68     
69     /**
70      * Default request buffer size
71      */

72     public final static int DEFAULT_REQUEST_BUFFER_SIZE = 4096;
73     
74     
75     /**
76      * Default request header size
77      */

78     public final static int DEFAULT_HEADER_SIZE = 8 * 1024;
79     
80     
81     /**
82      * Default recycle value.
83      */

84     public final static boolean DEFAULT_RECYCLE = true;
85     
86     
87     /**
88      * Default max keep-alive count.
89      */

90     public final static int DEFAULT_MAX_KEEP_ALIVE = 256;
91        
92     
93     /**
94      * Default queue in bytes size.
95      */

96     public final static int DEFAULT_QUEUE_SIZE = 4096;
97      
98   
99     /**
100      * The default <code>ByteBuffer</code> size used everytime a new buffer
101      * is created.
102      */

103     public static int CHANNEL_BYTE_SIZE = 4098;
104     
105
106     private static final String JavaDoc NIO_BUFFER_SIZE =
107         "com.sun.enterprise.web.connector.grizzly.buffersize";
108
109     private static final String JavaDoc SOCKET_SO_TIMEOUT=
110         "com.sun.enterprise.web.connector.grizzly.socketSoTimeout";
111
112     static{
113         String JavaDoc tmp = System.getProperty(NIO_BUFFER_SIZE);
114
115         if ( tmp != null){
116             try {
117                 CHANNEL_BYTE_SIZE = Integer.parseInt(tmp);
118             } catch (NumberFormatException JavaDoc ex) {
119                 ;
120             }
121         }
122
123         tmp = System.getProperty(SOCKET_SO_TIMEOUT);
124         if ( tmp != null){
125             try {
126                 DEFAULT_CONNECTION_TIMEOUT = Integer.parseInt(tmp);
127             } catch (NumberFormatException JavaDoc ex) {
128                 ;
129             }
130         }
131     }
132     
133
134     // -------------------------------------------------------------- Constants
135

136      /**
137      * CRLF.
138      */

139     public static final String JavaDoc CRLF = "\r\n";
140
141     
142     /**
143      * CR.
144      */

145     public static final byte CR = (byte) '\r';
146
147
148     /**
149      * LF.
150      */

151     public static final byte LF = (byte) '\n';
152
153
154     /**
155      * SP.
156      */

157     public static final byte SP = (byte) ' ';
158
159
160     /**
161      * HT.
162      */

163     public static final byte HT = (byte) '\t';
164
165
166     /**
167      * COLON.
168      */

169     public static final byte COLON = (byte) ':';
170
171
172     /**
173      * 'A'.
174      */

175     public static final byte A = (byte) 'A';
176
177
178     /**
179      * 'a'.
180      */

181     public static final byte a = (byte) 'a';
182
183
184     /**
185      * 'Z'.
186      */

187     public static final byte Z = (byte) 'Z';
188
189
190     /**
191      * '?'.
192      */

193     public static final byte QUESTION = (byte) '?';
194
195
196     /**
197      * Lower case offset.
198      */

199     public static final byte LC_OFFSET = A - a;
200
201
202     /**
203      * Default HTTP header buffer size.
204      */

205     public static final int DEFAULT_HTTP_HEADER_BUFFER_SIZE = 48 * 1024;
206
207
208     /* Various constant "strings" */
209     public static final byte[] CRLF_BYTES = ByteChunk.convertToBytes(CRLF);
210     public static final byte[] COLON_BYTES = ByteChunk.convertToBytes(": ");
211     public static final String JavaDoc CONNECTION = "Connection";
212     public static final String JavaDoc CLOSE = "close";
213     public static final byte[] CLOSE_BYTES =
214         ByteChunk.convertToBytes(CLOSE);
215     public static final String JavaDoc KEEPALIVE = "keep-alive";
216     public static final byte[] KEEPALIVE_BYTES =
217         ByteChunk.convertToBytes(KEEPALIVE);
218     public static final String JavaDoc CHUNKED = "chunked";
219     public static final byte[] ACK_BYTES =
220         ByteChunk.convertToBytes("HTTP/1.1 100 Continue" + CRLF + CRLF);
221     public static final String JavaDoc TRANSFERENCODING = "Transfer-Encoding";
222     public static final byte[] _200_BYTES =
223         ByteChunk.convertToBytes("200");
224     public static final byte[] _400_BYTES =
225         ByteChunk.convertToBytes("400");
226     public static final byte[] _404_BYTES =
227         ByteChunk.convertToBytes("404");
228     
229
230     /**
231      * Identity filters (input and output).
232      */

233     public static final int IDENTITY_FILTER = 0;
234
235
236     /**
237      * Chunked filters (input and output).
238      */

239     public static final int CHUNKED_FILTER = 1;
240
241
242     /**
243      * Void filters (input and output).
244      */

245     public static final int VOID_FILTER = 2;
246
247
248     /**
249      * GZIP filter (output).
250      */

251     public static final int GZIP_FILTER = 3;
252
253
254     /**
255      * Buffered filter (input)
256      */

257     public static final int BUFFERED_FILTER = 3;
258
259
260     /**
261      * HTTP/1.0.
262      */

263     public static final String JavaDoc HTTP_10 = "HTTP/1.0";
264
265
266     /**
267      * HTTP/1.1.
268      */

269     public static final String JavaDoc HTTP_11 = "HTTP/1.1";
270     public static final byte[] HTTP_11_BYTES =
271         ByteChunk.convertToBytes(HTTP_11);
272
273
274     /**
275      * GET.
276      */

277     public static final String JavaDoc GET = "GET";
278
279
280     /**
281      * HEAD.
282      */

283     public static final String JavaDoc HEAD = "HEAD";
284
285
286     /**
287      * POST.
288      */

289     public static final String JavaDoc POST = "POST";
290
291 }
292
Popular Tags