1. /*
  2. * @(#)RMIClassLoader.java 1.17 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.rmi.server;
  8. import java.net.MalformedURLException;
  9. import java.net.URL;
  10. /**
  11. * <code>RMIClassLoader</code> provides static methods for loading classes
  12. * from a network location (one or more URLs) and obtaining the location
  13. * from which an existing class can be loaded. These methods are used by
  14. * the RMI runtime when marshalling and unmarshalling classes of parameters
  15. * and return values.
  16. *
  17. * @version 1.17, 11/29/01
  18. * @author Ann Wollrath
  19. * @author Peter Jones
  20. * @since JDK1.1
  21. */
  22. public class RMIClassLoader {
  23. /*
  24. * Disallow anyone from creating one of these.
  25. */
  26. private RMIClassLoader() {}
  27. /**
  28. * Load a class from the codebase URL path specified by the
  29. * <code>java.rmi.server.codebase</code> property.
  30. *
  31. * @param name the name of the class to load
  32. * @return the <code>Class</code> object representing the loaded class
  33. * @exception MalformedURLException
  34. * if the system property <b>java.rmi.server.codebase</b>
  35. * contains an invalid URL
  36. * @exception ClassNotFoundException
  37. * if a definition for the class could not
  38. * be found at the codebase location
  39. * @since JDK1.1
  40. * @deprecated replaced by <code>loadClass(String,String)</code> method
  41. * @see #loadClass(String,String)
  42. */
  43. public static Class loadClass(String name)
  44. throws MalformedURLException, ClassNotFoundException
  45. {
  46. return sun.rmi.server.LoaderHandler.loadClass(name);
  47. }
  48. /**
  49. * Load a class from a codebase URL.
  50. *
  51. * @param codebase the URL to load the class from
  52. * @param name the name of the class to load
  53. * @return the <code>Class</code> object representing the loaded class
  54. * @exception MalformedURLException
  55. * if the <code>codebase</code> paramater
  56. * contains an invalid URL
  57. * @exception ClassNotFoundException
  58. * if a definition for the class could not
  59. * be found at the specified URL
  60. * @since JDK1.1
  61. */
  62. public static Class loadClass(URL codebase, String name)
  63. throws MalformedURLException, ClassNotFoundException
  64. {
  65. return sun.rmi.server.LoaderHandler.loadClass(codebase, name);
  66. }
  67. /**
  68. * Load a class from a codebase URL path.
  69. *
  70. * @param codebase the list of URLs to load the class from
  71. * @param name the name of the class to load
  72. * @return the <code>Class</code> object representing the loaded class
  73. * @exception MalformedURLException
  74. * if the <code>codebase</code> paramater
  75. * contains an invalid URL
  76. * @exception ClassNotFoundException
  77. * if a definition for the class could not
  78. * be found at the specified location
  79. * @since JDK1.2
  80. */
  81. public static Class loadClass(String codebase, String name)
  82. throws MalformedURLException, ClassNotFoundException
  83. {
  84. return sun.rmi.server.LoaderHandler.loadClass(codebase, name);
  85. }
  86. /**
  87. * Returns the class annotation (representing the location for
  88. * a class) that RMI will use to annotate the call stream when
  89. * marshalling objects of the given class.
  90. *
  91. * @param cl the class to obtain the annotation for
  92. * @return a string to be used to annotate the class when marshalled
  93. * @since JDK1.2
  94. */
  95. public static String getClassAnnotation(Class cl) {
  96. return sun.rmi.server.LoaderHandler.getClassAnnotation(cl);
  97. }
  98. /**
  99. * Return the security context of the given class loader.
  100. *
  101. * @param loader a class loader from which to get the security context
  102. * @return the security context
  103. * @since JDK1.1
  104. * @deprecated no replacement. As of JDK1.2, RMI no longer uses this
  105. * method to obtain a classloader's security context.
  106. * @see java.lang.SecurityManager#getSecurityContext()
  107. */
  108. public static Object getSecurityContext(ClassLoader loader)
  109. {
  110. return sun.rmi.server.LoaderHandler.getSecurityContext(loader);
  111. }
  112. }