1 19 20 package org.netbeans.modules.web.jsf; 21 22 import java.util.List ; 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.web.api.webmodule.WebModule; 27 import org.netbeans.modules.web.jsf.api.ConfigurationUtils; 28 import org.netbeans.modules.web.jsf.api.facesmodel.ManagedBean; 29 import org.openide.filesystems.FileObject; 30 import org.openide.util.Parameters; 31 32 36 37 public class JSFInjectionTargetQueryImplementation implements InjectionTargetQueryImplementation { 38 39 public JSFInjectionTargetQueryImplementation() { 40 } 41 42 47 public boolean isInjectionTarget(CompilationController controller, TypeElement typeElement) { 48 Parameters.notNull("controller", controller); 49 Parameters.notNull("typeElement", typeElement); 50 51 WebModule webModule = WebModule.getWebModule(controller.getFileObject()); 53 if (webModule != null && !webModule.getJ2eePlatformVersion().equals(WebModule.J2EE_13_LEVEL) 55 && !webModule.getJ2eePlatformVersion().equals(WebModule.J2EE_14_LEVEL)){ 56 FileObject ddFileObject = webModule.getDeploymentDescriptor(); 58 if (ddFileObject != null){ 59 FileObject[] jsfConfigs = ConfigurationUtils.getFacesConfigFiles(webModule); 61 for (FileObject jsfConfigFO : ConfigurationUtils.getFacesConfigFiles(webModule)) { 62 List <ManagedBean> beans = ConfigurationUtils.getConfigModel(jsfConfigFO, true).getRootComponent().getManagedBeans(); 64 for (ManagedBean managedBean : beans) { 65 if (typeElement.getQualifiedName().contentEquals(managedBean.getManagedBeanClass())) { 66 return true; 67 } 68 } 69 } 70 } 71 } 72 return false; 73 } 74 75 public boolean isStaticReferenceRequired(CompilationController controller, TypeElement typeElement) { 76 return false; 77 } 78 79 } 80 | Popular Tags |