FileDocCategorySizeDatePackage
AMXDebugHelper.javaAPI DocGlassfish v2 API5147Fri May 04 22:30:50 BST 2007com.sun.appserv.management.helper

AMXDebugHelper

public final class AMXDebugHelper extends Object
Convenient wrapper around {@link AMXDebug}. Can be made non-final if necessary; declared as 'final' until needed. Note that the "-DAMX-DEBUG=true" must be set in order to see any output.

(Omit source code)

Fields Summary
private final com.sun.appserv.management.util.misc.Output
mOutput
private final String
mName
volatile boolean
mEchoToStdOut
Constructors Summary
public AMXDebugHelper(String name)

        mOutput  = AMXDebug.getInstance().getOutput( name );
        mName   = name;
        
        mEchoToStdOut   = false;
    
public AMXDebugHelper()

        this( "debug" );
    
Methods Summary
public voiddumpStack(java.lang.String msg)

        if ( getDebug() )
        {
            println();
            println( "STACK DUMP FOLLOWS: " + msg);
            println( StringUtil.toString( new Exception( "not a real exception" ) ) );
            println();
        }
    
public booleangetDebug()

        return AMXDebug.getInstance().getDebug( mName );
    
public booleangetEchoToStdOut(boolean echo)

        return mEchoToStdOut;
    
public voidprintln(java.lang.Object items)
This form is preferred for multiple arguments so that String concatenation can be avoided when no message will actually be output. For example, use:
println( a, b, c)
instead of:
println( a + b + c )

        if ( getDebug() && items != null )
        {
            String msg  = null;
            
            if ( items.length == 1 )
            {
                msg = StringUtil.toString( items[0] );
            }
            else
            {
                msg = StringUtil.toString( "", (Object[])items );
            }
            printlnWithTime( msg );
        }
    
public voidprintln(java.lang.Object o)

        if ( getDebug() )
        {
            printlnWithTime( "" + StringUtil.toString(o) );
        }
    
public voidprintln()

        println( "" );
    
private voidprintlnWithTime(java.lang.String s)

         final long now  = System.currentTimeMillis();
         final String msg   = now + ": " + s;
         
         mOutput.println( msg );
         if ( mEchoToStdOut )
         {
            System.out.println( msg );
         }
    
public voidsetDebug(boolean debug)

        AMXDebug.getInstance().setDebug( mName, debug );
    
public voidsetEchoToStdOut(boolean echo)

        mEchoToStdOut   = echo;