KickJava   Java API By Example, From Geeks To Geeks.

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


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.Principal;
32 import com.sun.enterprise.deployment.runtime.RuntimeDescriptor;
33 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
34
35 /**
36  * This node handles the principal runtime deployment descriptors
37  *
38  * @author Jerome Dochez
39  * @version
40  */

41 public class PrincipalNode extends RuntimeDescriptorNode {
42     
43     /**
44      * receives notification of the value for a particular tag
45      *
46      * @param element the xml element
47      * @param value it's associated value
48      */

49     public void setElementValue(XMLElement element, String JavaDoc value) {
50     RuntimeDescriptor descriptor = (RuntimeDescriptor) getDescriptor();
51     if (descriptor==null) {
52         throw new RuntimeException JavaDoc("Trying to set values on a null descriptor");
53     }
54     if (element.getQName().equals(RuntimeTagNames.USER_NAME)) {
55         descriptor.setAttributeValue(Principal.USER_NAME, value);
56     } else
57     if (element.getQName().equals(RuntimeTagNames.PASSWORD)) {
58         descriptor.setAttributeValue(Principal.PASSWORD, value);
59     } else
60     if (element.getQName().equals(RuntimeTagNames.CREDENTIAL)) {
61         descriptor.setAttributeValue(Principal.CREDENTIAL, value);
62     } else
63     super.setElementValue(element, value);
64     }
65     
66     
67     /**
68      * write the descriptor class to a DOM tree and return it
69      *
70      * @param parent node for the DOM tree
71      * @param node name for the descriptor
72      * @param the descriptor to write
73      * @return the DOM tree top node
74      */

75     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, Principal descriptor) {
76     Element JavaDoc principalNode = (Element JavaDoc) super.writeDescriptor(parent, nodeName, descriptor);
77     appendTextChild(principalNode, RuntimeTagNames.DESCRIPTION, descriptor.getDescription());
78     setAttribute(principalNode, RuntimeTagNames.USER_NAME, (String JavaDoc) descriptor.getValue(Principal.USER_NAME));
79     setAttribute(principalNode, RuntimeTagNames.PASSWORD, (String JavaDoc) descriptor.getValue(Principal.PASSWORD));
80     setAttribute(principalNode, RuntimeTagNames.CREDENTIAL, (String JavaDoc) descriptor.getValue(Principal.CREDENTIAL));
81     return principalNode;
82     }
83 }
84
Popular Tags