1 14 15 package org.quickserver.util.xmlreader; 16 17 import java.nio.charset.UnsupportedCharsetException ; 18 import java.nio.charset.Charset ; 19 20 37 public class AdvancedSettings implements java.io.Serializable { 38 private String charset = "ISO-8859-1"; 39 private int byteBufferSize = 1024*64; 40 private int backlog = 0; 41 private boolean useDirectByteBuffer = true; 42 private int socketLinger = -1; 43 private boolean debugNonBlockingMode; 44 private String clientIdentifierClass = 45 "org.quickserver.net.server.impl.OptimisticClientIdentifier"; 46 private String qSObjectPoolMakerClass = null; 47 private int maxThreadsForNioWrite = 10; 48 49 55 public void setCharset(String charset) { 56 if(charset==null || charset.trim().length()==0) 57 return; 58 if(Charset.isSupported(charset)==false) { 59 throw new UnsupportedCharsetException (charset); 60 } 61 this.charset = charset; 62 } 63 67 public String getCharset() { 68 return charset; 69 } 70 71 77 public void setByteBufferSize(int byteBufferSize) { 78 if(byteBufferSize>0) 79 this.byteBufferSize = byteBufferSize; 80 } 81 85 public int getByteBufferSize() { 86 return byteBufferSize; 87 } 88 89 97 public void setBacklog(int backlog) { 98 if(backlog>=0) 99 this.backlog = backlog; 100 } 101 105 public int getBacklog() { 106 return backlog; 107 } 108 109 116 public void setUseDirectByteBuffer(boolean flag) { 117 this.useDirectByteBuffer = flag; 118 } 119 123 public boolean getUseDirectByteBuffer() { 124 return useDirectByteBuffer; 125 } 126 127 134 public void setSocketLinger(int socketLinger) { 135 this.socketLinger = socketLinger; 136 } 137 141 public int getSocketLinger() { 142 return socketLinger; 143 } 144 145 152 public void setDebugNonBlockingMode(boolean debugNonBlockingMode) { 153 this.debugNonBlockingMode = debugNonBlockingMode; 154 } 155 159 public boolean getDebugNonBlockingMode() { 160 return debugNonBlockingMode; 161 } 162 163 171 public void setClientIdentifier(String clientIdentifierClass) { 172 if(clientIdentifierClass==null || clientIdentifierClass.trim().length()==0) 173 return; 174 this.clientIdentifierClass = clientIdentifierClass; 175 } 176 181 public String getClientIdentifier() { 182 return clientIdentifierClass; 183 } 184 185 193 public void setQSObjectPoolMaker(String qSObjectPoolMakerClass) { 194 this.qSObjectPoolMakerClass = qSObjectPoolMakerClass; 195 } 196 201 public String getQSObjectPoolMaker() { 202 if(qSObjectPoolMakerClass==null) 203 qSObjectPoolMakerClass = "org.quickserver.util.pool.MakeQSObjectPool"; 204 return qSObjectPoolMakerClass; 205 } 206 207 215 public void setMaxThreadsForNioWrite(int maxThreadsForNioWrite) { 216 this.maxThreadsForNioWrite = maxThreadsForNioWrite; 217 } 218 223 public int getMaxThreadsForNioWrite() { 224 return maxThreadsForNioWrite; 225 } 226 227 230 public String toXML(String pad) { 231 if(pad==null) pad=""; 232 StringBuffer sb = new StringBuffer (); 233 sb.append(pad+"<advanced-settings>\n"); 234 sb.append(pad+"\t<charset>").append(getCharset()).append("</charset>\n"); 235 sb.append(pad+"\t<use-direct-byte-buffer>"+getUseDirectByteBuffer()+"</use-direct-byte-buffer>\n"); 236 sb.append(pad+"\t<byte-buffer-size>").append(getByteBufferSize()).append("</byte-buffer-size>\n"); 237 sb.append(pad+"\t<backlog>"+getBacklog()+"</backlog>\n"); 238 sb.append(pad+"\t<socket-linger>"+getSocketLinger()+"</socket-linger>\n"); 239 sb.append(pad+"\t<debug-non-blocking-mode>"+getDebugNonBlockingMode()+"</debug-non-blocking-mode>\n"); 240 sb.append(pad+"\t<client-identifier>"+getClientIdentifier()+"</client-identifier>\n"); 241 sb.append(pad+"\t<qsobject-pool-maker>"+getQSObjectPoolMaker()+"</qsobject-pool-maker>\n"); 242 sb.append(pad+"\t<max-threads-for-nio-write>"+getMaxThreadsForNioWrite()+"</max-threads-for-nio-write>\n"); 243 sb.append(pad+"</advanced-settings>\n"); 244 return sb.toString(); 245 } 246 247 248 } 249 | Popular Tags |