javassist.scopedpool
Class ScopedClassPool

java.lang.Object
  extended by javassist.ClassPool
      extended by javassist.scopedpool.ScopedClassPool

public class ScopedClassPool
extends ClassPool

A scoped class pool.

Version:
$Revision: 1.8 $
Author:
Bill Burke, Adrian Brock, Kabir Khan

Field Summary
protected  java.lang.ref.WeakReference classLoader
           
protected  LoaderClassPath classPath
           
protected  ScopedClassPoolRepository repository
           
protected  SoftValueHashMap softcache
           
 
Fields inherited from class javassist.ClassPool
childFirstLookup, classes, doPruning, parent, releaseUnmodifiedClassFile, source
 
Constructor Summary
protected ScopedClassPool(java.lang.ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
          Deprecated.  
protected ScopedClassPool(java.lang.ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, boolean isTemp)
          Create a new ScopedClassPool.
 
Method Summary
protected  void cacheCtClass(java.lang.String classname, CtClass c, boolean dynamic)
          Cache a class
 void close()
          Close the class pool
 void flushClass(java.lang.String classname)
          Flush a class
protected  CtClass getCached(java.lang.String classname)
          Get the cached class
protected  CtClass getCachedLocally(java.lang.String classname)
          Whether the class is cached in this pooled
 java.lang.ClassLoader getClassLoader()
          Get the class loader
protected  java.lang.ClassLoader getClassLoader0()
           
 CtClass getLocally(java.lang.String classname)
          Get any local copy of the class
 boolean isUnloadedClassLoader()
          Whether the classloader is loader
 void lockInCache(CtClass c)
          Lock a class into the cache
 void soften(CtClass clazz)
          Soften a class
 java.lang.Class toClass(CtClass ct, java.lang.ClassLoader loader, java.security.ProtectionDomain domain)
          Convert a javassist class to a java class
 
Methods inherited from class javassist.ClassPool
appendClassPath, appendClassPath, appendPathList, appendSystemPath, clearImportedPackages, createCtClass, find, get, get, get0, getAndRename, getCtClass, getDefault, getImportedPackages, getMethod, importPackage, insertClassPath, insertClassPath, lookupCflow, makeClass, makeClass, makeClass, makeClass, makeClassIfNew, makeInterface, makeInterface, recordInvalidClassName, removeCached, removeClassPath, toClass, toClass, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

repository

protected ScopedClassPoolRepository repository

classLoader

protected java.lang.ref.WeakReference classLoader

classPath

protected LoaderClassPath classPath

softcache

protected SoftValueHashMap softcache
Constructor Detail

ScopedClassPool

protected ScopedClassPool(java.lang.ClassLoader cl,
                          ClassPool src,
                          ScopedClassPoolRepository repository)
Deprecated. 

Create a new ScopedClassPool.

Parameters:
cl - the classloader
src - the original class pool
repository - the repository

ScopedClassPool

protected ScopedClassPool(java.lang.ClassLoader cl,
                          ClassPool src,
                          ScopedClassPoolRepository repository,
                          boolean isTemp)
Create a new ScopedClassPool.

Parameters:
cl - the classloader
src - the original class pool
repository - the repository
isTemp - Whether this is a temporary pool used to resolve references
Method Detail

getClassLoader

public java.lang.ClassLoader getClassLoader()
Get the class loader

Overrides:
getClassLoader in class ClassPool
Returns:
the class loader
See Also:
ClassPool.toClass(CtClass), CtClass.getAnnotations()

getClassLoader0

protected java.lang.ClassLoader getClassLoader0()

close

public void close()
Close the class pool


flushClass

public void flushClass(java.lang.String classname)
Flush a class

Parameters:
classname - the class to flush

soften

public void soften(CtClass clazz)
Soften a class

Parameters:
clazz - the class

isUnloadedClassLoader

public boolean isUnloadedClassLoader()
Whether the classloader is loader

Returns:
false always

getCached

protected CtClass getCached(java.lang.String classname)
Get the cached class

Overrides:
getCached in class ClassPool
Parameters:
classname - the class name
Returns:
the class
See Also:
ClassPool.cacheCtClass(String,CtClass,boolean), ClassPool.removeCached(String)

cacheCtClass

protected void cacheCtClass(java.lang.String classname,
                            CtClass c,
                            boolean dynamic)
Cache a class

Overrides:
cacheCtClass in class ClassPool
Parameters:
classname - the class name
c - the ctClass
dynamic - whether the class is dynamically generated
See Also:
ClassPool.getCached(String), #removeCached(String,CtClass)

lockInCache

public void lockInCache(CtClass c)
Lock a class into the cache

Parameters:
c - the class

getCachedLocally

protected CtClass getCachedLocally(java.lang.String classname)
Whether the class is cached in this pooled

Parameters:
classname - the class name
Returns:
the cached class

getLocally

public CtClass getLocally(java.lang.String classname)
                   throws NotFoundException
Get any local copy of the class

Parameters:
classname - the class name
Returns:
the class
Throws:
NotFoundException - when the class is not found

toClass

public java.lang.Class toClass(CtClass ct,
                               java.lang.ClassLoader loader,
                               java.security.ProtectionDomain domain)
                        throws CannotCompileException
Convert a javassist class to a java class

Overrides:
toClass in class ClassPool
Parameters:
ct - the javassist class
loader - the loader
domain - the protection domain for the class. If it is null, the default domain created by java.lang.ClassLoader is used.
Throws:
CannotCompileException - for any error
See Also:
ClassPool.getClassLoader()


Copyright © 2011. All Rights Reserved.