KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > remoting > ImportedClassLoaderTable


1 package hudson.remoting;
2
3 import hudson.remoting.RemoteClassLoader.IClassLoader;
4
5 import java.util.Hashtable JavaDoc;
6 import java.util.Map JavaDoc;
7
8 /**
9  * @author Kohsuke Kawaguchi
10  */

11 final class ImportedClassLoaderTable {
12     final Channel channel;
13     final Map JavaDoc<IClassLoader,ClassLoader JavaDoc> classLoaders = new Hashtable JavaDoc<IClassLoader,ClassLoader JavaDoc>();
14
15     ImportedClassLoaderTable(Channel channel) {
16         this.channel = channel;
17     }
18
19     public synchronized ClassLoader JavaDoc get(int oid) {
20         return get(RemoteInvocationHandler.wrap(channel,oid,IClassLoader.class,false));
21     }
22
23     public synchronized ClassLoader JavaDoc get(IClassLoader classLoaderProxy) {
24         ClassLoader JavaDoc r = classLoaders.get(classLoaderProxy);
25         if(r==null) {
26             // we need to be able to use the same hudson.remoting classes, hence delegate
27
// to this class loader.
28
r = new RemoteClassLoader(getClass().getClassLoader(),classLoaderProxy);
29             classLoaders.put(classLoaderProxy,r);
30         }
31         return r;
32     }
33 }
34
Popular Tags