KickJava   Java API By Example, From Geeks To Geeks.

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


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.ArrayList JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import org.w3c.dom.Node JavaDoc;
28
29 import com.sun.enterprise.deployment.node.XMLElement;
30 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
31 import com.sun.enterprise.deployment.node.MethodNode;
32 import com.sun.enterprise.deployment.runtime.PrefetchDisabledDescriptor;
33 import com.sun.enterprise.deployment.MethodDescriptor;
34 import com.sun.enterprise.deployment.EjbDescriptor;
35 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
36
37 /**
38  * This node handles the prefetch-disabled runtime deployment descriptors
39  *
40  */

41 public class PrefetchDisabledNode extends DeploymentDescriptorNode {
42
43     protected PrefetchDisabledDescriptor descriptor=null;
44     
45     /** Creates new PrefetchDisabledNode */
46     public PrefetchDisabledNode() {
47         registerElementHandler(new XMLElement(RuntimeTagNames.QUERY_METHOD), MethodNode.class);
48     }
49     
50    /**
51     * @return the descriptor instance to associate with this XMLNode
52     */

53     public Object JavaDoc getDescriptor() {
54         if (descriptor==null) {
55             descriptor = new PrefetchDisabledDescriptor();
56             Object JavaDoc parentDesc = getParentNode().getDescriptor();
57             if (parentDesc instanceof EjbDescriptor) {
58                 descriptor.setEjbDescriptor((EjbDescriptor)parentDesc);
59             }
60         }
61         return descriptor;
62     }
63     
64
65     /**
66      * Adds a new DOL descriptor instance to the descriptor instance associated
67      * with this XMLNode
68      *
69      * @param descriptor the new descriptor
70      */

71     public void addDescriptor(Object JavaDoc newDescriptor) {
72         if (newDescriptor instanceof MethodDescriptor) {
73             descriptor.addMethodDescriptor(
74                 (MethodDescriptor) newDescriptor);
75         }
76     }
77
78     /**
79      * write the descriptor class to a DOM tree and return it
80      *
81      * @param parent node for the DOM tree
82      * @param node name for the descriptor
83      * @param the descriptor to write
84      * @return the DOM tree top node
85      */

86     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName,
87         PrefetchDisabledDescriptor prefetchDisabledDescriptor) {
88     Node JavaDoc prefetchDisabledNode = super.writeDescriptor(parent, nodeName,
89             prefetchDisabledDescriptor);
90         ArrayList JavaDoc methodDescs =
91             prefetchDisabledDescriptor.getConvertedMethodDescs();
92         if (!methodDescs.isEmpty()) {
93             MethodNode methodNode = new MethodNode();
94             for (Iterator JavaDoc methodIterator = methodDescs.iterator();
95                 methodIterator.hasNext();) {
96                 MethodDescriptor methodDesc =
97                     (MethodDescriptor) methodIterator.next();
98                 methodNode.writeQueryMethodDescriptor(prefetchDisabledNode,
99                     RuntimeTagNames.QUERY_METHOD, methodDesc);
100             }
101         }
102
103     return prefetchDisabledNode;
104     }
105 }
106
Popular Tags