KickJava   Java API By Example, From Geeks To Geeks.

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


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.CheckpointAtEndOfMethodDescriptor;
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 checkpoint-at-end-of-method runtime deployment descriptors
39  *
40  */

41 public class CheckpointAtEndOfMethodNode extends DeploymentDescriptorNode {
42
43     protected CheckpointAtEndOfMethodDescriptor descriptor=null;
44     
45     /** Creates new CheckpointAtEndOfMethodNode */
46     public CheckpointAtEndOfMethodNode() {
47         registerElementHandler(new XMLElement(RuntimeTagNames.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 CheckpointAtEndOfMethodDescriptor();
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         CheckpointAtEndOfMethodDescriptor checkpointMethodDescriptor) {
88     Node JavaDoc checkpointMethodNode = super.writeDescriptor(parent, nodeName,
89             checkpointMethodDescriptor);
90         ArrayList JavaDoc methodDescs = checkpointMethodDescriptor.getConvertedMethodDescs();
91         if (!methodDescs.isEmpty()) {
92             MethodNode methodNode = new MethodNode();
93             for (Iterator JavaDoc methodIterator = methodDescs.iterator();
94                 methodIterator.hasNext();) {
95                 MethodDescriptor methodDesc =
96                     (MethodDescriptor) methodIterator.next();
97                 // do not write out ejb-name element for the method
98
methodNode.writeDescriptor(checkpointMethodNode,
99                     RuntimeTagNames.METHOD, methodDesc, null);
100             }
101         }
102
103     return checkpointMethodNode;
104     }
105 }
106
Popular Tags