KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > serverbeans > ThreadPools


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /**
25  * This generated bean class ThreadPools matches the DTD element thread-pools
26  *
27  */

28
29 package com.sun.enterprise.config.serverbeans;
30
31 import org.w3c.dom.*;
32 import org.netbeans.modules.schema2beans.*;
33 import java.beans.*;
34 import java.util.*;
35 import java.io.Serializable JavaDoc;
36 import com.sun.enterprise.config.ConfigBean;
37 import com.sun.enterprise.config.ConfigException;
38 import com.sun.enterprise.config.StaleWriteConfigException;
39 import com.sun.enterprise.util.i18n.StringManager;
40
41 // BEGIN_NOI18N
42

43 public class ThreadPools extends ConfigBean implements Serializable JavaDoc
44 {
45
46     static Vector comparators = new Vector();
47     private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 2, 0);
48
49     static public final String JavaDoc THREAD_POOL = "ThreadPool";
50
51     public ThreadPools() {
52         this(Common.USE_DEFAULT_VALUES);
53     }
54
55     public ThreadPools(int options)
56     {
57         super(comparators, runtimeVersion);
58         // Properties (see root bean comments for the bean graph)
59
initPropertyTables(1);
60         this.createProperty("thread-pool", THREAD_POOL,
61             Common.TYPE_1_N | Common.TYPE_BEAN | Common.TYPE_KEY,
62             ThreadPool.class);
63         this.createAttribute(THREAD_POOL, "thread-pool-id", "ThreadPoolId",
64                         AttrProp.CDATA | AttrProp.REQUIRED,
65                         null, null);
66         this.createAttribute(THREAD_POOL, "min-thread-pool-size", "MinThreadPoolSize",
67                         AttrProp.CDATA,
68                         null, "0");
69         this.createAttribute(THREAD_POOL, "max-thread-pool-size", "MaxThreadPoolSize",
70                         AttrProp.CDATA,
71                         null, "200");
72         this.createAttribute(THREAD_POOL, "idle-thread-timeout-in-seconds", "IdleThreadTimeoutInSeconds",
73                         AttrProp.CDATA,
74                         null, "120");
75         this.createAttribute(THREAD_POOL, "num-work-queues", "NumWorkQueues",
76                         AttrProp.CDATA,
77                         null, "1");
78         this.initialize(options);
79     }
80
81     // Setting the default values of the properties
82
void initialize(int options) {
83
84     }
85
86     // This attribute is an array containing at least one element
87
public void setThreadPool(int index, ThreadPool value) {
88         this.setValue(THREAD_POOL, index, value);
89     }
90
91     // Get Method
92
public ThreadPool getThreadPool(int index) {
93         return (ThreadPool)this.getValue(THREAD_POOL, index);
94     }
95
96     // This attribute is an array containing at least one element
97
public void setThreadPool(ThreadPool[] value) {
98         this.setValue(THREAD_POOL, value);
99     }
100
101     // Getter Method
102
public ThreadPool[] getThreadPool() {
103         return (ThreadPool[])this.getValues(THREAD_POOL);
104     }
105
106     // Return the number of properties
107
public int sizeThreadPool() {
108         return this.size(THREAD_POOL);
109     }
110
111     // Add a new element returning its index in the list
112
public int addThreadPool(ThreadPool value)
113             throws ConfigException{
114         return addThreadPool(value, true);
115     }
116
117     // Add a new element returning its index in the list with a boolean flag
118
public int addThreadPool(ThreadPool value, boolean overwrite)
119             throws ConfigException{
120         ThreadPool old = getThreadPoolByThreadPoolId(value.getThreadPoolId());
121         if(old != null) {
122             throw new ConfigException(StringManager.getManager(ThreadPools.class).getString("cannotAddDuplicate", "ThreadPool"));
123         }
124         return this.addValue(THREAD_POOL, value, overwrite);
125     }
126
127     //
128
// Remove an element using its reference
129
// Returns the index the element had in the list
130
//
131
public int removeThreadPool(ThreadPool value){
132         return this.removeValue(THREAD_POOL, value);
133     }
134
135     //
136
// Remove an element using its reference
137
// Returns the index the element had in the list
138
// with boolean overwrite
139
//
140
public int removeThreadPool(ThreadPool value, boolean overwrite)
141             throws StaleWriteConfigException{
142         return this.removeValue(THREAD_POOL, value, overwrite);
143     }
144
145     public ThreadPool getThreadPoolByThreadPoolId(String JavaDoc id) {
146      if (null != id) { id = id.trim(); }
147     ThreadPool[] o = getThreadPool();
148      if (o == null) return null;
149
150      for (int i=0; i < o.length; i++) {
151          if(o[i].getAttributeValue(Common.convertName(ServerTags.THREAD_POOL_ID)).equals(id)) {
152              return o[i];
153          }
154      }
155
156         return null;
157         
158     }
159     /**
160      * Create a new bean using it's default constructor.
161      * This does not add it to any bean graph.
162      */

163     public ThreadPool newThreadPool() {
164         return new ThreadPool();
165     }
166
167     /**
168     * get the xpath representation for this element
169     * returns something like abc[@name='value'] or abc
170     * depending on the type of the bean
171     */

172     protected String JavaDoc getRelativeXPath() {
173         String JavaDoc ret = null;
174         ret = "thread-pools";
175         return (null != ret ? ret.trim() : null);
176     }
177
178     /*
179     * generic method to get default value from dtd
180     */

181     public static String JavaDoc getDefaultAttributeValue(String JavaDoc attr) {
182         if(attr == null) return null;
183         attr = attr.trim();
184     return null;
185     }
186     //
187
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
188         comparators.add(c);
189     }
190
191     //
192
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
193         comparators.remove(c);
194     }
195     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
196     }
197
198     // Dump the content of this bean returning it as a String
199
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
200         String JavaDoc s;
201         Object JavaDoc o;
202         org.netbeans.modules.schema2beans.BaseBean n;
203         str.append(indent);
204         str.append("ThreadPool["+this.sizeThreadPool()+"]"); // NOI18N
205
for(int i=0; i<this.sizeThreadPool(); i++)
206         {
207             str.append(indent+"\t");
208             str.append("#"+i+":");
209             n = (org.netbeans.modules.schema2beans.BaseBean) this.getThreadPool(i);
210             if (n != null)
211                 n.dump(str, indent + "\t"); // NOI18N
212
else
213                 str.append(indent+"\tnull"); // NOI18N
214
this.dumpAttributes(THREAD_POOL, i, str, indent);
215         }
216
217     }
218     public String JavaDoc dumpBeanNode(){
219         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
220         str.append("ThreadPools\n"); // NOI18N
221
this.dump(str, "\n "); // NOI18N
222
return str.toString();
223     }}
224
225 // END_NOI18N
226

227
Popular Tags