001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *  http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    package org.apache.geronimo.tomcat.connector;
020    
021    import java.util.Map;
022    
023    import org.apache.geronimo.gbean.GBeanInfo;
024    import org.apache.geronimo.gbean.GBeanInfoBuilder;
025    import org.apache.geronimo.management.geronimo.WebManager;
026    import org.apache.geronimo.system.serverinfo.ServerInfo;
027    import org.apache.geronimo.tomcat.TomcatContainer;
028    
029    public class Http11NIOConnectorGBean extends AbstractHttp11ConnectorGBean implements Http11NIOProtocol{
030    
031        public Http11NIOConnectorGBean(String name,  Map initParams, String host, int port, TomcatContainer container, ServerInfo serverInfo) throws Exception {
032            super(name, initParams, "org.apache.coyote.http11.Http11NioProtocol", host, port, container, serverInfo);
033        }
034        
035        public int getDefaultPort() {
036            return 80; 
037        }  
038        
039        public String getGeronimoProtocol(){
040            return WebManager.PROTOCOL_HTTP;
041        }
042    
043        public int getAcceptorThreadCount() {
044            Object value = connector.getAttribute("acceptorThreadCount");
045            return value == null ? 1 : Integer.parseInt(value.toString());
046        }
047    
048        public int getAcceptorThreadPriority() {
049            Object value = connector.getAttribute("acceptorThreadCount");
050            return value == null ? Thread.NORM_PRIORITY : Integer.parseInt(value.toString());
051        }
052    
053        public boolean getCommand_line_options() {
054            Object value = connector.getAttribute("command-line-options");
055            return value == null ? true : new Boolean(value.toString()).booleanValue();
056        }
057    
058        public int getOomParachute() {
059            Object value = connector.getAttribute("oomParachute");
060            return value == null ? 1048576 : Integer.parseInt(value.toString());
061        }
062    
063        public int getPollerThreadCount() {
064            Object value = connector.getAttribute("pollerThreadCount");
065            return value == null ? 1 : Integer.parseInt(value.toString());
066        }
067        
068        public int getPollerThreadPriority() {
069            Object value = connector.getAttribute("pollerThreadCount");
070            return value == null ? Thread.NORM_PRIORITY : Integer.parseInt(value.toString());
071        }
072    
073        public int getProcessCache() {
074            Object value = connector.getAttribute("processCache");
075            return value == null ? 200 : Integer.parseInt(value.toString());
076        }
077    
078        public int getSelectorPool_maxSelectors() {
079            Object value = connector.getAttribute("selectorPool.maxSelectors");
080            return value == null ? 200 : Integer.parseInt(value.toString());
081        }
082    
083        public int getSelectorPool_maxSpareSelectors() {
084            Object value = connector.getAttribute("selectorPool.maxSpareSelectors");
085            return value == null ? -1 : Integer.parseInt(value.toString());
086        }
087    
088        public int getSelectorTimeout() {
089            Object value = connector.getAttribute("selectorTimeout");
090            return value == null ? 1000 : Integer.parseInt(value.toString());
091        }
092    
093        public int getSocket_appReadBufSize() {
094            Object value = connector.getAttribute("socket.appReadBufSize");
095            return value == null ? 8192 : Integer.parseInt(value.toString());
096        }
097    
098        public int getSocket_appWriteBufSize() {
099            Object value = connector.getAttribute("socket.appWriteBufSize");
100            return value == null ? 8192 : Integer.parseInt(value.toString());
101        }
102    
103        public int getSocket_bufferPool() {
104            Object value = connector.getAttribute("socket.bufferPool");
105            return value == null ? 500 : Integer.parseInt(value.toString());
106        }
107    
108        public int getSocket_bufferPoolSize() {
109            Object value = connector.getAttribute("socket.bufferPoolSize");
110            return value == null ? 104857600 : Integer.parseInt(value.toString());
111        }
112    
113        public boolean getSocket_directBuffer() {
114            Object value = connector.getAttribute("socket.directBuffer");
115            return value == null ? false : new Boolean(value.toString()).booleanValue();
116        }
117    
118        public int getSocket_eventCache() {
119            Object value = connector.getAttribute("socket.eventCache");
120            return value == null ? 500 : Integer.parseInt(value.toString());
121        }
122    
123        public int getSocket_keyCache() {
124            Object value = connector.getAttribute("socket.keyCache");
125            return value == null ? 500 : Integer.parseInt(value.toString());
126        }
127    
128        public boolean getSocket_ooBInline() {
129            Object value = connector.getAttribute("socket.ooBInline");
130            return value == null ? true : new Boolean(value.toString()).booleanValue();
131        }
132    
133        public int getSocket_performanceBandwidth() {
134            Object value = connector.getAttribute("socket.performanceBandwidth");
135            return value == null ? 1 : Integer.parseInt(value.toString());
136        }
137    
138        public int getSocket_performanceConnectionTime() {
139            Object value = connector.getAttribute("socket.performanceConnectionTime");
140            return value == null ? 1 : Integer.parseInt(value.toString());
141        }
142    
143        public int getSocket_performanceLatency() {
144            Object value = connector.getAttribute("socket.performanceLatency");
145            return value == null ? 0 : Integer.parseInt(value.toString());
146        }
147    
148        public int getSocket_processorCache() {
149            Object value = connector.getAttribute("socket.processorCache");
150            return value == null ? 500 : Integer.parseInt(value.toString());
151        }
152    
153        public int getSocket_rxBufSize() {
154            Object value = connector.getAttribute("socket.rxBufSize");
155            return value == null ? 25188 : Integer.parseInt(value.toString());
156        }
157    
158        public boolean getSocket_soKeepAlive() {
159            Object value = connector.getAttribute("socket.soKeepAlive");
160            return value == null ? false : new Boolean(value.toString()).booleanValue();
161        }
162    
163        public boolean getSocket_soLingerOn() {
164            Object value = connector.getAttribute("socket.soLingerOn");
165            return value == null ? true : new Boolean(value.toString()).booleanValue();
166        }
167    
168        public int getSocket_soLingerTime() {
169            Object value = connector.getAttribute("socket.soLingerTime");
170            return value == null ? 25 : Integer.parseInt(value.toString());
171        }
172    
173        public boolean getSocket_soReuseAddress() {
174            Object value = connector.getAttribute("socket.soReuseAddress");
175            return value == null ? true : new Boolean(value.toString()).booleanValue();
176        }
177    
178        public int getSocket_soTimeout() {
179            Object value = connector.getAttribute("socket.soTimeout");
180            return value == null ? 5000 : Integer.parseInt(value.toString());
181        }
182    
183        public int getSocket_soTrafficClass() {
184            Object value = connector.getAttribute("socket.soTrafficClass");
185            return value == null ? (0x04 | 0x08 | 0x010) : new Integer(value.toString()).intValue();
186        }
187    
188        public boolean getSocket_tcpNoDelay() {
189            Object value = connector.getAttribute("socket.tcpNoDelay");
190            return value == null ? false : new Boolean(value.toString()).booleanValue();
191        }
192    
193        public int getSocket_txBufSize() {
194            Object value = connector.getAttribute("socket.txBufSize");
195            return value == null ? 43800 : Integer.parseInt(value.toString());
196        }
197    
198        public boolean getUseComet() {
199            Object value = connector.getAttribute("useComet");
200            return value == null ? true : new Boolean(value.toString()).booleanValue();
201        }
202    
203        public boolean getUseExecutor() {
204            Object value = connector.getAttribute("useExecutor");
205            return value == null ? true : new Boolean(value.toString()).booleanValue();
206        }
207    
208        public boolean getUseSendfile() {
209            Object value = connector.getAttribute("useSendfile");
210            return value == null ? true : new Boolean(value.toString()).booleanValue();
211        }
212    
213        public void setAcceptorThreadCount(int acceptorThreadCount) {
214            connector.setAttribute("acceptorThreadCount", new Integer(acceptorThreadCount));
215        }
216    
217        public void setAcceptorThreadPriority(int acceptorThreadPriority) {
218            connector.setAttribute("acceptorThreadPriority", new Integer(acceptorThreadPriority));
219        }
220    
221        public void setCommand_line_options(boolean command_line_options) {
222            connector.setAttribute("command-line-options", new Boolean(command_line_options));
223        }
224    
225        public void setOomParachute(int oomParachute) {
226            connector.setAttribute("oomParachute", new Integer(oomParachute));
227        }
228    
229        public void setPollerThreadCount(int pollerThreadCount) {
230            connector.setAttribute("pollerThreadCount", new Integer(pollerThreadCount));
231        }
232        
233        public void setPollerThreadPriority(int pollerThreadPriority) {
234            connector.setAttribute("pollerThreadPriority", new Integer(pollerThreadPriority));
235        }
236    
237        public void setProcessCache(int processCache) {
238            connector.setAttribute("processCache", new Integer(processCache));
239        }
240    
241        public void setSelectorPool_maxSelectors(int selectorPool_maxSelectors) {
242            connector.setAttribute("selectorPool.maxSelectors", new Integer(selectorPool_maxSelectors));
243        }
244    
245        public void setSelectorPool_maxSpareSelectors(int selectorPool_maxSpareSelectors) {
246            connector.setAttribute("selectorPool.maxSpareSelectors", new Integer(selectorPool_maxSpareSelectors));
247        }
248    
249        public void setSelectorTimeout(int selectorTimeout) {
250            connector.setAttribute("selectorTimeout", new Integer(selectorTimeout));
251        }
252    
253        public void setSocket_appReadBufSize(int socket_appReadBufSize) {
254            connector.setAttribute("socket.appReadBufSize", new Integer(socket_appReadBufSize));
255        }
256    
257        public void setSocket_appWriteBufSize(int socket_appWriteBufSize) {
258            connector.setAttribute("socket.appWriteBufSize", new Integer(socket_appWriteBufSize));
259        }
260    
261        public void setSocket_bufferPool(int socket_bufferPool) {
262            connector.setAttribute("socket.bufferPool", new Integer(socket_bufferPool));
263        }
264    
265        public void setSocket_bufferPoolSize(int socket_bufferPoolSize) {
266            connector.setAttribute("socket.bufferPoolSize", new Integer(socket_bufferPoolSize));
267        }
268    
269        public void setSocket_directBuffer(boolean socket_directBuffer) {
270            connector.setAttribute("socket.directBuffer", new Boolean(socket_directBuffer));
271        }
272    
273        public void setSocket_eventCache(int socket_eventCache) {
274            connector.setAttribute("socket.eventCache", new Integer(socket_eventCache));
275        }
276    
277        public void setSocket_keyCache(int socket_keyCache) {
278            connector.setAttribute("socket.keyCache", new Integer(socket_keyCache));
279        }
280    
281        public void setSocket_ooBInline(boolean socket_ooBInline) {
282            connector.setAttribute("socket.ooBInline", new Boolean(socket_ooBInline));
283        }
284    
285        public void setSocket_performanceBandwidth(int socket_performanceBandwidth) {
286            connector.setAttribute("socket.performanceBandwidth", new Integer(socket_performanceBandwidth));
287        }
288    
289        public void setSocket_performanceConnectionTime(int socket_performanceConnectionTime) {
290            connector.setAttribute("socket.performanceConnectionTime", new Integer(socket_performanceConnectionTime));
291        }
292    
293        public void setSocket_performanceLatency(int socket_performanceLatency) {
294            connector.setAttribute("socket.performanceLatency", new Integer(socket_performanceLatency));
295        }
296    
297        public void setSocket_processorCache(int socket_processorCache) {
298            connector.setAttribute("socket.processorCache", new Integer(socket_processorCache));
299        }
300    
301        public void setSocket_rxBufSize(int socket_rxBufSize) {
302            connector.setAttribute("socket.rxBufSize", new Integer(socket_rxBufSize));
303        }
304    
305        public void setSocket_soKeepAlive(boolean socket_soKeepAlive) {
306            connector.setAttribute("socket.soKeepAlive", new Boolean(socket_soKeepAlive));
307        }
308    
309        public void setSocket_soLingerOn(boolean socket_soLingerOn) {
310            connector.setAttribute("socket.soLingerOn", new Boolean(socket_soLingerOn));
311        }
312    
313        public void setSocket_soLingerTime(int socket_soLingerTime) {
314            connector.setAttribute("socket.soLingerTime", new Integer(socket_soLingerTime));
315        }
316    
317        public void setSocket_soReuseAddress(boolean socket_soReuseAddress) {
318            connector.setAttribute("socket.soReuseAddress", new Boolean(socket_soReuseAddress));
319        }
320    
321        public void setSocket_soTimeout(int socket_soTimeout) {
322            connector.setAttribute("socket.soTimeout", new Integer(socket_soTimeout));
323        }
324    
325        public void setSocket_soTrafficClass(int socket_soTrafficClass) {
326            connector.setAttribute("socket.soTrafficClass", new Integer(socket_soTrafficClass));
327        }
328    
329        public void setSocket_tcpNoDelay(boolean socket_tcpNoDelay) {
330            connector.setAttribute("socket.tcpNoDelay", new Boolean(socket_tcpNoDelay));
331        }
332    
333        public void setSocket_txBufSize(int socket_txBufSize) {
334            connector.setAttribute("socket.txBufSize", new Integer(socket_txBufSize));
335        }
336    
337        public void setUseComet(boolean useComet) {
338            connector.setAttribute("useExecutor", new Boolean(useComet));
339        }
340    
341        public void setUseExecutor(boolean useExecutor) {
342            connector.setAttribute("useExecutor", new Boolean(useExecutor));
343        }
344    
345        public void setUseSendfile(boolean useSendfile) {
346            connector.setAttribute("useSendfile", new Boolean(useSendfile));
347        }
348        public static final GBeanInfo GBEAN_INFO;
349    
350        static {
351            GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Tomcat Connector HTTP NIO", Http11NIOConnectorGBean.class, AbstractHttp11ConnectorGBean.GBEAN_INFO);
352            infoFactory.addInterface(Http11NIOProtocol.class, 
353                    new String[] {
354                        "useSendfile", 
355                        "useExecutor", 
356                        "acceptorThreadCount", 
357                        "pollerThreadCount", 
358                        "pollerThreadPriority", 
359                        "acceptorThreadPriority", 
360                        "selectorTimeout", 
361                        "useComet", 
362                        "processCache", 
363                        "socket_directBuffer", 
364                        "socket_rxBufSize", 
365                        "socket_txBufSize", 
366                        "socket_appReadBufSize", 
367                        "socket_appWriteBufSize", 
368                        "socket_processorCache", 
369                        "socket_bufferPool", 
370                        "socket_bufferPoolSize", 
371                        "socket_keyCache", 
372                        "socket_eventCache", 
373                        "socket_tcpNoDelay", 
374                        "socket_soKeepAlive", 
375                        "socket_ooBInline", 
376                        "socket_soReuseAddress", 
377                        "socket_soLingerOn", 
378                        "socket_soLingerTime", 
379                        "socket_soTimeout", 
380                        "socket_soTrafficClass", 
381                        "socket_performanceConnectionTime", 
382                        "socket_performanceLatency", 
383                        "socket_performanceBandwidth", 
384                        "selectorPool_maxSelectors", 
385                        "selectorPool_maxSpareSelectors", 
386                        "command_line_options", 
387                        "oomParachute"
388                    },
389                    new String[] {
390                        "useSendfile", 
391                        "useExecutor", 
392                        "acceptorThreadCount", 
393                        "pollerThreadCount", 
394                        "pollerThreadPriority", 
395                        "acceptorThreadPriority", 
396                        "selectorTimeout", 
397                        "useComet", 
398                        "processCache", 
399                        "socket_directBuffer", 
400                        "socket_rxBufSize", 
401                        "socket_txBufSize", 
402                        "socket_appReadBufSize", 
403                        "socket_appWriteBufSize", 
404                        "socket_processorCache", 
405                        "socket_bufferPool", 
406                        "socket_bufferPoolSize", 
407                        "socket_keyCache", 
408                        "socket_eventCache", 
409                        "socket_tcpNoDelay", 
410                        "socket_soKeepAlive", 
411                        "socket_ooBInline", 
412                        "socket_soReuseAddress", 
413                        "socket_soLingerOn", 
414                        "socket_soLingerTime", 
415                        "socket_soTimeout", 
416                        "socket_soTrafficClass", 
417                        "socket_performanceConnectionTime", 
418                        "socket_performanceLatency", 
419                        "socket_performanceBandwidth", 
420                        "selectorPool_maxSelectors", 
421                        "selectorPool_maxSpareSelectors", 
422                        "command_line_options", 
423                        "oomParachute",
424    
425                    }
426            );
427            infoFactory.setConstructor(new String[] { "name", "initParams", "host", "port", "TomcatContainer", "ServerInfo"});
428            GBEAN_INFO = infoFactory.getBeanInfo();
429        }
430        
431        public static GBeanInfo getGBeanInfo() {
432            return GBEAN_INFO;
433        }
434    
435    }