KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quickserver > util > xmlreader > ObjectPoolConfig


1 /*
2  * This file is part of the QuickServer library
3  * Copyright (C) 2003-2005 QuickServer.org
4  *
5  * Use, modification, copying and distribution of this software is subject to
6  * the terms and conditions of the GNU Lesser General Public License.
7  * You should have received a copy of the GNU LGP License along with this
8  * library; if not, you can download a copy from <http://www.quickserver.org/>.
9  *
10  * For questions, suggestions, bug-reports, enhancement-requests etc.
11  * visit http://www.quickserver.org
12  *
13  */

14
15 package org.quickserver.util.xmlreader;
16
17 /**
18  * This class encapsulate the Object pool configuration.
19  * The xml is &lt;object-pool&gt;...&lt;/object-pool&gt;
20  * @author Akshathkumar Shetty
21  * @since 1.3
22  */

23 public class ObjectPoolConfig extends PoolConfig {
24     private ThreadObjectPoolConfig threadObjectPoolConfig;
25     private ClientHandlerObjectPoolConfig clientHandlerObjectPoolConfig;
26     private ByteBufferObjectPoolConfig byteBufferObjectPoolConfig;
27     private ClientDataObjectPoolConfig clientDataObjectPoolConfig;
28     private String JavaDoc poolManager = null;
29
30     /**
31      * Returns PoolManager object
32      * @return poolManager
33      */

34     public String JavaDoc getPoolManager() {
35         if(poolManager==null)
36             poolManager = "org.quickserver.net.server.impl.BasicPoolManager";
37         return poolManager;
38     }
39     /**
40      * @param poolManager
41      */

42     public void setPoolManager(String JavaDoc poolManager) {
43         this.poolManager = poolManager;
44     }
45
46     /**
47      * Returns ByteBufferObjectPoolConfig object
48      * @return byteBufferObjectPoolConfig
49      */

50     public ByteBufferObjectPoolConfig getByteBufferObjectPoolConfig() {
51         if(byteBufferObjectPoolConfig==null)
52             byteBufferObjectPoolConfig = new ByteBufferObjectPoolConfig(this);
53         return byteBufferObjectPoolConfig;
54     }
55     /**
56      * @param byteBufferObjectPoolConfig
57      */

58     public void setByteBufferObjectPoolConfig(ByteBufferObjectPoolConfig byteBufferObjectPoolConfig) {
59         this.byteBufferObjectPoolConfig = byteBufferObjectPoolConfig;
60     }
61
62     /**
63      * Returns ClientHandlerObjectPoolConfig object
64      * @return clientHandlerObjectPoolConfig
65      */

66     public ClientHandlerObjectPoolConfig getClientHandlerObjectPoolConfig() {
67         if(clientHandlerObjectPoolConfig==null)
68             clientHandlerObjectPoolConfig = new ClientHandlerObjectPoolConfig(this);
69         return clientHandlerObjectPoolConfig;
70     }
71     /**
72      * @param clientHandlerObjectPoolConfig
73      */

74     public void setClientHandlerObjectPoolConfig(ClientHandlerObjectPoolConfig clientHandlerObjectPoolConfig) {
75         this.clientHandlerObjectPoolConfig = clientHandlerObjectPoolConfig;
76     }
77
78     /**
79      * Returns ThreadObjectPoolConfig object
80      * @return threadObjectPoolConfig
81      */

82     public ThreadObjectPoolConfig getThreadObjectPoolConfig() {
83         if(threadObjectPoolConfig==null)
84             threadObjectPoolConfig = new ThreadObjectPoolConfig(this);
85         return threadObjectPoolConfig;
86     }
87     /**
88      * @param threadObjectPoolConfig
89      */

90     public void setThreadObjectPoolConfig(ThreadObjectPoolConfig threadObjectPoolConfig) {
91         this.threadObjectPoolConfig = threadObjectPoolConfig;
92     }
93
94     /**
95      * Returns ClientDataObjectPoolConfig object
96      * @return clientDataObjectPoolConfig
97      */

98     public ClientDataObjectPoolConfig getClientDataObjectPoolConfig() {
99         if(clientDataObjectPoolConfig==null)
100             clientDataObjectPoolConfig = new ClientDataObjectPoolConfig(this);
101         return clientDataObjectPoolConfig;
102     }
103     /**
104      * @param clientDataObjectPoolConfig
105      */

106     public void setClientDataObjectPoolConfig(ClientDataObjectPoolConfig clientDataObjectPoolConfig) {
107         this.clientDataObjectPoolConfig = clientDataObjectPoolConfig;
108     }
109
110     /**
111      * Returns XML config of this class.
112      */

113     public String JavaDoc toXML(String JavaDoc pad) {
114         if(pad==null) pad="";
115         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
116         sb.append(pad+"<object-pool>\n");
117         sb.append(pad+"\t<max-active>"+getMaxActive()+"</max-active>\n");
118         sb.append(pad+"\t<max-idle>"+getMaxIdle()+"</max-idle>\n");
119         sb.append(pad+"\t<init-size>"+getInitSize()+"</init-size>\n");
120         sb.append(getThreadObjectPoolConfig().toXML(pad+"\t"));
121         sb.append(getClientHandlerObjectPoolConfig().toXML(pad+"\t"));
122         sb.append(getByteBufferObjectPoolConfig().toXML(pad+"\t"));
123         sb.append(getClientDataObjectPoolConfig().toXML(pad+"\t"));
124         sb.append(pad+"\t<pool-manager>"+getPoolManager()+"</pool-manager>\n");
125         sb.append(pad+"</object-pool>\n");
126         return sb.toString();
127     }
128 }
129
Popular Tags