src/java.rmi/share/classes/java/rmi/server/RemoteServer.java
changeset 47216 71c04702a3d5
parent 25859 3317bb8137f4
equal deleted inserted replaced
47215:4ebc2e2fb97c 47216:71c04702a3d5
       
     1 /*
       
     2  * Copyright (c) 1996, 2002, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 package java.rmi.server;
       
    26 
       
    27 import java.rmi.*;
       
    28 import sun.rmi.server.UnicastServerRef;
       
    29 import sun.rmi.runtime.Log;
       
    30 
       
    31 /**
       
    32  * The <code>RemoteServer</code> class is the common superclass to server
       
    33  * implementations and provides the framework to support a wide range
       
    34  * of remote reference semantics.  Specifically, the functions needed
       
    35  * to create and export remote objects (i.e. to make them remotely
       
    36  * available) are provided abstractly by <code>RemoteServer</code> and
       
    37  * concretely by its subclass(es).
       
    38  *
       
    39  * @author  Ann Wollrath
       
    40  * @since   1.1
       
    41  */
       
    42 public abstract class RemoteServer extends RemoteObject
       
    43 {
       
    44     /* indicate compatibility with JDK 1.1.x version of class */
       
    45     private static final long serialVersionUID = -4100238210092549637L;
       
    46 
       
    47     /**
       
    48      * Constructs a <code>RemoteServer</code>.
       
    49      * @since 1.1
       
    50      */
       
    51     protected RemoteServer() {
       
    52         super();
       
    53     }
       
    54 
       
    55     /**
       
    56      * Constructs a <code>RemoteServer</code> with the given reference type.
       
    57      *
       
    58      * @param ref the remote reference
       
    59      * @since 1.1
       
    60      */
       
    61     protected RemoteServer(RemoteRef ref) {
       
    62         super(ref);
       
    63     }
       
    64 
       
    65     /**
       
    66      * Returns a string representation of the client host for the
       
    67      * remote method invocation being processed in the current thread.
       
    68      *
       
    69      * @return  a string representation of the client host
       
    70      *
       
    71      * @throws  ServerNotActiveException if no remote method invocation
       
    72      * is being processed in the current thread
       
    73      *
       
    74      * @since   1.1
       
    75      */
       
    76     public static String getClientHost() throws ServerNotActiveException {
       
    77         return sun.rmi.transport.tcp.TCPTransport.getClientHost();
       
    78     }
       
    79 
       
    80     /**
       
    81      * Log RMI calls to the output stream <code>out</code>. If
       
    82      * <code>out</code> is <code>null</code>, call logging is turned off.
       
    83      *
       
    84      * <p>If there is a security manager, its
       
    85      * <code>checkPermission</code> method will be invoked with a
       
    86      * <code>java.util.logging.LoggingPermission("control")</code>
       
    87      * permission; this could result in a <code>SecurityException</code>.
       
    88      *
       
    89      * @param   out the output stream to which RMI calls should be logged
       
    90      * @throws  SecurityException  if there is a security manager and
       
    91      *          the invocation of its <code>checkPermission</code> method
       
    92      *          fails
       
    93      * @see #getLog
       
    94      * @since 1.1
       
    95      */
       
    96     public static void setLog(java.io.OutputStream out)
       
    97     {
       
    98         logNull = (out == null);
       
    99         UnicastServerRef.callLog.setOutputStream(out);
       
   100     }
       
   101 
       
   102     /**
       
   103      * Returns stream for the RMI call log.
       
   104      * @return the call log
       
   105      * @see #setLog
       
   106      * @since 1.1
       
   107      */
       
   108     public static java.io.PrintStream getLog()
       
   109     {
       
   110         return (logNull ? null : UnicastServerRef.callLog.getPrintStream());
       
   111     }
       
   112 
       
   113     // initialize log status
       
   114     private static boolean logNull = !UnicastServerRef.logCalls;
       
   115 }