KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > runtime > connector > RoleMapNode


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.connector;
24
25 import java.util.Map JavaDoc;
26 import org.w3c.dom.Node JavaDoc;
27 import org.w3c.dom.Element JavaDoc;
28
29 import com.sun.enterprise.deployment.node.XMLElement;
30 import com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorNode;
31 import com.sun.enterprise.deployment.runtime.connector.RoleMap;
32 import com.sun.enterprise.deployment.runtime.connector.MapElement;
33 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
34
35 /**
36  * This node handles the role-map runtime deployment descriptors
37  *
38  * @author Jerome Dochez
39  * @version
40  */

41 public class RoleMapNode extends RuntimeDescriptorNode {
42     
43     
44     public RoleMapNode() {
45         registerElementHandler(new XMLElement(RuntimeTagNames.MAP_ELEMENT),
46                                MapElementNode.class, "addMapElement");
47     }
48     
49     /**
50      * write the descriptor class to a DOM tree and return it
51      *
52      * @param parent node for the DOM tree
53      * @param node name for the descriptor
54      * @param the descriptor to write
55      * @return the DOM tree top node
56      */

57     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, RoleMap descriptor) {
58     Element JavaDoc roleMapNode = (Element JavaDoc) super.writeDescriptor(parent, nodeName, descriptor);
59     appendTextChild(roleMapNode, RuntimeTagNames.DESCRIPTION, descriptor.getDescription());
60     setAttribute(roleMapNode, RuntimeTagNames.MAP_ID, (String JavaDoc) descriptor.getValue(RoleMap.MAP_ID));
61
62     // map-element*
63
MapElement[] maps = descriptor.getMapElement();
64     if (maps.length>0) {
65         MapElementNode men = new MapElementNode();
66         for (int i=0;i<maps.length;i++) {
67         men.writeDescriptor(roleMapNode, RuntimeTagNames.MAP_ELEMENT, maps[i]);
68         }
69     }
70     
71     return roleMapNode;
72     }
73 }
74
Popular Tags