KickJava   Java API By Example, From Geeks To Geeks.

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


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 com.sun.enterprise.deployment.archivist.AppClientArchivist;
26 import com.sun.enterprise.deployment.archivist.ApplicationArchivist;
27 import com.sun.enterprise.deployment.archivist.EjbArchivist;
28 import com.sun.enterprise.deployment.deploy.shared.AbstractArchive;
29 import com.sun.enterprise.deployment.deploy.shared.FileArchive;
30 import com.sun.enterprise.deployment.deploy.shared.InputJarArchive;
31 import com.sun.enterprise.deployment.interfaces.SecurityRoleMapper;
32 import com.sun.enterprise.deployment.interfaces.SecurityRoleMapperFactory;
33 import com.sun.enterprise.deployment.interfaces.SecurityRoleMapperFactoryMgr;
34 import com.sun.enterprise.deployment.node.ApplicationNode;
35 import com.sun.enterprise.deployment.Role;
36 import com.sun.enterprise.deployment.runtime.common.SecurityRoleMapping;
37 import com.sun.enterprise.deployment.types.RoleMappingContainer;
38 import com.sun.enterprise.deployment.util.AppClientVisitor;
39 import com.sun.enterprise.deployment.util.ApplicationVisitor;
40 import com.sun.enterprise.deployment.util.ConnectorVisitor;
41 import com.sun.enterprise.deployment.util.DescriptorVisitor;
42 import com.sun.enterprise.deployment.util.DOLUtils;
43 import com.sun.enterprise.deployment.util.EjbBundleVisitor;
44 import com.sun.enterprise.deployment.util.EjbComponentAnnotationDetector;
45 import com.sun.enterprise.deployment.util.ModuleDescriptor;
46 import com.sun.enterprise.deployment.util.WebBundleVisitor;
47 import com.sun.enterprise.util.LocalStringManagerImpl;
48 import com.sun.enterprise.util.NotificationEvent;
49 import com.sun.enterprise.util.NotificationListener;
50 import com.sun.enterprise.util.io.FileUtils;
51
52 import java.io.File JavaDoc;
53 import java.io.FilenameFilter JavaDoc;
54 import java.io.IOException JavaDoc;
55 import java.net.URI JavaDoc;
56 import java.net.URISyntaxException JavaDoc;
57 import java.util.ArrayList JavaDoc;
58 import java.util.Arrays JavaDoc;
59 import java.util.Collection JavaDoc;
60 import java.util.Comparator JavaDoc;
61 import java.util.Enumeration JavaDoc;
62 import java.util.HashMap JavaDoc;
63 import java.util.HashSet JavaDoc;
64 import java.util.Hashtable JavaDoc;
65 import java.util.Iterator JavaDoc;
66 import java.util.List JavaDoc;
67 import java.util.logging.Level JavaDoc;
68 import java.util.logging.Logger JavaDoc;
69 import java.util.Map JavaDoc;
70 import java.util.Set JavaDoc;
71 import java.util.StringTokenizer JavaDoc;
72 import java.util.Vector JavaDoc;
73
74 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
75 import javax.persistence.EntityManagerFactory;
76
77 /**
78  * Objects of this type encapsulate the data and behaviour of a J2EE
79  * application.
80  *@author Danny Coward
81  */

