KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > runtime > MDBConnectionFactoryNode


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 package com.sun.enterprise.deployment.node.runtime;
24
25 import java.util.Map JavaDoc;
26 import org.w3c.dom.Node JavaDoc;
27
28 import com.sun.enterprise.deployment.node.XMLElement;
29 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
30 import com.sun.enterprise.deployment.runtime.MdbConnectionFactoryDescriptor;
31 import com.sun.enterprise.deployment.ResourcePrincipal;
32 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
33
34 public class MDBConnectionFactoryNode extends DeploymentDescriptorNode {
35     
36     protected MdbConnectionFactoryDescriptor descriptor;
37     
38     public MDBConnectionFactoryNode() {
39     registerElementHandler(new XMLElement(RuntimeTagNames.DEFAULT_RESOURCE_PRINCIPAL), DefaultResourcePrincipalNode.class);
40     }
41     
42     
43    /**
44     * @return the descriptor instance to associate with this XMLNode
45     */

46     public Object JavaDoc getDescriptor() {
47     if (descriptor==null) {
48         descriptor = new MdbConnectionFactoryDescriptor();
49     }
50     return descriptor;
51     }
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 JavaDoc getDispatchTable() {
60     Map JavaDoc dispatchTable = super.getDispatchTable();
61     dispatchTable.put(RuntimeTagNames.JNDI_NAME, "setJndiName");
62     return dispatchTable;
63     }
64     
65     /**
66      * Adds a new DOL descriptor instance to the descriptor instance associated with
67      * this XMLNode
68      *
69      * @param descriptor the new descriptor
70      */

71     public void addDescriptor(Object JavaDoc newDescriptor) {
72     if (newDescriptor instanceof ResourcePrincipal) {
73         descriptor.setDefaultResourcePrincipal((ResourcePrincipal) newDescriptor);
74     } else super.addDescriptor(newDescriptor);
75     }
76     
77     /**
78      * write the descriptor class to a DOM tree and return it
79      *
80      * @param parent node for the DOM tree
81      * @param node name for the descriptor
82      * @param the descriptor to write
83      * @return the DOM tree top node
84      */

85     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, MdbConnectionFactoryDescriptor mcf) {
86     Node JavaDoc mcfNode = super.writeDescriptor(parent, nodeName, mcf);
87     appendTextChild(mcfNode, RuntimeTagNames.JNDI_NAME, mcf.getJndiName());
88         if (mcf.getDefaultResourcePrincipal()!=null) {
89             DefaultResourcePrincipalNode subNode = new DefaultResourcePrincipalNode();
90             subNode.writeDescriptor(mcfNode, RuntimeTagNames.DEFAULT_RESOURCE_PRINCIPAL, mcf.getDefaultResourcePrincipal());
91         }
92     return mcfNode;
93     }
94 }
95
Popular Tags