KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Map JavaDoc;
28 import java.util.logging.Level JavaDoc;
29 import org.w3c.dom.Node JavaDoc;
30 import org.w3c.dom.Document JavaDoc;
31
32 import com.sun.enterprise.deployment.Descriptor;
33 import com.sun.enterprise.deployment.JndiNameEnvironment;
34 import com.sun.enterprise.deployment.BundleDescriptor;
35 import com.sun.enterprise.deployment.MessageDestinationDescriptor;
36 import com.sun.enterprise.deployment.node.XMLElement;
37 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode;
38 import com.sun.enterprise.deployment.types.EjbReferenceContainer;
39 import com.sun.enterprise.deployment.types.ResourceReferenceContainer;
40 import com.sun.enterprise.deployment.types.ResourceEnvReferenceContainer;
41 import com.sun.enterprise.deployment.types.MessageDestinationReferenceContainer;
42 import com.sun.enterprise.deployment.runtime.RuntimeDescriptor;
43 import com.sun.enterprise.deployment.xml.RuntimeTagNames;
44 import com.sun.enterprise.deployment.util.DOLUtils;
45 import com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorFactory;
46
47 /**
48  * Superclass for all the runtime descriptor nodes
49  *
50  * @author Jerome Dochez
51  * @version
52  */

53 public class RuntimeDescriptorNode extends DeploymentDescriptorNode
54 {
55    /**
56     * @return the descriptor instance to associate with this XMLNode
57     */

58     public Object JavaDoc getDescriptor() {
59         
60         if (abstractDescriptor==null) {
61         abstractDescriptor = RuntimeDescriptorFactory.getDescriptor(getXMLPath());
62             if (abstractDescriptor ==null) {
63                 return getParentNode().getDescriptor();
64             }
65         }
66         return abstractDescriptor;
67     }
68     
69     /**
70      * receives notification of the value for a particular tag
71      *
72      * @param element the xml element
73      * @param value it's associated value
74      */

75     public void setElementValue(XMLElement element, String JavaDoc value) {
76     if (getDispatchTable().containsKey(element.getQName())) {
77         super.setElementValue(element, value);
78     } else {
79         Object JavaDoc o = getDescriptor();
80         if (o instanceof RuntimeDescriptor) {
81         RuntimeDescriptor rd = (RuntimeDescriptor) o;
82         rd.setValue(element.getQName(), value);
83         } else {
84                 DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure",
85                     new Object JavaDoc[]{element.getQName() , value });
86             }
87     }
88     }
89     
90     /**
91      * writes all information common to all J2EE components
92      *
93      * @param xml node parent to add the info to
94      * @param the descriptor
95      */

96     public static void writeCommonComponentInfo(Node JavaDoc parent, Descriptor descriptor) {
97         if (descriptor instanceof EjbReferenceContainer) {
98             EjbRefNode.writeEjbReferences(parent, (EjbReferenceContainer) descriptor);
99         }
100         if (descriptor instanceof ResourceReferenceContainer) {
101             ResourceRefNode.writeResourceReferences(parent, (ResourceReferenceContainer) descriptor);
102         }
103         if (descriptor instanceof ResourceEnvReferenceContainer) {
104             ResourceEnvRefNode.writeResoureEnvReferences(parent, (ResourceEnvReferenceContainer) descriptor);
105         }
106         if( descriptor instanceof JndiNameEnvironment ) {
107             ServiceRefNode.writeServiceReferences
108                 (parent, (JndiNameEnvironment) descriptor);
109         }
110         if (descriptor instanceof MessageDestinationReferenceContainer) {
111             MessageDestinationRefNode.writeMessageDestinationReferences(parent,
112                 (MessageDestinationReferenceContainer) descriptor);
113         }
114     }
115
116     public static void writeMessageDestinationInfo(Node JavaDoc parent,
117                                                BundleDescriptor descriptor) {
118         for(Iterator JavaDoc iter = descriptor.getMessageDestinations().iterator();
119             iter.hasNext();) {
120             MessageDestinationRuntimeNode node =
121                 new MessageDestinationRuntimeNode();
122             node.writeDescriptor(parent, RuntimeTagNames.MESSAGE_DESTINATION,
123                                  (MessageDestinationDescriptor) iter.next());
124         }
125     }
126
127 }
128
Popular Tags