82  
83 public class Application extends RootDeploymentDescriptor
84         implements NotificationListener, Roles, RoleMappingContainer {
85
86     /** default value for the library-directory element */
87     private static final String JavaDoc LIBRARY_DIRECTORY_DEFAULT_VALUE = "lib";
88
89     private static final String JavaDoc PERSISTENCE_UNIT_NAME_SEPARATOR = "#";
90
91     /**
92      * Store generated XML dir to be able to get the generated WSDL
93      */

94     private String JavaDoc generatedXMLDir;
95         
96     // Set of modules in this application
97
private Set JavaDoc modules = new HashSet JavaDoc();
98     
99     // IASRI 4645310
100
/** unique id for this application */
101     private long uniqueId;
102
103     // IASRI 4645310
104
/** represents the virtual status of this application object */
105     private boolean virtual = false;
106     
107     // IASRI 4662001, 4720955
108
/** represents whether all ejb modules in an application will be pass by
109         value or pass by reference */

110     private Boolean JavaDoc passByReference = null;
111     
112     // table of EJB2.0 CMP descriptors (EntityBeans)
113
// keyed on their class names
114
private Hashtable JavaDoc cmpDescriptors = null;
115     
116     // flag to indicate that the memory representation of this application
117
// is not in sync with the disk representation
118
private boolean isDirty;
119     
120     // data structure to map roles to users and groups
121
private SecurityRoleMapper roleMapper;
122     
123     // IASRI 4648645 - application registration name
124
/** name used to register this application */
125     private String JavaDoc registrationName;
126     
127     // realm associated with this application
128
private String JavaDoc realm;
129
130     // Physical entity manager factory corresponding to the unit name of
131
// each application-level persistence unit. Only available at runtime.
132
private Map JavaDoc<String JavaDoc, EntityManagerFactory> entityManagerFactories =
133         new HashMap JavaDoc<String JavaDoc, EntityManagerFactory>();
134
135     private Set JavaDoc<String JavaDoc> entityManagerFactoryUnitNames =
136         new HashSet JavaDoc<String JavaDoc>();
137         
138     // for i18N
139
private static LocalStringManagerImpl localStrings=
140         new LocalStringManagerImpl(Application.class);
141     
142     private Set JavaDoc appRoles;
143
144     private String JavaDoc libraryDirectory;
145
146     private List JavaDoc<SecurityRoleMapping> roleMaps = new ArrayList JavaDoc<SecurityRoleMapping>();
147
148     private boolean loadedFromApplicationXml = true;
149
150     private List JavaDoc resourceList = null;
151
152     /**
153     * Creates a new application object with the diven display name and file.
154     *
155     * @param name the display name of the application
156     * @the file object used to initialize the archivist.
157     *
158     */

159     public Application(String JavaDoc name, File JavaDoc jar) {
160     super(name, localStrings.getLocalString(
161                         "enterprise.deployment.application.description",
162                         "Application description"));
163     }
164     
165     public Application() {
166     super("", localStrings.getLocalString(
167                         "enterprise.deployment.application.description",
168                         "Application description"));
169     }
170     
171
172     // Create logger object per Java SDK 1.4 to log messages
173
// introduced Santanu De, Sun Microsystems, March 2002
174

175     static Logger JavaDoc _logger = com.sun.enterprise.deployment.util.LogDomains.getLogger(com.sun.enterprise.deployment.util.LogDomains.DPL_LOGGER);
176
177         
178     /**
179      * @return the default version of the deployment descriptor
180      * loaded by this descriptor
181      */

182     public String JavaDoc getDefaultSpecVersion() {
183         return ApplicationNode.SPEC_VERSION;
184     }
185     
186     /**
187      * Creates a new application to hold a standalone module
188      * @param the application name
189      * @param the standalone module descriptor
190      * @return the application
191      */

192     public static Application createApplication(String JavaDoc name, ModuleDescriptor newModule) {
193     
194         // create a new empty application
195
Application application = new Application();
196     application.setVirtual(true);
197         if (name==null && newModule.getDescriptor()!=null) {
198             name = newModule.getDescriptor().getDisplayName();
199             
200         }
201         if (name!=null) {
202             application.setDisplayName(name);
203             application.setName(name);
204         }
205         
206         // add the module to it
207
newModule.setStandalone(true);
208         newModule.setArchiveUri(name);
209         if (newModule.getDescriptor()!=null) {
210             newModule.getDescriptor().setApplication(application);
211         }
212         application.addModule(newModule);
213         
214         return application;
215     }
216
217     /**
218      * This method creates a top level Application object for an ear.
219      * @param archive the archive for the application
220      * @param introspect whether or not to create via introspection. if
221      * true, an application object is constructed in the
222      * absence of an application.xml. if false, it is
223      * constructed from reading the application.xml from
224      * the archive.
225      */

226     public static Application createApplication(
227             AbstractArchive archive, boolean introspect) {
228         return createApplication(archive, introspect, false);
229     }
230
231     /**
232      * This method creates a top level Application object for an ear.
233      * @param archive the archive for the application
234      * @param introspect whether or not to create via introspection. if
235      * true, an application object is constructed in the
236      * absence of an application.xml. if false, it is
237      * constructed from reading the application.xml from
238      * the archive.
239      * @param directory whether the application is packaged as a directory
240      */

241     public static Application createApplication(
242             AbstractArchive archive, boolean introspect, boolean directory) {
243         if (introspect) {
244             return getApplicationFromIntrospection(archive, directory);
245         } else {
246             return getApplicationFromAppXml(archive);
247         }
248     }
249
250     private static Application getApplicationFromAppXml(AbstractArchive archive) {
251         ApplicationArchivist archivist = new ApplicationArchivist();
252         archivist.setXMLValidation(false);
253
254         // read the standard deployment descriptors
255
Application application = null;
256         try {
257             application =
258                 (Application) archivist.readStandardDeploymentDescriptor(archive);
259         } catch (Exception JavaDoc ex) {
260             //@@@ i18n
261
_logger.log(Level.SEVERE,
262                 "Error loading application.xml from " + archive.getArchiveUri());
263             _logger.log(Level.SEVERE, ex.getMessage());
264         }
265
266         return application;
267     }
268
269     /**
270      * This method introspect an ear file and populate the Application object.
271      * We follow the Java EE platform specification, Section EE.8.4.2
272      * to determine the type of the modules included in this application.
273      * @param archive the archive representing the application root
274      * @param directory whether this is a directory deployment
275      */

276     private static Application getApplicationFromIntrospection(
277             AbstractArchive archive, boolean directory) {
278         String JavaDoc appRoot = archive.getArchiveUri(); //archive is a directory
279
Application app = new Application();
280         app.setLoadedFromApplicationXml(false);
281         app.setVirtual(false);
282
283         //name of the file without its extension
284
String JavaDoc appName = appRoot.substring(
285                             appRoot.lastIndexOf(File.separatorChar)+1);
286         app.setName(appName);
287
288         List JavaDoc<AbstractArchive> unknowns = new ArrayList JavaDoc();
289         File JavaDoc[] files = getEligibleEntries(new File JavaDoc(appRoot), directory);
290         for (File JavaDoc subModule : files) {
291             AbstractArchive subArchive = null;
292             try {
293                 try {
294                     if (!directory) {
295                         subArchive = new InputJarArchive();
296                         ((InputJarArchive)subArchive).open(subModule.getAbsolutePath());
297                     } else {
298                         subArchive = new FileArchive();
299                         ((FileArchive)subArchive).open(subModule.getAbsolutePath());
300                     }
301                 } catch (IOException JavaDoc ex) {
302                     _logger.log(Level.WARNING, ex.getMessage());
303                 }
304
305                 //for archive deployment, we check the sub archives by its
306
//file extension; for directory deployment, we check the sub
307
//directories by its name, i.e. "_war" "_rar" etc.
308

309                 //Section EE.8.4.2.1.a
310
String JavaDoc name = subModule.getName();
311                 String JavaDoc uri = deriveArchiveUri(appRoot, subModule, directory);
312                 if ( (!directory && name.endsWith(".war"))
313                         || (directory && name.endsWith("_war")) ) {
314                     String JavaDoc contextRoot =
315                     uri.substring(uri.lastIndexOf('/')+1, uri.lastIndexOf('.'));
316                     ModuleDescriptor md = new ModuleDescriptor();
317                     md.setArchiveUri(uri);
318                     md.setModuleType(ModuleType.WAR);
319                     md.setContextRoot(contextRoot);
320                     app.addModule(md);
321                 }
322                 //Section EE.8.4.2.1.b
323
else if ( (!directory && name.endsWith(".rar"))
324                             || (directory && name.endsWith("_rar")) ) {
325                     ModuleDescriptor md = new ModuleDescriptor();
326                     md.setArchiveUri(uri);
327                     md.setModuleType(ModuleType.RAR);
328                     app.addModule(md);
329                 }
330                 else if ( (!directory && name.endsWith(".jar"))
331                             || (directory && name.endsWith("_jar")) ) {
332                     try {
333                         //Section EE.8.4.2.1.d.i
334
AppClientArchivist acArchivist = new AppClientArchivist();
335                         if (acArchivist.hasStandardDeploymentDescriptor(subArchive)
336                             || acArchivist.hasRuntimeDeploymentDescriptor(subArchive)
337                             || acArchivist.getMainClassName(subArchive.getManifest()) != null) {
338
339                             ModuleDescriptor md = new ModuleDescriptor();
340                             md.setArchiveUri(uri);
341                             md.setModuleType(ModuleType.CAR);
342                             md.setManifest(subArchive.getManifest());
343                             app.addModule(md);
344                             continue;
345                         }
346
347                         //Section EE.8.4.2.1.d.ii
348
EjbArchivist ejbArchivist = new EjbArchivist();
349                         if (ejbArchivist.hasStandardDeploymentDescriptor(subArchive)
350                             || ejbArchivist.hasRuntimeDeploymentDescriptor(subArchive)) {
351
352                             ModuleDescriptor md = new ModuleDescriptor();
353                             md.setArchiveUri(uri);
354                             md.setModuleType(ModuleType.EJB);
355                             app.addModule(md);
356                             continue;
357                         }
358                     } catch (IOException JavaDoc ex) {
359                         _logger.log(Level.WARNING, ex.getMessage());
360                     }
361
362                     //Still could not decide between an ejb and a library
363
unknowns.add(subArchive);
364                 } else {
365                     //ignored
366
}
367             } finally {
368                 if (subArchive != null) {
369                     try {
370                         subArchive.close();
371                     } catch (IOException JavaDoc ioe) {
372                         _logger.log(Level.WARNING, localStrings.getLocalString("enterprise.deployment.errorClosingSubArch", "Error closing subarchive {0}", new Object JavaDoc[] {subModule.getAbsolutePath()}), ioe);
373                     }
374                 }
375             }
376         }
377
378         if (unknowns.size() > 0) {
379             EjbComponentAnnotationDetector detector =
380                     new EjbComponentAnnotationDetector();
381             for (int i = 0; i < unknowns.size(); i++) {
382                 File JavaDoc jarFile = new File JavaDoc(unknowns.get(i).getArchiveUri());
383                 try {
384                     if (detector.hasAnnotationInArchive(unknowns.get(i))) {
385                         String JavaDoc uri = deriveArchiveUri(appRoot, jarFile, directory);
386                         //Section EE.8.4.2.1.d.ii, alas EJB
387
ModuleDescriptor md = new ModuleDescriptor();
388                         md.setArchiveUri(uri);
389                         md.setModuleType(ModuleType.EJB);
390                         app.addModule(md);
391                     }
392                 } catch (IOException JavaDoc ex) {
393                     _logger.log(Level.WARNING, ex.getMessage());
394                 }
395             }
396         }
397
398         return app;
399     }
400     
401     public void setGeneratedXMLDirectory(String JavaDoc xmlDir) {
402         generatedXMLDir = xmlDir;
403     }
404
405     /**
406     * Returns the generated XML directory for this app
407     *
408     */

409     public String JavaDoc getGeneratedXMLDirectory() {
410         return generatedXMLDir;
411     }
412
413     // START OF IASRI 4648645 - application registration name
414
/**
415      * Sets the registration name for this application. This name is used
416      * while deploying the application. The deployment process gurantees
417      * that this name is unique.
418      *
419      * @param appId the registration name used for this application
420      */

421     public void setRegistrationName(String JavaDoc appId) {
422         
423         // at his point we need to swap our RoleMapper, if we have one...
424
SecurityRoleMapper roleMapper=null;
425         try {
426             roleMapper = getRoleMapper();
427         } catch(IllegalArgumentException JavaDoc ignore) {};
428         
429         if (roleMapper!=null) {
430             SecurityRoleMapperFactory factory = SecurityRoleMapperFactoryMgr.getFactory();
431             if (factory==null) {
432                 throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
433                     "enterprise.deployment.norolemapperfactorydefine",
434                     "This application has no role mapper factory defined"));
435             }
436         factory.removeRoleMapper(getName());
437             roleMapper.setName(appId);
438             factory.setRoleMapper(appId, roleMapper);
439         }
440         
441         this.registrationName = appId;
442     }
443
444     /**
445      * Returns the registration name of this application.
446      *
447      * @return the registration name of this application
448      */

449     public String JavaDoc getRegistrationName() {
450         if (registrationName!=null) {
451             return registrationName;
452         } else {
453             return getName();
454         }
455     }
456     // END OF IASRI 4648645
457

458     /**
459      * Set the physical entity manager factory for a persistence unit
460      * within this application.
461      * This method takes a parameter called persistenceRootUri to support for
462      * fully-qualified persistence-unit-name syntax within
463      * persistence-unit-refs and persistence-context-refs. The syntax is similar
464      * to ejb-link and messge-destination-link. See (EJB 3 core spec: 15.10.2)
465      *
466      * @param unitName: Name of the persistence-unit
467      * @param persistenceRootUri: uri of the root of the persistence.xml
468      * (excluding META-INF) in which the persistence unit was defined.
469      * This uri is relative to the top of the .ear.
470      * @param emf: an entity manager factory.
471      */

472     public void addEntityManagerFactory(
473             String JavaDoc unitName,
474             String JavaDoc persistenceRootUri,
475             EntityManagerFactory emf) {
476
477         String JavaDoc fullyQualifiedUnitName = persistenceRootUri +
478             PERSISTENCE_UNIT_NAME_SEPARATOR + unitName;
479
480         // Always allow fully qualified lookup.
481
entityManagerFactories.put(fullyQualifiedUnitName, emf);
482
483         // Allow unqualified lookup, unless there are multiple .ear level
484
// persistence units declaring the same persistence unit name. In that
485
// case, only a fully-qualified lookup will work. Note that even
486
// though the entity manager factory map might contain more than one
487
// key pointing to the same entity manager factory, the behavior
488
// of getEntityManagerFactories() is not affected since it returns a Set.
489
if( entityManagerFactoryUnitNames.contains(unitName) ) {
490             entityManagerFactories.remove(unitName);
491         } else {
492             entityManagerFactories.put(unitName, emf);
493             entityManagerFactoryUnitNames.add(unitName);
494         }
495     }
496
497     /**
498      * Retrieve the physical entity manager factory associated with the
499      * unitName of an application-level persistence unit. Returns null if
500      * no matching entry is found.
501      */

