KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > WebBundleDescriptor


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;
24
25 import java.util.*;
26 import com.sun.enterprise.deployment.*;
27
28 import com.sun.enterprise.util.NotificationListener;
29 import com.sun.enterprise.util.NotificationEvent;
30
31 import com.sun.enterprise.deployment.web.MimeMapping;
32 import com.sun.enterprise.deployment.web.ErrorPageDescriptor;
33 import com.sun.enterprise.deployment.web.AppListenerDescriptor;
34 import com.sun.enterprise.deployment.web.ResourceReference;
35 import com.sun.enterprise.deployment.web.ContextParameter;
36 import com.sun.enterprise.deployment.web.SecurityRole;
37 import com.sun.enterprise.deployment.web.SecurityRoleReference;
38 import com.sun.enterprise.deployment.web.SecurityConstraint;
39 import com.sun.enterprise.deployment.web.LocalizedContentDescriptor;
40 import com.sun.enterprise.deployment.web.LoginConfiguration;
41 import com.sun.enterprise.deployment.web.EnvironmentEntry;
42 import com.sun.enterprise.deployment.web.ServletFilter;
43 import com.sun.enterprise.deployment.web.ServletFilterMapping;
44 import com.sun.enterprise.deployment.web.WebResourceCollection;
45 import com.sun.enterprise.deployment.WebServiceEndpoint;
46 import com.sun.enterprise.deployment.node.web.WebBundleNode;
47
48 import com.sun.enterprise.deployment.util.WebBundleVisitor;
49 import com.sun.enterprise.deployment.util.DescriptorVisitor;
50
51 import com.sun.enterprise.deployment.types.EjbReference;
52 import com.sun.enterprise.deployment.types.ResourceReferenceContainer;
53 import com.sun.enterprise.deployment.types.ResourceEnvReferenceContainer;
54 import com.sun.enterprise.deployment.types.MessageDestinationReference;
55 import com.sun.enterprise.deployment.types.MessageDestinationReferenceContainer;
56 import com.sun.enterprise.deployment.types.EjbReferenceContainer;
57 import com.sun.enterprise.deployment.types.ServiceReferenceContainer;
58 import com.sun.enterprise.deployment.types.MessageDestinationReferencer;
59
60 import com.sun.enterprise.deployment.runtime.web.SunWebApp;
61
62 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
63 import com.sun.enterprise.util.LocalStringManagerImpl;
64
65     /**
66     * I am an object that represents all the deployment information about
67     * a web application.
68     * @author Danny Coward
69     */

