Source Code Cross Referenced for AbstractIoSessionConfig.java in  » Net » mina-2.0.0-M1 » org » apache » mina » common » 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 » Net » mina 2.0.0 M1 » org.apache.mina.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:         */
020:        package org.apache.mina.common;
021:
022:        /**
023:         * A base implementation of {@link IoSessionConfig}.
024:         *
025:         * @author The Apache MINA Project (dev@mina.apache.org)
026:         * @version $Rev: 597940 $, $Date: 2007-11-24 18:00:09 -0700 (Sat, 24 Nov 2007) $
027:         */
028:        public abstract class AbstractIoSessionConfig implements 
029:                IoSessionConfig {
030:
031:            private int minReadBufferSize = 64;
032:            private int readBufferSize = 2048;
033:            private int maxReadBufferSize = 65536;
034:            private int idleTimeForRead;
035:            private int idleTimeForWrite;
036:            private int idleTimeForBoth;
037:            private int writeTimeout = 60;
038:            private boolean useReadOperation;
039:            private int throughputCalculationInterval = 3;
040:
041:            protected AbstractIoSessionConfig() {
042:            }
043:
044:            public final void setAll(IoSessionConfig config) {
045:                if (config == null) {
046:                    throw new NullPointerException("config");
047:                }
048:
049:                setReadBufferSize(config.getReadBufferSize());
050:                setMinReadBufferSize(config.getMinReadBufferSize());
051:                setMaxReadBufferSize(config.getMaxReadBufferSize());
052:                setIdleTime(IdleStatus.BOTH_IDLE, config
053:                        .getIdleTime(IdleStatus.BOTH_IDLE));
054:                setIdleTime(IdleStatus.READER_IDLE, config
055:                        .getIdleTime(IdleStatus.READER_IDLE));
056:                setIdleTime(IdleStatus.WRITER_IDLE, config
057:                        .getIdleTime(IdleStatus.WRITER_IDLE));
058:                setWriteTimeout(config.getWriteTimeout());
059:                setUseReadOperation(config.isUseReadOperation());
060:                setThroughputCalculationInterval(config
061:                        .getThroughputCalculationInterval());
062:
063:                doSetAll(config);
064:            }
065:
066:            /**
067:             * Implement this method to set all transport-specific configuration
068:             * properties retrieved from the specified <tt>config</tt>.
069:             */
070:            protected abstract void doSetAll(IoSessionConfig config);
071:
072:            public int getReadBufferSize() {
073:                return readBufferSize;
074:            }
075:
076:            public void setReadBufferSize(int readBufferSize) {
077:                if (readBufferSize <= 0) {
078:                    throw new IllegalArgumentException("readBufferSize: "
079:                            + readBufferSize + " (expected: 1+)");
080:                }
081:                this .readBufferSize = readBufferSize;
082:            }
083:
084:            public int getMinReadBufferSize() {
085:                return minReadBufferSize;
086:            }
087:
088:            public void setMinReadBufferSize(int minReadBufferSize) {
089:                if (minReadBufferSize <= 0) {
090:                    throw new IllegalArgumentException("minReadBufferSize: "
091:                            + minReadBufferSize + " (expected: 1+)");
092:                }
093:                if (minReadBufferSize > maxReadBufferSize) {
094:                    throw new IllegalArgumentException("minReadBufferSize: "
095:                            + minReadBufferSize + " (expected: smaller than "
096:                            + maxReadBufferSize + ')');
097:
098:                }
099:                this .minReadBufferSize = minReadBufferSize;
100:            }
101:
102:            public int getMaxReadBufferSize() {
103:                return maxReadBufferSize;
104:            }
105:
106:            public void setMaxReadBufferSize(int maxReadBufferSize) {
107:                if (maxReadBufferSize <= 0) {
108:                    throw new IllegalArgumentException("maxReadBufferSize: "
109:                            + maxReadBufferSize + " (expected: 1+)");
110:                }
111:
112:                if (maxReadBufferSize < minReadBufferSize) {
113:                    throw new IllegalArgumentException("maxReadBufferSize: "
114:                            + maxReadBufferSize + " (expected: greater than "
115:                            + minReadBufferSize + ')');
116:
117:                }
118:                this .maxReadBufferSize = maxReadBufferSize;
119:            }
120:
121:            public int getIdleTime(IdleStatus status) {
122:                if (status == IdleStatus.BOTH_IDLE) {
123:                    return idleTimeForBoth;
124:                }
125:
126:                if (status == IdleStatus.READER_IDLE) {
127:                    return idleTimeForRead;
128:                }
129:
130:                if (status == IdleStatus.WRITER_IDLE) {
131:                    return idleTimeForWrite;
132:                }
133:
134:                throw new IllegalArgumentException("Unknown idle status: "
135:                        + status);
136:            }
137:
138:            public long getIdleTimeInMillis(IdleStatus status) {
139:                return getIdleTime(status) * 1000L;
140:            }
141:
142:            public void setIdleTime(IdleStatus status, int idleTime) {
143:                if (idleTime < 0) {
144:                    throw new IllegalArgumentException("Illegal idle time: "
145:                            + idleTime);
146:                }
147:
148:                if (status == IdleStatus.BOTH_IDLE) {
149:                    idleTimeForBoth = idleTime;
150:                } else if (status == IdleStatus.READER_IDLE) {
151:                    idleTimeForRead = idleTime;
152:                } else if (status == IdleStatus.WRITER_IDLE) {
153:                    idleTimeForWrite = idleTime;
154:                } else {
155:                    throw new IllegalArgumentException("Unknown idle status: "
156:                            + status);
157:                }
158:            }
159:
160:            public final int getBothIdleTime() {
161:                return getIdleTime(IdleStatus.BOTH_IDLE);
162:            }
163:
164:            public final long getBothIdleTimeInMillis() {
165:                return getIdleTimeInMillis(IdleStatus.BOTH_IDLE);
166:            }
167:
168:            public final int getReaderIdleTime() {
169:                return getIdleTime(IdleStatus.READER_IDLE);
170:            }
171:
172:            public final long getReaderIdleTimeInMillis() {
173:                return getIdleTimeInMillis(IdleStatus.READER_IDLE);
174:            }
175:
176:            public final int getWriterIdleTime() {
177:                return getIdleTime(IdleStatus.WRITER_IDLE);
178:            }
179:
180:            public final long getWriterIdleTimeInMillis() {
181:                return getIdleTimeInMillis(IdleStatus.WRITER_IDLE);
182:            }
183:
184:            public void setBothIdleTime(int idleTime) {
185:                setIdleTime(IdleStatus.BOTH_IDLE, idleTime);
186:            }
187:
188:            public void setReaderIdleTime(int idleTime) {
189:                setIdleTime(IdleStatus.READER_IDLE, idleTime);
190:            }
191:
192:            public void setWriterIdleTime(int idleTime) {
193:                setIdleTime(IdleStatus.WRITER_IDLE, idleTime);
194:            }
195:
196:            public int getWriteTimeout() {
197:                return writeTimeout;
198:            }
199:
200:            public long getWriteTimeoutInMillis() {
201:                return writeTimeout * 1000L;
202:            }
203:
204:            public void setWriteTimeout(int writeTimeout) {
205:                if (writeTimeout < 0) {
206:                    throw new IllegalArgumentException(
207:                            "Illegal write timeout: " + writeTimeout);
208:                }
209:                this .writeTimeout = writeTimeout;
210:            }
211:
212:            public boolean isUseReadOperation() {
213:                return useReadOperation;
214:            }
215:
216:            public void setUseReadOperation(boolean useReadOperation) {
217:                this .useReadOperation = useReadOperation;
218:            }
219:
220:            public int getThroughputCalculationInterval() {
221:                return throughputCalculationInterval;
222:            }
223:
224:            public void setThroughputCalculationInterval(
225:                    int throughputCalculationInterval) {
226:                if (throughputCalculationInterval < 0) {
227:                    throw new IllegalArgumentException(
228:                            "throughputCalculationInterval: "
229:                                    + throughputCalculationInterval);
230:                }
231:
232:                this .throughputCalculationInterval = throughputCalculationInterval;
233:            }
234:
235:            public long getThroughputCalculationIntervalInMillis() {
236:                return throughputCalculationInterval * 1000L;
237:            }
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.