502     public EntityManagerFactory getEntityManagerFactory
503         (String JavaDoc unitName, BundleDescriptor declaringModule) {
504         
505         String JavaDoc lookupString = unitName;
506
507         int separatorIndex =
508             unitName.lastIndexOf(PERSISTENCE_UNIT_NAME_SEPARATOR);
509         
510         if( separatorIndex != -1 ) {
511             String JavaDoc unqualifiedUnitName =
512                 unitName.substring(separatorIndex + 1);
513             String JavaDoc path = unitName.substring(0, separatorIndex);
514
515             String JavaDoc persistenceRootUri = getTargetUri(declaringModule, path);
516
517             lookupString = persistenceRootUri +
518                 PERSISTENCE_UNIT_NAME_SEPARATOR + unqualifiedUnitName;
519         }
520
521         return entityManagerFactories.get(lookupString);
522     }
523
524     /**
525      * Returns the set of physical entity manager factories associated with
526      * persistence units in this application.
527      */

528     public Set JavaDoc<EntityManagerFactory> getEntityManagerFactories() {
529
530         return new HashSet JavaDoc<EntityManagerFactory>
531             (entityManagerFactories.values());
532
533     }
534     
535     /** Return the set of roles used in this application. Currently, for release 1.0, it is an
536     ** aggregation of all the roles in the sub-modules of the application.
537     *
538     *@return the Set of roles in the application.
539     */

540     public Set JavaDoc getRoles() {
541     Set JavaDoc roles = new HashSet JavaDoc();
542     for (Iterator JavaDoc itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();) {
543         WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next();
544             if (wbd!=null) {
545                 roles.addAll(wbd.getRoles());
546             }
547     }
548     for (Iterator JavaDoc itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
549         EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next();
550             if (ejbd != null) {
551                 roles.addAll(ejbd.getRoles());
552             }
553     }
554     return roles;
555     }
556     
557     /**
558      * Return the set of com.sun.enterprise.deployment.Role objects
559      * I have (the ones defined in application xml).
560      */

561     public Set JavaDoc getAppRoles() {
562         if (this.appRoles == null) {
563             this.appRoles = new OrderedSet();
564         }
565         return this.appRoles;
566     }
567
568     public void addAppRole(SecurityRoleDescriptor descriptor) {
569         Role role = new Role(descriptor.getName());
570         role.setDescription(descriptor.getDescription());
571         getAppRoles().add(role);
572     }
573
574
575     /** Adds a new abstract role
576     */

577     public void addRole(Role role) {
578         for (Iterator JavaDoc itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();){
579              WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next();
580              wbd.addRole(role);
581         }
582         for (Iterator JavaDoc itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();){
583              EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next();
584              ejbd.addRole(role);
585         }
586     changed();
587     }
588     
589     /**
590     * Removes the given role.
591     */

592     public void removeRole(Role role) {
593         getAppRoles().remove(role);
594         for (Iterator JavaDoc itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();){
595         WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next();
596             wbd.removeRole(role);
597         }
598         for (Iterator JavaDoc itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();){
599         EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next();
600             ejbd.removeRole(role);
601         }
602     changed();
603     }
604     
605     /**
606     * Return the Set of all reource references that my components have.
607     */

608     
609     public Set JavaDoc getResourceReferenceDescriptors() {
610     Set JavaDoc resourceReferences = new HashSet JavaDoc();
611     for (Iterator JavaDoc itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
612         EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next();
613         resourceReferences.addAll(ejbd.getResourceReferenceDescriptors());
614     }
615     return resourceReferences;
616     }
617         
618    /**
619     * Reset the display name of this application.
620     *
621     * @param name the display name of the application.
622     */

623     public void setName(String JavaDoc name) {
624     name = name.replace('/', '-');
625     name = name.replace('\\', '-'); // for deploying from NT to solaris & vice versa. This will
626
// need to be cleaned when we clean up the backend for registering apps
627
setDirty(true);
628     super.setName(name);
629         if (this.getRoleMapper() != null) {
630         this.getRoleMapper().setName(name);
631         }
632     }
633
634     public void setDescription(String JavaDoc description) {
635         setDirty(true);
636         super.setDescription(description);
637     }
638
639     public void setLargeIconUri(String JavaDoc largeIconUri) {
640         setDirty(true);
641         super.setLargeIconUri(largeIconUri);
642     }
643
644     public void setSmallIconUri(String JavaDoc smallIconUri) {
645         setDirty(true);
646         super.setSmallIconUri(smallIconUri);
647     }
648
649     public void setLibraryDirectory(String JavaDoc value)
650     {
651         libraryDirectory = value;
652     }
653
654     /**
655      *Returns an "intelligent" value for the library directory setting, meaning
656      *the current value if it has been set to a non-null, non-empty value;
657      *the default value if the value has never been set, and null if the value
658      *has been set to empty.
659      *@return String value of the library directory setting
660      */

661     public String JavaDoc getLibraryDirectory()
662     {
663         if (libraryDirectory != null) {
664             return (libraryDirectory.length() == 0) ? null : libraryDirectory;
665         } else {
666             return LIBRARY_DIRECTORY_DEFAULT_VALUE;
667         }
668     }
669
670     public String JavaDoc getLibraryDirectoryRawValue() {
671         return libraryDirectory;
672     }
673     
674     /**
675     * The number of Web Components in this application.
676     * Current implementation only return the number of servlets
677     * inside the application, and not the JSPs since we cannot
678     * get that information from deployment descriptors.
679     *
680     * @return the number of Web Components
681     */

682     public int getWebComponentCount() {
683     int count = 0;
684     for (Iterator JavaDoc itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();) {
685         WebBundleDescriptor wbd = (WebBundleDescriptor) itr.next();
686         count = count + wbd.getWebDescriptors().size();
687     }
688     return count;
689     }
690
691     public void removeModule(ModuleDescriptor descriptor) {
692     if (modules.contains(descriptor)) {
693         if (descriptor.getDescriptor() != null) {
694         descriptor.getDescriptor().removeNotificationListener(this);
695         descriptor.getDescriptor().setApplication(null);
696         }
697         modules.remove(descriptor);
698         this.changed(true);
699     }
700     }
701
702     public void addModule(ModuleDescriptor descriptor) {
703         modules.add(descriptor);
704         if (descriptor.getDescriptor()!=null) {
705         descriptor.getDescriptor().addNotificationListener(this);
706             descriptor.getDescriptor().setApplication(this);
707         }
708         this.changed(true);
709     }
710     
711     /**
712      * Obtain a full set of module descriptors
713      *
714      * @return the set of bundle descriptors
715      */

716     public Iterator JavaDoc getModules() {
717         return modules.iterator();
718     }
719     
720     /**
721      * Obtain a full set of module descriptors for a particular type
722      *
723      * @param type the bundle descriptor type requested
724      * @return the set of bundle descriptors
725      */

726     public Iterator JavaDoc getModulesByType(ModuleType JavaDoc type) {
727         if (type==null) {
728             return null;
729         }
730         Set JavaDoc moduleSet = new HashSet JavaDoc();
731         for (Iterator JavaDoc bundles = getModules();bundles.hasNext();) {
732             ModuleDescriptor aModule = (ModuleDescriptor) bundles.next();
733             if (type.equals(aModule.getModuleType())) {
734         moduleSet.add(aModule);
735         }
736     }
737     return moduleSet.iterator();
738     }
739     
740     public void addDescriptor(Object JavaDoc descriptor) {
741         if (descriptor instanceof EjbBundleDescriptor) {
742             addEjbBundleDescriptor((EjbBundleDescriptor) descriptor);
743         }
744         if (descriptor instanceof WebBundleDescriptor) {
745             addWebBundleDescriptor((WebBundleDescriptor) descriptor);
746         }
747         if (descriptor instanceof ConnectorDescriptor) {
748             addRarDescriptor((ConnectorDescriptor) descriptor);
749         }
750     }
751     
752     /**
753     * The number of EJB JARs in this application.
754     *
755     * @return the number of EJB JARS
756     */

757     public int getEjbComponentCount() {
758     int count = 0;
759     for (Iterator JavaDoc itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
760         EjbBundleDescriptor ejbd = (EjbBundleDescriptor) itr.next();
761         count = count + ejbd.getEjbs().size();
762     }
763     return count;
764     }
765
766
767     public int getRarComponentCount() {
768         return this.getRarDescriptors().size();
769     }
770     
771
772     /**
773     * The Vector of EJB references in all subcomponents of this application.
774     *
775     * @return The Vector of EJB references
776     */