70
71 public class WebBundleDescriptor extends BundleDescriptor
72     implements WritableJndiNameEnvironment,
73                 ResourceReferenceContainer,
74                 ResourceEnvReferenceContainer,
75                 EjbReferenceContainer,
76                 MessageDestinationReferenceContainer,
77                 ServiceReferenceContainer,
78                 NotificationListener
79
80 {
81
82
83     private Set webComponentDescriptors;
84     private int sessionTimeout;
85     private Set mimeMappings;
86     private Set welcomeFiles;
87     private Set errorPageDescriptors;
88     private Vector appListenerDescriptors;
89     private Set contextParameters;
90     private Set ejbReferences;
91     private Set resourceReferences;
92     private Set jmsDestReferences;
93     private Set messageDestReferences;
94     private Set serviceReferences;
95
96     private Set<LifecycleCallbackDescriptor> postConstructDescs =
97         new HashSet<LifecycleCallbackDescriptor>();
98     private Set<LifecycleCallbackDescriptor> preDestroyDescs =
99         new HashSet<LifecycleCallbackDescriptor>();
100
101     private Set<EntityManagerFactoryReferenceDescriptor>
102         entityManagerFactoryReferences =
103         new HashSet<EntityManagerFactoryReferenceDescriptor>();
104
105     private Set<EntityManagerReferenceDescriptor>
106         entityManagerReferences =
107         new HashSet<EntityManagerReferenceDescriptor>();
108
109     private boolean isDistributable;
110     private Set securityRoles;
111     private Set securityConstraints;
112     private String JavaDoc contextRoot;
113     private LoginConfiguration loginConfiguration;
114     private Set environmentEntries;
115     private LocaleEncodingMappingListDescriptor localeEncodingMappingDesc = null;
116     private JspConfigDescriptor jspConfigDescriptor = null;
117
118     private Vector servletFilters = null;
119     private Vector servletFilterMappings = null;
120
121     public static final int SESSION_TIMEOUT_DEFAULT = 30;
122     private final static String JavaDoc DEPLOYMENT_DESCRIPTOR_DIR="WEB-INF";
123     
124     private static LocalStringManagerImpl localStrings =
125         new LocalStringManagerImpl(WebBundleDescriptor.class);
126    
127    private SunWebApp sunWebApp=null;
128    
129     /** Constrct an empty web app.
130     */

131     public WebBundleDescriptor() {
132         sessionTimeout = SESSION_TIMEOUT_DEFAULT;
133     }
134     
135     /**
136      * @return the default version of the deployment descriptor
137      * loaded by this descriptor
138      */

139     public String JavaDoc getDefaultSpecVersion() {
140         return WebBundleNode.SPEC_VERSION;
141     }
142
143     /**
144     * Return the set of named descriptors that I have.
145     */

146     public Collection getNamedDescriptors() {
147     return super.getNamedDescriptorsFrom(this);
148     }
149     
150    /** Return the saet of NamedReferencePairs that I have.
151    */

152     public Vector getNamedReferencePairs() {
153     return super.getNamedReferencePairsFrom(this);
154     }
155     
156     /**
157     * return the name of my context root
158     */

159     public String JavaDoc getContextRoot() {
160         if (getModuleDescriptor()!=null && getModuleDescriptor().getContextRoot()!=null) {
161             return getModuleDescriptor().getContextRoot();
162         }
163     if (this.contextRoot == null) {
164         this.contextRoot = "";
165     }
166     return this.contextRoot;
167     }
168     
169     /**
170     * Set the name of my context root.
171     */

172     public void setContextRoot(String JavaDoc contextRoot) {
173         if (getModuleDescriptor()!=null) {
174             getModuleDescriptor().setContextRoot(contextRoot);
175         }
176     this.contextRoot = contextRoot;
177     this.changed();
178     }
179     
180     public void addWebBundleDescriptor(WebBundleDescriptor webBundleDescriptor) {
181     super.addBundleDescriptor(webBundleDescriptor);
182
183     // mdf - #4400074 ejb added to existing ejb-jar in wizard has wrong bundle
184
// (this problem occured for WebComponents as well)
185
//this.getWebComponentDescriptorsSet().addAll(webBundleDescriptor.getWebComponentDescriptorsSet());
186
for (Iterator itr = webBundleDescriptor.getWebComponentDescriptorsSet().iterator(); itr.hasNext();) {
187         WebComponentDescriptor webComponentDescriptor = (WebComponentDescriptor)itr.next();
188         webComponentDescriptor.setWebBundleDescriptor(this);
189         this.getWebComponentDescriptorsSet().add(webComponentDescriptor);
190     }
191
192     this.getMimeMappingsSet().addAll(webBundleDescriptor.getMimeMappingsSet());
193     this.getWelcomeFilesSet().addAll(webBundleDescriptor.getWelcomeFilesSet());
194     this.getErrorPageDescriptorsSet().addAll(webBundleDescriptor.getErrorPageDescriptorsSet());
195     this.getAppListeners().addAll(webBundleDescriptor.getAppListeners());
196     this.getContextParametersSet().addAll(webBundleDescriptor.getContextParametersSet());
197     this.getEjbReferenceDescriptors().addAll(webBundleDescriptor.getEjbReferenceDescriptors());
198     this.getResourceReferenceDescriptors().addAll(webBundleDescriptor.getResourceReferenceDescriptors());
199         this.getMessageDestinationReferenceDescriptors().addAll(webBundleDescriptor.getMessageDestinationReferenceDescriptors());
200     this.getServiceReferenceDescriptors().addAll(webBundleDescriptor.getServiceReferenceDescriptors());
201     this.getEnvironmentProperties().addAll(webBundleDescriptor.getEnvironmentProperties());
202     this.getSecurityConstraintsSet().addAll(webBundleDescriptor.getSecurityConstraintsSet());
203
204     // ServletFilters
205
// mdf - #4399820 Servlet Filters and their mapping don't appear in inspector
206
this.getServletFilters().addAll(webBundleDescriptor.getServletFilters());
207     this.getServletFilterMappings().addAll(webBundleDescriptor.getServletFilterMappings());
208     this.setLocaleEncodingMappingListDescriptor(webBundleDescriptor.getLocaleEncodingMappingListDescriptor());
209     this.setJspConfigDescriptor(webBundleDescriptor.getJspConfigDescriptor());
210
211     // WebServices
212
WebServicesDescriptor thisWebServices = this.getWebServices();
213     WebServicesDescriptor otherWebServices = webBundleDescriptor.getWebServices();
214     for (Iterator i = otherWebServices.getWebServices().iterator(); i.hasNext();) {
215         WebService ws = (WebService)i.next();
216         thisWebServices.addWebService(new WebService(ws));
217     }
218
219     this.changed();
220     }
221     
222     /** Return the Set of Web COmponent Descriptors (JSP or JavaServlets) in me.
223     */

224     public Set getWebDescriptors() {
225     if (this.webComponentDescriptors == null) {
226         this.webComponentDescriptors = new OrderedSet();
227     }
228     return this.webComponentDescriptors;
229     }
230     
231     public Set getWebComponentDescriptorsSet() {
232     if (this.webComponentDescriptors == null) {
233         this.webComponentDescriptors = new OrderedSet();
234     }
235     return this.webComponentDescriptors;
236     }
237
238     /** Return an Enumeration of Web COmponent Descriptors (JSP or JavaServlets) in me.
239     */

240     public Enumeration getWebComponentDescriptors() {
241     return (new Vector(this.getWebComponentDescriptorsSet())).elements();
242     }
243     
244     /** Adds a new Web Component Descriptor to me.
245     */

246     
247     public void addWebComponentDescriptor(WebComponentDescriptor webComponentDescriptor) {
248     ((WebComponentDescriptor) webComponentDescriptor).setWebBundleDescriptor(this);
249         for (Iterator wcdIter = getWebComponentDescriptorsSet().iterator();
250             wcdIter.hasNext();) {
251             WebComponentDescriptor wbd = (WebComponentDescriptor)wcdIter.next();
252             if (wbd.getCanonicalName().equals(
253                 webComponentDescriptor.getCanonicalName())) {
254                 // combine the contents of the two
255
webComponentDescriptor.add(wbd);
256                 // remove the original one from the set
257
// so we can add the new one
258
getWebComponentDescriptorsSet().remove(wbd);
259                 break;
260             }
261         }
262     this.getWebComponentDescriptorsSet().add(webComponentDescriptor);
263     this.changed();
264     }
265     
266     /**
267     * Remove the given web component from me.
268     */

269     
270     public void removeWebComponentDescriptor(WebComponentDescriptor webComponentDescriptor) {
271     ((WebComponentDescriptor) webComponentDescriptor).setWebBundleDescriptor(null);
272     this.getWebComponentDescriptorsSet().remove(webComponentDescriptor);
273     this.changed();
274     }
275     
276     /**
277      * WEB SERVICES REF APIS
278      */

279     public boolean hasServiceReferenceDescriptors() {
280     if (serviceReferences==null)
281         return false;
282     return serviceReferences.size()!=0;
283     }
284     
285     public Set getServiceReferenceDescriptors() {
286         if( this.serviceReferences == null ) {
287             this.serviceReferences = new OrderedSet();
288         }
289         return this.serviceReferences = new OrderedSet(this.serviceReferences);
290     }
291
292     public void addServiceReferenceDescriptor(ServiceReferenceDescriptor
293                                               serviceRef) {
294         serviceRef.setBundleDescriptor(this);
295         this.getServiceReferenceDescriptors().add(serviceRef);
296         this.changed();
297     }
298
299     public void removeServiceReferenceDescriptor(ServiceReferenceDescriptor
300                                                  serviceRef) {
301         this.getServiceReferenceDescriptors().remove(serviceRef);
302         this.changed();
303     }
304     
305     /**
306      * Looks up an service reference with the given name.
307      * Throws an IllegalArgumentException if it is not found.
308      */

309     public ServiceReferenceDescriptor getServiceReferenceByName(String JavaDoc name) {
310     for (Iterator itr = this.getServiceReferenceDescriptors().iterator();
311              itr.hasNext();) {
312         ServiceReferenceDescriptor srd = (ServiceReferenceDescriptor)
313                 itr.next();
314         if (srd.getName().equals(name)) {
315         return srd;
316         }
317     }
318     throw new IllegalArgumentException JavaDoc("This web application has no service refernce by the name " + name);
319     }
320
321 /**
322     * Return the set of JMS destination references this ejb declares.
323     */

324     public Set getJmsDestinationReferenceDescriptors() {
325     if (this.jmsDestReferences == null) {
326         this.jmsDestReferences = new OrderedSet();
327     }
328     return this.jmsDestReferences = new OrderedSet(this.jmsDestReferences);
329     }
330
331     public void addJmsDestinationReferenceDescriptor(JmsDestinationReferenceDescriptor jmsDestReference) {
332     this.getJmsDestinationReferenceDescriptors().add(jmsDestReference);
333     this.changed();
334     }
335     
336     public void removeJmsDestinationReferenceDescriptor(JmsDestinationReferenceDescriptor jmsDestReference) {
337     this.getJmsDestinationReferenceDescriptors().remove(jmsDestReference);
338     this.changed();
339     }
340
341     /**
342     * Return a JMS destination reference by the same name or throw an IllegalArgumentException.
343     */

344     public JmsDestinationReferenceDescriptor getJmsDestinationReferenceByName(String JavaDoc name) {
345     for (Iterator itr = this.getJmsDestinationReferenceDescriptors().iterator(); itr.hasNext();) {
346         JmsDestinationReferenceDescriptor jdr = (JmsDestinationReferenceDescriptor) itr.next();
347         if (jdr.getName().equals(name)) {
348         return jdr;
349         }
350     }
351     throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
352                                        "enterprise.deployment.exceptionwebcomphasnojmsdestrefbyname",
353                                        "This web component has no JMS destination reference by the name of {0}", new Object JavaDoc[] {name}));
354     }
355
356     /**
357     * Return the value in seconds of when requests should time out.
358     */

359     public int getSessionTimeout() {
360     return this.sessionTimeout;
361     }
362     
363     /** Sets thew value in seconds after sessions should timeout.
364     */

