1 19 20 package org.netbeans.modules.j2ee.ejbcore; 21 22 import java.io.IOException ; 23 import javax.lang.model.element.TypeElement; 24 import org.netbeans.api.java.source.CompilationController; 25 import org.netbeans.modules.j2ee.common.queries.spi.InjectionTargetQueryImplementation; 26 import org.netbeans.modules.j2ee.dd.api.ejb.DDProvider; 27 import org.netbeans.modules.j2ee.dd.api.ejb.EjbJar; 28 import org.netbeans.modules.j2ee.dd.api.ejb.EnterpriseBeans; 29 import org.netbeans.modules.j2ee.dd.api.ejb.MessageDriven; 30 import org.netbeans.modules.j2ee.dd.api.ejb.Session; 31 import org.openide.ErrorManager; 32 33 37 public class EjbInjectionTargetQueryImplementation implements InjectionTargetQueryImplementation { 38 39 public EjbInjectionTargetQueryImplementation() { 40 } 41 42 public boolean isInjectionTarget(CompilationController controller, TypeElement typeElement) { 43 org.netbeans.modules.j2ee.api.ejbjar.EjbJar apiEjbJar = org.netbeans.modules.j2ee.api.ejbjar.EjbJar.getEjbJar(controller.getFileObject()); 44 String fqn = typeElement.getQualifiedName().toString(); 45 if (apiEjbJar != null && 46 !apiEjbJar.getJ2eePlatformVersion().equals("1.3") && 47 !apiEjbJar.getJ2eePlatformVersion().equals("1.4")) { 48 try { 49 EjbJar ejbJar = DDProvider.getDefault().getMergedDDRoot(apiEjbJar.getMetadataUnit()); 50 if (ejbJar != null && ejbJar.getEnterpriseBeans() != null) { 51 if (ejbJar.getEnterpriseBeans().findBeanByName(EnterpriseBeans.SESSION, Session.EJB_CLASS, fqn) != null) { 52 return true; 53 } 54 if (ejbJar.getEnterpriseBeans().findBeanByName(EnterpriseBeans.MESSAGE_DRIVEN, MessageDriven.EJB_CLASS, fqn) != null) { 55 return true; 56 } 57 } 58 } catch (IOException ex) { 59 ErrorManager.getDefault().notify(ex); 60 } 61 } 62 return false; 63 } 64 65 public boolean isStaticReferenceRequired(CompilationController controller, TypeElement typeElement) { 66 return false; 67 } 68 69 } 70 | Popular Tags |