/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Utility which provides an abstract "logger" like RMI internal API
* which can be directed to use one of two types of logging
* infrastructure: the java.util.logging API or the
* java.rmi.server.LogStream API. The default behavior is to use the
* java.util.logging API. The LogStream API may be used instead by
* setting the system property sun.rmi.log.useOld to true.
*
* For backwards compatibility, supports the RMI system logging
* properties which pre-1.4 comprised the only way to configure RMI
* logging. If the java.util.logging API is used and RMI system log
* properties are set, the system properties override initial RMI
* logger values as appropriate. If the java.util.logging API is
* turned off, pre-1.4 logging behavior is used.
*
* @author Laird Dornin
* @since 1.4
*/
public abstract class Log {
/** Logger re-definition of old RMI log values */
/* selects log implementation */
static {
boolean useOld =
"sun.rmi.log.useOld"))).booleanValue();
/* set factory to select the logging facility to use */
(LogFactory) new LoggerLogFactory());
}
/** "logger like" API to be used by RMI implementation */
/** get and set the RMI server call output stream */
/** factory interface enables Logger and LogStream implementations */
private static interface LogFactory {
}
/* access log objects */
/**
* Access log for a tri-state system property.
*
* Need to first convert override value to a log level, taking
* care to interpret a range of values between BRIEF, VERBOSE and
* SILENT.
*
* An override < 0 is interpreted to mean that the logging
* configuration should not be overridden. The level passed to the
* factories createLog method will be null in this case.
*
* Note that if oldLogName is null and old logging is on, the
* returned LogStreamLog will ignore the override parameter - the
* log will never log messages. This permits new logs that only
* write to Loggers to do nothing when old logging is active.
*
* Do not call getLog multiple times on the same logger name.
* Since this is an internal API, no checks are made to ensure
* that multiple logs do not exist for the same logger.
*/
int override)
{
if (override < 0) {
{
} else {
}
}
/**
* Access logs associated with boolean properties
*
* Do not call getLog multiple times on the same logger name.
* Since this is an internal API, no checks are made to ensure
* that multiple logs do not exist for the same logger.
*/
boolean override)
{
}
/**
* Factory to create Log objects which deliver log messages to the
* java.util.logging API.
*/
LoggerLogFactory() {}
/*
* Accessor to obtain an arbitrary RMI logger with name
* loggerName. If the level of the logger is greater than the
* level for the system property with name, the logger level
* will be set to the value of system property.
*/
{
}
}
/**
* Class specialized to log messages to the java.util.logging API
*/
/* alternate console handler for RMI loggers */
return alternate;
}
});
/** handler to which messages are copied */
/* logger to which log messages are written */
/* used as return value of RemoteServer.getLog */
/** creates a Log which will delegate to the given logger */
}
return null;
}
}
);
}
}
}
if (isLoggable(level)) {
}
}
if (isLoggable(level)) {
}
}
/**
* Set the output stream associated with the RMI server call
* logger.
*
* Calling code needs LoggingPermission "control".
*/
}
} else {
/* ensure that messages are not logged */
if (copyHandler != null) {
}
copyHandler = null;
}
}
if (loggerSandwich == null) {
}
return loggerSandwich;
}
}
/**
* Subclass of StreamHandler for redirecting log output. flush
* must be called in the publish and close methods.
*/
super(out, new SimpleFormatter());
}
flush();
}
public void close() {
flush();
}
}
/**
* PrintStream which forwards log messages to the logger. Class
* is needed to maintain backwards compatibility with
* RemoteServer.{set|get}Log().
*/
/** logger where output of this log is sent */
/** record the last character written to this stream */
/** stream used for buffering lines */
{
super(new ByteArrayOutputStream());
}
public void write(int b) {
last = -1;
return;
} else if ((b == '\n') || (b == '\r')) {
try {
/* write the converted bytes of the log message */
} finally {
}
} else {
super.write(b);
}
last = b;
}
if (len < 0) {
throw new ArrayIndexOutOfBoundsException(len);
}
for (int i = 0; i < len; i++) {
}
}
return "RMI";
}
}
/**
* Factory to create Log objects which deliver log messages to the
* java.rmi.server.LogStream API
*/
LogStreamLogFactory() {}
/* create a new LogStreamLog for the specified log */
{
if (oldLogName != null) {
}
}
}
/**
* Class specialized to log messages to the
* java.rmi.server.LogStream API
*/
/** Log stream to which log messages are written */
/** the level of the log as set by associated property */
/* if the stream or level is null, dont log any
* messages
*/
}
}
}
if (isLoggable(messageLevel)) {
}
}
if (isLoggable(level)) {
/*
* keep output contiguous and maintain the contract of
* RemoteServer.getLog
*/
synchronized (stream) {
}
}
}
return stream;
}
}
} else {
/* ensure that messages are not logged */
}
}
/*
* Mimic old log messages that only contain unqualified names.
*/
if (lastDot >= 0) {
}
return name;
}
}
/**
* Obtain class and method names of code calling a log method.
*/
return new String[] {
};
}
}