1. /*
  2. * @(#)RemoteServer.java 1.32 03/12/19
  3. *
  4. * Copyright 2004 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.rmi.*;
  9. import sun.rmi.server.UnicastServerRef;
  10. import sun.rmi.runtime.Log;
  11. /**
  12. * The <code>RemoteServer</code> class is the common superclass to server
  13. * implementations and provides the framework to support a wide range
  14. * of remote reference semantics. Specifically, the functions needed
  15. * to create and export remote objects (i.e. to make them remotely
  16. * available) are provided abstractly by <code>RemoteServer</code> and
  17. * concretely by its subclass(es).
  18. *
  19. * @version 1.32, 12/19/03
  20. * @author Ann Wollrath
  21. * @since JDK1.1
  22. */
  23. public abstract class RemoteServer extends RemoteObject
  24. {
  25. /* indicate compatibility with JDK 1.1.x version of class */
  26. private static final long serialVersionUID = -4100238210092549637L;
  27. /**
  28. * Constructs a <code>RemoteServer</code>.
  29. * @since JDK1.1
  30. */
  31. protected RemoteServer() {
  32. super();
  33. }
  34. /**
  35. * Constructs a <code>RemoteServer</code> with the given reference type.
  36. *
  37. * @param ref the remote reference
  38. * @since JDK1.1
  39. */
  40. protected RemoteServer(RemoteRef ref) {
  41. super(ref);
  42. }
  43. /**
  44. * Returns a string representation of the client host for the
  45. * remote method invocation being processed in the current thread.
  46. *
  47. * @return a string representation of the client host
  48. *
  49. * @throws ServerNotActiveException if no remote method invocation
  50. * is being processed in the current thread
  51. *
  52. * @since JDK1.1
  53. */
  54. public static String getClientHost() throws ServerNotActiveException {
  55. return sun.rmi.transport.tcp.TCPTransport.getClientHost();
  56. }
  57. /**
  58. * Log RMI calls to the output stream <code>out</code>. If
  59. * <code>out</code> is <code>null</code>, call logging is turned off.
  60. *
  61. * <p>If there is a security manager, its
  62. * <code>checkPermission</code> method will be invoked with a
  63. * <code>java.util.logging.LoggingPermission("control")</code>
  64. * permission; this could result in a <code>SecurityException</code>.
  65. *
  66. * @param out the output stream to which RMI calls should be logged
  67. * @throws SecurityException if there is a security manager and
  68. * the invocation of its <code>checkPermission</code> method
  69. * fails
  70. * @see #getLog
  71. * @since JDK1.1
  72. */
  73. public static void setLog(java.io.OutputStream out)
  74. {
  75. logNull = (out == null);
  76. UnicastServerRef.callLog.setOutputStream(out);
  77. }
  78. /**
  79. * Returns stream for the RMI call log.
  80. * @return the call log
  81. * @see #setLog
  82. * @since JDK1.1
  83. */
  84. public static java.io.PrintStream getLog()
  85. {
  86. return (logNull ? null : UnicastServerRef.callLog.getPrintStream());
  87. }
  88. // initialize log status
  89. private static boolean logNull = !UnicastServerRef.logCalls;
  90. }