777     
778     
779     public Vector JavaDoc getEjbReferenceDescriptors() {
780     Vector JavaDoc ejbReferenceDescriptors = new Vector JavaDoc();
781     for (Iterator JavaDoc itr = this.getNamedDescriptors().iterator(); itr.hasNext();) {
782         Object JavaDoc next = itr.next();
783         if (next instanceof EjbReferenceDescriptor) {
784         ejbReferenceDescriptors.addElement(next);
785         }
786     }
787     return ejbReferenceDescriptors;
788     }
789
790
791    /**
792     * Obtain the EJB-JAR in this application of the given name.
793     * If the JAR is not
794     * present, throw an IllegalArgumentException.
795     *
796     * @return the EjbBundleDescriptor object with the given name
797     */

798     public EjbBundleDescriptor getEjbBundleByName(String JavaDoc name) {
799     for (Iterator JavaDoc itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
800         EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
801         if (ejbBundleDescriptor.getDisplayName().equals(name))
802         return ejbBundleDescriptor;
803     }
804     throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
805             "enterprise.deployment.exceptionapphasnoejbjarnamed",
806             "This application has no ejb jars of name {0}",
807             new Object JavaDoc []{name}));
808     }
809
810     /**
811      * Get the uri of a target based on a source module and a
812      * a relative uri from the perspective of that source module.
813      *
814      * @param origin bundle descriptor within this application
815      * @param relativeTargetUri relative uri from the given bundle descriptor
816      *
817      * @return target uri
818      */

819     public String JavaDoc getTargetUri(BundleDescriptor origin,
820                                String JavaDoc relativeTargetUri) {
821         String JavaDoc targetUri = null;
822
823         try {
824             String JavaDoc archiveUri = origin.getModuleDescriptor().getArchiveUri();
825             URI JavaDoc originUri = new URI JavaDoc(archiveUri);
826             URI JavaDoc resolvedUri = originUri.resolve(relativeTargetUri);
827             targetUri = resolvedUri.getPath();
828         } catch(URISyntaxException JavaDoc use) {
829             _logger.log(Level.FINE, "origin " + origin + " has invalid syntax",
830                         use);
831         }
832
833         return targetUri;
834     }
835
836     /**
837      * Get a target bundle descriptor based on an input bundle descriptor and
838      * a relative uri from the perspective of the input bundle descriptor.
839      *
840      * @param origin bundle descriptor within this application
841      * @param relativeTargetUri relative uri from the given bundle descriptor
842      * to another bundle within the application.
843      *
844      * @return target BundleDescriptor or null if not found.
845      */

846     public BundleDescriptor getRelativeBundle(BundleDescriptor origin,
847                                               String JavaDoc relativeTargetUri) {
848         String JavaDoc targetBundleUri = getTargetUri(origin, relativeTargetUri);
849                                               
850         BundleDescriptor targetBundle = null;
851
852         if( targetBundleUri != null ) {
853             Descriptor module = getModuleByUri(targetBundleUri);
854             targetBundle = (module instanceof BundleDescriptor) ?
855                 (BundleDescriptor) module : null;
856         }
857
858         return targetBundle;
859     }
860     
861     /**
862      * Return the relative uri between two modules, from the perspective
863      * of the first bundle.
864      *
865      * @return relative uri or empty string if the two bundles are the same
866      */

867     public String JavaDoc getRelativeUri(BundleDescriptor origin,
868                                  BundleDescriptor target) {
869
870         String JavaDoc originUri = origin.getModuleDescriptor().getArchiveUri();
871         String JavaDoc targetUri = target.getModuleDescriptor().getArchiveUri();
872
873         StringTokenizer JavaDoc tokenizer = new StringTokenizer JavaDoc(originUri, "/");
874         int numTokens = tokenizer.countTokens();
875         int numSeparators = (numTokens > 0) ? (numTokens - 1) : 0;
876
877         StringBuffer JavaDoc relativeUri = new StringBuffer JavaDoc();
878
879         // The simplest way to compute a relative uri is to add one "../"
880
// for each sub-path in the origin URI, then add the target URI.
881
// It's possible for the result to not be normalized if the origin
882
// and target have at least one common root, but that shouldn't
883
// matter as long as when the relative URI is resolved against the
884
// origin it produces the target.
885
for(int i = 0; i < numSeparators; i++) {
886             relativeUri.append("../");
887         }
888         
889         relativeUri.append(targetUri);
890
891         return relativeUri.toString();
892     }
893
894     /**
895      * Get EJB-JAR of the given URI (filename within EAR)
896      */

897     public EjbBundleDescriptor getEjbBundleByUri(String JavaDoc name) {
898         Descriptor desc = getModuleByTypeAndUri(ModuleType.EJB, name);
899         if (desc!=null && desc instanceof EjbBundleDescriptor) {
900             return (EjbBundleDescriptor) desc;
901         }
902     throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
903             "enterprise.deployment.exceptionapphasnoejbjarnamed",
904             "This application has no ejb jars of name {0}",
905             new Object JavaDoc []{name}));
906     }
907
908     /**
909      * Lookup module by uri.
910      *
911      * @param uri the module path in the application archive
912      *
913      * @return a bundle descriptor in this application identified by uri
914      * or null if not found.
915      *
916      */

917     public ModuleDescriptor getModuleDescriptorByUri(String JavaDoc uri) {
918         for (Iterator JavaDoc itr = getModules();itr.hasNext();) {
919             ModuleDescriptor aModule = (ModuleDescriptor) itr.next();
920             if (aModule.getArchiveUri().equals(uri)) {
921                 return aModule;
922             }
923         }
924         return null;
925     }
926     
927     /**
928      * Lookup module by uri.
929      *
930      * @param uri the module path in the application archive
931      *
932      * @return a bundle descriptor in this application identified by uri
933      * or null if not found.
934      *
935      */

936     public Descriptor getModuleByUri(String JavaDoc uri) {
937         ModuleDescriptor md = getModuleDescriptorByUri(uri);
938         if (md!=null) {
939             return md.getDescriptor();
940         }
941         return null;
942     }
943
944     /**
945      * @return a bundle descriptor in this application identified by
946      * its type and uri
947      *
948      * @param type the module type
949      * @param uri the module path in the application archive
950      */

951     public Descriptor getModuleByTypeAndUri(ModuleType JavaDoc type, String JavaDoc uri) {
952         for (Iterator JavaDoc itr = getModules();itr.hasNext();) {
953             ModuleDescriptor aModule = (ModuleDescriptor) itr.next();
954             if (aModule.getModuleType().equals(type)) {
955                 if (aModule.getArchiveUri().equals(uri)) {
956                     return aModule.getDescriptor();
957                 }
958             }
959         }
960         return null;
961     }
962     
963     /**
964     * Obtain the EJB in this application of the given display name. If the EJB is not
965     * present, throw an IllegalArgumentException.
966     *
967     * @param ejbName the name of the bean
968     * @return the EjbDescriptor object with the given display name
969     */

970     public EjbDescriptor getEjbByName(String JavaDoc ejbName) {
971     EjbDescriptor ejbDescriptor = null;
972     for (Iterator JavaDoc itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
973         EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
974         if (ejbBundleDescriptor.hasEjbByName(ejbName)) {
975         return ejbBundleDescriptor.getEjbByName(ejbName);
976         }
977     }
978     throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
979                         "enterprise.deployment.exceptionapphasnobeannamed",
980                         "This application has no beans of name {0}", new Object JavaDoc []{ejbName}));
981     }
982     
983     /**
984     * Return whether the application contains the given ejb by name..
985     *
986     * @param ejbName the name of the bean
987     * @return true if there is a bean matching the given name
988     */

989     public boolean hasEjbByName(String JavaDoc ejbName) {
990     EjbDescriptor ejbDescriptor = null;
991     for (Iterator JavaDoc itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
992         EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
993         if (ejbBundleDescriptor.hasEjbByName(ejbName)) {
994         return true;
995         }
996     }
997     return false;
998     }
999     
1000    /**
1001    * Obtain the application client in this application of the given display name. If the application client is not
1002    * present, throw an IllegalArgumentException.
1003    *
1004    * @return the ApplicationClientDescriptor object with the given display name
1005    */

1006    public ApplicationClientDescriptor getApplicationClientByName(String JavaDoc name) {
1007    for (Iterator JavaDoc itr = this.getApplicationClientDescriptors().iterator(); itr.hasNext();) {
1008        ApplicationClientDescriptor next = (ApplicationClientDescriptor) itr.next();
1009        if (next.getDisplayName().equals(name)) {
1010        return next;
1011        }
1012    }
1013    throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
1014                        "enterprise.deployment.exceptionapphasnoappclientname",
1015                        "This application has no application clients of name {0}", new Object JavaDoc []{name}));
1016    }
1017    
1018    /**
1019     * Obtain an application client descriptor in this application of the given URI. If the appclient is not
1020     * present, throw an IllegalArgumentException.
1021     *
1022     */

