KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > node > web > WebBundleNode


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.web;
25
26 import java.util.*;
27 import org.w3c.dom.Node JavaDoc;
28
29 import com.sun.enterprise.deployment.node.*;
30
31 import com.sun.enterprise.deployment.xml.TagNames;
32 import com.sun.enterprise.deployment.xml.WebTagNames;
33 import com.sun.enterprise.deployment.xml.WebServicesTagNames;
34 import com.sun.enterprise.deployment.Descriptor;
35 import com.sun.enterprise.deployment.WebBundleDescriptor;
36 import com.sun.enterprise.deployment.SecurityRoleDescriptor;
37
38 import com.sun.enterprise.deployment.types.EjbReference;
39 import com.sun.enterprise.deployment.SecurityRoleDescriptor;
40 import com.sun.enterprise.deployment.EntityManagerReferenceDescriptor;
41 import com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor;
42 import com.sun.enterprise.deployment.EnvironmentProperty;
43 import com.sun.enterprise.deployment.ServiceReferenceDescriptor;
44 import com.sun.enterprise.deployment.ResourceReferenceDescriptor;
45 import com.sun.enterprise.deployment.JmsDestinationReferenceDescriptor;
46 import com.sun.enterprise.deployment.WebComponentDescriptor;
47 import com.sun.enterprise.deployment.MimeMappingDescriptor;
48 import com.sun.enterprise.deployment.AppListenerDescriptorImpl;
49 import com.sun.enterprise.deployment.ServletFilterDescriptor;
50 import com.sun.enterprise.deployment.ServletFilterMappingDescriptor;
51 import com.sun.enterprise.deployment.ErrorPageDescriptorImpl;
52 import com.sun.enterprise.deployment.JspConfigDescriptor;
53 import com.sun.enterprise.deployment.TagLibConfigurationDescriptor;
54 import com.sun.enterprise.deployment.LocaleEncodingMappingDescriptor;
55 import com.sun.enterprise.deployment.LocaleEncodingMappingListDescriptor;
56 import com.sun.enterprise.deployment.LifecycleCallbackDescriptor;
57 import com.sun.enterprise.deployment.SecurityConstraintImpl;
58 import com.sun.enterprise.deployment.LoginConfigurationImpl;
59 import com.sun.enterprise.deployment.WebComponentDescriptor;
60 import com.sun.enterprise.deployment.util.DOLUtils;
61 import com.sun.enterprise.deployment.util.DOLLoadingContextFactory;
62 import com.sun.enterprise.deployment.web.LoginConfiguration;
63
64 /**
65  * This node is responsible for handling the web-app xml tree
66  *
67  * @author Jerome Dochez
68  * @version
69  */

