/[classpath]/classpath/java/rmi/server/RMIClassLoader.java
ViewVC logotype

Diff of /classpath/java/rmi/server/RMIClassLoader.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by mkoch, Thu Sep 25 12:39:27 2003 UTC revision 1.9 by mkoch, Mon Oct 6 14:02:57 2003 UTC
# Line 35  or based on this library.  If you modify Line 35  or based on this library.  If you modify
35  this exception to your version of the library, but you are not  this exception to your version of the library, but you are not
36  obligated to do so.  If you do not wish to do so, delete this  obligated to do so.  If you do not wish to do so, delete this
37  exception statement from your version. */  exception statement from your version. */
38    
39  package java.rmi.server;  package java.rmi.server;
40    
41  import java.net.MalformedURLException;  import java.net.MalformedURLException;
# Line 152  public class RMIClassLoader Line 153  public class RMIClassLoader
153    
154    private static Map cacheLoaders; //map annotations to loaders    private static Map cacheLoaders; //map annotations to loaders
155    private static Map cacheAnnotations; //map loaders to annotations    private static Map cacheAnnotations; //map loaders to annotations
156    
157      //defaultAnnotation is got from system property
158      // "java.rmi.server.defaultAnnotation"
159    private static String defaultAnnotation;    private static String defaultAnnotation;
160    
161    //URL object for defaultAnnotation    //URL object for defaultAnnotation
# Line 169  public class RMIClassLoader Line 173  public class RMIClassLoader
173      defaultAnnotation = System.getProperty ("java.rmi.server.defaultAnnotation");      defaultAnnotation = System.getProperty ("java.rmi.server.defaultAnnotation");
174    
175      try      try
176      {        {
177        if (defaultAnnotation != null)          if (defaultAnnotation != null)
178          defaultCodebase = new URL (defaultAnnotation);            defaultCodebase = new URL (defaultAnnotation);
179      }        }
180      catch (Exception _)      catch (Exception _)
181      {        {
182        defaultCodebase = null;          defaultCodebase = null;
183      }        }
184    
185      if (defaultCodebase != null)      if (defaultCodebase != null)
186        {        {
# Line 203  public class RMIClassLoader Line 207  public class RMIClassLoader
207      ClassLoader loader = Thread.currentThread().getContextClassLoader();      ClassLoader loader = Thread.currentThread().getContextClassLoader();
208    
209      //try context class loader first      //try context class loader first
210      try      try
211      {        {
212        return loader.loadClass (name);          return loader.loadClass (name);
213      }        }
214      catch (ClassNotFoundException e)      catch (ClassNotFoundException e)
215      {        {
216        // class not found in the local classpath          // class not found in the local classpath
217      }        }
218    
219      if (codebases.length() == 0) //==""      if (codebases.length() == 0) //==""
220        {        {
# Line 267  public class RMIClassLoader Line 271  public class RMIClassLoader
271                        
272      return loader;      return loader;
273    }    }
274    
275    /**    /**
276     * Returns a string representation of the network location where a remote     * Returns a string representation of the network location where a remote
277     * endpoint can get the class-definition of the given class.     * endpoint can get the class-definition of the given class.
# Line 280  public class RMIClassLoader Line 284  public class RMIClassLoader
284    public static String getClassAnnotation (Class cl)    public static String getClassAnnotation (Class cl)
285    {    {
286      ClassLoader loader = cl.getClassLoader();      ClassLoader loader = cl.getClassLoader();
287        
288      if ((loader == null)      if (loader == null
289          || (loader == ClassLoader.getSystemClassLoader()))          || loader == ClassLoader.getSystemClassLoader())
290        {        {
291          return System.getProperty ("java.rmi.server.codebase");          return System.getProperty ("java.rmi.server.codebase");
292        }        }
# Line 295  public class RMIClassLoader Line 299  public class RMIClassLoader
299      String s = (String) cacheAnnotations.get (loader);      String s = (String) cacheAnnotations.get (loader);
300    
301      if (s != null)      if (s != null)
302        {        return s;
         return s;  
       }  
303    
304      if (loader instanceof URLClassLoader)      if (loader instanceof URLClassLoader)
305        {        {
306          URL[] urls = ((URLClassLoader) loader).getURLs();          URL[] urls = ((URLClassLoader) loader).getURLs();
307    
308          if (urls.length == 0)          if (urls.length == 0)
309            {            return null;
             return null;  
           }  
310    
311          StringBuffer annotation = new StringBuffer (64 * urls.length);          StringBuffer annotation = new StringBuffer (64 * urls.length);
312    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26