365     public void setSessionTimeout(int sessionTimeout) {
366     this.sessionTimeout = sessionTimeout;
367     this.changed();
368     }
369     
370     private Set getMimeMappingsSet() {
371     if (this.mimeMappings == null) {
372         this.mimeMappings = new HashSet();
373     }
374     return this.mimeMappings;
375     }
376     
377     /**
378     * Sets the Set of Mime Mappings for this web application.
379     */

380     public void setMimeMappings(Set mimeMappings) {
381     this.mimeMappings = mimeMappings;
382     this.changed();
383     }
384     
385     /**
386     * Returns an enumeration of my mime mappings.
387     */

388     public Enumeration getMimeMappings() {
389     return (new Vector(this.getMimeMappingsSet())).elements();
390     }
391     
392     /**
393     * Adds the given mime mapping to my list.
394     */

395     public void addMimeMapping(MimeMapping mimeMapping) {
396         // always override
397
// Since Set.add API doesn't replace
398
// remove the element first if it's already contained
399
for (Iterator itr = getMimeMappingsSet().iterator(); itr.hasNext();) {
400         MimeMapping mm = (MimeMapping) itr.next();
401         if (mm.getExtension().equals(mimeMapping.getExtension())) {
402         getMimeMappingsSet().remove(mm);
403                 break;
404         }
405         }
406     this.getMimeMappingsSet().add(mimeMapping);
407     this.changed();
408     }
409     
410     /**
411     * Adds the given mime mapping to my list.
412     */

413     public void addMimeMapping(MimeMappingDescriptor mimeMapping) {
414         addMimeMapping((MimeMapping) mimeMapping);
415     }
416     
417     public void addLocaleEncodingMappingListDescriptor(LocaleEncodingMappingListDescriptor lemDesc) {
418     localeEncodingMappingDesc = lemDesc;
419     }
420
421     public LocaleEncodingMappingListDescriptor getLocaleEncodingMappingListDescriptor() {
422     return localeEncodingMappingDesc;
423     }
424     
425     public void setLocaleEncodingMappingListDescriptor(LocaleEncodingMappingListDescriptor lemDesc) {
426     localeEncodingMappingDesc = lemDesc;
427     }
428     /**
429     * Removes the given mime mapping from my list.
430     */

431     public void removeMimeMapping(MimeMapping mimeMapping) {
432     this.getMimeMappingsSet().remove(mimeMapping);
433     this.changed();
434     }
435     
436     /**
437     * Return an enumeration of the welcome files I have..
438     */

439     public Enumeration getWelcomeFiles() {
440     return (new Vector(this.getWelcomeFilesSet())).elements();
441     }
442     
443     public Set getWelcomeFilesSet() {
444     if (this.welcomeFiles == null) {
445         this.welcomeFiles = new OrderedSet();
446     }
447     return welcomeFiles;
448     }
449     
450     /** Adds a new welcome file to my list.
451     */

452     public void addWelcomeFile(String JavaDoc fileUri) {
453     this.getWelcomeFilesSet().add(fileUri);
454     this.changed();
455     }
456     
457     /** Removes a welcome file from my list.
458     */

459     public void removeWelcomeFile(String JavaDoc fileUri) {
460     this.getWelcomeFilesSet().remove(fileUri);
461     this.changed();
462     }
463     
464     /**
465     * Sets the collection of my welcome files.
466     */

467     public void setWelcomeFiles(Set welcomeFiles) {
468     this.welcomeFiles = welcomeFiles;
469     this.changed();
470     }
471
472     private Set getErrorPageDescriptorsSet() {
473     if (this.errorPageDescriptors == null) {
474         this.errorPageDescriptors = new HashSet();
475     }
476     return this.errorPageDescriptors;
477     }
478     
479     /** Returns an enumeration of the error pages I have.
480     */

481     public Enumeration getErrorPageDescriptors() {
482     return (new Vector(this.getErrorPageDescriptorsSet())).elements();
483     }
484
485     /** Adds a new error page to my list.
486     */

487     public void addErrorPageDescriptor(ErrorPageDescriptor errorPageDescriptor) {
488     this.getErrorPageDescriptorsSet().add(errorPageDescriptor);
489     this.changed();
490     }
491     
492     public void addErrorPageDescriptor(ErrorPageDescriptorImpl errorPageDescriptor) {
493     addErrorPageDescriptor((ErrorPageDescriptor) errorPageDescriptor);
494     }
495     
496     /**
497     * Removes the given error page from my list.
498     */

499     public void removeErrorPageDescriptor(ErrorPageDescriptor errorPageDescriptor) {
500     this.getErrorPageDescriptorsSet().remove(errorPageDescriptor);
501     this.changed();
502     }
503     
504     /**
505     * Search my error pages for one with thei given signifier or null if there isn't one.
506     */

507     public ErrorPageDescriptor getErrorPageDescriptorBySignifier(String JavaDoc signifier) {
508     for (Iterator itr = this.getErrorPageDescriptorsSet().iterator(); itr.hasNext();) {
509         ErrorPageDescriptorImpl next = (ErrorPageDescriptorImpl) itr.next();
510         if (next.getErrorSignifierAsString().equals(signifier)) {
511         return next;
512         }
513     }
514     return null;
515     }
516     
517     /**
518     * Returns the Set og my COntext Parameters.
519     */

520     public Set getContextParametersSet() {
521     if (this.contextParameters == null) {
522         this.contextParameters = new OrderedSet();
523     }
524     return this.contextParameters = new OrderedSet(this.contextParameters);
525     }
526     
527     /** Returns my COntext Parameters in an enumeration.
528     */

529     public Enumeration getContextParameters() {
530     return (new Vector(this.getContextParametersSet())).elements();
531     }
532     
533     /** Adds a new context parameter to my list.
534     */

535     public void addContextParameter(ContextParameter contextParameter) {
536     this.getContextParametersSet().add(contextParameter);
537     this.changed();
538     }
539     
540     /** Adds a new context parameter to my list.
541     */

542     public void addContextParameter(EnvironmentProperty contextParameter) {
543         addContextParameter((ContextParameter) contextParameter);
544     }
545     
546     /**
547     * Removes the given context parameter from my list.
548     */

549     public void removeContextParameter(ContextParameter contextParameter) {
550     this.getContextParametersSet().remove(contextParameter);
551     this.changed();
552     }
553     
554     /**
555     * Return true if this web app can be distributed across different processes.
556     */

557     
558     public boolean isDistributable() {
559     return isDistributable;
560     }
561     
562      /**
563     * Sets whether this web app can be distributed across different processes.
564     */

565     public void setDistributable(boolean isDistributable) {
566     this.isDistributable = isDistributable;
567     this.changed();
568     }
569     
570     /**
571     * Returns the enumeration of my references to Enterprise Beans.
572     */

573     
574     public Enumeration getEjbReferences() {
575     return (new Vector(this.getEjbReferenceDescriptors())).elements();
576     }
577     /**
578     * Returns the Set of my references to Enterprise Beans.
579     */

580     
581     public Set getEjbReferenceDescriptors() {
582     if (this.ejbReferences == null) {
583         this.ejbReferences = new OrderedSet();
584     }
585     return this.ejbReferences = new OrderedSet(this.ejbReferences);
586     }
587     
588     /**
589     * Returns an Enterprise Bean with the matching name or throw.
590     */

