comparison src/org/eclipse/jetty/http/HttpBuffersImpl.java @ 802:3428c60d7cfc

replace jetty jars with source
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 07 Sep 2016 21:15:48 -0600
parents
children 688b875e18ba
comparison
equal deleted inserted replaced
801:6a21393191c1 802:3428c60d7cfc
1 //
2 // ========================================================================
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.http;
20
21 import org.eclipse.jetty.io.Buffers;
22 import org.eclipse.jetty.io.BuffersFactory;
23 import org.eclipse.jetty.util.component.AbstractLifeCycle;
24
25 /* ------------------------------------------------------------ */
26 /** Abstract Buffer pool.
27 * simple unbounded pool of buffers for header, request and response sizes.
28 *
29 */
30 public class HttpBuffersImpl extends AbstractLifeCycle implements HttpBuffers
31 {
32 private int _requestBufferSize=16*1024;
33 private int _requestHeaderSize=6*1024;
34 private int _responseBufferSize=32*1024;
35 private int _responseHeaderSize=6*1024;
36 private int _maxBuffers=1024;
37
38 private Buffers.Type _requestBufferType=Buffers.Type.BYTE_ARRAY;
39 private Buffers.Type _requestHeaderType=Buffers.Type.BYTE_ARRAY;
40 private Buffers.Type _responseBufferType=Buffers.Type.BYTE_ARRAY;
41 private Buffers.Type _responseHeaderType=Buffers.Type.BYTE_ARRAY;
42
43 private Buffers _requestBuffers;
44 private Buffers _responseBuffers;
45
46
47 public HttpBuffersImpl()
48 {
49 super();
50 }
51
52 /**
53 * @return the requestBufferSize
54 */
55 public int getRequestBufferSize()
56 {
57 return _requestBufferSize;
58 }
59
60 /**
61 * @param requestBufferSize the requestBufferSize to set
62 */
63 public void setRequestBufferSize(int requestBufferSize)
64 {
65 _requestBufferSize = requestBufferSize;
66 }
67
68 /**
69 * @return the requestHeaderSize
70 */
71 public int getRequestHeaderSize()
72 {
73 return _requestHeaderSize;
74 }
75
76 /**
77 * @param requestHeaderSize the requestHeaderSize to set
78 */
79 public void setRequestHeaderSize(int requestHeaderSize)
80 {
81 _requestHeaderSize = requestHeaderSize;
82 }
83
84 /**
85 * @return the responseBufferSize
86 */
87 public int getResponseBufferSize()
88 {
89 return _responseBufferSize;
90 }
91
92 /**
93 * @param responseBufferSize the responseBufferSize to set
94 */
95 public void setResponseBufferSize(int responseBufferSize)
96 {
97 _responseBufferSize = responseBufferSize;
98 }
99
100 /**
101 * @return the responseHeaderSize
102 */
103 public int getResponseHeaderSize()
104 {
105 return _responseHeaderSize;
106 }
107
108 /**
109 * @param responseHeaderSize the responseHeaderSize to set
110 */
111 public void setResponseHeaderSize(int responseHeaderSize)
112 {
113 _responseHeaderSize = responseHeaderSize;
114 }
115
116 /**
117 * @return the requestBufferType
118 */
119 public Buffers.Type getRequestBufferType()
120 {
121 return _requestBufferType;
122 }
123
124 /**
125 * @param requestBufferType the requestBufferType to set
126 */
127 public void setRequestBufferType(Buffers.Type requestBufferType)
128 {
129 _requestBufferType = requestBufferType;
130 }
131
132 /**
133 * @return the requestHeaderType
134 */
135 public Buffers.Type getRequestHeaderType()
136 {
137 return _requestHeaderType;
138 }
139
140 /**
141 * @param requestHeaderType the requestHeaderType to set
142 */
143 public void setRequestHeaderType(Buffers.Type requestHeaderType)
144 {
145 _requestHeaderType = requestHeaderType;
146 }
147
148 /**
149 * @return the responseBufferType
150 */
151 public Buffers.Type getResponseBufferType()
152 {
153 return _responseBufferType;
154 }
155
156 /**
157 * @param responseBufferType the responseBufferType to set
158 */
159 public void setResponseBufferType(Buffers.Type responseBufferType)
160 {
161 _responseBufferType = responseBufferType;
162 }
163
164 /**
165 * @return the responseHeaderType
166 */
167 public Buffers.Type getResponseHeaderType()
168 {
169 return _responseHeaderType;
170 }
171
172 /**
173 * @param responseHeaderType the responseHeaderType to set
174 */
175 public void setResponseHeaderType(Buffers.Type responseHeaderType)
176 {
177 _responseHeaderType = responseHeaderType;
178 }
179
180 /**
181 * @param requestBuffers the requestBuffers to set
182 */
183 public void setRequestBuffers(Buffers requestBuffers)
184 {
185 _requestBuffers = requestBuffers;
186 }
187
188 /**
189 * @param responseBuffers the responseBuffers to set
190 */
191 public void setResponseBuffers(Buffers responseBuffers)
192 {
193 _responseBuffers = responseBuffers;
194 }
195
196 @Override
197 protected void doStart()
198 throws Exception
199 {
200 _requestBuffers=BuffersFactory.newBuffers(_requestHeaderType,_requestHeaderSize,_requestBufferType,_requestBufferSize,_requestBufferType,getMaxBuffers());
201 _responseBuffers=BuffersFactory.newBuffers(_responseHeaderType,_responseHeaderSize,_responseBufferType,_responseBufferSize,_responseBufferType,getMaxBuffers());
202 super.doStart();
203 }
204
205 @Override
206 protected void doStop()
207 throws Exception
208 {
209 _requestBuffers=null;
210 _responseBuffers=null;
211 }
212
213 public Buffers getRequestBuffers()
214 {
215 return _requestBuffers;
216 }
217
218
219 public Buffers getResponseBuffers()
220 {
221 return _responseBuffers;
222 }
223
224 public void setMaxBuffers(int maxBuffers)
225 {
226 _maxBuffers = maxBuffers;
227 }
228
229 public int getMaxBuffers()
230 {
231 return _maxBuffers;
232 }
233
234 public String toString()
235 {
236 return _requestBuffers+"/"+_responseBuffers;
237 }
238 }