1023    public ApplicationClientDescriptor getApplicationClientByUri(String JavaDoc name) {
1024        Descriptor desc = getModuleByTypeAndUri(ModuleType.CAR, name);
1025        if (desc!=null && desc instanceof ApplicationClientDescriptor) {
1026            return (ApplicationClientDescriptor) desc;
1027        }
1028    throw new IllegalArgumentException JavaDoc(name);
1029    }
1030    
1031    /**
1032    * Obtain the WAR in this application of the given display name. If the WAR is not
1033    * present, throw an IllegalArgumentException.
1034    *
1035    * @return the WebBundleDescriptor object with the given display name
1036    */

1037    public WebBundleDescriptor getWebBundleDescriptorByName(String JavaDoc name) {
1038    for (Iterator JavaDoc itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();) {
1039        WebBundleDescriptor next = (WebBundleDescriptor) itr.next();
1040        if (next.getDisplayName().equals(name)) {
1041        return next;
1042        }
1043    }
1044    throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
1045                        "enterprise.deployment.exceptionapphasnowebappname",
1046                        "This application has no web app of name {0}", new Object JavaDoc []{name}));
1047    }
1048
1049    /**
1050     * Get WAR of a given URI (filename within EAR)
1051     */

1052    public WebBundleDescriptor getWebBundleDescriptorByUri(String JavaDoc name) {
1053        Descriptor desc = getModuleByTypeAndUri(ModuleType.WAR, name);
1054        if (desc!=null && desc instanceof WebBundleDescriptor) {
1055            return (WebBundleDescriptor) desc;
1056        }
1057    throw new IllegalArgumentException JavaDoc(localStrings.getLocalString(
1058                        "enterprise.deployment.exceptionapphasnowebappname",
1059                        "This application has no web app of name {0}", new Object JavaDoc []{name}));
1060    }
1061
1062    
1063    /**
1064     * Obtain the RAR in this application of the given URI. If the RAR is not
1065     * present, throw an IllegalArgumentException.
1066     *
1067     */

1068    public ConnectorDescriptor getRarDescriptorByUri(String JavaDoc name) {
1069        Descriptor desc = getModuleByTypeAndUri(ModuleType.RAR, name);
1070        if (desc!=null && desc instanceof ConnectorDescriptor) {
1071            return (ConnectorDescriptor) desc;
1072        }
1073    throw new IllegalArgumentException JavaDoc(name);
1074    }
1075
1076
1077    /**
1078    * Obtain the full set of all the subcomponents of this application that use
1079    * a JNDI name environment..
1080    *
1081    * @return the Set of JndiNameEnvironment objects.
1082    */

1083    public Set JavaDoc getJndiNameEnvironments() {
1084    Set JavaDoc jndiNameEnvironments = new HashSet JavaDoc();
1085    jndiNameEnvironments.addAll(this.getWebBundleDescriptors());
1086    jndiNameEnvironments.addAll(this.getApplicationClientDescriptors());
1087    jndiNameEnvironments.addAll(this.getEjbDescriptors());
1088    return jndiNameEnvironments;
1089    }
1090    
1091    /**
1092     * Obtain the set of all service reference descriptors for
1093     * components in this application.
1094     */

1095    public Set JavaDoc getServiceReferenceDescriptors() {
1096        Set JavaDoc serviceRefs = new HashSet JavaDoc();
1097        Set JavaDoc jndiNameEnvironments = this.getJndiNameEnvironments();
1098        for(Iterator JavaDoc iter = jndiNameEnvironments.iterator(); iter.hasNext();) {
1099            JndiNameEnvironment next = (JndiNameEnvironment) iter.next();
1100            serviceRefs.addAll(next.getServiceReferenceDescriptors());
1101        }
1102        return serviceRefs;
1103    }
1104
1105    /**
1106     * Return a set of all com.sun.enterprise.deployment.WebService
1107     * descriptors in the application.
1108     */

1109    public Set JavaDoc getWebServiceDescriptors() {
1110        Set JavaDoc webServiceDescriptors = new HashSet JavaDoc();
1111        Set JavaDoc bundles = new HashSet JavaDoc();
1112        bundles.addAll(getEjbBundleDescriptors());
1113        bundles.addAll(getWebBundleDescriptors());
1114        for(Iterator JavaDoc iter = bundles.iterator(); iter.hasNext();) {
1115            BundleDescriptor next = (BundleDescriptor) iter.next();
1116            WebServicesDescriptor webServicesDesc =
1117                next.getWebServices();
1118            webServiceDescriptors.addAll(webServicesDesc.getWebServices());
1119        }
1120        return webServiceDescriptors;
1121    }
1122
1123    /**
1124    * Obtain the full set of all the WARs in this application.
1125    *
1126    * @return the Set of WebBundleDescriptor objects.
1127    */

1128    public Set JavaDoc getWebBundleDescriptors() {
1129        return getBundleDescriptors(ModuleType.WAR);
1130    }
1131    
1132    /**
1133     * if this application object is virtual, return the standalone
1134     * bundle descriptor it is wrapping otherwise return null
1135     *
1136     * @return the wrapped standalone bundle descriptor
1137     */

1138     public BundleDescriptor getStandaloneBundleDescriptor() {
1139     if (isVirtual()) {
1140         Iterator JavaDoc modules = getModules();
1141         if (modules.hasNext()) {
1142         ModuleDescriptor module = (ModuleDescriptor) modules.next();
1143         if (modules.hasNext()) {
1144             // this is an error, the application is virtual,
1145
// which mean a wrapper for a standalone module and
1146
// it seems I have more than one module in my list...
1147
throw new IllegalStateException JavaDoc("Virtual application contains more than one module");
1148         }
1149         return module.getDescriptor();
1150         }
1151         return null;
1152     } else {
1153         return null;
1154     }
1155     }
1156             
1157    
1158    /**
1159     * Obtain a full set of bundle descriptors for a particular type
1160     *
1161     * @param type the bundle descriptor type requested
1162     * @return the set of bundle descriptors
1163     */

1164    public Set JavaDoc getBundleDescriptors(ModuleType JavaDoc type) {
1165        if (type==null) {
1166            return null;
1167        }
1168        Set JavaDoc bundleSet = new HashSet JavaDoc();
1169        for (Iterator JavaDoc bundles = getModules();bundles.hasNext();) {
1170            ModuleDescriptor aModule = (ModuleDescriptor) bundles.next();
1171            if (type.equals(aModule.getModuleType())) {
1172                if (aModule.getDescriptor()!=null) {
1173                    bundleSet.add(aModule.getDescriptor());
1174                } else {
1175                    DOLUtils.getDefaultLogger().fine("Null descriptor for module " + aModule.getArchiveUri());
1176                }
1177            }
1178        }
1179        return bundleSet;
1180    }
1181        
1182    /**
1183     * Obtain a set of all bundle descriptors, regardless of type
1184     *
1185     * @return the set of bundle descriptors
1186     */

1187    public Set JavaDoc getBundleDescriptors() {
1188        Set JavaDoc bundleSet = new HashSet JavaDoc();
1189        for (Iterator JavaDoc bundles = getModules();bundles.hasNext();) {
1190            ModuleDescriptor aModule = (ModuleDescriptor) bundles.next();
1191                if (aModule.getDescriptor()!=null) {
1192                    bundleSet.add(aModule.getDescriptor());
1193                } else {
1194                    DOLUtils.getDefaultLogger().fine("Null descriptor for module " + aModule.getArchiveUri());
1195                }
1196        }
1197        return bundleSet;
1198    }
1199    
1200    /**
1201    * Add a web bundle descriptor to this application.
1202    *
1203    * @param webBundleDescriptor the web bundle descriptor to add
1204    */

1205    public void addWebBundleDescriptor(WebBundleDescriptor webBundleDescriptor) {
1206        addBundleDescriptor(webBundleDescriptor);
1207    }
1208    
1209    private void addBundleDescriptor(BundleDescriptor bundleDescriptor) {
1210        ModuleDescriptor newModule = bundleDescriptor.getModuleDescriptor();
1211        addModule(newModule);
1212    }
1213    
1214    /**
1215    * Remove a web bundle descriptor from this application.
1216    *
1217    * @param webBundleDescriptor the web bundle descriptor to remove
1218    */

1219    public void removeWebBundleDescriptor(WebBundleDescriptor webBundleDescriptor) {
1220    webBundleDescriptor.removeNotificationListener(this);
1221    webBundleDescriptor.setApplication(null);
1222    this.getWebBundleDescriptors().remove(webBundleDescriptor);
1223    this.changed(true);
1224    }
1225    
1226 /**
1227    * Obtain the full set of all the RARs in this application.
1228    *
1229    * @return the Set of RarDescriptor objects.
1230    */

1231    public Set JavaDoc getRarDescriptors() {
1232        return getBundleDescriptors(ModuleType.RAR);
1233    }
1234    
1235    /**
1236    * Add a RAR descriptor to this application.
1237    *
1238    * @param RarDescriptor the Rar descriptor to add
1239    */

1240    public void addRarDescriptor(ConnectorDescriptor rarDescriptor) {
1241        addBundleDescriptor(rarDescriptor);
1242    }
1243    
1244    /**
1245    * Remove a rar descriptor from this application.
1246    *
1247    * @param rarDescriptor the rar descriptor to remove
1248    */

