KickJava   Java API By Example, From Geeks To Geeks.

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


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.runtime;
25
26 import com.sun.enterprise.deployment.ApplicationClientDescriptor;
27 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
28 import com.sun.enterprise.deployment.node.XMLNode;
29 import com.sun.enterprise.deployment.runtime.JavaWebStartAccessDescriptor;
30 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
31 import com.sun.enterprise.deployment.xml.TagNames;
32 import java.util.Map JavaDoc;
33 import org.w3c.dom.Node JavaDoc;
34
35 /**
36  *
37  * @author tjquinn
38  */

39 public class JavaWebStartAccessNode extends DeploymentDescriptorNode {
40     
41     protected JavaWebStartAccessDescriptor descriptor;
42     
43     /** Creates a new instance of JavaWebStartAccessNode */
44     public JavaWebStartAccessNode() {
45     }
46     
47    /**
48     * @return the descriptor instance to associate with this XMLNode
49     */

50     public Object JavaDoc getDescriptor() {
51     if (descriptor==null) {
52         descriptor = new JavaWebStartAccessDescriptor();
53             XMLNode parentNode = getParentNode();
54             if (parentNode != null && (parentNode instanceof AppClientRuntimeNode)) {
55                 Object JavaDoc parentDescriptor = parentNode.getDescriptor();
56                 if (parentDescriptor != null && (parentDescriptor instanceof ApplicationClientDescriptor) ) {
57                     ApplicationClientDescriptor acDescriptor = (ApplicationClientDescriptor) parentDescriptor;
58                     acDescriptor.setJavaWebStartAccessDescriptor(descriptor);
59                 }
60                 
61             }
62     }
63     return descriptor;
64     }
65     
66     /**
67      * all sub-implementation of this class can use a dispatch table to map xml element to
68      * method name on the descriptor class for setting the element value.
69      *
70      * @return the map with the element name as a key, the setter method as a value
71      */

72     protected Map JavaDoc getDispatchTable() {
73         Map JavaDoc table = super.getDispatchTable();
74         table.put(RuntimeTagNames.CONTEXT_ROOT, "setContextRoot");
75         table.put(RuntimeTagNames.ELIGIBLE, "setEligible");
76         table.put(RuntimeTagNames.VENDOR, "setVendor");
77         return table;
78     }
79
80     /**
81      * write the descriptor class to a DOM tree and return it
82      *
83      * @param parent node for the DOM tree
84      * @param node name for the descriptor
85      * @param the descriptor to write
86      * @return the DOM tree top node
87      */

88     public Node writeDescriptor(Node parent, String JavaDoc nodeName, JavaWebStartAccessDescriptor descr) {
89     Node accessNode = super.writeDescriptor(parent, nodeName, descr);
90         appendTextChild(accessNode, RuntimeTagNames.CONTEXT_ROOT, descr.getContextRoot());
91         appendTextChild(accessNode, RuntimeTagNames.ELIGIBLE, Boolean.toString(descr.isEligible()));
92         appendTextChild(accessNode, RuntimeTagNames.VENDOR, descr.getVendor());
93
94     return accessNode;
95     }
96     
97     public static void writeJavaWebStartInfo(Node parent, JavaWebStartAccessDescriptor descr) {
98         if (descr != null) {
99             JavaWebStartAccessNode newNode = new JavaWebStartAccessNode();
100             newNode.writeDescriptor(parent, RuntimeTagNames.JAVA_WEB_START_ACCESS, descr);
101         }
102     }
103 }
104
Popular Tags