1 22 package org.jboss.aop.instrument; 23 24 import java.util.ArrayList ; 25 import java.util.Collection ; 26 import java.util.Iterator ; 27 28 import javassist.CannotCompileException; 29 import javassist.CtMethod; 30 31 36 public class Codifier 37 { 38 39 private Collection pendingCodes; 40 41 44 public Codifier() 45 { 46 this.pendingCodes = new ArrayList (); 47 } 48 49 54 public synchronized void addPendingCode(CtMethod method, String body) 55 { 56 PendingCode pendingCode = new PendingCode(method, body); 57 this.pendingCodes.add(pendingCode); 58 } 59 60 67 public synchronized void codifyPending() throws CannotCompileException 68 { 69 for (Iterator iterator = pendingCodes.iterator(); iterator.hasNext();) 70 { 71 PendingCode pendingCode = (PendingCode) iterator.next(); 72 pendingCode.method.setBody(pendingCode.body); 73 } 74 pendingCodes.clear(); 75 } 76 77 80 private class PendingCode 81 { 82 CtMethod method; 83 String body; 84 85 public PendingCode(CtMethod method, String body) 86 { 87 this.method = method; 88 this.body = body; 89 } 90 } 91 } | Popular Tags |