1 /*
2 * ====================================================================
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 * ====================================================================
20 *
21 * This software consists of voluntary contributions made by many
22 * individuals on behalf of the Apache Software Foundation. For more
23 * information on the Apache Software Foundation, please see
24 * <http://www.apache.org/>.
25 *
26 */
27
28 package org.apache.http.nio.params;
29
30 import org.apache.http.impl.nio.reactor.IOReactorConfig;
31 import org.apache.http.params.HttpParams;
32 import org.apache.http.util.Args;
33
34 /**
35 * Utility class for accessing I/O reactor parameters in {@link HttpParams}.
36 *
37 * @since 4.0
38 *
39 * @see NIOReactorPNames
40 *
41 * @deprecated (4.2) use {@link IOReactorConfig}
42 */
43 @Deprecated
44 public final class NIOReactorParams implements NIOReactorPNames {
45
46 private NIOReactorParams() {
47 super();
48 }
49
50 /**
51 * Obtains the value of {@link NIOReactorPNames#CONTENT_BUFFER_SIZE} parameter.
52 * If not set, defaults to <code>4096</code>.
53 *
54 * @param params HTTP parameters.
55 * @return content buffer size.
56 */
57 public static int getContentBufferSize(final HttpParams params) {
58 Args.notNull(params, "HTTP parameters");
59 return params.getIntParameter(CONTENT_BUFFER_SIZE, 4096);
60 }
61
62 /**
63 * Sets value of the {@link NIOReactorPNames#CONTENT_BUFFER_SIZE} parameter.
64 *
65 * @param params HTTP parameters.
66 * @param size content buffer size.
67 */
68 public static void setContentBufferSize(final HttpParams params, final int size) {
69 Args.notNull(params, "HTTP parameters");
70 params.setIntParameter(CONTENT_BUFFER_SIZE, size);
71 }
72
73 /**
74 * Obtains the value of {@link NIOReactorPNames#SELECT_INTERVAL} parameter.
75 * If not set, defaults to <code>1000</code>.
76 *
77 * @param params HTTP parameters.
78 * @return I/O select interval in milliseconds.
79 */
80 public static long getSelectInterval(final HttpParams params) {
81 Args.notNull(params, "HTTP parameters");
82 return params.getLongParameter(SELECT_INTERVAL, 1000);
83 }
84
85 /**
86 * Sets value of the {@link NIOReactorPNames#SELECT_INTERVAL} parameter.
87 *
88 * @param params HTTP parameters.
89 * @param ms I/O select interval in milliseconds.
90 */
91 public static void setSelectInterval(final HttpParams params, final long ms) {
92 Args.notNull(params, "HTTP parameters");
93 params.setLongParameter(SELECT_INTERVAL, ms);
94 }
95
96 /**
97 * Obtains the value of {@link NIOReactorPNames#GRACE_PERIOD} parameter.
98 * If not set, defaults to <code>500</code>.
99 *
100 * @param params HTTP parameters.
101 * @return shutdown grace period in milliseconds.
102 */
103 public static long getGracePeriod(final HttpParams params) {
104 Args.notNull(params, "HTTP parameters");
105 return params.getLongParameter(GRACE_PERIOD, 500);
106 }
107
108 /**
109 * Sets value of the {@link NIOReactorPNames#GRACE_PERIOD} parameter.
110 *
111 * @param params HTTP parameters.
112 * @param ms shutdown grace period in milliseconds.
113 */
114 public static void setGracePeriod(final HttpParams params, final long ms) {
115 Args.notNull(params, "HTTP parameters");
116 params.setLongParameter(GRACE_PERIOD, ms);
117 }
118
119 /**
120 * Obtains the value of {@link NIOReactorPNames#INTEREST_OPS_QUEUEING} parameter.
121 * If not set, defaults to <code>false</code>.
122 *
123 * @param params HTTP parameters.
124 * @return interest ops queuing flag.
125 *
126 * @since 4.1
127 */
128 public static boolean getInterestOpsQueueing(final HttpParams params) {
129 Args.notNull(params, "HTTP parameters");
130 return params.getBooleanParameter(INTEREST_OPS_QUEUEING, false);
131 }
132
133 /**
134 * Sets value of the {@link NIOReactorPNames#INTEREST_OPS_QUEUEING} parameter.
135 *
136 * @param params HTTP parameters.
137 * @param interestOpsQueueing interest ops queuing.
138 *
139 * @since 4.1
140 */
141 public static void setInterestOpsQueueing(
142 final HttpParams params, final boolean interestOpsQueueing) {
143 Args.notNull(params, "HTTP parameters");
144 params.setBooleanParameter(INTEREST_OPS_QUEUEING, interestOpsQueueing);
145 }
146
147 }