KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > MessageDestinationRefNode


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;
25
26 import java.util.Map JavaDoc;
27 import org.w3c.dom.Node JavaDoc;
28
29 import com.sun.enterprise.deployment.MessageDestinationReferenceDescriptor;
30 import com.sun.enterprise.deployment.InjectionTarget;
31 import com.sun.enterprise.deployment.node.LocalizedNode;
32 import com.sun.enterprise.deployment.xml.TagNames;
33 import com.sun.enterprise.deployment.Descriptor;
34
35 /**
36  * This class handles all information related to the message-destination-ref
37  * xml tag
38  *
39  * @author Kenneth Saks
40  * @version
41  */

42 public class MessageDestinationRefNode extends DeploymentDescriptorNode {
43     
44     public MessageDestinationRefNode() {
45         super();
46         registerElementHandler(new XMLElement(TagNames.INJECTION_TARGET),
47                                 InjectionTargetNode.class, "addInjectionTarget");
48     }
49     
50     /**
51      * all sub-implementation of this class can use a dispatch table to
52      * map xml element to method name on the descriptor class for setting
53      * the element value.
54      *
55      * @return map with the element name as a key, the setter method as a value
56      */

57     protected Map JavaDoc getDispatchTable() {
58         Map JavaDoc table = super.getDispatchTable();
59         table.put(TagNames.MESSAGE_DESTINATION_REFERENCE_NAME, "setName");
60         table.put(TagNames.MESSAGE_DESTINATION_TYPE, "setDestinationType");
61         table.put(TagNames.MESSAGE_DESTINATION_USAGE, "setUsage");
62         table.put(TagNames.MESSAGE_DESTINATION_LINK,
63                   "setMessageDestinationLinkName");
64         table.put(TagNames.MAPPED_NAME, "setMappedName");
65
66         return table;
67     }
68     
69     /**
70      * write the descriptor class to a DOM tree and return it
71      *
72      * @param parent node in the DOM tree
73      * @param node name for the root element of this xml fragment
74      * @param the descriptor to write
75      * @return the DOM tree top node
76      */

77     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName,
78                                 MessageDestinationReferenceDescriptor desc) {
79     
80         Node JavaDoc msgDestRefNode = appendChild(parent, nodeName);
81
82         writeLocalizedDescriptions(msgDestRefNode, desc);
83
84         appendTextChild(msgDestRefNode,
85                         TagNames.MESSAGE_DESTINATION_REFERENCE_NAME,
86                         desc.getName());
87         appendTextChild(msgDestRefNode, TagNames.MESSAGE_DESTINATION_TYPE,
88                         desc.getDestinationType());
89         appendTextChild(msgDestRefNode, TagNames.MESSAGE_DESTINATION_USAGE,
90                         desc.getUsage());
91         appendTextChild(msgDestRefNode, TagNames.MESSAGE_DESTINATION_LINK,
92                             desc.getMessageDestinationLinkName());
93         appendTextChild(msgDestRefNode, TagNames.MAPPED_NAME,
94             desc.getMappedName());
95
96         if( desc.isInjectable() ) {
97             InjectionTargetNode ijNode = new InjectionTargetNode();
98             for (InjectionTarget target : desc.getInjectionTargets()) {
99                 ijNode.writeDescriptor(msgDestRefNode, TagNames.INJECTION_TARGET, target);
100             }
101         }
102
103         return msgDestRefNode;
104     }
105 }
106
Popular Tags