Source Code Cross Referenced for HttpConnectionManagerParams.java in  » Net » Apache-common-HttpClient » org » apache » commons » httpclient » 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 » Apache common HttpClient » org.apache.commons.httpclient.params 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java,v 1.9 2004/09/13 16:25:20 olegk Exp $
003:         * $Revision: 480424 $
004:         * $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
005:         *
006:         * ====================================================================
007:         *
008:         *  Licensed to the Apache Software Foundation (ASF) under one or more
009:         *  contributor license agreements.  See the NOTICE file distributed with
010:         *  this work for additional information regarding copyright ownership.
011:         *  The ASF licenses this file to You under the Apache License, Version 2.0
012:         *  (the "License"); you may not use this file except in compliance with
013:         *  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, software
018:         *  distributed under the License is distributed on an "AS IS" BASIS,
019:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
020:         *  See the License for the specific language governing permissions and
021:         *  limitations under the License.
022:         * ====================================================================
023:         *
024:         * This software consists of voluntary contributions made by many
025:         * individuals on behalf of the Apache Software Foundation.  For more
026:         * information on the Apache Software Foundation, please see
027:         * <http://www.apache.org/>.
028:         *
029:         */
030:
031:        package org.apache.commons.httpclient.params;
032:
033:        import java.util.HashMap;
034:        import java.util.Map;
035:
036:        import org.apache.commons.httpclient.HostConfiguration;
037:        import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
038:
039:        /**
040:         * This class represents a collection of HTTP protocol parameters applicable to 
041:         * {@link org.apache.commons.httpclient.HttpConnectionManager HTTP connection managers}. 
042:         * Protocol parameters may be linked together to form a hierarchy. If a particular 
043:         * parameter value has not been explicitly defined in the collection itself, its 
044:         * value will be drawn from the parent collection of parameters.
045:         * 
046:         * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
047:         * @author Michael Becke
048:         * 
049:         * @version $Revision: 480424 $
050:         * 
051:         * @since 3.0
052:         */
053:        public class HttpConnectionManagerParams extends HttpConnectionParams {
054:
055:            /** 
056:             * Defines the maximum number of connections allowed per host configuration. 
057:             * These values only apply to the number of connections from a particular instance 
058:             * of HttpConnectionManager.
059:             * <p>
060:             * This parameter expects a value of type {@link java.util.Map}.  The value
061:             * should map instances of {@link org.apache.commons.httpclient.HostConfiguration}
062:             * to {@link Integer integers}.  The default value can be specified using
063:             * {@link org.apache.commons.httpclient.HostConfiguration#ANY_HOST_CONFIGURATION}.
064:             * </p>
065:             */
066:            public static final String MAX_HOST_CONNECTIONS = "http.connection-manager.max-per-host";
067:
068:            /** 
069:             * Defines the maximum number of connections allowed overall. This value only applies
070:             * to the number of connections from a particular instance of HttpConnectionManager.
071:             * <p>
072:             * This parameter expects a value of type {@link Integer}.
073:             * </p>
074:             */
075:            public static final String MAX_TOTAL_CONNECTIONS = "http.connection-manager.max-total";
076:
077:            /**
078:             * Sets the default maximum number of connections allowed for a given
079:             * host config.
080:             *
081:             * @param maxHostConnections The default maximum.
082:             * 
083:             * @see #MAX_HOST_CONNECTIONS
084:             */
085:            public void setDefaultMaxConnectionsPerHost(int maxHostConnections) {
086:                setMaxConnectionsPerHost(
087:                        HostConfiguration.ANY_HOST_CONFIGURATION,
088:                        maxHostConnections);
089:            }
090:
091:            /**
092:             * Sets the maximum number of connections to be used for the given host config.
093:             * 
094:             * @param hostConfiguration The host config to set the maximum for.  Use 
095:             * {@link HostConfiguration#ANY_HOST_CONFIGURATION} to configure the default value
096:             * per host.
097:             * @param maxHostConnections The maximum number of connections, <code>> 0</code>
098:             * 
099:             * @see #MAX_HOST_CONNECTIONS
100:             */
101:            public void setMaxConnectionsPerHost(
102:                    HostConfiguration hostConfiguration, int maxHostConnections) {
103:
104:                if (maxHostConnections <= 0) {
105:                    throw new IllegalArgumentException(
106:                            "maxHostConnections must be greater than 0");
107:                }
108:
109:                Map currentValues = (Map) getParameter(MAX_HOST_CONNECTIONS);
110:                // param values are meant to be immutable so we'll make a copy
111:                // to modify
112:                Map newValues = null;
113:                if (currentValues == null) {
114:                    newValues = new HashMap();
115:                } else {
116:                    newValues = new HashMap(currentValues);
117:                }
118:                newValues.put(hostConfiguration,
119:                        new Integer(maxHostConnections));
120:                setParameter(MAX_HOST_CONNECTIONS, newValues);
121:            }
122:
123:            /**
124:             * Gets the default maximum number of connections allowed for a given
125:             * host config.
126:             *
127:             * @return The default maximum.
128:             * 
129:             * @see #MAX_HOST_CONNECTIONS
130:             */
131:            public int getDefaultMaxConnectionsPerHost() {
132:                return getMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION);
133:            }
134:
135:            /**
136:             * Gets the maximum number of connections to be used for a particular host config.  If
137:             * the value has not been specified for the given host the default value will be
138:             * returned.
139:             * 
140:             * @param hostConfiguration The host config.
141:             * @return The maximum number of connections to be used for the given host config.
142:             * 
143:             * @see #MAX_HOST_CONNECTIONS
144:             */
145:            public int getMaxConnectionsPerHost(
146:                    HostConfiguration hostConfiguration) {
147:
148:                Map m = (Map) getParameter(MAX_HOST_CONNECTIONS);
149:                if (m == null) {
150:                    // MAX_HOST_CONNECTIONS have not been configured, using the default value
151:                    return MultiThreadedHttpConnectionManager.DEFAULT_MAX_HOST_CONNECTIONS;
152:                } else {
153:                    Integer max = (Integer) m.get(hostConfiguration);
154:                    if (max == null
155:                            && hostConfiguration != HostConfiguration.ANY_HOST_CONFIGURATION) {
156:                        // the value has not been configured specifically for this host config,
157:                        // use the default value
158:                        return getMaxConnectionsPerHost(HostConfiguration.ANY_HOST_CONFIGURATION);
159:                    } else {
160:                        return (max == null ? MultiThreadedHttpConnectionManager.DEFAULT_MAX_HOST_CONNECTIONS
161:                                : max.intValue());
162:                    }
163:                }
164:            }
165:
166:            /**
167:             * Sets the maximum number of connections allowed.
168:             *
169:             * @param maxTotalConnections The maximum number of connections allowed.
170:             * 
171:             * @see #MAX_TOTAL_CONNECTIONS
172:             */
173:            public void setMaxTotalConnections(int maxTotalConnections) {
174:                setIntParameter(
175:                        HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS,
176:                        maxTotalConnections);
177:            }
178:
179:            /**
180:             * Gets the maximum number of connections allowed.
181:             *
182:             * @return The maximum number of connections allowed.
183:             * 
184:             * @see #MAX_TOTAL_CONNECTIONS
185:             */
186:            public int getMaxTotalConnections() {
187:                return getIntParameter(
188:                        HttpConnectionManagerParams.MAX_TOTAL_CONNECTIONS,
189:                        MultiThreadedHttpConnectionManager.DEFAULT_MAX_TOTAL_CONNECTIONS);
190:            }
191:
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.