KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > connector > RequiredConfigNode


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.connector;
25
26 import java.util.*;
27 import org.xml.sax.Attributes JavaDoc;
28 import com.sun.enterprise.deployment.Descriptor;
29 import com.sun.enterprise.deployment.ConnectorDescriptor;
30 import com.sun.enterprise.deployment.OutboundResourceAdapter;
31 import com.sun.enterprise.deployment.MessageListener;
32 import com.sun.enterprise.deployment.EnvironmentProperty;
33 import com.sun.enterprise.deployment.xml.ConnectorTagNames;
34 import com.sun.enterprise.deployment.xml.TagNames;
35 import com.sun.enterprise.deployment.node.DescriptorFactory;
36 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
37 import com.sun.enterprise.deployment.node.ConfigurableNode;
38 import com.sun.enterprise.deployment.node.XMLElement;
39
40 import org.xml.sax.Attributes JavaDoc;
41 import org.w3c.dom.Node JavaDoc;
42
43 /**
44  * This node is responsible for handling the Connector DTD related required-config-property XML tag
45  *
46  * @author Sheetal Vartak
47  * @version
48  */

49 public class RequiredConfigNode extends DeploymentDescriptorNode {
50
51     private EnvironmentProperty config = null;
52
53    /**
54      * all sub-implementation of this class can use a dispatch table to map xml element to
55      * method name on the descriptor class for setting the element value.
56      *
57      * @return the map with the element name as a key, the setter method as a value
58      */

59     protected Map getDispatchTable() {
60         Map table = super.getDispatchTable();
61         table.put(ConnectorTagNames.CONFIG_PROPERTY_NAME, "setName");
62     return table;
63     }
64
65     /**
66     * @return the descriptor instance to associate with this XMLNode
67     */

68     public Object JavaDoc getDescriptor() {
69         if (config == null) {
70             config = (EnvironmentProperty) DescriptorFactory.getDescriptor(getXMLPath());
71         }
72         return config;
73     }
74
75     /**
76      * write the descriptor class to a DOM tree and return it
77      *
78      * @param parent node for the DOM tree
79      * @param the descriptor to write
80      * @return the DOM tree top node
81      */

82     public Node writeDescriptor(Node parent, Descriptor descriptor) {
83
84         if (! (descriptor instanceof MessageListener)) {
85             throw new IllegalArgumentException JavaDoc(getClass() + " cannot handle descriptors of type " + descriptor.getClass());
86         }
87     Iterator configProps = null;
88     if (descriptor instanceof MessageListener) {
89         configProps = ((MessageListener)descriptor).getConfigProperties().iterator();
90     }
91
92     //config property info
93
for (;configProps.hasNext();) {
94         EnvironmentProperty config = (EnvironmentProperty) configProps.next();
95         Node configNode = appendChild(parent, ConnectorTagNames.REQUIRED_CONFIG_PROP);
96             writeLocalizedDescriptions(configNode, config);
97         appendTextChild(configNode, ConnectorTagNames.CONFIG_PROPERTY_NAME, config.getName());
98     }
99     return parent;
100     }
101 }
102
Popular Tags