1249    public void removeRarDescriptor(ConnectorDescriptor rarDescriptor) {
1250        rarDescriptor.removeNotificationListener(this);
1251    rarDescriptor.setApplication(null);
1252    this.getRarDescriptors().remove(rarDescriptor);
1253    this.changed(true);
1254    }
1255    
1256
1257
1258    /**
1259    * Obtain the full set of all the Ejb JAR deployment information in this application.
1260    *
1261    * @return the Set of EjbBundleDescriptor objects.
1262    */

1263    public Set JavaDoc getEjbBundleDescriptors() {
1264        return getBundleDescriptors(ModuleType.EJB);
1265    }
1266    
1267    /** Adds a new Enterprise bean to me.
1268    */

1269    public void addEjbBundleDescriptor(EjbBundleDescriptor ejbBundleDescriptor) {
1270        addBundleDescriptor(ejbBundleDescriptor);
1271    }
1272    
1273    /**
1274    * Remove the deployment information about an Enterprise Bean.*/

1275    public void removeEjbBundleDescriptor(EjbBundleDescriptor ejbBundleDescriptor) {
1276    this.getEjbBundleDescriptors().remove(ejbBundleDescriptor);
1277    ejbBundleDescriptor.removeNotificationListener(this);
1278    ejbBundleDescriptor.setApplication(null);
1279    this.changed(true);
1280    }
1281    
1282    /** Return the Set of app client deploymenbt objects.*/
1283    public Set JavaDoc getApplicationClientDescriptors() {
1284        return getBundleDescriptors(ModuleType.CAR);
1285    }
1286    
1287    /** Add deplyoment information about an application client.*/
1288    public void addApplicationClientDescriptor(ApplicationClientDescriptor applicationClientDescriptor) {
1289        addBundleDescriptor(applicationClientDescriptor);
1290    }
1291    
1292    /** Remove deplyoment information about an application client.*/
1293    public void removeApplicationClientDescriptor(ApplicationClientDescriptor applicationClientDescriptor) {
1294    this.getApplicationClientDescriptors().remove(applicationClientDescriptor);
1295    applicationClientDescriptor.removeNotificationListener(this);
1296    applicationClientDescriptor.setApplication(null);
1297    this.changed(true);
1298    }
1299
1300    /**
1301     * Return the EjbCMPEntityDescriptor for a bean
1302     * for the given classname.
1303     * It is assumed that there is a 1-to-1 mapping
1304     * from class to descriptor.
1305     * This is called at runtime from the Persistence Manager.
1306     */

1307    public EjbCMPEntityDescriptor getCMPDescriptorFor(String JavaDoc className)
1308    {
1309    if ( cmpDescriptors == null ) {
1310        cmpDescriptors = new Hashtable JavaDoc();
1311        Iterator JavaDoc ejbBundles = getEjbBundleDescriptors().iterator();
1312        while ( ejbBundles.hasNext() ) {
1313        EjbBundleDescriptor bundle = (EjbBundleDescriptor)ejbBundles.next();
1314        Iterator JavaDoc ejbs = bundle.getEjbs().iterator();
1315        while ( ejbs.hasNext() ) {
1316            EjbDescriptor ejb = (EjbDescriptor)ejbs.next();
1317            if ( ejb instanceof EjbCMPEntityDescriptor )
1318            cmpDescriptors.put(ejb.getEjbImplClassName(), ejb);
1319        }
1320        }
1321    }
1322        return (EjbCMPEntityDescriptor)cmpDescriptors.get(className);
1323    }
1324
1325
1326
1327    
1328    /**
1329    * Return all the Named reference pairs I have. This is a Vector of NamedReferenceDescriptors - essentially a mapping of
1330    * components to the Named Objects they reference. E.g.:
1331    ** ejb -> ejb
1332    ** ejb - resource reference
1333    ** ejb - ejb ref
1334    ** ejb1 - ejb ref
1335    */

1336    public Vector JavaDoc getNamedReferencePairs() {
1337    Vector JavaDoc pairs = new Vector JavaDoc();
1338    for (Iterator JavaDoc itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
1339        EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
1340        pairs.addAll(ejbBundleDescriptor.getNamedReferencePairs());
1341    }
1342    for (Iterator JavaDoc itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();) {
1343        WebBundleDescriptor webBundleDescriptor = (WebBundleDescriptor) itr.next();
1344        pairs.addAll(webBundleDescriptor.getNamedReferencePairs());
1345    }
1346    for (Iterator JavaDoc itr = this.getApplicationClientDescriptors().iterator(); itr.hasNext();) {
1347        ApplicationClientDescriptor applicationClientDescriptor = (ApplicationClientDescriptor) itr.next();
1348        pairs.addAll(applicationClientDescriptor.getNamedReferencePairs());
1349    }
1350    return pairs;
1351    }
1352    
1353    /**
1354     * return the set of descriptors with jndi names.
1355     */

1356    public Collection JavaDoc getNamedDescriptors() {
1357    Collection JavaDoc namedDescriptors = new Vector JavaDoc();
1358    for (Iterator JavaDoc itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
1359        EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
1360        namedDescriptors.addAll(ejbBundleDescriptor.getNamedDescriptors());
1361    }
1362    for (Iterator JavaDoc itr = this.getWebBundleDescriptors().iterator(); itr.hasNext();) {
1363        WebBundleDescriptor webBundleDescriptor = (WebBundleDescriptor) itr.next();
1364        namedDescriptors.addAll(webBundleDescriptor.getNamedDescriptors());
1365    }
1366    for (Iterator JavaDoc itr = this.getApplicationClientDescriptors().iterator(); itr.hasNext();) {
1367        ApplicationClientDescriptor applicationClientDescriptor = (ApplicationClientDescriptor) itr.next();
1368        namedDescriptors.addAll(applicationClientDescriptor.getNamedDescriptors());
1369    }
1370    return namedDescriptors;
1371    
1372    }
1373    
1374    /** Return the Vector of ejb deployment objects.*/
1375    public Vector JavaDoc getEjbDescriptors() {
1376    Vector JavaDoc ejbDescriptors = new Vector JavaDoc();
1377    for (Iterator JavaDoc itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
1378        EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
1379        ejbDescriptors.addAll(ejbBundleDescriptor.getEjbs());
1380    }
1381        
1382    return ejbDescriptors;
1383    }
1384    
1385    /**
1386     * @return true if this bundle descriptor contains at least one CMP
1387     * EntityBean
1388     */

1389    public boolean containsCMPEntity() {
1390    for (Iterator JavaDoc itr = this.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
1391            if (((EjbBundleDescriptor) itr.next()).containsCMPEntity())
1392                return true;
1393        }
1394        return false;
1395    }
1396
1397
1398    // START OF IASRI 4718761 - pass-by-ref need to compare DD from previous
1399
// deployment when reusing the old bits
1400

1401    /**
1402     * Returns all the ejb descriptor in this application in ordered form.
1403     * The comparison is done based on the descriptor's name.
1404     *
1405     * @return all ejb descriptors in ordered form
1406     */

1407    public EjbDescriptor[] getSortedEjbDescriptors()
1408    {
1409        Vector JavaDoc ejbDesc = getEjbDescriptors();
1410        EjbDescriptor[] descs = (EjbDescriptor[])ejbDesc.toArray(
1411                                    new EjbDescriptor[ejbDesc.size()]);
1412
1413        // The sorting algorithm used by this api is a modified mergesort.
1414
// This algorithm offers guaranteed n*log(n) performance, and
1415
// can approach linear performance on nearly sorted lists.
1416

1417        // since ejb name is only unique within a module, add the module uri
1418
// as the additional piece of information for comparison
1419
Arrays.sort(descs,
1420            new Comparator JavaDoc() {
1421                public int compare(Object JavaDoc o1, Object JavaDoc o2) {
1422                    EjbDescriptor desc1 = (EjbDescriptor)o1;
1423                    EjbDescriptor desc2 = (EjbDescriptor)o2;
1424                    String JavaDoc moduleUri1 = desc1.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri();
1425                    String JavaDoc moduleUri2 = desc2.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri();
1426                    return (moduleUri1 + desc1.getName()).compareTo(
1427                            moduleUri2 + desc2.getName());
1428                }
1429            }
1430        );
1431
1432        return descs;
1433    }
1434
1435    // END OF IASRI 4718761
1436

1437    // START OF IASRI 4645310
1438
/**
1439     * Sets the virtual status of this application.
1440     * If this application object represents a stand alone module,
1441     * virtaul status should be true; else false.
1442     *
1443     * @param virtual new value of this application's virtaul status
1444     */

1445    public void setVirtual(boolean virtual)
1446    {
1447        this.virtual = virtual;
1448    }
1449
1450    /**
1451     * Returns the virtual status of this application.
1452     *
1453     * @return true if this application obj represents a stand alone module
1454     */

1455    public boolean isVirtual()
1456    {
1457        return this.virtual;
1458    }
1459
1460    /**
1461     * Sets the unique id for this application. It traverses through all
1462     * the ejbs in the application and sets the unique id for each of them.
1463     * The traversal is done in ascending element order.
1464     *
1465     * @param id unique id for this application
1466     */

