KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

57
58     private InboundResourceAdapter descriptor = null;
59
60     //default constructor
61
public InBoundRANode() {
62     registerElementHandler(new XMLElement(ConnectorTagNames.MSG_LISTENER),
63                    MessageListenerNode.class);
64     }
65
66     /**
67      * SAX Parser API implementation, we don't really care for now.
68      */

69      public void startElement(XMLElement element, Attributes JavaDoc attributes) {
70      }
71
72     /**
73      * all sub-implementation of this class can use a dispatch table to map xml element to
74      * method name on the descriptor class for setting the element value.
75      *
76      * @return the map with the element name as a key, the setter method as a value
77      */

78     protected Map getDispatchTable() {
79         Map table = super.getDispatchTable();
80     return table;
81     }
82
83     /**
84     * @return the descriptor instance to associate with this XMLNode
85     */

86     public Object JavaDoc getDescriptor() {
87         if (descriptor==null) {
88         // the descriptor associated with the InBoundRANode is a InboundResourceAdapter
89
// This descriptor is available with the parent node of the InBoundRANode
90
descriptor = (InboundResourceAdapter)DescriptorFactory.getDescriptor(getXMLPath());
91         ((ConnectorDescriptor)(getParentNode().getDescriptor())).setInboundResourceAdapter(descriptor);
92            
93         }
94         return descriptor;
95     }
96
97      /**
98      * Adds a new DOL descriptor instance to the descriptor instance associated with
99      * this XMLNode
100      *
101      * @param descriptor the new descriptor
102      */

103     public void addDescriptor(Object JavaDoc obj) {
104     if (obj instanceof MessageListener) {
105         descriptor.addMessageListener((MessageListener)obj);
106     }
107     }
108
109     /**
110      * write the descriptor class to a DOM tree and return it
111      *
112      * @param parent node for the DOM tree
113      * @param the descriptor to write
114      * @return the DOM tree top node
115      */

116     public Node writeDescriptor(Node connectorNode, Descriptor descriptor) {
117     Node inBoundNode = appendChild(connectorNode, ConnectorTagNames.INBOUND_RESOURCE_ADAPTER);
118     appendInBoundNode(inBoundNode, (InboundResourceAdapter)((ConnectorDescriptor)descriptor).getInboundResourceAdapter());
119     return connectorNode;
120     }
121
122     /**
123      * method to add the child nodes of INBOUND_RESOURCE_ADAPTER
124      */

125     private void appendInBoundNode (Node inBoundNode, InboundResourceAdapter conDesc) {
126
127     Node msgAdapter = appendChild(inBoundNode, ConnectorTagNames.MSG_ADAPTER);
128
129     MessageListenerNode msgListener = new MessageListenerNode();
130     msgAdapter = msgListener.writeDescriptor(msgAdapter, conDesc);
131     }
132
133 }
134
Popular Tags