- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Dynamic ending searching path of URLClassLoader of a remote actor
Mon, 2011-08-08, 17:22
We were told that JVM load classes "on demand". Therefore it should
be possible to extend the searching path of a classloader on the fly.
In following code, I attempted to simulate this in an actor model.
class myActor extends Actor{
private object myClassLoader(port:Int, name: Symbol) extends
URLClassLoader(Array(), getClass().getClassLoader()){
override def addURL(url:URL) {
super.addURL(url)
}
}
def act() {
RemoteActor.classLoader = myClassLoader
//myClassLoader.addURL(new URL("file:///home/jiansen/Desktop/
scalatest/client/"))
alive(port)
register(name, self)
loop(
react {
case URLClassPath(url) => {
myClassLoader.addURL(url)
println("new URL added to class path: "+url)
}
...
}
)
}
}