1 22 package org.jboss.aop.deployment; 23 24 import java.io.File ; 25 import java.io.IOException ; 26 import java.net.URL ; 27 import org.jboss.mx.loading.UnifiedClassLoader; 28 import javassist.ClassPool; 29 import javassist.scopedpool.ScopedClassPool; 30 import javassist.scopedpool.ScopedClassPoolFactory; 31 import javassist.scopedpool.ScopedClassPoolRepository; 32 33 40 public class JBossClassPoolFactory32 implements ScopedClassPoolFactory 41 { 42 protected File tmpClassesDir; 43 44 public JBossClassPoolFactory32(File tmpClassesDir) throws IOException 45 { 46 this.tmpClassesDir = tmpClassesDir; 47 48 } 49 public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository) 50 { 51 try 52 { 53 File tempdir = createTempDir(cl); 54 return new JBossClassPool32(cl, src, repository, tempdir); 55 } 56 catch (IOException e) 57 { 58 throw new RuntimeException (e); 59 } 60 } 61 62 public ScopedClassPool create(ClassPool src, ScopedClassPoolRepository repository) 63 { 64 return new JBossClassPool32(src, repository); 65 } 66 67 public File createTempDir(ClassLoader cl) throws IOException 68 { 69 if (!(cl instanceof UnifiedClassLoader)) return null; 70 File tempdir = File.createTempFile("ucl", "", tmpClassesDir); 71 tempdir.delete(); 72 tempdir.mkdir(); 73 tempdir.deleteOnExit(); 74 UnifiedClassLoader ucl = (UnifiedClassLoader) cl; 75 URL tmpURL = tempdir.toURL(); 76 URL tmpCP = new URL (tmpURL, "?dynamic=true"); 77 if (ucl.getLoaderRepository() != null) ucl.addURL(tmpCP); 79 return tempdir; 80 } 81 } 82 | Popular Tags |