1 23 24 29 package com.sun.appserv.management.util.jmx; 30 31 import javax.management.*; 32 import java.io.IOException ; 33 import java.io.PrintStream ; 34 import java.util.Set ; 35 36 import com.sun.appserv.management.util.misc.DebugState; 37 import com.sun.appserv.management.util.misc.Output; 38 39 40 41 51 public class MBeanServerConnection_Debug 52 extends MBeanServerConnection_Hook 53 { 54 final MBeanServerConnection_Hook.Hook mHook; 55 final DebugState mDebugState; 56 final Output mOutput; 57 58 public 59 MBeanServerConnection_Debug( 60 MBeanServerConnection impl, 61 DebugState debugState, 62 Output output ) 63 { 64 super( impl ); 65 66 mDebugState = debugState; 67 mOutput = output; 68 mHook = new DebugHook(); 69 } 70 71 Hook 72 getHook() 73 { 74 return( mHook ); 75 } 76 77 final DebugState 78 getDebugState() 79 { 80 return( mDebugState ); 81 } 82 83 private final static Object [] EMPTY_ARRAY = new Object [ 0 ]; 84 85 private class DebugHook extends MBeanServerConnection_Hook.HookImpl 86 { 87 public 88 DebugHook() 89 { 90 } 91 92 final void 93 printDebug( Object o ) 94 { 95 if ( getDebugState().getDebug() ) 96 { 97 mOutput.printDebug( o ); 98 } 99 } 100 101 public long 102 preHook( String methodName ) 103 { 104 return( preHook( methodName, EMPTY_ARRAY ) ); 105 } 106 107 public long 108 preHook( String methodName, Object [] args ) 109 { 110 final long id = getNewID(); 111 112 printDebug( "pre: " + getInvocationString( id, methodName, args ) ); 113 114 return( id ); 115 } 116 117 public void 118 postHook( long id, String methodName ) 119 { 120 printDebug( "post: " + getInvocationString( id, methodName, null ) ); 121 } 122 123 public void 124 postHook( long id, String methodName, Object [] args ) 125 { 126 printDebug( "post: " + getInvocationString( id, methodName, args ) ); 127 } 128 129 public void 130 postHook( long id, String methodName, Object [] args, Object result ) 131 { 132 final String resultString = result == null ? 133 "null" : result.getClass().getName() + " => " + result.toString(); 134 135 printDebug( "post: " + 136 getInvocationString( id, methodName, args ) + resultString ); 137 } 138 } 139 }; 140 141 | Popular Tags |