1 23 24 28 package com.sun.enterprise.management.support; 29 30 import javax.management.MBeanServer ; 31 import javax.management.ObjectName ; 32 33 import java.io.File ; 34 35 import com.sun.appserv.management.base.AMXDebug; 36 import com.sun.appserv.management.base.Util; 37 import com.sun.appserv.management.util.misc.FileUtils; 38 39 import com.sun.enterprise.management.support.BootUtil; 40 41 42 44 public final class AMXDebugSupport 45 implements AMXDebugSupportMBean 46 { 47 private final MBeanServer mServer; 48 49 public static final String NAME = "amx-debug"; 50 51 public 52 AMXDebugSupport( final MBeanServer server ) 53 { 54 mServer = server; 55 56 final String domain = 57 BootUtil.getInstance().getAMXSupportJMXDomain(); 58 59 final String props = Util.makeNameProp( NAME); 60 61 final ObjectName objectName = Util.newObjectName( domain, props ); 62 try 63 { 64 mServer.registerMBean( this, objectName ); 65 } 66 catch( Exception e ) 67 { 68 throw new RuntimeException ( e ); 69 } 70 } 71 72 private AMXDebug 73 getAMXDebug() 74 { 75 return AMXDebug.getInstance(); 76 } 77 78 public String [] 79 getOutputIDs() 80 { 81 return AMXDebug.getInstance().getOutputIDs(); 82 } 83 84 public boolean 85 getDefaultDebug() 86 { 87 return getAMXDebug().getDefaultDebug(); 88 } 89 90 public void 91 setDefaultDebug( boolean debug ) 92 { 93 getAMXDebug().setDefaultDebug( debug ); 94 } 95 96 public boolean 97 getDebug( final String id ) 98 { 99 return getAMXDebug().getDebug( id ); 100 } 101 102 public void 103 setDebug( final String id, final boolean debug ) 104 { 105 getAMXDebug().setDebug( id, debug ); 106 } 107 108 public void 109 setAll( final boolean debug ) 110 { 111 getAMXDebug().setAll( debug ); 112 } 113 114 public void 115 cleanup() 116 { 117 getAMXDebug().cleanup(); 118 } 119 120 public String 121 getOutputFrom( final String id ) 122 { 123 String output = ""; 124 125 final File f = getAMXDebug().getOutputFile( id ); 126 if ( f != null && f.exists() ) 127 { 128 try 129 { 130 output = FileUtils.fileToString( f ); 131 } 132 catch( Exception e ) 133 { 134 output = ""; 135 } 136 } 137 138 return output; 139 } 140 } 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | Popular Tags |