KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > runtime > web > ClassLoaderNode


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.web;
25
26 import java.util.Map JavaDoc;
27 import org.w3c.dom.Node JavaDoc;
28 import org.w3c.dom.Element JavaDoc;
29
30 import com.sun.enterprise.deployment.runtime.RuntimeDescriptor;
31 import com.sun.enterprise.deployment.runtime.web.ClassLoader;
32 import com.sun.enterprise.deployment.runtime.web.WebProperty;
33 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
34 import com.sun.enterprise.deployment.node.XMLElement;
35
36 /**
37 * node for class-loader tag
38 */

39 public class ClassLoaderNode extends WebRuntimeNode {
40     
41     public ClassLoaderNode() {
42         registerElementHandler(new XMLElement(RuntimeTagNames.PROPERTY),
43             WebPropertyNode.class, "addWebProperty");
44     }
45
46     /**
47      * parsed an attribute of an element
48      *
49      * @param the element name
50      * @param the attribute name
51      * @param the attribute value
52      * @return true if the attribute was processed
53      */

54     protected boolean setAttributeValue(XMLElement elementName,
55         XMLElement attributeName, String JavaDoc value) {
56     RuntimeDescriptor descriptor =
57             (RuntimeDescriptor) getRuntimeDescriptor();
58     if (descriptor==null) {
59         throw new RuntimeException JavaDoc(
60                 "Trying to set values on a null descriptor");
61     }
62     if (attributeName.getQName().equals(RuntimeTagNames.EXTRA_CLASS_PATH)) {
63         descriptor.setAttributeValue(ClassLoader.EXTRA_CLASS_PATH, value);
64         return true;
65     } else if (attributeName.getQName().equals(RuntimeTagNames.DELEGATE)) {
66         descriptor.setAttributeValue(ClassLoader.DELEGATE, value);
67         return true;
68     } else if (attributeName.getQName().equals(
69             RuntimeTagNames.DYNAMIC_RELOAD_INTERVAL)) {
70         descriptor.setAttributeValue(ClassLoader.DYNAMIC_RELOAD_INTERVAL,
71                 value);
72         return true;
73     }
74     return false;
75     }
76     
77     /**
78      * write the descriptor class to a DOM tree and return it
79      *
80      * @param parent node for the DOM tree
81      * @param node name
82      * @param the descriptor to write
83      * @return the DOM tree top node
84      */

85     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName,
86         ClassLoader JavaDoc descriptor) {
87
88     Element JavaDoc classLoader = (Element JavaDoc) super.writeDescriptor(parent,
89             nodeName, descriptor);
90     
91         // property*
92
WebProperty[] properties = descriptor.getWebProperty();
93         if (properties != null && properties.length > 0) {
94             WebPropertyNode wpn = new WebPropertyNode();
95             wpn.writeDescriptor(classLoader, RuntimeTagNames.PROPERTY,
96                 properties);
97         }
98
99     // extra-class-path, delegate, dynamic-reload-interval
100
setAttribute(classLoader, RuntimeTagNames.EXTRA_CLASS_PATH, (String JavaDoc) descriptor.getAttributeValue(ClassLoader.EXTRA_CLASS_PATH));
101     setAttribute(classLoader, RuntimeTagNames.DELEGATE, (String JavaDoc) descriptor.getAttributeValue(ClassLoader.DELEGATE));
102     setAttribute(classLoader, RuntimeTagNames.DYNAMIC_RELOAD_INTERVAL, (String JavaDoc) descriptor.getAttributeValue(ClassLoader.DYNAMIC_RELOAD_INTERVAL));
103     
104     return classLoader;
105     }
106 }
107
Popular Tags