1 19 20 package org.netbeans.modules.j2ee.refactoring; 21 22 import java.util.Collection ; 23 import javax.jmi.reflect.RefObject; 24 import org.netbeans.jmi.javamodel.Method; 25 import org.netbeans.modules.j2ee.refactoring.whereused.EjbJarWhereUsedRefactoring; 26 import org.netbeans.modules.j2ee.refactoring.whereused.EntityWhereUsedRefactoring; 27 import org.netbeans.modules.j2ee.refactoring.whereused.JaxWsXmlWhereUsedRefactoring; 28 import org.netbeans.modules.j2ee.refactoring.whereused.PersistenceXmlWhereUsedRefactoring; 29 import org.netbeans.modules.j2ee.refactoring.whereused.SunJaxWsXmlWhereUsedRefactoring; 30 import org.netbeans.modules.j2ee.refactoring.whereused.TldWhereUsedRefactoring; 31 import org.netbeans.modules.j2ee.refactoring.whereused.WebXmlWhereUsedRefactoring; 32 import org.netbeans.modules.j2ee.refactoring.whereused.WebservicesXmlWhereUsedRefactoring; 33 import org.netbeans.modules.refactoring.api.AbstractRefactoring; 34 import org.netbeans.modules.refactoring.api.Problem; 35 import org.netbeans.modules.refactoring.spi.RefactoringElementsBag; 36 import org.netbeans.modules.refactoring.api.WhereUsedQuery; 37 import org.netbeans.modules.refactoring.spi.RefactoringPlugin; 38 import org.openide.ErrorManager; 39 import org.openide.util.NbBundle; 40 41 42 46 public class J2EEWhereUsedRefactoringPlugin implements RefactoringPlugin { 47 48 49 private static ThreadLocal semafor = new ThreadLocal (); 50 51 private EjbJarWhereUsedRefactoring ejbJarWhereUsedRefactor; 52 private WebXmlWhereUsedRefactoring webXmlWhereUsedRefactor; 53 private TldWhereUsedRefactoring tldWhereUsedRefactor; 54 private WebservicesXmlWhereUsedRefactoring webservicesXmlWhereUsedRefactor; 55 private JaxWsXmlWhereUsedRefactoring jaxWsXmlWhereUsedRefactor; 56 private PersistenceXmlWhereUsedRefactoring persistenceXmlWhereUsedRefactor; 57 private SunJaxWsXmlWhereUsedRefactoring sunJaxWsXmlWhereUsedRefactor; 58 private EntityWhereUsedRefactoring entityWhereUsedRefactor; 59 60 public void cancelRequest() { 61 62 } 63 64 public Problem fastCheckParameters() { 65 return null; 66 } 67 68 private AbstractRefactoring refactoring; 69 private static ErrorManager err = ErrorManager.getDefault().getInstance("org.netbeans.modules.j2ee.refactoring.whereused"); 71 72 public J2EEWhereUsedRefactoringPlugin(AbstractRefactoring refactoring) { 73 this.refactoring = refactoring; 74 } 75 76 79 public Problem preCheck() { 80 return null; 81 } 82 83 86 public Problem checkParameters() { 87 Problem problem = null; 88 if (semafor.get() == null) { 89 semafor.set(new Object ()); 90 WhereUsedQuery whereUsedRefactor = ((WhereUsedQuery)refactoring); 91 RefObject refObject = (RefObject) whereUsedRefactor.getRefactoredObject(); 92 try { 93 if (Utility.isEjb30((refObject)) && Utility.hasEjbJar(refObject)){ 94 Problem ejbJarProblem = new Problem(false, NbBundle.getMessage(J2EEWhereUsedRefactoringPlugin.class, "TXT_EjbJarWhereUsedWarning")); problem = Utility.addProblemsToEnd(problem, ejbJarProblem); 96 } 97 }finally { 98 semafor.set(null); 99 } 100 } 101 return problem; 102 } 103 104 110 public Problem prepare(RefactoringElementsBag refactoringElements) { 111 if (semafor.get() != null) { 112 return null; 113 } 114 semafor.set(new Object ()); 115 try { 116 WhereUsedQuery whereUsedRefactor = ((WhereUsedQuery)refactoring); 117 118 if (!whereUsedRefactor.isFindUsages()) { return null; 120 } 121 122 Problem problem = null; 123 124 RefObject refO = (RefObject) whereUsedRefactor.getRefactoredObject(); 125 err.log("refO: " + refO); 126 127 Problem webXmlProblem = getWebXmlWhereUsedRefactor().prepare(whereUsedRefactor, refO, refactoringElements); 128 problem = Utility.addProblemsToEnd(problem, webXmlProblem); 129 130 Problem tldProblem = getTldWhereUsedRefactor().prepare(whereUsedRefactor, refO, refactoringElements); 131 problem = Utility.addProblemsToEnd(problem, tldProblem); 132 133 if (!Utility.isEjb30(refO)){ 134 Problem ejbJarProblem = getEjbJarWhereUsedRefactor().prepare(whereUsedRefactor, refO, refactoringElements); 135 problem = Utility.addProblemsToEnd(problem, ejbJarProblem); 136 } 137 138 Problem webservicesProblem = getWebservicesXmlWhereUsedRefactor().prepare(whereUsedRefactor, refO, refactoringElements); 139 problem = Utility.addProblemsToEnd(problem, webservicesProblem); 140 141 Problem jaxWsXmlProblem = getJaxWsXmlWhereUsedRefactoring().prepare(whereUsedRefactor, refO, refactoringElements); 142 problem = Utility.addProblemsToEnd(problem, jaxWsXmlProblem); 143 144 Problem persistenceXmlProblem = getPersistenceXmlWhereUsedRefactoring().prepare(whereUsedRefactor, refO, refactoringElements); 145 problem = Utility.addProblemsToEnd(problem, persistenceXmlProblem); 146 147 Problem sunJaxWsXmlProblem = getSunJaxWsXmlWhereUsedRefactoring().prepare(whereUsedRefactor, refO, refactoringElements); 148 problem = Utility.addProblemsToEnd(problem, sunJaxWsXmlProblem); 149 150 Problem entityProblem = getEntityWhereUsedRefactor().prepare(whereUsedRefactor, refO, refactoringElements); 151 problem = Utility.addProblemsToEnd(problem, entityProblem ); 152 153 154 155 if (refO instanceof Method) { 157 Method method = (Method)refO; 158 method.getName(); 159 } 160 161 err.log("Gonna return problem: " + problem); 162 return problem; 163 } finally { 164 semafor.set(null); 165 } 166 } 167 168 private EjbJarWhereUsedRefactoring getEjbJarWhereUsedRefactor() { 169 if (ejbJarWhereUsedRefactor == null) { 170 ejbJarWhereUsedRefactor = new EjbJarWhereUsedRefactoring(); 171 } 172 return ejbJarWhereUsedRefactor; 173 } 174 175 private WebXmlWhereUsedRefactoring getWebXmlWhereUsedRefactor() { 176 if (webXmlWhereUsedRefactor == null) { 177 webXmlWhereUsedRefactor = new WebXmlWhereUsedRefactoring(); 178 } 179 return webXmlWhereUsedRefactor; 180 } 181 182 private TldWhereUsedRefactoring getTldWhereUsedRefactor() { 183 if (tldWhereUsedRefactor == null) { 184 tldWhereUsedRefactor = new TldWhereUsedRefactoring(); 185 } 186 return tldWhereUsedRefactor; 187 } 188 189 private WebservicesXmlWhereUsedRefactoring getWebservicesXmlWhereUsedRefactor() { 190 if (webservicesXmlWhereUsedRefactor == null) { 191 webservicesXmlWhereUsedRefactor = new WebservicesXmlWhereUsedRefactoring(); 192 } 193 return webservicesXmlWhereUsedRefactor; 194 } 195 196 private JaxWsXmlWhereUsedRefactoring getJaxWsXmlWhereUsedRefactoring() { 197 if (jaxWsXmlWhereUsedRefactor == null) { 198 jaxWsXmlWhereUsedRefactor = new JaxWsXmlWhereUsedRefactoring(); 199 } 200 return jaxWsXmlWhereUsedRefactor; 201 } 202 203 private PersistenceXmlWhereUsedRefactoring getPersistenceXmlWhereUsedRefactoring(){ 204 if (persistenceXmlWhereUsedRefactor == null){ 205 persistenceXmlWhereUsedRefactor = new PersistenceXmlWhereUsedRefactoring(); 206 } 207 return persistenceXmlWhereUsedRefactor; 208 } 209 210 private SunJaxWsXmlWhereUsedRefactoring getSunJaxWsXmlWhereUsedRefactoring() { 211 if (sunJaxWsXmlWhereUsedRefactor == null) { 212 sunJaxWsXmlWhereUsedRefactor = new SunJaxWsXmlWhereUsedRefactoring(); 213 } 214 return sunJaxWsXmlWhereUsedRefactor; 215 } 216 217 private EntityWhereUsedRefactoring getEntityWhereUsedRefactor() { 218 if (entityWhereUsedRefactor == null){ 219 entityWhereUsedRefactor = new EntityWhereUsedRefactoring(); 220 } 221 return entityWhereUsedRefactor; 222 } 223 224 225 226 } 227 | Popular Tags |