KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > ejb > packaging > ExplodedJarVisitor


1 //$Id: ExplodedJarVisitor.java,v 1.4 2005/08/04 00:46:04 epbernard Exp $
2
package org.hibernate.ejb.packaging;
3
4 import java.io.File JavaDoc;
5 import java.net.URL JavaDoc;
6
7 /**
8  * @author Emmanuel Bernard
9  */

10 public class ExplodedJarVisitor extends JarVisitor {
11
12     public ExplodedJarVisitor(String JavaDoc jarFileName, boolean detectClasses, boolean detectHbm) {
13         super( jarFileName, detectClasses, detectHbm );
14     }
15
16     public ExplodedJarVisitor(URL JavaDoc url, boolean detectClasses, boolean detectHbm) {
17         this.detectClasses = detectClasses;
18         this.detectHbm = detectHbm;
19         String JavaDoc file = url.getFile();
20         jarFileName = file.substring( 0, file.length() - "/META-INF/persistence.xml".length() );
21         unqualify();
22     }
23
24     protected void doProcessElements() {
25         File JavaDoc jarFile;
26         jarFile = new File JavaDoc( jarFileName );
27         if ( !jarFile.isDirectory() ) {
28             log.warn( "Exploded jar file not a directory (ignored): " + jarFileName );
29             return;
30         }
31         getClassNamesInTree( jarFile, null );
32     }
33
34     private void getClassNamesInTree(File JavaDoc jarFile, String JavaDoc header) {
35         File JavaDoc[] files = jarFile.listFiles();
36         header = header == null ? "" : header + "/";
37         for ( File JavaDoc localFile : files ) {
38             if ( !localFile.isDirectory() ) {
39                 String JavaDoc entryName = localFile.getName();
40                 addElement( header + entryName );
41             }
42             else {
43                 getClassNamesInTree( localFile, header + localFile.getName() );
44             }
45         }
46     }
47 }
48
Popular Tags