KickJava   Java API By Example, From Geeks To Geeks.

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


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.XMLElement;
29 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
30 import com.sun.enterprise.deployment.runtime.BeanCacheDescriptor;
31 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
32
33 /**
34  * This node handles the bean-cache untime deployment descriptors
35  *
36  * @author Jerome Dochez
37  * @version
38  */

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

46     public Object JavaDoc getDescriptor() {
47         if (descriptor==null) {
48         descriptor = new BeanCacheDescriptor();
49     }
50         return descriptor;
51     }
52     
53     /**
54      * receives notification of the value for a particular tag
55      *
56      * @param element the xml element
57      * @param value it's associated value
58      */

59     public void setElementValue(XMLElement element, String JavaDoc value) {
60     if (RuntimeTagNames.IS_CACHE_OVERFLOW_ALLOWED.equals(element.getQName())) {
61         descriptor.setIsCacheOverflowAllowed(Boolean.valueOf(value));
62     } else
63         super.setElementValue(element, value);
64     }
65     
66     /**
67      * all sub-implementation of this class can use a dispatch table to map xml element to
68      * method name on the descriptor class for setting the element value.
69      *
70      * @return the map with the element name as a key, the setter method as a value
71      */

72     protected Map JavaDoc getDispatchTable() {
73     Map JavaDoc dispatchTable = super.getDispatchTable();
74     dispatchTable.put(RuntimeTagNames.MAX_CACHE_SIZE, "setMaxCacheSize");
75     dispatchTable.put(RuntimeTagNames.RESIZE_QUANTITY, "setResizeQuantity");
76     dispatchTable.put(RuntimeTagNames.CACHE_IDLE_TIMEOUT_IN_SECONDS, "setCacheIdleTimeoutInSeconds");
77     dispatchTable.put(RuntimeTagNames.REMOVAL_TIMEOUT_IN_SECONDS, "setRemovalTimeoutInSeconds");
78     dispatchTable.put(RuntimeTagNames.VICTIM_SELECTION_POLICY, "setVictimSelectionPolicy");
79     return dispatchTable;
80     }
81     
82     /**
83      * write the descriptor class to a DOM tree and return it
84      *
85      * @param parent node for the DOM tree
86      * @param node name for the descriptor
87      * @param the descriptor to write
88      * @return the DOM tree top node
89      */

90     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, BeanCacheDescriptor descriptor) {
91     Node JavaDoc beanCacheNode = super.writeDescriptor(parent, nodeName, descriptor);
92     appendTextChild(beanCacheNode, RuntimeTagNames.MAX_CACHE_SIZE, descriptor.getMaxCacheSize());
93     appendTextChild(beanCacheNode, RuntimeTagNames.RESIZE_QUANTITY, descriptor.getResizeQuantity());
94     appendTextChild(beanCacheNode, RuntimeTagNames.IS_CACHE_OVERFLOW_ALLOWED, String.valueOf(descriptor.isIsCacheOverflowAllowed()));
95     appendTextChild(beanCacheNode, RuntimeTagNames.CACHE_IDLE_TIMEOUT_IN_SECONDS, descriptor.getCacheIdleTimeoutInSeconds());
96     appendTextChild(beanCacheNode, RuntimeTagNames.REMOVAL_TIMEOUT_IN_SECONDS, descriptor.getRemovalTimeoutInSeconds());
97     appendTextChild(beanCacheNode, RuntimeTagNames.VICTIM_SELECTION_POLICY, descriptor.getVictimSelectionPolicy());
98     return beanCacheNode;
99     }
100 }
101
Popular Tags