KickJava   Java API By Example, From Geeks To Geeks.

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


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 /*
25  * ConnectorNode.java. This class is responsible for encapsulating all information specific to the Connector DTD
26  *
27  * Created on April 18th, 2002, 4.34 PM
28  */

29
30 package com.sun.enterprise.deployment.node.connector;
31
32 import java.util.*;
33 import org.w3c.dom.Node JavaDoc;
34 import org.xml.sax.Attributes JavaDoc;
35 import com.sun.enterprise.deployment.ConnectorDescriptor;
36 import com.sun.enterprise.deployment.AdminObject;
37 import com.sun.enterprise.deployment.Descriptor;
38 import com.sun.enterprise.deployment.EnvironmentProperty;
39 import com.sun.enterprise.deployment.SecurityPermission;
40 import com.sun.enterprise.deployment.node.DescriptorFactory;
41 import com.sun.enterprise.deployment.node.BundleNode;
42 import com.sun.enterprise.deployment.node.ConfigurableNode;
43 import com.sun.enterprise.deployment.xml.ConnectorTagNames;
44 import com.sun.enterprise.deployment.xml.TagNames;
45 import com.sun.enterprise.deployment.node.XMLElement;
46 import com.sun.enterprise.deployment.node.RootXMLNode;
47 import com.sun.enterprise.deployment.node.XMLNode;
48 import com.sun.enterprise.deployment.MessageListener;
49 import com.sun.enterprise.deployment.node.connector.MessageListenerNode;
50 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
51
52 //for 1.0 DTD
53
import com.sun.enterprise.deployment.AuthMechanism;
54 import com.sun.enterprise.deployment.SecurityPermission;
55 import com.sun.enterprise.deployment.util.DOLUtils;
56
57
58 /**
59  *
60  * @author Sheetal Vartak
61  * @version
62  */

63 public class RANode extends DeploymentDescriptorNode {
64
65     // Descriptor class we are using
66
private ConnectorDescriptor descriptor = null;
67     public static String JavaDoc VERSION_10 = "1.0";
68     public static String JavaDoc VERSION_15 = "1.5";
69
70     //default constructor
71
public RANode() {
72     register();
73     }
74
75     public RANode(XMLElement element) {
76     this.setXMLRootTag(element);
77     register();
78     }
79
80     private void register() {
81     //check for the version of DTD
82
registerElementHandler(new XMLElement(ConnectorTagNames.OUTBOUND_RESOURCE_ADAPTER),
83                    OutBoundRANode.class);
84     registerElementHandler(new XMLElement(ConnectorTagNames.INBOUND_RESOURCE_ADAPTER),
85                    InBoundRANode.class);
86     registerElementHandler(new XMLElement(ConnectorTagNames.CONFIG_PROPERTY),
87                    ConfigPropertyNode.class, "addConfigProperty");
88     registerElementHandler(new XMLElement(ConnectorTagNames.ADMIN_OBJECT),
89                    AdminObjectNode.class, "addAdminObject");
90     registerElementHandler(new XMLElement(ConnectorTagNames.SECURITY_PERMISSION),
91                    SecurityPermissionNode.class, "addSecurityPermission");
92     }
93
94        
95    /**
96     * @return the descriptor instance to associate with this XMLNode
97     */

98     public Object JavaDoc getDescriptor() {
99         if (descriptor == null) {
100         descriptor = (ConnectorDescriptor)getParentNode().getDescriptor();
101         }
102     return descriptor;
103     }
104     
105     /**
106      * all sub-implementation of this class can use a dispatch table to map xml element to
107      * method name on the descriptor class for setting the element value.
108      *
109      * @return the map with the element name as a key, the setter method as a value
110      */

111     protected Map getDispatchTable() {
112         // no need to be synchronized for now
113
Map table = super.getDispatchTable();
114         table.put(ConnectorTagNames.RESOURCE_ADAPTER_CLASS, "setResourceAdapterClass");
115     return table;
116     }
117
118     /**
119      * write the descriptor class to a DOM tree and return it
120      *
121      * @param parent node for the DOM tree
122      * @param the descriptor to write
123      * @return the DOM tree top node
124      */

125     public Node JavaDoc writeDescriptor(Node JavaDoc connectorNode, Descriptor descriptor) {
126
127         if (! (descriptor instanceof ConnectorDescriptor)) {
128             throw new IllegalArgumentException JavaDoc(getClass() + " cannot handle descriptors of type " + descriptor.getClass());
129         }
130         ConnectorDescriptor conDesc = (ConnectorDescriptor) descriptor;
131         Node JavaDoc raNode = appendChild(connectorNode, ConnectorTagNames.RESOURCE_ADAPTER);
132
133     appendTextChild(raNode, ConnectorTagNames.RESOURCE_ADAPTER_CLASS, conDesc.getResourceAdapterClass());
134     
135     //config-property
136
ConfigPropertyNode config = new ConfigPropertyNode();
137     raNode = config.writeDescriptor(raNode, conDesc);
138     
139     if (conDesc.getOutBoundDefined() == true) {
140         //outbound RA info
141
OutBoundRANode obNode = new OutBoundRANode();
142         raNode = obNode.writeDescriptor(raNode, conDesc);
143     }
144     
145     if (conDesc.getInBoundDefined() == true) {
146         //inbound RA info
147
InBoundRANode inNode = new InBoundRANode();
148         raNode = inNode.writeDescriptor(raNode, conDesc);
149     }
150     
151     //adminobject
152
AdminObjectNode admin = new AdminObjectNode();
153     raNode = admin.writeDescriptor(raNode, conDesc);
154     //}
155

156         // security-permission*
157
SecurityPermissionNode secPerm = new SecurityPermissionNode();
158     raNode = secPerm.writeDescriptor(raNode, conDesc);
159                  
160     return connectorNode;
161     }
162 }
163
Popular Tags