KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.w3c.dom.Node JavaDoc;
27 import org.w3c.dom.Element JavaDoc;
28
29 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
30 import com.sun.enterprise.deployment.node.XMLElement;
31 import com.sun.enterprise.deployment.runtime.web.IdempotentUrlPattern;
32
33
34
35 /**
36 * node to handle idempotent-url-pattern node
37 */

38 public class IdempotentUrlPatternNode extends WebRuntimeNode {
39
40     IdempotentUrlPattern descriptor = null;
41
42     /**
43     * @return the descriptor instance to associate with this XMLNode
44     */

45     public Object JavaDoc getDescriptor() {
46         if (descriptor == null) {
47             descriptor = new IdempotentUrlPattern();
48         }
49         return descriptor;
50     }
51
52     /**
53      * parsed an attribute of an element
54      *
55      * @param the element name
56      * @param the attribute name
57      * @param the attribute value
58      * @return true if the attribute was processed
59      */

60     protected boolean setAttributeValue(XMLElement elementName, XMLElement attributeName, String JavaDoc value) {
61         if (attributeName.getQName().equals(RuntimeTagNames.URL_PATTERN)) {
62             descriptor.setAttributeValue(IdempotentUrlPattern.URL_PATTERN,
63                 value);
64             return true;
65         } else if (attributeName.getQName().equals(
66             RuntimeTagNames.NUM_OF_RETRIES)) {
67             descriptor.setAttributeValue(IdempotentUrlPattern.NUM_OF_RETRIES,
68                 value);
69             return true;
70         }
71         return false;
72     }
73     
74     /**
75      * write the descriptor class to a DOM tree and return it
76      *
77      * @param parent node for the DOM tree
78      * @param node name for the descriptor
79      * @param the descriptor to write
80      * @return the DOM tree top node
81      */

82     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName,
83        IdempotentUrlPattern pattern) {
84        Element JavaDoc patternNode =
85             (Element JavaDoc)super.writeDescriptor(parent, nodeName, pattern);
86         
87         // url-pattern
88
if (pattern.getAttributeValue(pattern.URL_PATTERN) != null) {
89             setAttribute(patternNode, RuntimeTagNames.URL_PATTERN, pattern.getAttributeValue(pattern.URL_PATTERN));
90         }
91
92         // num-of-retries
93
if (pattern.getAttributeValue(pattern.NUM_OF_RETRIES) != null) {
94             setAttribute(patternNode, RuntimeTagNames.NUM_OF_RETRIES, pattern.getAttributeValue(pattern.NUM_OF_RETRIES));
95         }
96
97         return patternNode;
98     }
99 }
100
101
Popular Tags