KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > runtime > common > ResourceRefNode


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.common;
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.runtime.RuntimeDescriptorNode;
30 import com.sun.enterprise.deployment.runtime.common.ResourceRef;
31 import com.sun.enterprise.deployment.runtime.common.DefaultResourcePrincipal;
32 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
33
34 /**
35  * This node handles all the role mapping information
36  *
37  * @author Jerome Dochez
38  * @version
39  */

40 public class ResourceRefNode extends RuntimeDescriptorNode {
41     
42     public ResourceRefNode() {
43     registerElementHandler(new XMLElement(RuntimeTagNames.DEFAULT_RESOURCE_PRINCIPAL),
44                 DefaultResourcePrincipalNode.class, "setDefaultResourcePrincipal");
45     }
46
47     /**
48      * all sub-implementation of this class can use a dispatch table to map xml element to
49      * method name on the descriptor class for setting the element value.
50      *
51      * @return the map with the element name as a key, the setter method as a value
52      */

53     protected Map JavaDoc getDispatchTable() {
54         Map JavaDoc table = super.getDispatchTable();
55         table.put(RuntimeTagNames.RES_REF_NAME, "setResRefName");
56         table.put(RuntimeTagNames.JNDI_NAME, "setJndiName");
57         return table;
58     }
59     
60     /**
61      * write the descriptor class to a DOM tree and return it
62      *
63      * @param parent node for the DOM tree
64      * @param node name
65      * @param the descriptor to write
66      * @return the DOM tree top node
67      */

68     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, ResourceRef descriptor) {
69         Node JavaDoc refNode = appendChild(parent, nodeName);
70     appendTextChild(refNode, RuntimeTagNames.RES_REF_NAME, descriptor.getResRefName());
71     appendTextChild(refNode, RuntimeTagNames.JNDI_NAME, descriptor.getJndiName());
72     DefaultResourcePrincipal defaultPrincipal = descriptor.getDefaultResourcePrincipal();
73     if (defaultPrincipal!=null) {
74         DefaultResourcePrincipalNode subNode = new DefaultResourcePrincipalNode();
75         subNode.writeDescriptor(refNode, RuntimeTagNames.DEFAULT_RESOURCE_PRINCIPAL, defaultPrincipal);
76     }
77         return refNode;
78     }
79 }
80
Popular Tags