1467    public void setUniqueId(long id)
1468    {
1469        _logger.log(Level.FINE,"[Application]uid: " + id);
1470        this.uniqueId = id;
1471
1472        EjbDescriptor[] descs = getSortedEjbDescriptors();
1473
1474        for (int i=0; i<descs.length; i++)
1475        {
1476            // 2^16 beans max per stand alone module
1477
descs[i].setUniqueId( (id | i) );
1478            if(_logger.isLoggable(Level.FINE)){
1479            _logger.log(Level.FINE,"[Application]desc name: " + descs[i].getName());
1480            _logger.log(Level.FINE,"[Application]desc id: "+descs[i].getUniqueId());
1481          }
1482        }
1483    }
1484 
1485    /**
1486     * Returns the unique id used for this application.
1487     *
1488     * @return unique id used for this application
1489     */

1490    public long getUniqueId()
1491    {
1492        return this.uniqueId;
1493    }
1494    // END OF IASRI 4645310
1495

1496   // START IASRI 4662001, 4720955
1497
/**
1498     * Sets the pass-by-reference property for this application.
1499     * EJB spec requires pass-by-value (false) which is the default.
1500     * This can be set to true for non-compliant operation and possibly
1501     * higher performance. For a stand-alone server, this can be used.
1502     * By setting pass-by-reference in sun-application.xml, it can apply to
1503     * all the enclosed ejb modules.
1504     *
1505     * @param boolean true or false - pass-by-reference property of application.
1506     * true - application is pass-by-reference
1507     * false - application is pass-by-value
1508     */

1509    public void setPassByReference(boolean passByReference)
1510    {
1511       this.passByReference = Boolean.valueOf(passByReference);
1512    }
1513    
1514    /**
1515     * Gets the value of pass-by-reference property for this application
1516     * Checks to see if the pass-by-reference property is defined. If
1517     * this application's pass-by-reference property is defined, this method
1518     * returns the value of the application's pass-by-reference property.
1519     * Otherwise, if the application's pass-by-reference property is undefined,
1520     * this method returns a default value of false.
1521     *
1522     * @return boolean pass-by-reference property for this application
1523     */

1524    public boolean getPassByReference()
1525    {
1526        boolean passByReference = false;
1527        
1528        if (this.isPassByReferenceDefined()) {
1529            passByReference = this.passByReference.booleanValue();
1530        }
1531        return passByReference;
1532    }
1533    // END OF IASRI 4662001, 4720955
1534

1535    // START OF IASRI 4720955
1536
/* *
1537     * Determines if the application's pass-by-reference property has been
1538     * defined or undefined in sun-application.xml
1539     *
1540     * @return true - pass-by-reference is defined in sun-application.xml
1541     * false - pass-by-reference is undefined in sun-application.xml
1542     */

1543    public boolean isPassByReferenceDefined()
1544    {
1545        boolean passByReferenceDefined = false;
1546        if (this.passByReference != null) {
1547            passByReferenceDefined = true;
1548        }
1549        return passByReferenceDefined;
1550    }
1551    // END OF IASRI 4720955
1552

1553    /**
1554     * Add all the deployment information about the given application to me.
1555     */

1556    public void addApplication(Application application) {
1557       for (Iterator JavaDoc itr = application.getEjbBundleDescriptors().iterator(); itr.hasNext();) {
1558        EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) itr.next();
1559        this.addEjbBundleDescriptor(ejbBundleDescriptor);
1560    }
1561     for (Iterator JavaDoc itr = application.getWebBundleDescriptors().iterator(); itr.hasNext();) {
1562        WebBundleDescriptor webBundleDescriptor = (WebBundleDescriptor) itr.next();
1563        this.addWebBundleDescriptor(webBundleDescriptor);
1564    }
1565    for (Iterator JavaDoc itr = application.getApplicationClientDescriptors().iterator(); itr.hasNext();) {
1566        ApplicationClientDescriptor acd = (ApplicationClientDescriptor) itr.next();
1567        this.addApplicationClientDescriptor(acd);
1568    }
1569        for (Iterator JavaDoc itr = application.getRarDescriptors().iterator(); itr.hasNext();) {
1570        ConnectorDescriptor rarDescriptor = (ConnectorDescriptor) itr.next();
1571        this.addRarDescriptor(rarDescriptor);
1572    }
1573    }
1574    
1575    /**
1576     * Return all my subcomponents that have a file format (EJB, WAR and
1577     * AppCLient JAR).
1578     */

1579    public Set JavaDoc getArchivableDescriptors() {
1580    Set JavaDoc archivableDescriptors = new HashSet JavaDoc();
1581    archivableDescriptors.addAll(this.getEjbBundleDescriptors());
1582    archivableDescriptors.addAll(this.getWebBundleDescriptors());
1583    archivableDescriptors.addAll(this.getApplicationClientDescriptors());
1584    archivableDescriptors.addAll(this.getRarDescriptors());
1585    return archivableDescriptors;
1586    }
1587    
1588    /**
1589     * Sets the mapping of rolename to users and groups on a particular server.
1590     */

1591    public void setRoleMapper(SecurityRoleMapper roleMapper) {
1592    // should verify against the roles
1593
this.roleMapper = roleMapper;
1594    this.changed(true);
1595    }
1596    
1597    /**
1598     * Return true if I have information to do with deployment on a
1599     * particular operational environment.
1600     */

1601    public boolean hasRuntimeInformation() {
1602    return true;
1603    }
1604    
1605    /**
1606     * Return my mapping of rolename to users and groups on a particular
1607     * server.
1608     */

1609    public SecurityRoleMapper getRoleMapper() {
1610    if (this.roleMapper == null) {
1611            SecurityRoleMapperFactory factory = SecurityRoleMapperFactoryMgr.getFactory();
1612            if (factory==null) {
1613                _logger.log(Level.FINE, "SecurityRoleMapperFactory NOT set.");
1614            } else {
1615            this.roleMapper = factory.getRoleMapper(this.getName());
1616            }
1617    }
1618    return this.roleMapper;
1619    }
1620    
1621    /**
1622     * Sets the realm for this application
1623     */

1624    public void setRealm(String JavaDoc realm) {
1625        this.realm=realm;
1626    }
1627    
1628    /**
1629     * @return the realm for this application
1630     */

1631    public String JavaDoc getRealm() {
1632        return realm;
1633    }
1634    
1635    /**
1636     * A flag to indicate that my data has changed since the last save.
1637     */

1638    public boolean isDirty() {
1639    return this.isDirty;
1640    }
1641    
1642    /** I listen to my subcomponents for state changes.. */
1643    public void notification(NotificationEvent ne) {
1644    // so one of my descriptors is telling me it changed....
1645
// I actually pretend that its me that changed...
1646

1647    this.changed(true);
1648    }
1649    
1650    /**
1651     * @return the class loader associated with this application
1652     */

1653    public ClassLoader JavaDoc getClassLoader() {
1654        if (classLoader==null) {
1655            throw new RuntimeException JavaDoc("No class loader associated with application " + getName());
1656        }
1657        return classLoader;
1658    }
1659        
1660    /**
1661     * Called when my data changes and causes notification.
1662     */

1663    public void changed() {
1664    NotificationEvent ne = new NotificationEvent(this, DESCRIPTOR_CHANGED, this);
1665     
1666    Vector JavaDoc listenersClone = null;
1667    synchronized (listeners) {
1668        listenersClone = (Vector JavaDoc) listeners.clone();
1669    }
1670    for (Enumeration JavaDoc e = listenersClone.elements(); e.hasMoreElements();) {
1671        NotificationListener nl = (NotificationListener) e.nextElement();
1672        nl.notification(ne);
1673    }
1674    }
1675    
1676    /**
1677    * A formatted String representing my state.
1678    */

1679    public void print(StringBuffer JavaDoc toStringBuffer) {
1680        toStringBuffer.append("Application");
1681    toStringBuffer.append("\n");
1682        super.print(toStringBuffer);
1683    toStringBuffer.append("\n smallIcon ").append(super.getSmallIconUri());
1684        for (Iterator JavaDoc itr = getModules();itr.hasNext();) {
1685            toStringBuffer.append("\n Module : ");
1686            ((Descriptor)itr.next()).print(toStringBuffer);
1687        }
1688    toStringBuffer.append("\n EjbBundles: \n");
1689        if(this.getEjbBundleDescriptors() != null)
1690            printDescriptorSet(this.getEjbBundleDescriptors(),toStringBuffer);
1691    toStringBuffer.append("\n WebBundleDescriptors ");
1692        if(this.getWebBundleDescriptors() != null)
1693            printDescriptorSet(this.getWebBundleDescriptors(),toStringBuffer);
1694    toStringBuffer.append("\n applicationClientDescriptors ");
1695        if(this.getApplicationClientDescriptors() != null)
1696            printDescriptorSet(this.getApplicationClientDescriptors(),toStringBuffer);
1697    toStringBuffer.append("\n roles ").append(getRoles());
1698    toStringBuffer.append("\n RoleMapper ").append(this.getRoleMapper());
1699        toStringBuffer.append("\n Realm ").append(realm);
1700    }
1701    private void printDescriptorSet(Set JavaDoc descSet, StringBuffer JavaDoc sbuf){
1702        for(Iterator JavaDoc itr = descSet.iterator(); itr.hasNext();){
1703            Object JavaDoc obj = itr.next();
1704            if(obj instanceof Descriptor)
1705                ((Descriptor)obj).print(sbuf);
1706            else
1707                sbuf.append(obj);
1708        }
1709    }
1710    /**
1711     * visit the descriptor and all sub descriptors with a DOL visitor implementation
1712     *
1713     * @param a visitor to traverse the descriptors
1714     */

