001: /*
002: * This file is part of the QuickServer library
003: * Copyright (C) 2003-2005 QuickServer.org
004: *
005: * Use, modification, copying and distribution of this software is subject to
006: * the terms and conditions of the GNU Lesser General Public License.
007: * You should have received a copy of the GNU LGP License along with this
008: * library; if not, you can download a copy from <http://www.quickserver.org/>.
009: *
010: * For questions, suggestions, bug-reports, enhancement-requests etc.
011: * visit http://www.quickserver.org
012: *
013: */
014:
015: package org.quickserver.util.xmlreader;
016:
017: /**
018: * This class encapsulate the Object pool configuration.
019: * The xml is <object-pool>...</object-pool>
020: * @author Akshathkumar Shetty
021: * @since 1.3
022: */
023: public class ObjectPoolConfig extends PoolConfig {
024: private ThreadObjectPoolConfig threadObjectPoolConfig;
025: private ClientHandlerObjectPoolConfig clientHandlerObjectPoolConfig;
026: private ByteBufferObjectPoolConfig byteBufferObjectPoolConfig;
027: private ClientDataObjectPoolConfig clientDataObjectPoolConfig;
028: private String poolManager = null;
029:
030: /**
031: * Returns PoolManager object
032: * @return poolManager
033: */
034: public String getPoolManager() {
035: if (poolManager == null)
036: poolManager = "org.quickserver.net.server.impl.BasicPoolManager";
037: return poolManager;
038: }
039:
040: /**
041: * @param poolManager
042: */
043: public void setPoolManager(String poolManager) {
044: this .poolManager = poolManager;
045: }
046:
047: /**
048: * Returns ByteBufferObjectPoolConfig object
049: * @return byteBufferObjectPoolConfig
050: */
051: public ByteBufferObjectPoolConfig getByteBufferObjectPoolConfig() {
052: if (byteBufferObjectPoolConfig == null)
053: byteBufferObjectPoolConfig = new ByteBufferObjectPoolConfig(
054: this );
055: return byteBufferObjectPoolConfig;
056: }
057:
058: /**
059: * @param byteBufferObjectPoolConfig
060: */
061: public void setByteBufferObjectPoolConfig(
062: ByteBufferObjectPoolConfig byteBufferObjectPoolConfig) {
063: this .byteBufferObjectPoolConfig = byteBufferObjectPoolConfig;
064: }
065:
066: /**
067: * Returns ClientHandlerObjectPoolConfig object
068: * @return clientHandlerObjectPoolConfig
069: */
070: public ClientHandlerObjectPoolConfig getClientHandlerObjectPoolConfig() {
071: if (clientHandlerObjectPoolConfig == null)
072: clientHandlerObjectPoolConfig = new ClientHandlerObjectPoolConfig(
073: this );
074: return clientHandlerObjectPoolConfig;
075: }
076:
077: /**
078: * @param clientHandlerObjectPoolConfig
079: */
080: public void setClientHandlerObjectPoolConfig(
081: ClientHandlerObjectPoolConfig clientHandlerObjectPoolConfig) {
082: this .clientHandlerObjectPoolConfig = clientHandlerObjectPoolConfig;
083: }
084:
085: /**
086: * Returns ThreadObjectPoolConfig object
087: * @return threadObjectPoolConfig
088: */
089: public ThreadObjectPoolConfig getThreadObjectPoolConfig() {
090: if (threadObjectPoolConfig == null)
091: threadObjectPoolConfig = new ThreadObjectPoolConfig(this );
092: return threadObjectPoolConfig;
093: }
094:
095: /**
096: * @param threadObjectPoolConfig
097: */
098: public void setThreadObjectPoolConfig(
099: ThreadObjectPoolConfig threadObjectPoolConfig) {
100: this .threadObjectPoolConfig = threadObjectPoolConfig;
101: }
102:
103: /**
104: * Returns ClientDataObjectPoolConfig object
105: * @return clientDataObjectPoolConfig
106: */
107: public ClientDataObjectPoolConfig getClientDataObjectPoolConfig() {
108: if (clientDataObjectPoolConfig == null)
109: clientDataObjectPoolConfig = new ClientDataObjectPoolConfig(
110: this );
111: return clientDataObjectPoolConfig;
112: }
113:
114: /**
115: * @param clientDataObjectPoolConfig
116: */
117: public void setClientDataObjectPoolConfig(
118: ClientDataObjectPoolConfig clientDataObjectPoolConfig) {
119: this .clientDataObjectPoolConfig = clientDataObjectPoolConfig;
120: }
121:
122: /**
123: * Returns XML config of this class.
124: */
125: public String toXML(String pad) {
126: if (pad == null)
127: pad = "";
128: StringBuffer sb = new StringBuffer();
129: sb.append(pad + "<object-pool>\n");
130: sb.append(pad + "\t<max-active>" + getMaxActive()
131: + "</max-active>\n");
132: sb
133: .append(pad + "\t<max-idle>" + getMaxIdle()
134: + "</max-idle>\n");
135: sb.append(pad + "\t<init-size>" + getInitSize()
136: + "</init-size>\n");
137: sb.append(getThreadObjectPoolConfig().toXML(pad + "\t"));
138: sb.append(getClientHandlerObjectPoolConfig().toXML(pad + "\t"));
139: sb.append(getByteBufferObjectPoolConfig().toXML(pad + "\t"));
140: sb.append(getClientDataObjectPoolConfig().toXML(pad + "\t"));
141: sb.append(pad + "\t<pool-manager>" + getPoolManager()
142: + "</pool-manager>\n");
143: sb.append(pad + "</object-pool>\n");
144: return sb.toString();
145: }
146: }
|