diff options
author | Michael Koch <konqueror@gmx.de> | 2003-09-26 20:03:28 +0000 |
---|---|---|
committer | Michael Koch <mkoch@gcc.gnu.org> | 2003-09-26 20:03:28 +0000 |
commit | 6634a0e914af681099d147755f90ed4011a35809 (patch) | |
tree | 74e4522e25a7ad14aaae77906538a7095dc3d904 /libjava | |
parent | fc56f7acc1f6e1d32c601054c3af3ede4d82a6db (diff) | |
download | gcc-6634a0e914af681099d147755f90ed4011a35809.zip gcc-6634a0e914af681099d147755f90ed4011a35809.tar.gz gcc-6634a0e914af681099d147755f90ed4011a35809.tar.bz2 |
RMIClassLoader.java: Reformatted file, no functional code changes.
2003-09-26 Michael Koch <konqueror@gmx.de>
* java/rmi/server/RMIClassLoader.java:
Reformatted file, no functional code changes.
From-SVN: r71831
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 5 | ||||
-rw-r--r-- | libjava/java/rmi/server/RMIClassLoader.java | 108 |
2 files changed, 66 insertions, 47 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index a3ebdb3..ec64e3a 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2003-09-26 Michael Koch <konqueror@gmx.de> + + * java/rmi/server/RMIClassLoader.java: + Reformatted file, no functional code changes. + 2003-09-26 Sascha Brawer <brawer@dandelis.ch> * java/awt/image/SinglePixelPackedSampleModel.java (createDataBuffer): diff --git a/libjava/java/rmi/server/RMIClassLoader.java b/libjava/java/rmi/server/RMIClassLoader.java index 057ca0f..20dd7f6 100644 --- a/libjava/java/rmi/server/RMIClassLoader.java +++ b/libjava/java/rmi/server/RMIClassLoader.java @@ -1,5 +1,6 @@ /* RMIClassLoader.java - Copyright (c) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc. + Copyright (c) 1996, 1997, 1998, 1999, 2002, 2003 + Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,12 +38,12 @@ exception statement from your version. */ package java.rmi.server; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.net.URLClassLoader; import java.io.IOException; import java.io.DataInputStream; -import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -51,40 +52,47 @@ import java.util.Map; import java.util.StringTokenizer; import java.util.WeakHashMap; + +/** + * This class provides a set of public static utility methods for supporting + * network-based class loading in RMI. These methods are called by RMI's + * internal marshal streams to implement the dynamic class loading of types for + * RMI parameters and return values. + */ public class RMIClassLoader { - static private class MyClassLoader extends URLClassLoader { - - private MyClassLoader(URL[] urls, ClassLoader parent, String annotation) + private MyClassLoader (URL[] urls, ClassLoader parent, String annotation) { - super(urls, parent); + super (urls, parent); this.annotation = annotation; } - private MyClassLoader(URL[] urls, ClassLoader parent) + private MyClassLoader (URL[] urls, ClassLoader parent) { super (urls, parent); - this.annotation = urlToAnnotation(urls); + this.annotation = urlToAnnotation (urls); } - public static String urlToAnnotation(URL[] urls) + public static String urlToAnnotation (URL[] urls) { if (urls.length == 0) - return null; + return null; - StringBuffer annotation = new StringBuffer(64*urls.length); - for(int i = 0; i < urls.length; i++) - { - annotation.append(urls[i].toExternalForm()); - annotation.append(' '); - } + StringBuffer annotation = new StringBuffer (64 * urls.length); + + for (int i = 0; i < urls.length; i++) + { + annotation.append (urls [i].toExternalForm()); + annotation.append (' '); + } return annotation.toString(); } - public final String getClassAnnotation(){ + public final String getClassAnnotation() + { return annotation; } @@ -100,47 +108,51 @@ public class RMIClassLoader private static String defaultAnnotation; //URL object for defaultAnnotation private static URL defaultCodebase; + //class loader for defaultAnnotation private static MyClassLoader defaultLoader; - + static { // 89 is a nice prime number for Hashtable initial capacity - cacheLoaders = new Hashtable(89); - cacheAnnotations = new Hashtable(89); - - defaultAnnotation = System.getProperty("java.rmi.server.defaultAnnotation"); - try - { - if (defaultAnnotation != null) - defaultCodebase = new URL(defaultAnnotation); - } - catch(Exception _) - { - defaultCodebase = null; - } + cacheLoaders = new Hashtable (89); + cacheAnnotations = new Hashtable (89); + + defaultAnnotation = System.getProperty ("java.rmi.server.defaultAnnotation"); + + try + { + if (defaultAnnotation != null) + defaultCodebase = new URL (defaultAnnotation); + } + catch (Exception _) + { + defaultCodebase = null; + } + if (defaultCodebase != null) { defaultLoader = new MyClassLoader(new URL[]{ defaultCodebase }, null, defaultAnnotation); cacheLoaders.put(defaultAnnotation, defaultLoader); } - } - + } + /** * @deprecated */ - public static Class loadClass(String name) + public static Class loadClass (String name) throws MalformedURLException, ClassNotFoundException { - return (loadClass("", name)); + return loadClass ("", name); } - public static Class loadClass(String codebases, String name) - throws MalformedURLException, ClassNotFoundException + public static Class loadClass (String codebases, String name) + throws MalformedURLException, ClassNotFoundException { Class c = null; ClassLoader loader = Thread.currentThread().getContextClassLoader(); + //try context class loader first try { @@ -182,16 +194,19 @@ public class RMIClassLoader { return null; //?? } - + if (loader instanceof MyClassLoader) { - return ((MyClassLoader)loader).getClassAnnotation(); + return ((MyClassLoader) loader).getClassAnnotation(); } - - String s = (String)cacheAnnotations.get(loader); + + String s = (String) cacheAnnotations.get (loader); + if (s != null) - return s; - + { + return s; + } + if (loader instanceof URLClassLoader) { URL[] urls = ((URLClassLoader)loader).getURLs(); @@ -209,13 +224,12 @@ public class RMIClassLoader } return null; } - + /** * @deprecated */ - public static Object getSecurityContext(ClassLoader loader) + public static Object getSecurityContext (ClassLoader loader) { - throw new Error("Not implemented"); + throw new Error ("Not implemented"); } - } |