591     
592     public EjbReferenceDescriptor getEjbReferenceByName(String JavaDoc name) {
593         return (EjbReferenceDescriptor) getEjbReference(name);
594     }
595     
596     public EjbReference getEjbReference(String JavaDoc name) {
597     for (Iterator itr = this.getEjbReferenceDescriptors().iterator(); itr.hasNext();) {
598         EjbReference er = (EjbReference) itr.next();
599         if (er.getName().equals(name)) {
600         return er;
601         }
602     }
603     throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
604                                   "enterprise.deployment.exceptionwebapphasnoejbrefbyname",
605                                   "This web app has no ejb reference by the name of {0} ", new Object JavaDoc[] {name}));
606     }
607     
608      /**
609     * Returns a reource reference with the matching name or throw.
610     */

611     
612     public ResourceReferenceDescriptor getResourceReferenceByName(String JavaDoc name) {
613     for (Iterator itr = this.getResourceReferenceDescriptors().iterator(); itr.hasNext();) {
614         ResourceReferenceDescriptor next = (ResourceReferenceDescriptor) itr.next();
615         if (next.getName().equals(name)) {
616         return next;
617         }
618     }
619     throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
620                                   "enterprise.deployment.exceptionwebapphasnoresourcerefbyname",
621                                   "This web app has no resource reference by the name of {0}", new Object JavaDoc[] {name}));
622     }
623     
624      /**
625     * RReturns my Set of references to resources.
626     */

627     
628     public Set getResourceReferenceDescriptors() {
629     if (this.resourceReferences == null) {
630         this.resourceReferences = new OrderedSet();
631     }
632     return this.resourceReferences = new OrderedSet(this.resourceReferences);
633     }
634     
635     public Set<EntityManagerFactoryReferenceDescriptor>
636         getEntityManagerFactoryReferenceDescriptors() {
637         if( this.entityManagerFactoryReferences == null ) {
638             this.entityManagerFactoryReferences =
639                 new HashSet<EntityManagerFactoryReferenceDescriptor>();
640         }
641         return this.entityManagerFactoryReferences =
642             new HashSet<EntityManagerFactoryReferenceDescriptor>
643             (entityManagerFactoryReferences);
644     }
645
646     /**
647      * Return the entity manager factory reference descriptor corresponding to
648      * the given name.
649      */

650     public EntityManagerFactoryReferenceDescriptor
651         getEntityManagerFactoryReferenceByName(String JavaDoc name) {
652     for (EntityManagerFactoryReferenceDescriptor next :
653              getEntityManagerFactoryReferenceDescriptors()) {
654
655         if (next.getName().equals(name)) {
656         return next;
657         }
658     }
659     throw new IllegalArgumentException JavaDoc("This web component has no entity "
660                  + "manager factory reference by the name " + name);
661     }
662
663     public void addEntityManagerFactoryReferenceDescriptor
664         (EntityManagerFactoryReferenceDescriptor reference) {
665         reference.setReferringBundleDescriptor(this);
666         this.getEntityManagerFactoryReferenceDescriptors().add(reference);
667         this.changed();
668     }
669
670     public Set<EntityManagerReferenceDescriptor>
671         getEntityManagerReferenceDescriptors() {
672         if( this.entityManagerReferences == null ) {
673             this.entityManagerReferences =
674                 new HashSet<EntityManagerReferenceDescriptor>();
675         }
676         return this.entityManagerReferences =
677             new HashSet<EntityManagerReferenceDescriptor>
678             (this.entityManagerReferences);
679     }
680
681     /**
682      * Return the entity manager factory reference descriptor corresponding to
683      * the given name.
684      */

685     public EntityManagerReferenceDescriptor
686         getEntityManagerReferenceByName(String JavaDoc name) {
687     for (EntityManagerReferenceDescriptor next :
688              getEntityManagerReferenceDescriptors()) {
689
690         if (next.getName().equals(name)) {
691         return next;
692         }
693     }
694     throw new IllegalArgumentException JavaDoc("This web component has no entity "
695                  + "manager refernce by the name " + name);
696     }
697
698     public void addEntityManagerReferenceDescriptor
699         (EntityManagerReferenceDescriptor reference) {
700         reference.setReferringBundleDescriptor(this);
701         this.getEntityManagerReferenceDescriptors().add(reference);
702         this.changed();
703     }
704
705
706
707     /** Return my set of environment properties.
708     */

709     
710     public Set getEnvironmentProperties() {
711     return this.getEnvironmentEntrySet();
712     }
713     
714     /** Adds a new reference to an ejb.*/
715     
716     public void addEjbReferenceDescriptor(EjbReference ejbReference) {
717     this.getEjbReferenceDescriptors().add(ejbReference);
718         ejbReference.setReferringBundleDescriptor(this);
719         this.changed();
720     }
721     
722      /** Adds a new reference to an ejb.*/
723     
724     public void addEjbReferenceDescriptor(EjbReferenceDescriptor ejbReferenceDescriptor) {
725     this.addEjbReferenceDescriptor((EjbReference) ejbReferenceDescriptor);
726
727     }
728     
729      /** Removes a reference to an ejb.*/
730     public void removeEjbReferenceDescriptor(EjbReferenceDescriptor ejbReferenceDescriptor) {
731     this.removeEjbReferenceDescriptor((EjbReference) ejbReferenceDescriptor);
732     }
733     
734     public void removeEjbReferenceDescriptor(EjbReference ejbReferenceDescriptor) {
735     this.getEjbReferenceDescriptors().remove(ejbReferenceDescriptor);
736         ejbReferenceDescriptor.setReferringBundleDescriptor(null);
737     this.changed();
738     }
739     
740     /** Return an enumeration of references to resources that I have.*/
741     public Enumeration getResourceReferences() {
742     return (new Vector(this.getResourceReferenceDescriptors())).elements();
743     }
744     
745     /** adds a new reference to a resource.*/
746     public void addResourceReference(ResourceReference resourceReference) {
747     this.getResourceReferenceDescriptors().add(resourceReference);
748     this.changed();
749     }
750     /** adds a new reference to a resource.*/
751     public void addResourceReferenceDescriptor(ResourceReferenceDescriptor resourceReference) {
752     this.addResourceReference((ResourceReference) resourceReference);
753     }
754     /** removes a reference to a resource.*/
755     public void removeResourceReferenceDescriptor(ResourceReferenceDescriptor resourceReference) {
756     this.getResourceReferenceDescriptors().remove(resourceReference);
757     this.changed();
758     }
759
760     public Set getMessageDestinationReferenceDescriptors() {
761         if( this.messageDestReferences == null ) {
762             this.messageDestReferences = new OrderedSet();
763         }
764         return this.messageDestReferences =
765             new OrderedSet(this.messageDestReferences);
766     }
767
768     public void addMessageDestinationReferenceDescriptor
769         (MessageDestinationReferenceDescriptor messageDestRef) {
770         messageDestRef.setReferringBundleDescriptor(this);
771         this.getMessageDestinationReferenceDescriptors().add(messageDestRef);
772         this.changed();
773     }
774
775     public void removeMessageDestinationReferenceDescriptor
776         (MessageDestinationReferenceDescriptor msgDestRef) {
777         this.getMessageDestinationReferenceDescriptors().remove(msgDestRef);
778         this.changed();
779     }
780     
781     /**
782      * Looks up an message destination reference with the given name.
783      * Throws an IllegalArgumentException if it is not found.
784      */

