KickJava   Java API By Example, From Geeks To Geeks.

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


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

50 public class ActivationSpecNode extends DeploymentDescriptorNode {
51     
52     private MessageListener msgListener = null;
53     
54     public ActivationSpecNode() {
55     registerElementHandler(new XMLElement(ConnectorTagNames.REQUIRED_CONFIG_PROP),
56                    RequiredConfigNode.class);
57     
58     }
59
60    /**
61      * all sub-implementation of this class can use a dispatch table to map xml element to
62      * method name on the descriptor class for setting the element value.
63      *
64      * @return the map with the element name as a key, the setter method as a value
65      */

66
67     protected Map getDispatchTable() {
68         Map table = super.getDispatchTable();
69     table.put(ConnectorTagNames.ACTIVATION_SPEC_CLASS, "setActivationSpecClass");
70         return table;
71     }
72
73     /**
74     * @return the descriptor instance to associate with this XMLNode
75     */

76     public Object JavaDoc getDescriptor() {
77         if (msgListener == null) {
78             msgListener = (MessageListener) getParentNode().getDescriptor();
79         }
80         return msgListener;
81     }
82
83     /**
84      * Adds a new DOL descriptor instance to the descriptor instance associated with
85      * this XMLNode
86      *
87      * @param descriptor the new descriptor
88      */

89     public void addDescriptor(Object JavaDoc obj) {
90     if (obj instanceof EnvironmentProperty) {
91         msgListener.addConfigProperty((EnvironmentProperty)obj);
92     }
93     }
94
95     /**
96      * write the descriptor class to a DOM tree and return it
97      *
98      * @param parent node for the DOM tree
99      * @param the descriptor to write
100      * @return the DOM tree top node
101      */

102     public Node writeDescriptor(Node parent, Descriptor descriptor) {
103
104         if (! (descriptor instanceof MessageListener)) {
105             throw new IllegalArgumentException JavaDoc(getClass() + " cannot handle descriptors of type " + descriptor.getClass());
106         }
107
108     MessageListener msgListener = (MessageListener)descriptor;
109     Node actSpecNode = appendChild(parent, ConnectorTagNames.ACTIVATION_SPEC);
110     appendTextChild(actSpecNode, ConnectorTagNames.ACTIVATION_SPEC_CLASS, msgListener.getActivationSpecClass());
111
112     //required-config-property
113
RequiredConfigNode reqNode = new RequiredConfigNode();
114     actSpecNode = reqNode.writeDescriptor(actSpecNode, msgListener);
115     
116     return parent;
117     }
118 }
119
Popular Tags