JBossClassPoolFactorypublic class JBossClassPoolFactory extends Object implements ScopedClassPoolFactory
Fields Summary |
---|
protected File | tmpClassesDir |
Constructors Summary |
---|
public JBossClassPoolFactory(File tmpClassesDir)
this.tmpClassesDir = tmpClassesDir;
|
Methods Summary |
---|
public javassist.scopedpool.ScopedClassPool | create(java.lang.ClassLoader cl, javassist.ClassPool src, javassist.scopedpool.ScopedClassPoolRepository repository)
try
{
if (cl instanceof RepositoryClassLoader)
{
File tempdir = getTempDirectory(cl);
URL tmpCP = createURLAndAddToLoader(cl, tempdir);
if (AspectManager.scopedCLHelper.ifScopedDeploymentGetScopedParentUclForCL(cl) != null)
{
//It is scoped
return new ScopedJBossClassPool(cl, src, repository, tempdir, tmpCP);
}
return new JBossClassPool(cl, src, repository, tempdir, tmpCP);
}
return new AOPClassPool(cl, src, repository);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
| public javassist.scopedpool.ScopedClassPool | create(javassist.ClassPool src, javassist.scopedpool.ScopedClassPoolRepository repository)
return new JBossClassPool(src, repository);
| public java.io.File | createTempDir(java.lang.ClassLoader cl)
File tempdir = File.createTempFile("ucl", "", tmpClassesDir);
tempdir.delete();
tempdir.mkdir();
tempdir.deleteOnExit();
return tempdir;
| private java.net.URL | createURLAndAddToLoader(java.lang.ClassLoader cl, java.io.File tempdir)
URL tmpURL = tempdir.toURL();
URL tmpCP = new URL(tmpURL, "?dynamic=true");
RepositoryClassLoader ucl = (RepositoryClassLoader) cl;
// We may be undeploying.
if (ucl.getLoaderRepository() != null)
{
ucl.addURL(tmpCP);
}
return tmpCP;
| private java.io.File | getTempDirectory(java.lang.ClassLoader cl)
File tempdir = null;
int attempts = 0;
IOException ex = null;
while (tempdir == null && attempts < 5)
{
//Workaround for JBAOP-254, retry a few times
try
{
tempdir = createTempDir(cl);
}
catch (IOException e)
{
ex = e;
}
}
if (tempdir == null)
{
throw new RuntimeException("", ex);
}
return tempdir;
|
|