KickJava   Java API By Example, From Geeks To Geeks.

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


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.runtime;
25
26 import java.util.Iterator JavaDoc;
27 import org.w3c.dom.Node JavaDoc;
28 import org.w3c.dom.Document JavaDoc;
29
30 import com.sun.enterprise.deployment.EjbBundleDescriptor;
31 import com.sun.enterprise.deployment.Application;
32 import com.sun.enterprise.deployment.EjbDescriptor;
33 import com.sun.enterprise.deployment.ResourceReferenceDescriptor;
34 import com.sun.enterprise.deployment.RelationshipDescriptor;
35 import com.sun.enterprise.deployment.Descriptor;
36 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
37 import com.sun.enterprise.deployment.node.XMLElement;
38 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
39 import com.sun.enterprise.deployment.xml.WebServicesTagNames;
40 import com.sun.enterprise.deployment.util.DOLUtils;
41
42 /**
43  * This node handles runtime deployment descriptors for ejb bundle
44  *
45  * @author Jerome Dochez
46  * @version
47  */

48 public class EntrepriseBeansRuntimeNode extends RuntimeDescriptorNode {
49     
50     /**
51      * Initializes the child handler;
52      */

53     public EntrepriseBeansRuntimeNode() {
54         // we do not care about our standard DDS handles
55
handlers = null;
56                          
57         registerElementHandler(new XMLElement(RuntimeTagNames.EJB),
58                                EjbNode.class);
59         registerElementHandler(new XMLElement(RuntimeTagNames.PM_DESCRIPTORS),
60                                PMDescriptorsNode.class);
61         registerElementHandler(new XMLElement(RuntimeTagNames.CMP_RESOURCE),
62                                CmpResourceNode.class);
63         registerElementHandler
64             (new XMLElement(RuntimeTagNames.MESSAGE_DESTINATION),
65              MessageDestinationRuntimeNode.class);
66
67         registerElementHandler
68             (new XMLElement(WebServicesTagNames.WEB_SERVICE),
69              WebServiceRuntimeNode.class);
70     }
71     
72    /**
73     * @return the descriptor instance to associate with this XMLNode
74     */

75     public Object JavaDoc getDescriptor() {
76         return getParentNode().getDescriptor();
77     }
78     
79     
80     protected XMLElement getXMLRootTag() {
81         return new XMLElement(RuntimeTagNames.EJBS);
82     }
83
84     /**
85      * receives notiification of the value for a particular tag
86      *
87      * @param element the xml element
88      * @param value it's associated value
89      */

90     public void setElementValue(XMLElement element, String JavaDoc value) {
91     
92         if (RuntimeTagNames.NAME.equals(element.getQName())) {
93             DOLUtils.getDefaultLogger().finer("Ignoring runtime bundle name " + value);
94             return;
95         }
96     if (getDescriptor()!=null && RuntimeTagNames.UNIQUE_ID.equals(element.getQName())) {
97             ((EjbBundleDescriptor) getDescriptor()).setUniqueId(Long.parseLong(value));
98         } else super.setElementValue(element, value);
99     }
100     
101     /**
102      * write the descriptor class to a DOM tree and return it
103      *
104      * @param parent node for the DOM tree
105      * @param the descriptor to write
106      * @return the DOM tree top node
107      */

108     public Node JavaDoc writeDescriptor(Node JavaDoc parent, String JavaDoc nodeName, EjbBundleDescriptor bundleDescriptor) {
109
110         Node JavaDoc ejbs = super.writeDescriptor(parent, nodeName, bundleDescriptor);
111     
112         appendTextChild(ejbs, RuntimeTagNames.UNIQUE_ID, String.valueOf(bundleDescriptor.getUniqueId()));
113         
114         // ejb*
115
EjbNode ejbNode = new EjbNode();
116         for (Iterator JavaDoc ejbIterator = bundleDescriptor.getEjbs().iterator();ejbIterator.hasNext();) {
117             EjbDescriptor ejbDescriptor = (EjbDescriptor) ejbIterator.next();
118             ejbNode.writeDescriptor(ejbs, RuntimeTagNames.EJB, ejbDescriptor);
119         }
120         
121         // pm-descriptors?
122
PMDescriptorsNode pmsNode = new PMDescriptorsNode();
123     pmsNode.writeDescriptor(ejbs, RuntimeTagNames.PM_DESCRIPTORS, bundleDescriptor);
124         
125         // cmpresource?
126
ResourceReferenceDescriptor rrd = bundleDescriptor.getCMPResourceReference();
127         if ( rrd != null ) {
128             CmpResourceNode crn = new CmpResourceNode();
129             crn.writeDescriptor(ejbs, RuntimeTagNames.CMP_RESOURCE, rrd);
130         }
131         
132         // message-destination*
133
writeMessageDestinationInfo(ejbs, bundleDescriptor);
134
135         // webservice-description*
136
WebServiceRuntimeNode webServiceNode = new WebServiceRuntimeNode();
137         webServiceNode.writeWebServiceRuntimeInfo(ejbs, bundleDescriptor);
138
139         return ejbs;
140     }
141         
142 }
143
Popular Tags