KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > ejb > AroundInvokeNode


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 package com.sun.enterprise.deployment.node.ejb;
25
26 import java.util.Iterator JavaDoc;
27 import java.util.Map JavaDoc;
28 import java.util.Set JavaDoc;
29 import org.w3c.dom.Node JavaDoc;
30
31 import com.sun.enterprise.deployment.LifecycleCallbackDescriptor;
32 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
33 import com.sun.enterprise.deployment.xml.EjbTagNames;
34 import com.sun.enterprise.deployment.EjbInterceptor;
35 import com.sun.enterprise.deployment.EjbDescriptor;
36 import com.sun.enterprise.deployment.Descriptor;
37
38
39 /**
40  * This node handles all information relative to injection-complete xml tag
41  */

42 public class AroundInvokeNode extends DeploymentDescriptorNode {
43
44     private LifecycleCallbackDescriptor descriptor;
45     
46    /**
47     * @return the descriptor instance to associate with this XMLNode
48     */

49     public Object JavaDoc getDescriptor() {
50         
51        if (descriptor==null) {
52             descriptor = new LifecycleCallbackDescriptor();
53             Descriptor parentDesc =
54                 (Descriptor)getParentNode().getDescriptor();
55             if (parentDesc instanceof EjbDescriptor) {
56                 EjbDescriptor ejbDesc = (EjbDescriptor)parentDesc;
57                 descriptor.setDefaultLifecycleCallbackClass(
58                     ejbDesc.getEjbClassName());
59             } else if (parentDesc instanceof EjbInterceptor) {
60                 EjbInterceptor ejbInterceptor =
61                     (EjbInterceptor)parentDesc;
62                 descriptor.setDefaultLifecycleCallbackClass(
63                     ejbInterceptor.getInterceptorClassName());
64             }
65         }
66         return descriptor;
67     }
68     
69     /**
70      * all sub-implementation of this class can use a dispatch table to map xml element to
71      * method name on the descriptor class for setting the element value.
72      *
73      * @return the map with the element name as a key, the setter method as a value
74      */

75     protected Map JavaDoc getDispatchTable() {
76         Map JavaDoc table = super.getDispatchTable();
77         table.put(EjbTagNames.AROUND_INVOKE_CLASS_NAME,
78             "setLifecycleCallbackClass");
79         table.put(EjbTagNames.AROUND_INVOKE_METHOD_NAME,
80             "setLifecycleCallbackMethod");
81         return table;
82     }
83     
84     /**
85      * write the descriptor class to a DOM tree and return it
86      *
87      * @param parent node in the DOM tree
88      * @param node name for the root element of this xml fragment
89      * @param the descriptor to write
90      * @return the DOM tree top node
91      */

92     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, LifecycleCallbackDescriptor descriptor) {
93         Node JavaDoc myNode = appendChild(parent, nodeName);
94         appendTextChild(myNode, EjbTagNames.AROUND_INVOKE_CLASS_NAME,
95             descriptor.getLifecycleCallbackClass());
96         appendTextChild(myNode, EjbTagNames.AROUND_INVOKE_METHOD_NAME,
97             descriptor.getLifecycleCallbackMethod());
98         return myNode;
99     }
100 }
101
Popular Tags