diff options
Diffstat (limited to 'stage1/CachingClassLoader.scala')
-rw-r--r-- | stage1/CachingClassLoader.scala | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/stage1/CachingClassLoader.scala b/stage1/CachingClassLoader.scala new file mode 100644 index 0000000..e75f14c --- /dev/null +++ b/stage1/CachingClassLoader.scala @@ -0,0 +1,12 @@ +package cbt +import java.net._ +import java.util.concurrent.ConcurrentHashMap +import scala.util.Try + +trait CachingClassLoader extends ClassLoader{ + def logger: Logger + val cache = new KeyLockedLazyCache[String,Try[Class[_]]]( new ConcurrentHashMap, new ConcurrentHashMap, Some(logger) ) + override def loadClass(name: String, resolve: Boolean) = { + cache.get( name, Try(super.loadClass(name, resolve)) ).get + } +} |