com.myarch.reloader
Class ReloadLogger

java.lang.Object
  |
  +--com.myarch.reloader.ReloadLogger
All Implemented Interfaces:
Actions, LoadActionListener

public class ReloadLogger
extends java.lang.Object
implements LoadActionListener, Actions

Logs AFTER_RELOAD event produced by Reloader after it successfully loads a class. By default the logging is off. To turn it on, set the following property: reloader.log=yes or java -Dreloader.log=yes You can also use the static methods ReloadLogger.setLogginOn().

Author:
Alexander Ananiev

Field Summary
static java.lang.String LOGGING_ENABLE_PROPERTY
           
 
Fields inherited from interface com.myarch.reloader.Actions
AFTER_PARENT_LOAD, AFTER_RELOAD, BEFORE_PARENT_LOAD, BEFORE_RELOAD
 
Constructor Summary
ReloadLogger()
          Construct a new ReloadLogger wich will use System.out for logging.
ReloadLogger(java.io.PrintStream out)
          Construct a new ReloadLogger for the specified PrintStream.
 
Method Summary
 void actionPerformed(int action, java.lang.String name, java.lang.String mainClassName, java.lang.ClassLoader loader)
          Reloader calls this method every time it tries to load a class.
 java.lang.String getMessagePrefix()
          Returns current prefix for logger messages.
static boolean loggingEnabled()
          Returns true if the logging is on.
static void setLoggingOff()
          Turns the logging off.
static void setLoggingOn()
          Turns the logging on.
 void setMessagePrefix(java.lang.String prefix)
          Sets the prefix for all logger messages.
 void setOutStream(java.io.PrintStream out)
          Sets the output stream for logging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGING_ENABLE_PROPERTY

public static final java.lang.String LOGGING_ENABLE_PROPERTY
Constructor Detail

ReloadLogger

public ReloadLogger()
Construct a new ReloadLogger wich will use System.out for logging.

ReloadLogger

public ReloadLogger(java.io.PrintStream out)
Construct a new ReloadLogger for the specified PrintStream.
Parameters:
out - output stream to use for logging
Method Detail

setLoggingOn

public static void setLoggingOn()
Turns the logging on.

setLoggingOff

public static void setLoggingOff()
Turns the logging off.

loggingEnabled

public static boolean loggingEnabled()
Returns true if the logging is on.
Returns:
true if the logging is on

setOutStream

public void setOutStream(java.io.PrintStream out)
Sets the output stream for logging.
Parameters:
out - stream to use for logging

setMessagePrefix

public void setMessagePrefix(java.lang.String prefix)
Sets the prefix for all logger messages. The default is ""[Reloader] ".
Parameters:
prefix - prefix for messages

getMessagePrefix

public java.lang.String getMessagePrefix()
Returns current prefix for logger messages.
Returns:
prefix

actionPerformed

public void actionPerformed(int action,
                            java.lang.String name,
                            java.lang.String mainClassName,
                            java.lang.ClassLoader loader)
Reloader calls this method every time it tries to load a class. ReloadLogger only logs AFTER_RELOAD and ignores other events.
Specified by:
actionPerformed in interface LoadActionListener
Parameters:
action - type of a loading event, such as "before loading by reloader", "successful loading by reloader", "successful loading by parent loader" and so on. See Actions class for details.
name - name of a class being loaded.
mainClassName - name of the "main" class, i.e., the class passed as a parameter to reload method.
loader - the actual class loader used to load a class. Can be a class loader created by Reloader or a parent class loader, such as system class loader.


Copyright © 2001 Alexander Ananiev & MyArch.com. All Rights Reserved.