785     public MessageDestinationReferenceDescriptor
786         getMessageDestinationReferenceByName(String JavaDoc name) {
787     for (Iterator itr =
788                  this.getMessageDestinationReferenceDescriptors().iterator();
789              itr.hasNext();) {
790         MessageDestinationReferenceDescriptor mdr =
791                 (MessageDestinationReferenceDescriptor) itr.next();
792         if (mdr.getName().equals(name)) {
793         return mdr;
794         }
795     }
796     throw new IllegalArgumentException JavaDoc("This ejb has no message destination refernce by the name " + name);
797     }
798
799     public Set<LifecycleCallbackDescriptor>
800         getPostConstructDescriptors() {
801         if (postConstructDescs == null) {
802             postConstructDescs =
803                 new HashSet<LifecycleCallbackDescriptor>();
804         }
805         return postConstructDescs;
806     }
807
808     public void addPostConstructDescriptor(LifecycleCallbackDescriptor
809         postConstructDesc) {
810         String JavaDoc className = postConstructDesc.getLifecycleCallbackClass();
811         boolean found = false;
812         for (LifecycleCallbackDescriptor next :
813              getPostConstructDescriptors()) {
814             if (next.getLifecycleCallbackClass().equals(className)) {
815                 found = true;
816                 break;
817             }
818         }
819         if (!found) {
820             getPostConstructDescriptors().add(postConstructDesc);
821         }
822     }
823
824     public LifecycleCallbackDescriptor
825         getPostConstructDescriptorByClass(String JavaDoc className) {
826         return getPostConstructDescriptorByClass(className, this);
827     }
828
829     public Set<LifecycleCallbackDescriptor>
830         getPreDestroyDescriptors() {
831         if (preDestroyDescs == null) {
832             preDestroyDescs =
833                 new HashSet<LifecycleCallbackDescriptor>();
834         }
835         return preDestroyDescs;
836     }
837
838     public void addPreDestroyDescriptor(LifecycleCallbackDescriptor
839         preDestroyDesc) {
840         String JavaDoc className = preDestroyDesc.getLifecycleCallbackClass();
841         boolean found = false;
842         for (LifecycleCallbackDescriptor next :
843              getPreDestroyDescriptors()) {
844             if (next.getLifecycleCallbackClass().equals(className)) {
845                 found = true;
846                 break;
847             }
848         }
849         if (!found) {
850             getPreDestroyDescriptors().add(preDestroyDesc);
851         }
852     }
853
854     public LifecycleCallbackDescriptor
855         getPreDestroyDescriptorByClass(String JavaDoc className) {
856         return getPreDestroyDescriptorByClass(className, this);
857     }
858
859     protected List<InjectionCapable>
860         getInjectableResourcesByClass(String JavaDoc className,
861                                       JndiNameEnvironment jndiNameEnv) {
862         List<InjectionCapable> injectables =
863             new LinkedList<InjectionCapable>();
864
865         for(InjectionCapable next : getInjectableResources(jndiNameEnv) ) {
866             if( next.isInjectable()) {
867                 for (InjectionTarget target : next.getInjectionTargets()) {
868                     if (target.getClassName().equals(className) ) {
869                         injectables.add(next);
870                     }
871                 }
872             }
873         }
874         
875         if(((WebBundleDescriptor)jndiNameEnv).hasWebServices()) {
876             // Add @Resource WebServiceContext present in endpoint impl class to the list of
877
// injectable resources; We do this for servelt endpoint only because the actual
878
// endpoint impl class gets replaced by JAXWSServlet in web.xml and hence
879
// will never be added as an injectable resource
880
for(InjectionCapable next : getInjectableResources(this) ) {
881                 if( next.isInjectable()) {
882                     for (InjectionTarget target : next.getInjectionTargets()) {
883                         Iterator<WebServiceEndpoint> epIter = getWebServices().getEndpoints().iterator();
884                         while(epIter.hasNext()) {
885                             String JavaDoc servletImplClass = epIter.next().getServletImplClass();
886                             if (target.getClassName().equals(servletImplClass) ) {
887                                 injectables.add(next);
888                             }
889                         }
890                     }
891                 }
892             }
893         }
894         return injectables;
895     }
896     
897     public List<InjectionCapable>
898         getInjectableResourcesByClass(String JavaDoc className) {
899         return(getInjectableResourcesByClass(className, this));
900     }
901
902     public InjectionInfo getInjectionInfoByClass(String JavaDoc className,
903                               JndiNameEnvironment jndiNameEnv) {
904         LifecycleCallbackDescriptor postConstructDesc =
905             getPostConstructDescriptorByClass(className, jndiNameEnv);
906         String JavaDoc postConstructMethodName = (postConstructDesc != null) ?
907             postConstructDesc.getLifecycleCallbackMethod() : null;
908         LifecycleCallbackDescriptor preDestroyDesc =
909             getPreDestroyDescriptorByClass(className, jndiNameEnv);
910         String JavaDoc preDestroyMethodName = (preDestroyDesc != null) ?
911             preDestroyDesc.getLifecycleCallbackMethod() : null;
912         return new InjectionInfo(className,
913                                  postConstructMethodName, preDestroyMethodName,
914                                  getInjectableResourcesByClass(className,
915                                                                jndiNameEnv));
916     }
917
918     public InjectionInfo getInjectionInfoByClass(String JavaDoc className) {
919         return(getInjectionInfoByClass(className, this));
920     }
921
922     /** Returns an Enumeration of my SecurityRole objects. */
923     public Enumeration getSecurityRoles() {
924     Vector securityRoles = new Vector();
925     for (Iterator itr = super.getRoles().iterator(); itr.hasNext();) {
926         Role r = (Role) itr.next();
927         SecurityRoleDescriptor srd = new SecurityRoleDescriptor(r);
928         securityRoles.add(srd);
929     }
930     return securityRoles.elements();
931     }
932     
933     /** Add a new abstrct role to me. */
934     public void addSecurityRole(SecurityRole securityRole) {
935     Role r = new Role(securityRole.getName());
936     r.setDescription(securityRole.getDescription());
937     super.addRole(r);
938     }
939     /** Add a new abstrct role to me. */
940     public void addSecurityRole(SecurityRoleDescriptor securityRole) {
941         addSecurityRole((SecurityRole) securityRole);
942     }
943     
944     /** Return all the references by a given component (by name) to the given rolename. */
945     public SecurityRoleReference getSecurityRoleReferenceByName(String JavaDoc compName, String JavaDoc roleName) {
946         for(Enumeration e = this.getWebComponentDescriptors(); e.hasMoreElements();){
947         WebComponentDescriptor comp = (WebComponentDescriptor) e.nextElement();
948         if(!comp.getCanonicalName().equals(compName))
949             continue;
950
951         SecurityRoleReference r = comp.getSecurityRoleReferenceByName(roleName);
952         if(r != null)
953             return r;
954         }
955
956         return null;
957     }
958
959     
960     private Set getSecurityConstraintsSet() {
961     if (this.securityConstraints == null) {
962         this.securityConstraints = new HashSet();
963     }
964     return this.securityConstraints;
965     }
966     
967     /** My list of security constraints.*/
968     public Enumeration getSecurityConstraints() {
969     return (new Vector(this.getSecurityConstraintsSet())).elements();
970     }
971
972     public Collection getSecurityConstraintsForUrlPattern(String JavaDoc urlPattern) {
973         Collection constraints = new HashSet();
974         for(Iterator i = getSecurityConstraintsSet().iterator(); i.hasNext();) {
975             SecurityConstraint next = (SecurityConstraint) i.next();
976             boolean include = false;
977             for(Enumeration wrc = next.getWebResourceCollections();
978                 wrc.hasMoreElements();) {
979                 WebResourceCollection nextCol = (WebResourceCollection)
980                     wrc.nextElement();
981                 for(Enumeration up = nextCol.getUrlPatterns();
982                     up.hasMoreElements();) {
983                     String JavaDoc nextPattern = (String JavaDoc) up.nextElement();
984                     if((urlPattern != null) && urlPattern.equals(nextPattern)) {
985                         include = true;
986                         break;
987                     }
988                 }
989                 if( include ) { break; }
990             }
991             if( include ) { constraints.add(next); }
992         }
993         return constraints;
994     }
995
996     /** Add a new security constraint.*/
997     public void addSecurityConstraint(SecurityConstraint securityConstraint) {
998     this.getSecurityConstraintsSet().add(securityConstraint);
999     this.changed();
1000    }
1001    
1002    /** Add a new security constraint.*/
1003    public void addSecurityConstraint(SecurityConstraintImpl securityConstraint) {
1004    addSecurityConstraint((SecurityConstraint )securityConstraint);
1005    }
1006    
1007     /** Remove the given security constraint.*/
1008    public void removeSecurityConstraint(SecurityConstraint securityConstraint) {
1009    this.getSecurityConstraintsSet().remove(securityConstraint);
1010    this.changed();
1011    }
1012    
1013    
1014    
1015    /** Unused. */
1016    public Enumeration getLocalizedContentDescriptors() {
1017    return (new Vector()).elements();
1018    }
1019
1020    public JspConfigDescriptor getJspConfigDescriptor() {
1021    return jspConfigDescriptor;
1022    }
1023
1024    public void setJspConfigDescriptor(JspConfigDescriptor jspC) {
1025    if (jspConfigDescriptor != null) {
1026            jspConfigDescriptor.removeNotificationListener(this);
1027    }
1028    jspConfigDescriptor = jspC;
1029    if (jspC != null) {
1030            jspC.addNotificationListener(this);
1031    }
1032    }
1033
1034    /* ----
1035    */

