1 23 24 25 package com.sun.jdo.api.persistence.enhancer.impl; 26 27 import java.util.Map ; 28 import java.util.Collection ; 29 import java.util.Enumeration ; 30 import java.util.Iterator ; 31 import java.util.ArrayList ; 32 import java.util.HashMap ; 33 34 import com.sun.jdo.api.persistence.enhancer.util.Support; 36 37 import com.sun.jdo.api.persistence.enhancer.util.ClassFileSource; 38 39 43 44 import com.sun.jdo.api.persistence.enhancer.meta.JDOMetaData; 45 46 import com.sun.jdo.api.persistence.enhancer.impl.ClassControl; 47 import com.sun.jdo.api.persistence.enhancer.impl.Environment; 48 52 53 74 75 78 public class EnhancerControl 80 { 82 83 85 private Environment env; 86 87 90 public EnhancerControl(Environment env) { 91 this.env = env; 92 } 93 94 97 109 110 115 236 237 240 static protected void dumpClass(ClassControl cc) { 242 final String name = cc.userClassName(); 243 System.out.println(); 244 System.out.println("dumping class " + name + " {"); cc.classFile().print(System.out); 246 System.out.println("} // end of class " + name); 247 System.out.println(); 248 } 249 250 251 254 public void modifyClasses() { 258 try{ 260 if (env.doTimingStatistics()) { 261 Support.timer.push("EnhancerControl.modifyClasses()"); } 263 final ArrayList classes = env.collectClasses(); 264 265 if (classes.size() > 1) { 266 env.messageNL("scanning classes"); } 268 269 for (Iterator e = classes.iterator(); e.hasNext();) { 271 ClassControl cc = (ClassControl)e.next(); 272 cc.scan1(); 273 274 if (false) { 275 dumpClass(cc); 276 } 277 } 278 279 284 285 if (env.errorCount() > 0) 286 return; 287 288 if (classes.size() > 1) { 289 env.messageNL("augmenting classes"); } 291 292 for (Iterator e = classes.iterator(); e.hasNext();) { 294 ClassControl cc = (ClassControl)e.next(); 295 cc.augment(); 297 298 if (false) { 299 dumpClass(cc); 300 } 301 } 302 303 if (env.errorCount() > 0) 304 return; 305 306 if (classes.size() > 1) { 307 env.messageNL("annotating classes"); } 309 310 for (Iterator e = classes.iterator(); e.hasNext();) { 312 ClassControl cc = (ClassControl)e.next(); 313 cc.annotate(); 314 315 if (false) { 316 dumpClass(cc); 317 } 318 } 319 } finally { 320 if (env.doTimingStatistics()) { 321 Support.timer.pop(); 322 } 323 } 324 } 325 326 330 343 344 348 425 426 430 447 } 448 | Popular Tags |