1 19 20 package org.netbeans.modules.j2ee.archive.wizard; 21 22 import java.io.IOException ; 23 import java.nio.channels.Channels ; 24 import java.nio.channels.ReadableByteChannel ; 25 import java.util.Enumeration ; 26 import java.util.jar.JarEntry ; 27 import java.util.jar.JarFile ; 28 import org.openide.ErrorManager; 29 30 34 public class EJBAnnotationDetector { 35 36 private EJBAnnotationDetector() { 37 } 38 39 40 48 public static boolean containsSomeAnnotatedEJBs(JarFile jf) throws IOException { 49 EJBClassFile classFile = new EJBClassFile(); 50 Enumeration <JarEntry > entriesEnum = jf.entries(); 51 boolean retVal = false; 52 while(!retVal && entriesEnum.hasMoreElements()) { 53 JarEntry je = entriesEnum.nextElement(); 54 if (je.getName().endsWith(".class")) { 55 ReadableByteChannel channel = null; 56 try { 57 channel = Channels.newChannel(jf.getInputStream(je)); 58 retVal = classFile.containsAnnotation(channel, je.getSize()); 59 } finally { 60 if (null != channel) { 61 try { 62 channel.close(); 63 } catch (IOException ioe) { 64 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, 65 ioe); 66 } 67 } 68 } 69 70 } 71 } 72 return retVal; 73 } 74 } 75 | Popular Tags |