Source Code Cross Referenced for HttpConnectionParams.java in  » Net » httpcomponents-core-4.0-beta1 » org » apache » http » params » 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 » Net » httpcomponents core 4.0 beta1 » org.apache.http.params 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0-beta1/module-main/src/main/java/org/apache/http/params/HttpConnectionParams.java $
003:         * $Revision: 576089 $
004:         * $Date: 2007-09-16 14:39:56 +0200 (Sun, 16 Sep 2007) $
005:         *
006:         * ====================================================================
007:         * Licensed to the Apache Software Foundation (ASF) under one
008:         * or more contributor license agreements.  See the NOTICE file
009:         * distributed with this work for additional information
010:         * regarding copyright ownership.  The ASF licenses this file
011:         * to you under the Apache License, Version 2.0 (the
012:         * "License"); you may not use this file except in compliance
013:         * with the License.  You may obtain a copy of the License at
014:         *
015:         *   http://www.apache.org/licenses/LICENSE-2.0
016:         *
017:         * Unless required by applicable law or agreed to in writing,
018:         * software distributed under the License is distributed on an
019:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
020:         * KIND, either express or implied.  See the License for the
021:         * specific language governing permissions and limitations
022:         * under the License.
023:         * ====================================================================
024:         *
025:         * This software consists of voluntary contributions made by many
026:         * individuals on behalf of the Apache Software Foundation.  For more
027:         * information on the Apache Software Foundation, please see
028:         * <http://www.apache.org/>.
029:         *
030:         */
031:
032:        package org.apache.http.params;
033:
034:        /**
035:         * An adaptor for accessing connection parameters in {@link HttpParams}.
036:         * <br/>
037:         * Note that the <i>implements</i> relation to {@link CoreConnectionPNames}
038:         * is for compatibility with existing application code only. References to
039:         * the parameter names should use the interface, not this class.
040:         * 
041:         * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
042:         * 
043:         * @version $Revision: 576089 $
044:         * 
045:         * @since 4.0
046:         */
047:        public final class HttpConnectionParams implements  CoreConnectionPNames {
048:
049:            /**
050:             */
051:            private HttpConnectionParams() {
052:                super ();
053:            }
054:
055:            /**
056:             * Returns the default socket timeout (<tt>SO_TIMEOUT</tt>) in milliseconds which is the 
057:             * timeout for waiting for data. A timeout value of zero is interpreted as an infinite 
058:             * timeout. This value is used when no socket timeout is set in the 
059:             * method parameters. 
060:             *
061:             * @return timeout in milliseconds
062:             */
063:            public static int getSoTimeout(final HttpParams params) {
064:                if (params == null) {
065:                    throw new IllegalArgumentException(
066:                            "HTTP parameters may not be null");
067:                }
068:                return params.getIntParameter(CoreConnectionPNames.SO_TIMEOUT,
069:                        0);
070:            }
071:
072:            /**
073:             * Sets the default socket timeout (<tt>SO_TIMEOUT</tt>) in milliseconds which is the 
074:             * timeout for waiting for data. A timeout value of zero is interpreted as an infinite 
075:             * timeout. This value is used when no socket timeout is set in the 
076:             * method parameters. 
077:             *
078:             * @param timeout Timeout in milliseconds
079:             */
080:            public static void setSoTimeout(final HttpParams params, int timeout) {
081:                if (params == null) {
082:                    throw new IllegalArgumentException(
083:                            "HTTP parameters may not be null");
084:                }
085:                params
086:                        .setIntParameter(CoreConnectionPNames.SO_TIMEOUT,
087:                                timeout);
088:
089:            }
090:
091:            /**
092:             * Tests if Nagle's algorithm is to be used.  
093:             *
094:             * @return <tt>true</tt> if the Nagle's algorithm is to NOT be used
095:             *   (that is enable TCP_NODELAY), <tt>false</tt> otherwise.
096:             */
097:            public static boolean getTcpNoDelay(final HttpParams params) {
098:                if (params == null) {
099:                    throw new IllegalArgumentException(
100:                            "HTTP parameters may not be null");
101:                }
102:                return params.getBooleanParameter(
103:                        CoreConnectionPNames.TCP_NODELAY, true);
104:            }
105:
106:            /**
107:             * Determines whether Nagle's algorithm is to be used. The Nagle's algorithm 
108:             * tries to conserve bandwidth by minimizing the number of segments that are 
109:             * sent. When applications wish to decrease network latency and increase 
110:             * performance, they can disable Nagle's algorithm (that is enable TCP_NODELAY). 
111:             * Data will be sent earlier, at the cost of an increase in bandwidth consumption. 
112:             *
113:             * @param value <tt>true</tt> if the Nagle's algorithm is to NOT be used
114:             *   (that is enable TCP_NODELAY), <tt>false</tt> otherwise.
115:             */
116:            public static void setTcpNoDelay(final HttpParams params,
117:                    boolean value) {
118:                if (params == null) {
119:                    throw new IllegalArgumentException(
120:                            "HTTP parameters may not be null");
121:                }
122:                params.setBooleanParameter(CoreConnectionPNames.TCP_NODELAY,
123:                        value);
124:            }
125:
126:            public static int getSocketBufferSize(final HttpParams params) {
127:                if (params == null) {
128:                    throw new IllegalArgumentException(
129:                            "HTTP parameters may not be null");
130:                }
131:                return params.getIntParameter(
132:                        CoreConnectionPNames.SOCKET_BUFFER_SIZE, -1);
133:            }
134:
135:            public static void setSocketBufferSize(final HttpParams params,
136:                    int size) {
137:                if (params == null) {
138:                    throw new IllegalArgumentException(
139:                            "HTTP parameters may not be null");
140:                }
141:                params.setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE,
142:                        size);
143:            }
144:
145:            /**
146:             * Returns linger-on-close timeout. Value <tt>0</tt> implies that the option is 
147:             * disabled. Value <tt>-1</tt> implies that the JRE default is used.
148:             * 
149:             * @return the linger-on-close timeout
150:             */
151:            public static int getLinger(final HttpParams params) {
152:                if (params == null) {
153:                    throw new IllegalArgumentException(
154:                            "HTTP parameters may not be null");
155:                }
156:                return params.getIntParameter(CoreConnectionPNames.SO_LINGER,
157:                        -1);
158:            }
159:
160:            /**
161:             * Returns linger-on-close timeout. This option disables/enables immediate return 
162:             * from a close() of a TCP Socket. Enabling this option with a non-zero Integer 
163:             * timeout means that a close() will block pending the transmission and 
164:             * acknowledgement of all data written to the peer, at which point the socket is 
165:             * closed gracefully. Value <tt>0</tt> implies that the option is 
166:             * disabled. Value <tt>-1</tt> implies that the JRE default is used.
167:             *
168:             * @param value the linger-on-close timeout
169:             */
170:            public static void setLinger(final HttpParams params, int value) {
171:                if (params == null) {
172:                    throw new IllegalArgumentException(
173:                            "HTTP parameters may not be null");
174:                }
175:                params.setIntParameter(CoreConnectionPNames.SO_LINGER, value);
176:            }
177:
178:            /**
179:             * Returns the timeout until a connection is etablished. A value of zero 
180:             * means the timeout is not used. The default value is zero.
181:             * 
182:             * @return timeout in milliseconds.
183:             */
184:            public static int getConnectionTimeout(final HttpParams params) {
185:                if (params == null) {
186:                    throw new IllegalArgumentException(
187:                            "HTTP parameters may not be null");
188:                }
189:                return params.getIntParameter(
190:                        CoreConnectionPNames.CONNECTION_TIMEOUT, 0);
191:            }
192:
193:            /**
194:             * Sets the timeout until a connection is etablished. A value of zero 
195:             * means the timeout is not used. The default value is zero.
196:             * 
197:             * @param timeout Timeout in milliseconds.
198:             */
199:            public static void setConnectionTimeout(final HttpParams params,
200:                    int timeout) {
201:                if (params == null) {
202:                    throw new IllegalArgumentException(
203:                            "HTTP parameters may not be null");
204:                }
205:                params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
206:                        timeout);
207:            }
208:
209:            /**
210:             * Tests whether stale connection check is to be used. Disabling 
211:             * stale connection check may result in slight performance improvement 
212:             * at the risk of getting an I/O error when executing a request over a
213:             * connection that has been closed at the server side. 
214:             * 
215:             * @return <tt>true</tt> if stale connection check is to be used, 
216:             *   <tt>false</tt> otherwise.
217:             */
218:            public static boolean isStaleCheckingEnabled(final HttpParams params) {
219:                if (params == null) {
220:                    throw new IllegalArgumentException(
221:                            "HTTP parameters may not be null");
222:                }
223:                return params.getBooleanParameter(
224:                        CoreConnectionPNames.STALE_CONNECTION_CHECK, true);
225:            }
226:
227:            /**
228:             * Defines whether stale connection check is to be used. Disabling 
229:             * stale connection check may result in slight performance improvement 
230:             * at the risk of getting an I/O error when executing a request over a
231:             * connection that has been closed at the server side. 
232:             * 
233:             * @param value <tt>true</tt> if stale connection check is to be used, 
234:             *   <tt>false</tt> otherwise.
235:             */
236:            public static void setStaleCheckingEnabled(final HttpParams params,
237:                    boolean value) {
238:                if (params == null) {
239:                    throw new IllegalArgumentException(
240:                            "HTTP parameters may not be null");
241:                }
242:                params.setBooleanParameter(
243:                        CoreConnectionPNames.STALE_CONNECTION_CHECK, value);
244:            }
245:
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.