1 25 26 package org.objectweb.easybeans.deployment.annotations.analyzer; 27 28 import java.net.URL ; 29 import java.net.URLConnection ; 30 import java.util.Iterator ; 31 32 import org.objectweb.asm.ClassReader; 33 import org.objectweb.easybeans.api.EZBArchive; 34 import org.objectweb.easybeans.api.EZBArchiveException; 35 import org.objectweb.easybeans.deployment.annotations.exceptions.AnalyzerException; 36 import org.objectweb.easybeans.deployment.annotations.metadata.EjbJarAnnotationMetadata; 37 import org.objectweb.easybeans.log.JLog; 38 import org.objectweb.easybeans.log.JLogFactory; 39 40 44 public class AnnotationDeploymentAnalyzer { 45 46 49 private EZBArchive archive = null; 50 51 54 private EjbJarAnnotationMetadata ejbJarAnnotationMetadata = null; 55 56 59 private static JLog logger = JLogFactory.getLog(AnnotationDeploymentAnalyzer.class); 60 61 64 private ScanClassVisitor scanVisitor = null; 65 66 71 public AnnotationDeploymentAnalyzer(final EZBArchive archive) { 72 this.archive = archive; 73 this.ejbJarAnnotationMetadata = new EjbJarAnnotationMetadata(); 74 scanVisitor = new ScanClassVisitor(ejbJarAnnotationMetadata); 75 } 76 77 81 public void analyze() throws AnalyzerException { 82 83 Iterator <URL > iterator; 84 try { 85 iterator = archive.getResources(); 86 while (iterator.hasNext()) { 88 URL url = iterator.next(); 89 if (url.getPath().toLowerCase().endsWith(".class")) { 91 try { 92 URLConnection urlConnection = url.openConnection(); 93 urlConnection.setDefaultUseCaches(false); 94 new ClassReader(urlConnection.getInputStream()).accept(scanVisitor, false); 95 } catch (Exception ioe) { 96 throw new AnalyzerException("Error while analyzing file entry '" + url + "' in archive '" 97 + archive.getName() + "'", ioe); 98 } 99 } 100 } 101 102 } catch (EZBArchiveException e) { 103 throw new AnalyzerException("Error while analyzing archive '" + archive.getName() + "'", e); 104 } finally { 105 archive.close(); 106 } 107 108 } 109 110 111 114 public EjbJarAnnotationMetadata getEjbJarAnnotationMetadata() { 115 return ejbJarAnnotationMetadata; 116 } 117 118 } 119 | Popular Tags |