1 package org.hibernate.ejb.packaging; 3 4 import java.io.File ; 5 import java.net.URL ; 6 7 10 public class ExplodedJarVisitor extends JarVisitor { 11 12 public ExplodedJarVisitor(String jarFileName, boolean detectClasses, boolean detectHbm) { 13 super( jarFileName, detectClasses, detectHbm ); 14 } 15 16 public ExplodedJarVisitor(URL url, boolean detectClasses, boolean detectHbm) { 17 this.detectClasses = detectClasses; 18 this.detectHbm = detectHbm; 19 String 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 jarFile; 26 jarFile = new File ( 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 jarFile, String header) { 35 File [] files = jarFile.listFiles(); 36 header = header == null ? "" : header + "/"; 37 for ( File localFile : files ) { 38 if ( !localFile.isDirectory() ) { 39 String entryName = localFile.getName(); 40 addElement( header + entryName ); 41 } 42 else { 43 getClassNamesInTree( localFile, header + localFile.getName() ); 44 } 45 } 46 } 47 } 48 | Popular Tags |