Source Code Cross Referenced for AbstractBuffers.java in  » Sevlet-Container » jetty-modules » org » mortbay » jetty » 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 » Sevlet Container » jetty modules » org.mortbay.jetty 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.mortbay.jetty;
002:
003:        import java.util.ArrayList;
004:
005:        import org.mortbay.component.AbstractLifeCycle;
006:        import org.mortbay.io.Buffer;
007:        import org.mortbay.io.Buffers;
008:
009:        /* ------------------------------------------------------------ */
010:        /** Abstract Buffer pool.
011:         * simple unbounded pool of buffers.
012:         * @author gregw
013:         *
014:         */
015:        public abstract class AbstractBuffers extends AbstractLifeCycle
016:                implements  Buffers {
017:            private int _headerBufferSize = 8 * 1024;
018:            private int _requestBufferSize = 32 * 1024;
019:            private int _responseBufferSize = 64 * 1024;
020:
021:            private transient ArrayList _headerBuffers;
022:            private transient ArrayList _requestBuffers;
023:            private transient ArrayList _responseBuffers;
024:
025:            /* ------------------------------------------------------------ */
026:            /**
027:             * @return Returns the headerBufferSize.
028:             */
029:            public int getHeaderBufferSize() {
030:                return _headerBufferSize;
031:            }
032:
033:            /* ------------------------------------------------------------ */
034:            /**
035:             * @param headerBufferSize The headerBufferSize to set.
036:             */
037:            public void setHeaderBufferSize(int headerBufferSize) {
038:                _headerBufferSize = headerBufferSize;
039:            }
040:
041:            /* ------------------------------------------------------------ */
042:            /**
043:             * @return Returns the requestBufferSize.
044:             */
045:            public int getRequestBufferSize() {
046:                return _requestBufferSize;
047:            }
048:
049:            /* ------------------------------------------------------------ */
050:            /**
051:             * @param requestBufferSize The requestBufferSize to set.
052:             */
053:            public void setRequestBufferSize(int requestBufferSize) {
054:                _requestBufferSize = requestBufferSize;
055:            }
056:
057:            /* ------------------------------------------------------------ */
058:            /**
059:             * @return Returns the responseBufferSize.
060:             */
061:            public int getResponseBufferSize() {
062:                return _responseBufferSize;
063:            }
064:
065:            /* ------------------------------------------------------------ */
066:            /**
067:             * @param responseBufferSize The responseBufferSize to set.
068:             */
069:            public void setResponseBufferSize(int responseBufferSize) {
070:                _responseBufferSize = responseBufferSize;
071:            }
072:
073:            /* ------------------------------------------------------------ */
074:            protected abstract Buffer newBuffer(int size);
075:
076:            /* ------------------------------------------------------------ */
077:            public Buffer getBuffer(int size) {
078:                if (size == _headerBufferSize) {
079:                    synchronized (_headerBuffers) {
080:                        if (_headerBuffers.size() == 0)
081:                            return newBuffer(size);
082:                        return (Buffer) _headerBuffers.remove(_headerBuffers
083:                                .size() - 1);
084:                    }
085:                } else if (size == _responseBufferSize) {
086:                    synchronized (_responseBuffers) {
087:                        if (_responseBuffers.size() == 0)
088:                            return newBuffer(size);
089:                        return (Buffer) _responseBuffers
090:                                .remove(_responseBuffers.size() - 1);
091:                    }
092:                } else if (size == _requestBufferSize) {
093:                    synchronized (_requestBuffers) {
094:                        if (_requestBuffers.size() == 0)
095:                            return newBuffer(size);
096:                        return (Buffer) _requestBuffers.remove(_requestBuffers
097:                                .size() - 1);
098:                    }
099:                }
100:
101:                return newBuffer(size);
102:            }
103:
104:            /* ------------------------------------------------------------ */
105:            public void returnBuffer(Buffer buffer) {
106:                buffer.clear();
107:                if (!buffer.isVolatile() && !buffer.isImmutable()) {
108:                    int c = buffer.capacity();
109:                    if (c == _headerBufferSize) {
110:                        synchronized (_headerBuffers) {
111:                            _headerBuffers.add(buffer);
112:                        }
113:                    } else if (c == _responseBufferSize) {
114:                        synchronized (_responseBuffers) {
115:                            _responseBuffers.add(buffer);
116:                        }
117:                    } else if (c == _requestBufferSize) {
118:                        synchronized (_requestBuffers) {
119:                            _requestBuffers.add(buffer);
120:                        }
121:                    }
122:                }
123:            }
124:
125:            /* ------------------------------------------------------------ */
126:            protected void doStart() throws Exception {
127:                super .doStart();
128:
129:                if (_headerBuffers != null)
130:                    _headerBuffers.clear();
131:                else
132:                    _headerBuffers = new ArrayList();
133:                if (_requestBuffers != null)
134:                    _requestBuffers.clear();
135:                else
136:                    _requestBuffers = new ArrayList();
137:                if (_responseBuffers != null)
138:                    _responseBuffers.clear();
139:                else
140:                    _responseBuffers = new ArrayList();
141:            }
142:
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.