1036
1037    public Set getServletDescriptors() {
1038    Set servletDescriptors = new HashSet();
1039    for (Iterator itr = this.getWebComponentDescriptorsSet().iterator(); itr.hasNext();) {
1040        WebComponentDescriptor next = (WebComponentDescriptor) itr.next();
1041            if (next.isServlet()) {
1042        servletDescriptors.add(next);
1043        }
1044    }
1045    return servletDescriptors;
1046    }
1047    
1048    /** Return my Set of jsps. */
1049    public Set getJspDescriptors() {
1050    Set jspDescriptors = new HashSet();
1051    for (Iterator itr = this.getWebComponentDescriptorsSet().iterator(); itr.hasNext();) {
1052        WebComponentDescriptor next = (WebComponentDescriptor) itr.next();
1053            if (!next.isServlet()) {
1054        jspDescriptors.add(next);
1055        }
1056    }
1057    return jspDescriptors;
1058    }
1059    
1060    private Set getEnvironmentEntrySet() {
1061    if (this.environmentEntries == null) {
1062        this.environmentEntries = new OrderedSet();
1063    }
1064    return this.environmentEntries = new OrderedSet(environmentEntries);
1065    }
1066    
1067    /** Return my set of environment properties.*/
1068    public Enumeration getEnvironmentEntries() {
1069    return (new Vector(this.getEnvironmentEntrySet())).elements();
1070    }
1071    
1072    /** Adds this given environment property to my list.*/
1073    public void addEnvironmentEntry(EnvironmentEntry environmentEntry) {
1074    this.getEnvironmentEntrySet().add(environmentEntry);
1075    this.changed();
1076    }
1077    
1078    /**
1079     * Returns the environment property object searching on the supplied key.
1080     * throws an illegal argument exception if no such environment property exists.
1081     */

1082    public EnvironmentProperty getEnvironmentPropertyByName(String JavaDoc name) {
1083    for (Iterator itr = this.getEnvironmentEntrySet().iterator();
1084             itr.hasNext();) {
1085        EnvironmentProperty ev = (EnvironmentProperty) itr.next();
1086        if (ev.getName().equals(name)) {
1087        return ev;
1088        }
1089    }
1090    throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
1091        "enterprise.deployment.exceptionbeanhasnoenvpropertybyname",
1092        "This bean has no environment property by the name of {0}",
1093                new Object JavaDoc[] {name}));
1094    }
1095
1096    /** Removes this given environment property from my list.*/
1097    public void removeEnvironmentProperty(EnvironmentProperty environmentProperty) {
1098    this.getEnvironmentEntrySet().remove(environmentProperty);
1099    this.changed();
1100    }
1101    
1102    /** Adds this given environment property to my list.*/
1103    public void addEnvironmentProperty(EnvironmentProperty environmentProperty) {
1104    this.getEnvironmentEntrySet().add(environmentProperty);
1105    this.changed();
1106    }
1107    
1108    /** Removes this given environment property from my list.*/
1109    public void removeEnvironmentEntry(EnvironmentEntry environmentEntry) {
1110    this.getEnvironmentEntrySet().remove(environmentEntry);
1111    this.changed();
1112    }
1113    
1114    /** Return the information about how I should log in.*/
1115    public LoginConfiguration getLoginConfiguration() {
1116    return this.loginConfiguration;
1117    }
1118    
1119    /** Specifies the information about how I should log in.*/
1120    public void setLoginConfiguration(LoginConfiguration loginConfiguration) {
1121    this.loginConfiguration = loginConfiguration;
1122    this.changed();
1123    }
1124
1125    public void setLoginConfiguration(LoginConfigurationImpl loginConfiguration) {
1126        setLoginConfiguration((LoginConfiguration) loginConfiguration);
1127    }
1128
1129    /** Search for a web component that I have by name.*/
1130    public WebComponentDescriptor getWebComponentByName(String JavaDoc name) {
1131    for (Iterator itr = this.getWebComponentDescriptorsSet().iterator(); itr.hasNext();) {
1132        Descriptor next = (Descriptor) itr.next();
1133        if (next.getName().equals(name)) {
1134        return (WebComponentDescriptor) next;
1135        }
1136    }
1137    return null;
1138    }
1139
1140    /** Search for a web component that I have by name.*/
1141    public WebComponentDescriptor getWebComponentByCanonicalName(String JavaDoc name) {
1142    for (Iterator itr = this.getWebComponentDescriptorsSet().iterator(); itr.hasNext();) {
1143        WebComponentDescriptor next = (WebComponentDescriptor) itr.next();
1144        if (next.getCanonicalName().equals(name)) {
1145        return (WebComponentDescriptor) next;
1146        }
1147    }
1148    return null;
1149    }
1150
1151    /**
1152     * @return a set of web component descriptor of given impl name.
1153     */

