KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > runtime > BeanPoolNode


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 package com.sun.enterprise.deployment.node.runtime;
24
25 import java.util.Map JavaDoc;
26 import org.w3c.dom.Node JavaDoc;
27
28 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
29 import com.sun.enterprise.deployment.runtime.BeanPoolDescriptor;
30 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
31
32 /**
33  * This node handles the bean-pool runtime deployment descriptors
34  *
35  * @author Jerome Dochez
36  * @version
37  */

38 public class BeanPoolNode extends DeploymentDescriptorNode {
39
40     protected BeanPoolDescriptor descriptor=null;
41     
42    /**
43     * @return the descriptor instance to associate with this XMLNode
44     */

45     public Object JavaDoc getDescriptor() {
46         if (descriptor==null) {
47         descriptor = new BeanPoolDescriptor();
48     }
49         return descriptor;
50     }
51     
52     /**
53      * all sub-implementation of this class can use a dispatch table to map xml element to
54      * method name on the descriptor class for setting the element value.
55      *
56      * @return the map with the element name as a key, the setter method as a value
57      */

58     protected Map JavaDoc getDispatchTable() {
59     Map JavaDoc dispatchTable = super.getDispatchTable();
60     dispatchTable.put(RuntimeTagNames.STEADY_POOL_SIZE, "setSteadyPoolSize");
61     dispatchTable.put(RuntimeTagNames.POOL_RESIZE_QUANTITY, "setPoolResizeQuantity");
62     dispatchTable.put(RuntimeTagNames.MAX_POOL_SIZE, "setMaxPoolSize");
63     dispatchTable.put(RuntimeTagNames.POOL_IDLE_TIMEOUT_IN_SECONDS, "setPoolIdleTimeoutInSeconds");
64     dispatchTable.put(RuntimeTagNames.MAX_WAIT_TIME_IN_MILLIS, "setMaxWaitTimeInMillis");
65     return dispatchTable;
66     }
67     
68     /**
69      * write the descriptor class to a DOM tree and return it
70      *
71      * @param parent node for the DOM tree
72      * @param node name for the descriptor
73      * @param the descriptor to write
74      * @return the DOM tree top node
75      */

76     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, BeanPoolDescriptor descriptor) {
77     Node JavaDoc beanpoolNode = super.writeDescriptor(parent, nodeName, descriptor);
78     appendTextChild(beanpoolNode, RuntimeTagNames.STEADY_POOL_SIZE, descriptor.getSteadyPoolSize());
79     appendTextChild(beanpoolNode, RuntimeTagNames.POOL_RESIZE_QUANTITY, descriptor.getPoolResizeQuantity());
80     appendTextChild(beanpoolNode, RuntimeTagNames.MAX_POOL_SIZE, descriptor.getMaxPoolSize());
81     appendTextChild(beanpoolNode, RuntimeTagNames.POOL_IDLE_TIMEOUT_IN_SECONDS, descriptor.getPoolIdleTimeoutInSeconds());
82     appendTextChild(beanpoolNode, RuntimeTagNames.MAX_WAIT_TIME_IN_MILLIS, descriptor.getMaxWaitTimeInMillis());
83     return beanpoolNode;
84     }
85 }
86
Popular Tags