1715    public void visit(DescriptorVisitor aVisitor) {
1716        if (aVisitor instanceof ApplicationVisitor) {
1717            visit((ApplicationVisitor) aVisitor);
1718        } else {
1719            super.visit(aVisitor);
1720        }
1721    }
1722    
1723    /**
1724     * visit the descriptor and all sub descriptors with a DOL visitor implementation
1725     *
1726     * @param a visitor to traverse the descriptors
1727     */

1728    public void visit(ApplicationVisitor aVisitor) {
1729        aVisitor.accept(this);
1730        EjbBundleVisitor ejbBundleVisitor = aVisitor.getEjbBundleVisitor();
1731        if (ejbBundleVisitor != null) {
1732            for (Iterator JavaDoc ejbBundles = getEjbBundleDescriptors().iterator();ejbBundles.hasNext();) {
1733                EjbBundleDescriptor anEjbBundle = (EjbBundleDescriptor) ejbBundles.next();
1734                anEjbBundle.visit(ejbBundleVisitor);
1735            }
1736        }
1737        WebBundleVisitor webVisitor = aVisitor.getWebBundleVisitor();
1738        if (webVisitor != null) {
1739            for (Iterator JavaDoc webBundles = getWebBundleDescriptors().iterator();webBundles.hasNext();) {
1740                WebBundleDescriptor aWebBundle = (WebBundleDescriptor) webBundles.next();
1741                // This might be null in the case of an appclient
1742
// processing a client stubs .jar whose original .ear contained
1743
// a .war. This will be fixed correctly in the deployment
1744
// stage but until then adding a non-null check will prevent
1745
// the validation step from bombing.
1746
if( aWebBundle != null ) {
1747                    aWebBundle.visit(webVisitor);
1748                }
1749            }
1750        }
1751    ConnectorVisitor connectorVisitor = aVisitor.getConnectorVisitor();
1752        if (connectorVisitor != null) {
1753            for (Iterator JavaDoc connectors = getRarDescriptors().iterator();connectors.hasNext();) {
1754                ConnectorDescriptor aConnector = (ConnectorDescriptor) connectors.next();
1755                aConnector.visit(connectorVisitor);
1756            }
1757        }
1758
1759    AppClientVisitor appclientVisitor = aVisitor.getAppClientVisitor();
1760        if (appclientVisitor != null) {
1761            for (Iterator JavaDoc appclients = getApplicationClientDescriptors().iterator();appclients.hasNext();) {
1762                ApplicationClientDescriptor appclient = (ApplicationClientDescriptor) appclients.next();
1763                appclient.visit(appclientVisitor);
1764            }
1765        }
1766    }
1767    
1768    void doneSaving() {
1769    this.isDirty = false;
1770    this.changed(false);
1771    }
1772    
1773    /** Called when I have just been opened
1774    */

1775    public void doneOpening() {
1776    this.isDirty = false;
1777    this.changed(false);
1778    }
1779
1780    private void setDirty(boolean dirty) {
1781        this.isDirty = dirty;
1782    }
1783
1784    /**
1785     * @return the module ID for this module descriptor
1786     */

1787    public String JavaDoc getModuleID() {
1788        return moduleID;
1789    }
1790    
1791    /**
1792     * @return true if this module is an application object
1793     */

1794    public boolean isApplication() {
1795        return true;
1796    }
1797    
1798    /** Calls changed() and sets the dirty flag.
1799    */

1800    
1801    public void changed(boolean dirtyChange) {
1802    if (dirtyChange) {
1803        this.isDirty = true;
1804    }
1805    super.changed();
1806    }
1807    
1808    /**
1809     * @return the module type for this bundle descriptor
1810     */

1811    public ModuleType JavaDoc getModuleType() {
1812        return ModuleType.EAR;
1813    }
1814    
1815    public void addSecurityRoleMapping(SecurityRoleMapping roleMapping) {
1816        roleMaps.add(roleMapping);
1817    }
1818
1819    public List JavaDoc<SecurityRoleMapping> getSecurityRoleMappings() {
1820        return roleMaps;
1821    }
1822
1823    /**
1824     * This method records how this Application object is constructed. We
1825     * keep this information to avoid additional disk access in
1826     * DescriptorArchivist.write() when deciding if the application.xml
1827     * should be copied or written to the generated/xml directory.
1828     */

1829    public void setLoadedFromApplicationXml(boolean bool) {
1830        loadedFromApplicationXml = bool;
1831    }
1832
1833    /**
1834     * @return true if this Application is from reading application.xml from
1835     * disk; false if this Application object is derived from the content
1836     * of the ear file.
1837     */

1838    public boolean isLoadedFromApplicationXml() {
1839        return loadedFromApplicationXml;
1840    }
1841
1842    // getter and setter of in-memory object of sun-configuration.xml
1843
public void setResourceList(List JavaDoc rList) {
1844        resourceList = rList;
1845    }
1846
1847    public List JavaDoc getResourceList() {
1848        return resourceList;
1849    }
1850
1851    private static String JavaDoc deriveArchiveUri(
1852            String JavaDoc appRoot, File JavaDoc subModule, boolean deploydir) {
1853
1854        //if deploydir, revert the name of the directory to
1855
//the format of foo/bar/voodoo.ext (where ext is war/rar/jar)
1856
if (deploydir) {
1857            return FileUtils.revertFriendlyFilename(subModule.getName());
1858        }
1859
1860        //if archive deploy, need to make sure all of the directory
1861
//structure is correctly included
1862
String JavaDoc uri = subModule.getAbsolutePath().substring(appRoot.length()+1);
1863        return uri.replace(File.separatorChar, '/');
1864    }
1865
1866    private static File JavaDoc[] getEligibleEntries(File JavaDoc appRoot, boolean deploydir) {
1867
1868        //For deploydir, all modules are exploded at the top of application root
1869
if (deploydir) {
1870            return appRoot.listFiles(new DirectoryIntrospectionFilter());
1871        }
1872
1873        //For archive deploy, recursively search the entire package
1874
Vector JavaDoc files = new Vector JavaDoc();
1875        getListOfFiles(appRoot, files,
1876                new ArchiveIntrospectionFilter(appRoot.getAbsolutePath()));
1877        return (File JavaDoc[]) files.toArray(new File JavaDoc[files.size()]);
1878    }
1879
1880    private static void getListOfFiles(
1881        File JavaDoc directory, Vector JavaDoc files, FilenameFilter JavaDoc filter) {
1882
1883        File JavaDoc[] list = directory.listFiles(filter);
1884        for (int i=0;i<list.length;i++) {
1885            if (!list[i].isDirectory()) {
1886                files.add(list[i]);
1887            } else {
1888                getListOfFiles(list[i], files, filter);
1889            }
1890        }
1891    }
1892
1893    private static class ArchiveIntrospectionFilter implements FilenameFilter JavaDoc {
1894        private String JavaDoc libDir;
1895        ArchiveIntrospectionFilter(String JavaDoc root) {
1896            libDir = root + File.separator + "lib" + File.separator;
1897        }
1898
1899        public boolean accept(File JavaDoc dir, String JavaDoc name) {
1900
1901            File JavaDoc currentFile = new File JavaDoc(dir, name);
1902            if (currentFile.isDirectory()) {
1903                return true;
1904            }
1905
1906            //For ".war" and ".rar", check all files in the archive
1907
if (name.endsWith(".war") || name.endsWith(".rar")) {
1908                return true;
1909            }
1910
1911            String JavaDoc path = currentFile.getAbsolutePath();
1912            if (!path.startsWith(libDir) && path.endsWith(".jar")) {
1913                return true;
1914            }
1915
1916            return false;
1917        }
1918    }
1919
1920    private static class DirectoryIntrospectionFilter implements FilenameFilter JavaDoc {
1921
1922        DirectoryIntrospectionFilter() { }
1923
1924        public boolean accept(File JavaDoc dir, String JavaDoc name) {
1925
1926            File JavaDoc currentFile = new File JavaDoc(dir, name);
1927            if (!currentFile.isDirectory()) {
1928                return false;
1929            }
1930
1931            if (name.endsWith("_war")
1932                    || name.endsWith("_rar")
1933                    || name.endsWith("_jar")) {
1934                return true;
1935            }
1936
1937            return false;
1938        }
1939    }
1940}
1941
Popular Tags