70 public class WebBundleNode extends BundleNode implements RootXMLNode {
71
72    public final static XMLElement tag = new XMLElement(WebTagNames.WEB_BUNDLE);
73
74     /**
75      * The public ID for my documents.
76      */

77     public final static String JavaDoc PUBLIC_DTD_ID = "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
78     public final static String JavaDoc PUBLIC_DTD_ID_12 = "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
79     /**
80      * The system ID of my documents.
81      */

82     public final static String JavaDoc SYSTEM_ID = "http://java.sun.com/dtd/web-app_2_3.dtd";
83     public final static String JavaDoc SYSTEM_ID_12 = "http://java.sun.com/dtd/web-app_2_2.dtd";
84     
85     public final static String JavaDoc SCHEMA_ID_24 = "web-app_2_4.xsd";
86     public final static String JavaDoc SCHEMA_ID = "web-app_2_5.xsd";
87     public final static String JavaDoc SPEC_VERSION = "2.5";
88     private static List<String JavaDoc> systemIDs = null;
89     
90     private WebBundleDescriptor descriptor;
91     private Map servletMappings;
92     private boolean isFirstWelcomeFile = true;
93
94    /**
95     * register this node as a root node capable of loading entire DD files
96     *
97     * @param publicIDToDTD is a mapping between xml Public-ID to DTD
98     * @return the doctype tag name
99     */

100     public static String JavaDoc registerBundle(Map publicIDToDTD) {
101         publicIDToDTD.put(PUBLIC_DTD_ID, SYSTEM_ID);
102         publicIDToDTD.put(PUBLIC_DTD_ID_12, SYSTEM_ID_12);
103         return tag.getQName();
104     }
105     
106     /** Creates new WebBundleNode */
107     public WebBundleNode() {
108         super();
109         registerElementHandler(new XMLElement(TagNames.ENVIRONMENT_PROPERTY), EnvEntryNode.class);
110         registerElementHandler(new XMLElement(TagNames.EJB_REFERENCE), EjbReferenceNode.class);
111         registerElementHandler(new XMLElement(TagNames.EJB_LOCAL_REFERENCE), EjbLocalReferenceNode.class);
112         registerElementHandler(new XMLElement(WebServicesTagNames.SERVICE_REF), ServiceReferenceNode.class, "addServiceReferenceDescriptor");
113         registerElementHandler(new XMLElement(TagNames.RESOURCE_REFERENCE),
114                                                             ResourceRefNode.class, "addResourceReferenceDescriptor");
115         registerElementHandler(new XMLElement(TagNames.RESOURCE_ENV_REFERENCE),
116                                                             ResourceEnvRefNode.class, "addJmsDestinationReferenceDescriptor");
117         registerElementHandler(new XMLElement(TagNames.MESSAGE_DESTINATION_REFERENCE), MessageDestinationRefNode.class, "addMessageDestinationReferenceDescriptor");
118         registerElementHandler(new XMLElement(TagNames.PERSISTENCE_CONTEXT_REF), EntityManagerReferenceNode.class, "addEntityManagerReferenceDescriptor");
119         registerElementHandler(new XMLElement(TagNames.PERSISTENCE_UNIT_REF), EntityManagerFactoryReferenceNode.class, "addEntityManagerFactoryReferenceDescriptor");
120         registerElementHandler(new XMLElement(TagNames.ROLE),
121                                                             SecurityRoleNode.class, "addRole");
122         registerElementHandler(new XMLElement(WebTagNames.SERVLET), ServletNode.class);
123         registerElementHandler(new XMLElement(WebTagNames.SERVLET_MAPPING), ServletMappingNode.class);
124         registerElementHandler(new XMLElement(WebTagNames.MIME_MAPPING),
125                                                             MimeMappingNode.class, "addMimeMapping");
126         registerElementHandler(new XMLElement(WebTagNames.CONTEXT_PARAM),
127                                                             InitParamNode.class, "addContextParameter");
128         registerElementHandler(new XMLElement(WebTagNames.SECURITY_CONSTRAINT),
129                                                             SecurityConstraintNode.class, "addSecurityConstraint");
130         registerElementHandler(new XMLElement(WebTagNames.FILTER),
131                                                             FilterNode.class, "addServletFilter");
132         registerElementHandler(new XMLElement(WebTagNames.FILTER_MAPPING),
133                                                             FilterMappingNode.class, "addServletFilterMapping");
134         registerElementHandler(new XMLElement(WebTagNames.LISTENER),
135                                                             ListenerNode.class, "addAppListenerDescriptor");
136         registerElementHandler(new XMLElement(WebTagNames.ERROR_PAGE),
137                                                             ErrorPageNode.class, "addErrorPageDescriptor");
138         registerElementHandler(new XMLElement(WebTagNames.LOGIN_CONFIG),
139                                                             LoginConfigNode.class);
140         // for backward compatibility, from Servlet 2.4 the taglib element is in jsp-config
141
registerElementHandler(new XMLElement(WebTagNames.TAGLIB),
142                                                             TagLibNode.class);
143         registerElementHandler(new XMLElement(WebTagNames.JSPCONFIG),
144                                                             JspConfigNode.class);
145         registerElementHandler(new XMLElement(WebTagNames.LOCALE_ENCODING_MAPPING_LIST),
146                                                             LocaleEncodingMappingListNode.class, "addLocaleEncodingMappingListDescriptor");
147         registerElementHandler(new XMLElement(TagNames.MESSAGE_DESTINATION),
148                                MessageDestinationNode.class,
149                                "addMessageDestination");
150         registerElementHandler(new XMLElement(TagNames.POST_CONSTRUCT), LifecycleCallbackNode.class, "addPostConstructDescriptor");
151         registerElementHandler(new XMLElement(TagNames.PRE_DESTROY), LifecycleCallbackNode.class, "addPreDestroyDescriptor");
152     }
153     
154    /**
155     * @return the descriptor instance to associate with this XMLNode
156     */

157     public Object JavaDoc getDescriptor() {
158         
159         if (descriptor==null &&
160             !DOLLoadingContextFactory.isParsingDefaultWebXML()) {
161             descriptor =
162                 DOLLoadingContextFactory.getDefaultWebBundleDescriptor();
163         }
164
165         // if that's not there, create one from the factory
166
if (descriptor==null) {
167             descriptor = (WebBundleDescriptor) DescriptorFactory.getDescriptor(getXMLPath());
168         }
169         return descriptor;
170     }
171     
172     /**
173      * Adds a new DOL descriptor instance to the descriptor instance associated with
174      * this XMLNode
175      *
176      * @param descriptor the new descriptor
177      */

178     public void addDescriptor(Object JavaDoc newDescriptor) {
179         if (newDescriptor instanceof EjbReference) {
180             descriptor.addEjbReferenceDescriptor(
181                         (EjbReference) newDescriptor);
182         } else if (newDescriptor instanceof EnvironmentProperty) {
183             DOLUtils.getDefaultLogger().fine("Adding env entry" + newDescriptor);
184            descriptor.addEnvironmentProperty((EnvironmentProperty) newDescriptor);
185         } else if (newDescriptor instanceof WebComponentDescriptor) {
186             DOLUtils.getDefaultLogger().fine("Adding web component" + newDescriptor);
187             descriptor.addWebComponentDescriptor((WebComponentDescriptor) newDescriptor);
188         } else if (newDescriptor instanceof TagLibConfigurationDescriptor) {
189             // for backward compatibility with 2.2 and 2.3 specs, we need to be able
190
// to read tag lib under web-app. Starting with 2.4, the tag moved under jsp-config
191
DOLUtils.getDefaultLogger().fine("Adding taglib component " + newDescriptor);
192             if (descriptor.getJspConfigDescriptor()==null) {
193                 descriptor.setJspConfigDescriptor(new JspConfigDescriptor());
194             }
195  
196             descriptor.getJspConfigDescriptor().addTagLib((TagLibConfigurationDescriptor) newDescriptor);
197         } else if (newDescriptor instanceof JspConfigDescriptor) {
198             DOLUtils.getDefaultLogger().fine("Adding JSP Config Descriptor"
199                 + newDescriptor);
200             if (descriptor.getJspConfigDescriptor()!=null) {
201                 throw new RuntimeException JavaDoc(
202                     "Has more than one jsp-config element!");
203             }
204             descriptor.setJspConfigDescriptor(
205                 (JspConfigDescriptor)newDescriptor);
206         } else if (newDescriptor instanceof LoginConfiguration) {
207             DOLUtils.getDefaultLogger().fine("Adding Login Config Descriptor"
208                  + newDescriptor);
209             if (descriptor.getLoginConfiguration()!=null) {
210                 throw new RuntimeException JavaDoc(
211                     "Has more than one login-config element!");
212             }
213             descriptor.setLoginConfiguration(
214                 (LoginConfiguration)newDescriptor);
215         } else {
216             super.addDescriptor(newDescriptor);
217         }
218     }
219     
220     /**
221      * receives notiification of the value for a particular tag
222      *
223      * @param element the xml element
224      * @param value it's associated value
225      */

226     public void setElementValue(XMLElement element, String JavaDoc value) {
227         if (WebTagNames.SESSION_TIMEOUT.equals(element.getQName())) {
228             // if the session out value is already set
229
// which means there are multiple session-config elements
230
// throw an exception
231
if (descriptor.getSessionTimeout() !=
232                 WebBundleDescriptor.SESSION_TIMEOUT_DEFAULT) {
233                 throw new RuntimeException JavaDoc(
234                     "Has more than one session-config element!");
235             }
236             descriptor.setSessionTimeout((new Integer JavaDoc(value.trim())).intValue());
237         } else if (WebTagNames.WELCOME_FILE.equals(element.getQName())) {
238             if (isFirstWelcomeFile &&
239                 !DOLLoadingContextFactory.isParsingDefaultWebXML()) {
240                 // start with an empty list (remove the ones from
241
// default-web.xml
242
descriptor.getWelcomeFilesSet().clear();
243                 isFirstWelcomeFile = false;
244             }
245             descriptor.addWelcomeFile(value);
246         } else {
247             super.setElementValue(element, value);
248         }
249     }
250     
251    /**
252      * @return the XML tag associated with this XMLNode
253      */

254     protected XMLElement getXMLRootTag() {
255         return tag;
256     }
257
258     /**
259      * @return the DOCTYPE of the XML file
260      */

261     public String JavaDoc getDocType() {
262         return null;
263     }
264     
265     /**
266      * @return the SystemID of the XML file
267      */

268     public String JavaDoc getSystemID() {
269         return SCHEMA_ID;
270     }
271
272     /**
273      * @return the list of SystemID of the XML schema supported
274      */

275     public List<String JavaDoc> getSystemIDs() {
276         if (systemIDs != null) {
277             return systemIDs;
278         }
279
280         systemIDs = new ArrayList<String JavaDoc>();
281         systemIDs.add(SCHEMA_ID);
282         systemIDs.add(SCHEMA_ID_24);
283         return systemIDs;
284     }
285     
286     /**
287      * add a servelt mapping for one of the servlet of this bundle
288      *
289      * @param servletName the servlet the mapping applies to
290      * @param urlPattern the url pattern mapping
291      */

292     void addServletMapping(String JavaDoc servletName, String JavaDoc urlPattern) {
293         if (servletMappings==null) {
294             servletMappings = new HashMap();
295         }
296         if (servletMappings.containsKey(servletName)) {
297             ((Vector) servletMappings.get(servletName)).add(urlPattern);
298         } else {
299             Vector mappings = new Vector();
300             mappings.add(urlPattern);
301             servletMappings.put(servletName, mappings);
302         }
303     }
304     
305     /**
306      * receives notification of the end of an XML element by the Parser
307      *
308      * @param element the xml tag identification
309      * @return true if this node is done processing the XML sub tree
310      */

311     public boolean endElement(XMLElement element) {
312         if (WebTagNames.DISTRIBUTABLE.equals(element.getQName())) {
313             descriptor.setDistributable(true);
314             return false;
315         } else {
316             boolean allDone = super.endElement(element);
317             if (allDone && servletMappings!=null) {
318                 for (Iterator keys = servletMappings.keySet().iterator(); keys.hasNext();) {
319                     String JavaDoc servletName = (String JavaDoc) keys.next();
320                     Vector mappings = (Vector) servletMappings.get(servletName);
321                     WebComponentDescriptor servlet= descriptor.getWebComponentByCanonicalName(servletName);
322                     if (servlet!=null) {
323                         for (Iterator mapping = mappings.iterator();mapping.hasNext();) {
324                             servlet.addUrlPattern((String JavaDoc) mapping.next());
325                         }
326                     } else {
327                         throw new RuntimeException JavaDoc("There is no web component by the name of " + servletName + " here.");
328                     }
329                 }
330             }
331             return allDone;
332         }
333     }
334
335     /**
336      * write the descriptor class to a DOM tree and return it
337      *
338      * @param parent node for the DOM tree
339      * @param the descriptor to write
340      * @return the DOM tree top node
341      */

342     public Node JavaDoc writeDescriptor(Node JavaDoc parent, Descriptor descriptor) {
343         if (! (descriptor instanceof WebBundleDescriptor)) {
344             throw new IllegalArgumentException JavaDoc(getClass() + " cannot handles descriptors of type " + descriptor.getClass());
345         }
346         WebBundleDescriptor webBundleDesc = (WebBundleDescriptor) descriptor;
347         Node JavaDoc jarNode = super.writeDescriptor(parent, webBundleDesc);
348         if (webBundleDesc.isDistributable()) {
349             appendChild(jarNode, WebTagNames.DISTRIBUTABLE);
350         }
351         
352         // context-param*
353
addInitParam(jarNode, WebTagNames.CONTEXT_PARAM, webBundleDesc.getContextParametersSet());
354         
355         // filter*
356
FilterNode filterNode = new FilterNode();
357         for (Enumeration filters = webBundleDesc.getServletFilters().elements();filters.hasMoreElements();) {
358             filterNode.writeDescriptor(jarNode, WebTagNames.FILTER,
359                                                      (ServletFilterDescriptor) filters.nextElement());
360         }
361         
362         // filter-mapping*
363
FilterMappingNode filterMappingNode = new FilterMappingNode();
364         for (Enumeration mappings = webBundleDesc.getServletFilterMappings().elements();
365               mappings.hasMoreElements();) {
366             filterMappingNode.writeDescriptor(jarNode, WebTagNames.FILTER_MAPPING,
367                                                      (ServletFilterMappingDescriptor) mappings.nextElement());
368         }
369         
370         // listener*
371
Vector appListeners = webBundleDesc.getAppListenerDescriptors();
372         if (appListeners!=null && !appListeners.isEmpty()) {
373             for (Enumeration e = appListeners.elements();e.hasMoreElements();) {
374                 AppListenerDescriptorImpl listener = (AppListenerDescriptorImpl) e.nextElement();
375                 Node JavaDoc listenerNode = appendChild(jarNode, WebTagNames.LISTENER);
376                 appendTextChild(listenerNode, WebTagNames.LISTENER_CLASS, listener.getListener());
377             }
378         }
379         
380         // servlet*
381
Set servlets = webBundleDesc.getWebComponentDescriptorsSet();
382         if (servlets!=null && !servlets.isEmpty()) {
383             ServletNode servletNode = new ServletNode();
384             for (Iterator e= servlets.iterator();e.hasNext();) {
385                 WebComponentDescriptor aServlet = (WebComponentDescriptor) e.next();
386                 servletNode.writeDescriptor(jarNode, aServlet);
387             }
388         }
389         
390         // servlet-mapping*
391
if (servlets!=null && !servlets.isEmpty()) {
392             for (Iterator servletsIterator = servlets.iterator(); servletsIterator.hasNext();) {
393                 WebComponentDescriptor aServlet = (WebComponentDescriptor) servletsIterator.next();
394                 for (Iterator patterns = aServlet.getUrlPatternsSet().iterator();patterns.hasNext();) {
395                     String JavaDoc pattern = (String JavaDoc) patterns.next();
396                     Node JavaDoc mappingNode= appendChild(jarNode, WebTagNames.SERVLET_MAPPING);
397                     appendTextChild(mappingNode, WebTagNames.SERVLET_NAME, aServlet.getCanonicalName());
398                     
399                     // If URL Pattern does not start with "/" then
400
// prepend it (for 1.2 Web apps)
401
if (webBundleDesc.getSpecVersion().equals("2.2")) {
402                         if (!pattern.startsWith("/")
403                             && !pattern.startsWith("*.")) {
404                             pattern = "/" + pattern;
405                         }
406                     }
407                     appendTextChild(mappingNode, WebTagNames.URL_PATTERN, pattern);
408         }
409             }
410         }
411         
412         // session-config
413
if (webBundleDesc.getSessionTimeout() != webBundleDesc.SESSION_TIMEOUT_DEFAULT) {
414             Node JavaDoc config = appendChild(jarNode, WebTagNames.SESSION_CONFIG);
415             appendTextChild(config, WebTagNames.SESSION_TIMEOUT,
416                                             String.valueOf(webBundleDesc.getSessionTimeout()));
417         }
418         
419         // mime-mapping*
420
MimeMappingNode mimeNode = new MimeMappingNode();
421         for (Enumeration e = webBundleDesc.getMimeMappings();e.hasMoreElements();) {
422             MimeMappingDescriptor mimeMapping = (MimeMappingDescriptor) e.nextElement();
423             mimeNode.writeDescriptor(jarNode, WebTagNames.MIME_MAPPING, mimeMapping);
424         }
425         
426         // welcome-file-list?
427
Enumeration welcomeFiles = webBundleDesc.getWelcomeFiles();
428         if (welcomeFiles.hasMoreElements()) {
429             Node JavaDoc welcomeList = appendChild(jarNode, WebTagNames.WELCOME_FILE_LIST);
430             while (welcomeFiles.hasMoreElements()) {
431                 appendTextChild(welcomeList, WebTagNames.WELCOME_FILE,
432                                 (String JavaDoc) welcomeFiles.nextElement());
433             }
434         }
435         
436         // error-page*
437
Enumeration errorPages = webBundleDesc.getErrorPageDescriptors();
438         if (errorPages.hasMoreElements()) {
439             ErrorPageNode errorPageNode = new ErrorPageNode();
440             while (errorPages.hasMoreElements()) {
441                 errorPageNode.writeDescriptor(jarNode, WebTagNames.ERROR_PAGE,
442                                 (ErrorPageDescriptorImpl) errorPages.nextElement());
443             }
444         }
445         
446         // jsp-config *
447
JspConfigDescriptor jspConf = webBundleDesc.getJspConfigDescriptor();
448     if(jspConf != null) {
449         JspConfigNode ln = new JspConfigNode();
450         ln.writeDescriptor(jarNode,
451                 WebTagNames.JSPCONFIG,
452                 jspConf);
453     }
454
455         // security-constraint*
456
Enumeration securityConstraints = webBundleDesc.getSecurityConstraints();
457         if (securityConstraints.hasMoreElements()) {
458             SecurityConstraintNode scNode = new SecurityConstraintNode();
459             while (securityConstraints.hasMoreElements()) {
460                 SecurityConstraintImpl sc = (SecurityConstraintImpl) securityConstraints.nextElement();
461                 scNode.writeDescriptor(jarNode, WebTagNames.SECURITY_CONSTRAINT, sc);
462             }
463         }
464
465         // login-config ?
466
LoginConfigurationImpl lci = (LoginConfigurationImpl) webBundleDesc.getLoginConfiguration();
467         if (lci!=null) {
468             LoginConfigNode lcn = new LoginConfigNode();
469             lcn.writeDescriptor(jarNode, WebTagNames.LOGIN_CONFIG, lci);
470         }
471         
472         // security-role*
473
Enumeration roles = webBundleDesc.getSecurityRoles();
474         if (roles.hasMoreElements()) {
475             SecurityRoleNode srNode = new SecurityRoleNode();
476             while (roles.hasMoreElements()) {
477                 SecurityRoleDescriptor role = (SecurityRoleDescriptor) roles.nextElement();
478                 srNode.writeDescriptor(jarNode, WebTagNames.ROLE, role);
479             }
480         }
481
482         // env-entry*
483
writeEnvEntryDescriptors(jarNode, webBundleDesc.getEnvironmentProperties().iterator());
484
485         // ejb-ref * and ejb-local-ref*
486
writeEjbReferenceDescriptors(jarNode, webBundleDesc.getEjbReferenceDescriptors().iterator());
487
488         // service-ref*
489
writeServiceReferenceDescriptors(jarNode, webBundleDesc.getServiceReferenceDescriptors().iterator());
490
491         // resource-ref*
492
writeResourceRefDescriptors(jarNode, webBundleDesc.getResourceReferenceDescriptors().iterator());
493                 
494         // resource-env-ref*
495
writeResourceEnvRefDescriptors(jarNode, webBundleDesc.getJmsDestinationReferenceDescriptors().iterator());
496
497         // message-destination-ref*
498
writeMessageDestinationRefDescriptors(jarNode, webBundleDesc.getMessageDestinationReferenceDescriptors().iterator());
499         
500         // persistence-context-ref*
501
writeEntityManagerReferenceDescriptors(jarNode, webBundleDesc.getEntityManagerReferenceDescriptors().iterator());
502         
503         // persistence-unit-ref*
504
writeEntityManagerFactoryReferenceDescriptors(jarNode, webBundleDesc.getEntityManagerFactoryReferenceDescriptors().iterator());
505         
506         // post-construct
507
writePostConstructDescriptors(jarNode, webBundleDesc.getPostConstructDescriptors().iterator());
508
509         // pre-destroy
510
writePreDestroyDescriptors(jarNode, webBundleDesc.getPreDestroyDescriptors().iterator());
511
512          // message-destination*
513
writeMessageDestinations
514            (jarNode, webBundleDesc.getMessageDestinations().iterator());
515
516        LocaleEncodingMappingListDescriptor lemDesc = webBundleDesc.getLocaleEncodingMappingListDescriptor();
517     if(lemDesc != null) {
518         LocaleEncodingMappingListNode ln = new LocaleEncodingMappingListNode();
519         ln.writeDescriptor(jarNode,
520                 WebTagNames.LOCALE_ENCODING_MAPPING_LIST,
521                 lemDesc);
522     }
523
524         return jarNode;
525     }
526    
527     static void addInitParam(Node JavaDoc parentNode, String JavaDoc nodeName, Set initParams) {
528         if (!initParams.isEmpty()) {
529             InitParamNode initParamNode = new InitParamNode();
530             for (Iterator e=initParams.iterator();e.hasNext();) {
531                 EnvironmentProperty ep = (EnvironmentProperty) e.next();
532                 initParamNode.writeDescriptor(parentNode, nodeName, ep);
533             }
534         }
535     }
536     
537     static void addInitParam(Node JavaDoc parentNode, String JavaDoc nodeName, Enumeration initParams) {
538         InitParamNode initParamNode = new InitParamNode();
539         while (initParams.hasMoreElements()) {
540             EnvironmentProperty ep = (EnvironmentProperty) initParams.nextElement();
541             initParamNode.writeDescriptor(parentNode, nodeName, ep);
542         }
543     }
544     
545     /**
546      * @return the default spec version level this node complies to
547      */

548     public String JavaDoc getSpecVersion() {
549         return SPEC_VERSION;
550     }
551     
552 }
553
Popular Tags