1154    public WebComponentDescriptor[] getWebComponentByImplName(String JavaDoc name) {
1155        ArrayList<WebComponentDescriptor> webCompList =
1156                new ArrayList<WebComponentDescriptor>();
1157    for (Object JavaDoc webCompObj : this.getWebDescriptors()) {
1158            WebComponentDescriptor webComp = (WebComponentDescriptor)webCompObj;
1159            if (webComp.getWebComponentImplementation().equals(name)) {
1160                webCompList.add(webComp);
1161            }
1162        }
1163        return webCompList.toArray(new WebComponentDescriptor[webCompList.size()]);
1164    }
1165    
1166    /* ----
1167    */

1168
1169    /**
1170    * Return a Vector of servlet filters that I have.
1171    */

1172    public Vector getServletFilters() {
1173    if (this.servletFilters == null) {
1174        this.servletFilters = new Vector();
1175    }
1176    return this.servletFilters;
1177    }
1178
1179    /**
1180    * Return a Vector of servlet filters that I have.
1181    */

1182    public Vector getServletFilterDescriptors() {
1183    return (Vector)this.getServletFilters().clone();
1184    }
1185
1186    /**
1187    * Adds a servlet filter to this web component.
1188    */

1189    public void addServletFilter(ServletFilter ref) {
1190    if (!this.getServletFilters().contains(ref)) {
1191        this.getServletFilters().addElement(ref);
1192        this.changed();
1193    }
1194    }
1195    
1196    public void addServletFilter(ServletFilterDescriptor ref) {
1197        addServletFilter((ServletFilter) ref);
1198    }
1199
1200    /**
1201    * Removes the given servlet filter from this web component.
1202    */

1203    public void removeServletFilter(ServletFilter ref) {
1204    this.removeVectorItem(this.getServletFilters(), ref);
1205    //this.getServletFilters().removeElement(ref); ** is based on 'equals()'
1206
this.changed();
1207    }
1208
1209    /* ----
1210    */

1211
1212    /**
1213    * Return a Vector of servlet filters that I have.
1214    */

1215    public Vector getServletFilterMappings() {
1216    if (this.servletFilterMappings == null) {
1217        this.servletFilterMappings = new Vector();
1218    }
1219    return this.servletFilterMappings;
1220    }
1221
1222    /**
1223    * Return a Vector of servlet filter mappings that I have.
1224    */

1225    public Vector getServletFilterMappingDescriptors() {
1226    return (Vector)this.getServletFilterMappings().clone();
1227    }
1228
1229    /**
1230    * Adds a servlet filter mapping to this web component.
1231    */

1232    public void addServletFilterMapping(ServletFilterMapping ref) {
1233    if (!this.getServletFilterMappings().contains(ref)) {
1234        this.getServletFilterMappings().addElement(ref);
1235        this.changed();
1236    }
1237    }
1238    
1239    /**
1240    * Adds a servlet filter mapping to this web component.
1241    */

1242    public void addServletFilterMapping(ServletFilterMappingDescriptor ref) {
1243        addServletFilterMapping((ServletFilterMapping) ref);
1244    }
1245    
1246    /**
1247    * Removes the given servlet filter mapping from this web component.
1248    */

1249    public void removeServletFilterMapping(ServletFilterMapping ref) {
1250    this.removeVectorItem(this.getServletFilterMappings(), ref);
1251    //this.getServletFilterMappings().removeElement(ref);
1252
this.changed();
1253    }
1254    /**
1255    ** Moves the given servlet filter mapping to a new relative location in
1256    ** the list
1257    */

1258    public void moveServletFilterMapping(ServletFilterMapping ref, int relPos) {
1259    this.moveVectorItem(this.getServletFilterMappings(), ref, relPos);
1260    this.changed();
1261    }
1262
1263    /* ----
1264    */

1265    
1266    private Vector getAppListeners() {
1267    if (this.appListenerDescriptors == null) {
1268        this.appListenerDescriptors = new Vector();
1269    }
1270    return this.appListenerDescriptors;
1271    }
1272    
1273    public Vector getAppListenerDescriptors() {
1274    return (Vector)this.getAppListeners().clone();
1275    }
1276
1277    public void setAppListeners(Collection c) {
1278    this.getAppListeners().clear();
1279    this.getAppListeners().addAll(c);
1280    this.changed();
1281    }
1282
1283    public void addAppListenerDescriptor(AppListenerDescriptor ref) {
1284    if (!this.getAppListeners().contains(ref)) {
1285        this.getAppListeners().addElement(ref);
1286        this.changed();
1287    }
1288    }
1289    
1290    public void addAppListenerDescriptor(AppListenerDescriptorImpl ref) {
1291        addAppListenerDescriptor((AppListenerDescriptor) ref);
1292    }
1293
1294    public void removeAppListenerDescriptor(AppListenerDescriptor ref) {
1295    this.removeVectorItem(this.getAppListeners(), ref);
1296    //this.getAppListeners().removeElement(ref);
1297
this.changed();
1298    }
1299
1300    public void moveAppListenerDescriptor(AppListenerDescriptor ref,
1301    int relPos) {
1302    this.moveVectorItem(this.getAppListeners(), ref, relPos);
1303    this.changed();
1304    }
1305
1306    /**
1307     * @return true if this bundle descriptor defines web service clients
1308     */

1309    public boolean hasWebServiceClients() {
1310        return !getServiceReferenceDescriptors().isEmpty();
1311    }
1312    
1313    /**
1314     * End of Web-Services related API
1315     */

1316    
1317    /* ----
1318    */

1319
1320    /**
1321    * remove a specific object from the given list (does not rely on 'equals')
1322    */

1323    protected boolean removeVectorItem(Vector list, Object JavaDoc ref) {
1324    for (Iterator i = list.iterator(); i.hasNext();) {
1325        if (ref == i.next()) {
1326        i.remove();
1327        return true;
1328        }
1329    }
1330    return false;
1331    }
1332
1333    /**
1334    * Moves the given object to a new relative location in the specified list
1335    */

1336    protected void moveVectorItem(Vector list, Object JavaDoc ref, int rpos) {
1337
1338    /* get current position of ref */
1339    // 'indexOf' is not used because it is base on 'equals()' which may
1340
// not be unique.
1341
int size = list.size(), old_pos = size - 1;
1342    for (;old_pos >= 0; old_pos--) {
1343        if (ref == list.elementAt(old_pos)) {
1344        break;
1345        }
1346    }
1347    if (old_pos < 0) {
1348        return; // not found
1349
}
1350
1351    /* limit up/down movement */
1352    int new_pos = old_pos + rpos;
1353    if (new_pos < 0) {
1354        new_pos = 0; // limit movement
1355
} else
1356    if (new_pos >= size) {
1357        new_pos = size - 1; // limit movement
1358
}
1359
1360    /* is it really moving? */
1361    if (new_pos == old_pos) {
1362        return; // it's not moving
1363
}
1364    
1365    /* move it */
1366    list.removeElementAt(old_pos);
1367    list.insertElementAt(ref, new_pos);
1368    this.changed();
1369
1370    }
1371    
1372    /**
1373     * visitor API implementation
1374     */

1375    public void visit(DescriptorVisitor aVisitor) {
1376        if (aVisitor instanceof WebBundleVisitor) {
1377            visit((WebBundleVisitor) aVisitor);
1378        } else {
1379            super.visit(aVisitor);
1380        }
1381    }
1382    
1383    /**
1384     * visitor API implementation
1385     */

