001: /*
002: * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0-beta1/module-nio/src/main/java/org/apache/http/nio/params/NIOReactorParams.java $
003: * $Revision: 613298 $
004: * $Date: 2008-01-18 23:09:22 +0100 (Fri, 18 Jan 2008) $
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.nio.params;
033:
034: import org.apache.http.params.HttpParams;
035:
036: /**
037: * This class implements an adaptor around the {@link HttpParams} interface
038: * to simplify manipulation of the NIO reactor specific parameters.
039: * <br/>
040: * Note that the <i>implements</i> relation to {@link NIOReactorPNames}
041: * is for compatibility with existing application code only. References to
042: * the parameter names should use the interface, not this class.
043: *
044: * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
045: *
046: * @version $Revision: 613298 $
047: *
048: * @since 4.0
049: *
050: * @see NIOReactorPNames
051: */
052: public final class NIOReactorParams implements NIOReactorPNames {
053:
054: private NIOReactorParams() {
055: super ();
056: }
057:
058: public static int getContentBufferSize(final HttpParams params) {
059: if (params == null) {
060: throw new IllegalArgumentException(
061: "HTTP parameters may not be null");
062: }
063: return params.getIntParameter(CONTENT_BUFFER_SIZE, 1024);
064: }
065:
066: public static void setContentBufferSize(final HttpParams params,
067: int size) {
068: if (params == null) {
069: throw new IllegalArgumentException(
070: "HTTP parameters may not be null");
071: }
072: params.setIntParameter(CONTENT_BUFFER_SIZE, size);
073: }
074:
075: public static long getSelectInterval(final HttpParams params) {
076: if (params == null) {
077: throw new IllegalArgumentException(
078: "HTTP parameters may not be null");
079: }
080: return params.getLongParameter(SELECT_INTERVAL, 1000);
081: }
082:
083: public static void setSelectInterval(final HttpParams params,
084: long ms) {
085: if (params == null) {
086: throw new IllegalArgumentException(
087: "HTTP parameters may not be null");
088: }
089: params.setLongParameter(SELECT_INTERVAL, ms);
090: }
091:
092: public static long getGracePeriod(final HttpParams params) {
093: if (params == null) {
094: throw new IllegalArgumentException(
095: "HTTP parameters may not be null");
096: }
097: return params.getLongParameter(GRACE_PERIOD, 500);
098: }
099:
100: public static void setGracePeriod(final HttpParams params, long ms) {
101: if (params == null) {
102: throw new IllegalArgumentException(
103: "HTTP parameters may not be null");
104: }
105: params.setLongParameter(GRACE_PERIOD, ms);
106: }
107:
108: }
|