1386    public void visit(WebBundleVisitor aVisitor) {
1387        super.visit(aVisitor);
1388        aVisitor.accept(this);
1389
1390        // Visit all injectables first. In some cases, basic type information
1391
// has to be derived from target inject method or inject field.
1392
for(InjectionCapable injectable : getInjectableResources(this)) {
1393            aVisitor.accept(injectable);
1394        }
1395
1396        for (Iterator i=getWebComponentDescriptorsSet().iterator();i.hasNext();) {
1397            WebComponentDescriptor aWebComp = (WebComponentDescriptor) i.next();
1398            aVisitor.accept(aWebComp);
1399        }
1400        for (Iterator itr=getWebServices().getWebServices().iterator();
1401             itr.hasNext(); ) {
1402            WebService aWebService = (WebService) itr.next();
1403            aVisitor.accept(aWebService);
1404        }
1405
1406        for (Iterator itr = getEjbReferenceDescriptors().iterator();itr.hasNext();) {
1407            EjbReference aRef = (EjbReference) itr.next();
1408            aVisitor.accept(aRef);
1409        }
1410        for (Iterator itr=getResourceReferenceDescriptors().iterator();
1411             itr.hasNext();) {
1412            ResourceReferenceDescriptor next =
1413                (ResourceReferenceDescriptor) itr.next();
1414            aVisitor.accept(next);
1415        }
1416        for (Iterator itr=getJmsDestinationReferenceDescriptors().iterator();
1417             itr.hasNext();) {
1418            JmsDestinationReferenceDescriptor next =
1419                (JmsDestinationReferenceDescriptor) itr.next();
1420            aVisitor.accept(next);
1421        }
1422        for (Iterator itr=getMessageDestinationReferenceDescriptors().iterator();
1423             itr.hasNext();) {
1424            MessageDestinationReferencer next =
1425                (MessageDestinationReferencer) itr.next();
1426            aVisitor.accept(next);
1427        }
1428        for (Iterator itr = getMessageDestinations().iterator();
1429                itr.hasNext();) {
1430            MessageDestinationDescriptor msgDestDescriptor =
1431                (MessageDestinationDescriptor)itr.next();
1432            aVisitor.accept(msgDestDescriptor);
1433        }
1434        for (Iterator itr=getServiceReferenceDescriptors().iterator();
1435             itr.hasNext();) {
1436            aVisitor.accept((ServiceReferenceDescriptor) itr.next());
1437        }
1438    }
1439
1440    /* ----
1441    */

1442
1443    public void notification(NotificationEvent ne) {
1444    // currently, notifications come only from the WebServiceBundleDescriptor
1445
this.changed();
1446    }
1447
1448    /* ----
1449    */

1450
1451    /** Return a formatted version as a String. */
1452    public void print(StringBuffer JavaDoc toStringBuffer) {
1453    toStringBuffer.append("\nWeb Bundle descriptor");
1454    toStringBuffer.append("\n");
1455        super.print(toStringBuffer);
1456        toStringBuffer.append( "\n context root ").append(getContextRoot());
1457    toStringBuffer.append( "\n sessionTimeout ").append(sessionTimeout);
1458    toStringBuffer.append( "\n mimeMappings ").append(mimeMappings);
1459    toStringBuffer.append( "\n welcomeFiles ").append(welcomeFiles);
1460    toStringBuffer.append( "\n errorPageDescriptors ").append(errorPageDescriptors);
1461    toStringBuffer.append( "\n appListenerDescriptors ").append(appListenerDescriptors);
1462    toStringBuffer.append( "\n contextParameters ").append(contextParameters);
1463    toStringBuffer.append( "\n ejbReferences ");
1464        if(ejbReferences != null)
1465            printDescriptorSet(ejbReferences,toStringBuffer);
1466        toStringBuffer.append( "\n jmsDestReferences ");
1467        if(jmsDestReferences != null)
1468            printDescriptorSet(jmsDestReferences,toStringBuffer);
1469        toStringBuffer.append( "\n messageDestReferences ");
1470        if(messageDestReferences != null)
1471            printDescriptorSet(messageDestReferences,toStringBuffer);
1472    toStringBuffer.append( "\n resourceReferences ");
1473        if(resourceReferences != null)
1474            printDescriptorSet(resourceReferences,toStringBuffer);
1475    toStringBuffer.append( "\n serviceReferences ");
1476        if(serviceReferences != null)
1477            printDescriptorSet(serviceReferences,toStringBuffer);
1478    toStringBuffer.append( "\n isDistributable ").append(isDistributable);
1479    toStringBuffer.append( "\n securityRoles ").append(securityRoles);
1480    toStringBuffer.append( "\n securityConstraints ").append(securityConstraints);
1481    toStringBuffer.append( "\n contextRoot ").append(contextRoot);
1482    toStringBuffer.append( "\n loginConfiguration ").append(this.loginConfiguration);
1483    toStringBuffer.append( "\n webComponentDescriptors ");
1484        if(webComponentDescriptors != null)
1485            printDescriptorSet(webComponentDescriptors,toStringBuffer);
1486    toStringBuffer.append( "\n environmentEntries ");
1487        if(environmentEntries != null)
1488            printDescriptorSet(environmentEntries,toStringBuffer);
1489    if (sunWebApp!=null) {
1490        toStringBuffer.append( "\n ========== Runtime Descriptors =========");
1491        toStringBuffer.append( "\n").append(sunWebApp.toString());
1492    }
1493    }
1494    private void printDescriptorSet(Set descSet, StringBuffer JavaDoc sbuf){
1495        if (descSet==null)
1496            return;
1497        for(Iterator itr = descSet.iterator(); itr.hasNext();){
1498            Object JavaDoc obj = itr.next();
1499            if(obj instanceof Descriptor)
1500                ((Descriptor)obj).print(sbuf);
1501            else
1502                sbuf.append(obj);
1503        }
1504    }
1505    
1506    /**
1507     * @return the module type for this bundle descriptor
1508     */

1509    public ModuleType JavaDoc getModuleType() {
1510        return ModuleType.WAR;
1511    }
1512    
1513    /**
1514     * @return the deployment descriptor directory location inside
1515     * the archive file
1516     */

1517    public String JavaDoc getDeploymentDescriptorDir() {
1518        return DEPLOYMENT_DESCRIPTOR_DIR;
1519    }
1520
1521        /***********************************************************************************************
1522     * START
1523     * Deployment Consolidation to Suppport Multiple Deployment API Clients
1524     * Methods: setSunDescriptor, getSunDescriptor
1525     ***********************************************************************************************/

1526    
1527    /**
1528     * This returns the extra web sun specific info not in the RI DID.
1529     *
1530     * @return object representation of web deployment descriptor
1531     */

1532    public SunWebApp getSunDescriptor(){
1533    if (sunWebApp==null) {
1534        sunWebApp = new SunWebApp();
1535    }
1536        return sunWebApp;
1537    }
1538    
1539    /**
1540     * This sets the extra web sun specific info not in the RI DID.
1541     *
1542     * @param webApp SunWebApp object representation of web deployment descriptor
1543     */

1544    public void setSunDescriptor(SunWebApp webApp){
1545        this.sunWebApp = webApp;
1546    }
1547   
1548    /*******************************************************************************************
1549     * END
1550     * Deployment Consolidation to Suppport Multiple Deployment API Clients
1551     *******************************************************************************************/

1552}
1553    
1554
Popular Tags