1 7 8 package com.sun.jmx.mbeanserver; 9 10 11 12 14 import java.lang.reflect.Method ; 15 import java.lang.reflect.Constructor ; 16 import java.lang.reflect.InvocationTargetException ; 17 import java.lang.ref.WeakReference ; 18 import java.security.AccessController ; 19 import java.security.PrivilegedAction ; 20 import java.util.Hashtable ; 21 import java.util.Iterator ; 22 import java.io.PrintWriter ; 23 import java.io.StringWriter ; 24 25 import javax.management.* ; 27 import com.sun.jmx.trace.Trace; 28 import com.sun.jmx.mbeanserver.GetPropertyAction; 29 30 37 class StandardMetaDataImpl extends BaseMetaDataImpl { 38 39 40 41 private final static String dbgTag = "StandardMetaDataImpl"; 42 43 46 private static java.util.Map mbeanInfoCache = 47 new java.util.WeakHashMap (); 48 49 52 private static java.util.Map mbeanInterfaceCache = 53 new java.util.WeakHashMap (); 54 55 62 private final boolean wrapRuntimeExceptions; 63 64 67 private final static Hashtable primitiveClasses = new Hashtable (8); 79 { 80 primitiveClasses.put(Boolean.TYPE.toString(), Boolean.TYPE); 81 primitiveClasses.put(Character.TYPE.toString(), Character.TYPE); 82 primitiveClasses.put(Byte.TYPE.toString(), Byte.TYPE); 83 primitiveClasses.put(Short.TYPE.toString(), Short.TYPE); 84 primitiveClasses.put(Integer.TYPE.toString(), Integer.TYPE); 85 primitiveClasses.put(Long.TYPE.toString(), Long.TYPE); 86 primitiveClasses.put(Float.TYPE.toString(), Float.TYPE); 87 primitiveClasses.put(Double.TYPE.toString(), Double.TYPE); 88 } 89 90 91 92 95 public StandardMetaDataImpl() { 96 this(true); 97 } 98 99 StandardMetaDataImpl(boolean wrapRuntimeExceptions) { 100 this.wrapRuntimeExceptions = wrapRuntimeExceptions; 101 } 102 103 114 public synchronized MBeanInfo buildMBeanInfo(Class c) 115 throws NotCompliantMBeanException { 116 return Introspector.testCompliance(c); 117 } 118 119 135 public synchronized 136 MBeanInfo buildMBeanInfo(Class c, Class mbeanInterface) 137 throws NotCompliantMBeanException { 138 return Introspector.testCompliance(c,mbeanInterface); 139 } 140 141 144 public synchronized void testCompliance(Class c) 145 throws NotCompliantMBeanException { 146 149 final MBeanInfo mbeanInfo = buildMBeanInfo(c); 150 final Class mbeanInterface = Introspector.getMBeanInterface(c); 151 cacheMBeanInfo(c,mbeanInterface,mbeanInfo); 152 } 153 154 159 public synchronized void testCompliance(Class c, Class mbeanInterface) 160 throws NotCompliantMBeanException { 161 164 final MBeanInfo mbeanInfo = 165 buildMBeanInfo(c,mbeanInterface); 166 if (mbeanInterface == null) 167 mbeanInterface = Introspector.getStandardMBeanInterface(c); 168 cacheMBeanInfo(c,mbeanInterface,mbeanInfo); 169 } 170 171 174 public Class getMBeanInterfaceFromClass(Class c) { 175 final Class itf = getCachedMBeanInterface(c); 176 if (itf != null) return itf; 177 synchronized (this) { 178 return Introspector.getMBeanInterface(c); 179 } 180 } 181 182 186 public Class getStandardMBeanInterface(Class c) { 187 synchronized (this) { 188 return Introspector.getStandardMBeanInterface(c); 189 } 190 } 191 192 207 public MBeanInfo getMBeanInfoFromClass(Class beanClass) 208 throws IntrospectionException, NotCompliantMBeanException { 209 210 MBeanInfo bi = getCachedMBeanInfo(beanClass); 212 213 if (bi != null) return (MBeanInfo) bi.clone() ; 215 216 testCompliance(beanClass); 219 220 bi = getCachedMBeanInfo(beanClass);; 221 222 if (bi != null) return (MBeanInfo) bi.clone() ; 224 return bi; 225 } 226 227 228 234 public String getMBeanClassName(Object moi) 235 throws IntrospectionException, NotCompliantMBeanException { 236 return moi.getClass().getName(); 237 } 238 239 public MBeanInfo getMBeanInfo(Object moi) 240 throws IntrospectionException { 241 try { 242 final MBeanInfo mbi = getMBeanInfoFromClass(moi.getClass()); 243 return new MBeanInfo(mbi.getClassName(), mbi.getDescription(), 244 mbi.getAttributes(), 245 mbi.getConstructors(), 246 mbi.getOperations(), 247 findNotifications(moi)); 248 } catch (NotCompliantMBeanException x) { 249 debugX("getMBeanInfo",x); 250 throw new IntrospectionException("Can't build MBeanInfo for "+ 251 moi.getClass().getName()); 252 } 253 } 254 255 public Object getAttribute(Object instance, String attribute) 256 throws MBeanException, AttributeNotFoundException, 257 ReflectionException { 258 259 Class mbeanClass = getMBeanInterfaceFromInstance(instance); 260 if (isDebugOn()) { 261 debug("getAttribute","MBean Class is " + instance.getClass()); 262 debug("getAttribute","MBean Interface is " + mbeanClass); 263 } 264 265 return getAttribute(instance, attribute, mbeanClass); 266 } 267 268 269 public AttributeList getAttributes(Object instance, String [] attributes) 270 throws ReflectionException { 271 272 final Class mbeanClass = 273 getMBeanInterfaceFromInstance(instance); 274 275 if (isDebugOn()) { 276 debug("getAttributes","MBean Class is " + instance.getClass()); 277 debug("getAttributes","MBean Interface is " + mbeanClass); 278 } 279 280 if (attributes == null) { 281 throw new RuntimeOperationsException(new 282 IllegalArgumentException ("Attributes cannot be null"), 283 "Exception occured trying to invoke the getter on the MBean"); 284 } 285 286 final int maxLimit = attributes.length; 289 final AttributeList result = new AttributeList(maxLimit); 290 291 for (int i=0;i<maxLimit;i++) { 292 final String elmt = (String )attributes[i]; 293 try { 294 final Object value = 295 getAttribute(instance, elmt, mbeanClass); 296 result.add(new Attribute(elmt, value)); 297 } catch (Exception excep) { 298 if (isDebugOn()) { 299 debug("getAttributes", "Object= " + instance + 300 ", Attribute=" + elmt + " failed: " + excep); 301 } 302 } 303 } 304 return result; 305 } 306 307 308 public AttributeList setAttributes(Object instance, 309 AttributeList attributes) 310 throws ReflectionException { 311 312 final Class objClass = instance.getClass(); 313 final Class mbeanClass = getMBeanInterfaceFromInstance(instance); 314 final ClassLoader aLoader = objClass.getClassLoader(); 315 316 if (isDebugOn()) { 317 debug("setAttributes","MBean Class is " + instance.getClass()); 318 debug("setAttributes","MBean Interface is " + mbeanClass); 319 } 320 321 if (attributes == null) return new AttributeList(); 322 323 final AttributeList result = new AttributeList(attributes.size()); 324 325 for (final Iterator i = attributes.iterator(); i.hasNext();) { 327 final Attribute attr = (Attribute) i.next(); 328 final String id = attr.getName(); 329 final Object value = attr.getValue(); 330 try { 331 final Object newValue = 332 setAttribute(instance, attr, mbeanClass); 333 if (isTraceOn()) { 334 trace("setAttributes", "Updating the list\n"); 335 } 336 result.add(new Attribute(id, newValue)); 337 } catch (Exception excep) { 338 if (isDebugOn()) { 339 debug("setAttributes", "Unexpected exception occured: " + 340 excep.getClass().getName()); 341 } 342 } 343 } 344 return result; 345 346 } 347 348 public Object setAttribute(Object instance, Attribute attribute) 349 throws AttributeNotFoundException, InvalidAttributeValueException, 350 MBeanException, ReflectionException { 351 352 final Class mbeanClass = 353 getMBeanInterfaceFromInstance(instance); 354 355 if (isDebugOn()) { 356 debug("setAttribute","MBean Class is " + instance.getClass()); 357 debug("setAttribute","MBean Interface is " + mbeanClass); 358 } 359 360 return setAttribute(instance,attribute,mbeanClass); 361 } 362 363 public Object invoke(Object instance, String operationName, 364 Object params[], String signature[]) 365 throws MBeanException, ReflectionException { 366 367 if (operationName == null) { 368 final RuntimeException r = 369 new IllegalArgumentException ("Operation name cannot be null"); 370 throw new RuntimeOperationsException(r, 371 "Exception occured trying to invoke the operation on the MBean"); 372 } 373 374 final Class objClass = instance.getClass(); 375 final Class mbeanClass = getMBeanInterfaceFromInstance(instance); 376 final ClassLoader aLoader = objClass.getClassLoader(); 377 378 if (isDebugOn()) { 379 debug("invoke","MBean Class is " + instance.getClass()); 380 debug("invoke","MBean Interface is " + mbeanClass); 381 } 382 383 final Class [] tab = 386 ((signature == null)?null: 387 findSignatureClasses(signature,aLoader)); 388 389 Method mth= findMethod(mbeanClass, operationName, tab); 392 393 if (mth == null) { 394 if (isTraceOn()) { 395 trace("invoke", operationName + " not found in class " + 396 mbeanClass.getName()); 397 } 398 throw new ReflectionException( 399 new NoSuchMethodException (operationName), 400 "The operation with name " + operationName + 401 " could not be found"); 402 } 403 404 forbidInvokeGetterSetter(mth, operationName); 407 408 if (isTraceOn()) { 410 trace("invoke", "Invoking " + operationName); 411 } 412 Object result=null; 413 try { 414 result= mth.invoke(instance, params); 415 } catch (IllegalAccessException e) { 416 debugX("invoke",e); 417 throw new ReflectionException(e, "IllegalAccessException" + 418 " occured trying to invoke operation " + operationName); 419 } catch (RuntimeException e) { 420 debugX("invoke",e); 421 throw new RuntimeOperationsException(e, "RuntimeException" + 422 " occured trying to invoke operation " + operationName); 423 } catch (InvocationTargetException e) { 424 Throwable t = e.getTargetException(); 426 debugX("invoke",t); 427 if (t instanceof RuntimeException ) { 428 final String msg = "RuntimeException thrown in operation " + 429 operationName; 430 throw wrapRuntimeException((RuntimeException ) t, msg); 431 } else if (t instanceof Error ) { 432 throw new RuntimeErrorException((Error ) t, 433 "Error thrown in operation " + operationName); 434 } else { 435 throw new MBeanException((Exception ) t, 436 "Exception thrown in operation " + operationName); 437 } 438 } 439 if (isTraceOn()) { 440 trace("invoke", "Send the result"); 441 } 442 return (result); 443 } 444 445 private static boolean startsWithAndHasMore(String s, String prefix) { 446 return (s.startsWith(prefix) && s.length() > prefix.length()); 447 } 448 449 private static void forbidInvokeGetterSetter(Method mth, 450 String operationName) 451 throws ReflectionException { 452 453 final Class argTypes[] = mth.getParameterTypes(); 454 final Class resultType = mth.getReturnType(); 455 final int argCount = argTypes.length; 456 457 boolean isInvokeGetterSetter = false; 458 459 switch (argCount) { 460 case 0: if ((startsWithAndHasMore(operationName, "get") && 462 resultType != Void.TYPE) || 463 (startsWithAndHasMore(operationName, "is") && 464 resultType == Boolean.TYPE)) { 465 isInvokeGetterSetter = true; 467 } 468 break; 469 470 case 1: if (startsWithAndHasMore(operationName, "set") && 472 resultType == Void.TYPE) { 473 isInvokeGetterSetter = true; 475 } 476 break; 477 } 478 479 if (isInvokeGetterSetter) { 480 boolean allow; 481 try { 482 GetPropertyAction getProp = 483 new GetPropertyAction("jmx.invoke.getters"); 484 allow = (AccessController.doPrivileged(getProp) != null); 485 } catch (SecurityException e) { 486 allow = false; 488 } 489 if (!allow) { 490 final String msg = 491 "Cannot invoke getter or setter (" + operationName + 492 ") as operation unless jmx.invoke.getters property is set"; 493 final Exception nested = 494 new NoSuchMethodException (operationName); 495 throw new ReflectionException(nested, msg); 496 } 497 } 498 } 499 500 public boolean isInstanceOf(Object instance, String className) 501 throws ReflectionException { 502 503 final Class c = 504 findClass(className, instance.getClass().getClassLoader()); 505 506 return c.isInstance(instance); 507 } 508 509 516 Class getMBeanInterfaceFromInstance(Object instance) { 517 if (instance == null) return null; 518 return getMBeanInterfaceFromClass(instance.getClass()); 519 } 520 521 544 void cacheMBeanInfo(Class c, Class mbeanInterface, 545 MBeanInfo info) 546 throws NotCompliantMBeanException { 547 if (info != null) { 548 synchronized (mbeanInfoCache) { 549 if (mbeanInfoCache.get(c) == null) { 550 mbeanInfoCache.put(c, info); 551 } 552 } 553 } 554 if (mbeanInterface != null) { 555 synchronized (mbeanInterfaceCache) { 556 if ((mbeanInterfaceCache.get(c) == null) || (((WeakReference )mbeanInterfaceCache.get(c)).get() == null)) { 557 mbeanInterfaceCache.put(c, new WeakReference (mbeanInterface)); 558 } 559 } 560 } 561 } 562 563 568 Class getCachedMBeanInterface(Class c) { 569 synchronized (mbeanInterfaceCache) { 570 return (Class )(((WeakReference )mbeanInterfaceCache.get(c)).get()); 571 } 572 } 573 574 579 MBeanInfo getCachedMBeanInfo(Class c) { 580 synchronized (mbeanInfoCache) { 581 return (MBeanInfo)mbeanInfoCache.get(c); 582 } 583 } 584 585 588 Class findClass(String className, ClassLoader loader) 589 throws ReflectionException { 590 return MBeanInstantiatorImpl.loadClass(className, 591 loader); 592 } 593 594 597 Class [] findSignatureClasses(String [] signature, 598 ClassLoader loader) 599 throws ReflectionException { 600 return ((signature == null)?null: 601 MBeanInstantiatorImpl.loadSignatureClasses(signature,loader)); 602 } 603 604 607 Object getAttribute(Object instance, String attribute, 608 Class mbeanClass) 609 throws MBeanException, AttributeNotFoundException, 610 ReflectionException { 611 612 if (attribute == null) { 613 final RuntimeException r = 614 new IllegalArgumentException ("Attribute name cannot be null"); 615 throw new RuntimeOperationsException(r, 616 "Exception occured trying to invoke the getter on the MBean"); 617 } 618 619 Method meth = null; 621 meth = findGetter(mbeanClass, attribute); 622 if (meth == null) { 623 if (isTraceOn()) { 624 trace("getAttribute", "Cannot find getter for "+attribute+ 625 " in class " + mbeanClass.getName()); 626 } 627 throw new AttributeNotFoundException(attribute + 628 " not accessible"); 629 } 630 631 if (isTraceOn()) { 633 trace("getAttribute", "Invoke callback"); 634 } 635 Object result= null; 636 try { 637 result = meth.invoke(instance, (Object []) null); 638 } catch (InvocationTargetException e) { 639 Throwable t = e.getTargetException(); 640 if (t instanceof RuntimeException ) { 641 debugX("getAttribute",t); 642 final String msg = 643 "RuntimeException thrown in the getter for the attribute " 644 + attribute; 645 throw wrapRuntimeException((RuntimeException ) t, msg); 646 } else if (t instanceof Error ) { 647 debugX("getAttribute",t); 648 throw new RuntimeErrorException((Error ) t , 649 "Error thrown in the getter for the attribute " + 650 attribute); 651 } else { 652 debugX("getAttribute",t); 653 throw new MBeanException((Exception ) t, 654 "Exception thrown in the getter for the attribute " + 655 attribute); 656 } 657 } catch (RuntimeException e) { 658 debugX("getAttribute",e); 659 throw new RuntimeOperationsException(e, 660 "RuntimeException thrown trying to invoke the getter" + 661 " for the attribute " + attribute); 662 } catch (IllegalAccessException e) { 663 debugX("getAttribute",e); 664 throw new ReflectionException(e, "Exception thrown trying to" + 665 " invoke the getter for the attribute " + attribute); 666 } catch (Error e) { 667 debugX("getAttribute",e); 668 throw new RuntimeErrorException((Error )e, 669 "Error thrown trying to invoke the getter " + 670 " for the attribute " + attribute); 671 } 672 673 if (isTraceOn()) { 674 trace("getAttribute", attribute + "= " + result + "\n"); 675 } 676 return result; 677 } 678 679 682 Object setAttribute(Object instance, Attribute attribute, 683 Class mbeanClass) 684 throws AttributeNotFoundException, InvalidAttributeValueException, 685 MBeanException, ReflectionException { 686 687 if (attribute == null) { 688 final RuntimeException r = 689 new IllegalArgumentException ("Attribute name cannot be null"); 690 throw new RuntimeOperationsException(r, 691 "Exception occured trying to invoke the setter on the MBean"); 692 } 693 694 final Class objClass = instance.getClass(); 695 final ClassLoader aLoader = objClass.getClassLoader(); 696 697 Object result = null; 698 final Object value = attribute.getValue(); 699 final String attname = attribute.getName(); 700 701 Method meth = null; 704 705 if (value == null) { 706 meth = findSetter(mbeanClass, attname); 707 } else { 708 meth = findSetter(mbeanClass, attname, value.getClass()); 709 } 710 if (meth == null) { 711 Class primClass = findPrimForClass(value); 713 714 if (primClass != null) { 715 meth = findSetter(mbeanClass, attname, primClass); 716 } 717 } 718 if (meth == null) { 719 meth= findSetter(mbeanClass, attname); 722 if (meth == null) { 723 if (isTraceOn()) { 724 trace("setAttribute", "Cannot find setter for "+attribute+ 725 " in class " + mbeanClass.getName()); 726 } 727 throw new AttributeNotFoundException( attname + 728 " not accessible"); 729 } else { 730 final Object v = attribute.getValue(); 731 if (v == null) { 732 throw new InvalidAttributeValueException("attribute= " + 733 attname + " value = null"); 734 } else { 735 throw new InvalidAttributeValueException("attribute= " + 736 attname + " value = " + v); 737 } 738 } 739 } 740 if (isTraceOn()) { 742 trace("setAttribute", "Invoking the set method for " + 743 attname); 744 } 745 746 final Object [] values = new Object [1]; 747 values[0] = value; 748 749 try { 750 result = meth.invoke(instance,values); 751 } catch (IllegalAccessException e) { 752 debugX("setAttribute",e); 753 throw new ReflectionException(e, "IllegalAccessException" + 755 " occured trying to invoke the setter on the MBean"); 756 } catch (InvocationTargetException e) { 757 Throwable t = e.getTargetException(); 758 debugX("setAttribute",t); 759 if (t instanceof RuntimeException ) { 760 final String msg = 761 "RuntimeException thrown in the setter for the attribute " 762 + attribute; 763 throw wrapRuntimeException((RuntimeException ) t, msg); 764 } else if (t instanceof Error ) { 765 throw new RuntimeErrorException((Error ) t, 766 "Error thrown in the MBean's setter"); 767 } else { 768 throw new MBeanException((Exception ) t, 769 "Exception thrown in the MBean's setter"); 770 } 771 } 772 if (isTraceOn()) { 773 trace("setAttribute", attname + "= " + value); 774 } 775 return value; 776 } 777 778 779 783 MBeanNotificationInfo[] findNotifications(Object moi) { 784 785 if (moi instanceof javax.management.NotificationBroadcaster ) { 786 MBeanNotificationInfo[] mbn = 787 ((NotificationBroadcaster)moi).getNotificationInfo(); 788 if (mbn == null) { 789 return new MBeanNotificationInfo[0]; 790 } 791 MBeanNotificationInfo[] result = 792 new MBeanNotificationInfo[mbn.length]; 793 for (int i = 0; i < mbn.length; i++) { 794 result[i] = (MBeanNotificationInfo) mbn[i].clone(); 795 } 796 return result; 797 } 798 return new MBeanNotificationInfo[0]; 799 } 800 801 805 public static Method findMethod(Class classObj, String name, 806 Class parameterTypes[]) { 807 Method method=null; 808 try { 809 method= classObj.getMethod(name, parameterTypes); 810 } catch(Exception e) { 811 } 813 814 return method; 815 } 816 817 822 public static Method findMethod(Class classObj, String name) { 823 Method method = null ; 824 825 try { 826 Method [] methods=classObj.getMethods(); 827 int i = 0; 828 while ((i < methods.length) && 829 !methods[i].getName().equals(name)) { 830 i++; 831 } 832 if (i < methods.length) { 833 method = methods[i]; 834 } 835 } catch(Exception e) { 836 } 838 return method; 839 } 840 841 842 846 public static Method findMethod(Class classObj, String name, 847 int paramCount) { 848 849 Method method = null; 850 try { 851 Method [] methods=classObj.getMethods(); 852 int i = 0; 853 boolean found = false; 854 while ((i < methods.length) && !found) { 855 found = methods[i].getName().equals(name); 856 if (found) { found = (methods[i].getParameterTypes().length == 858 paramCount); 859 } 860 i++; 861 } 862 if (found) { 863 method = methods[i-1] ; } 865 } catch(Exception e) { 866 } 868 return method; 869 } 870 871 872 876 public static Method findGetter(Class classObj, String attribute) { 877 if (attribute.length() == 0) 879 return null; 880 881 883 Method m = findMethod(classObj, "get" + attribute, null); 884 if (m != null && m.getReturnType() != void.class) 885 return m; 886 887 888 891 m = findMethod(classObj, "is" + attribute, null); 892 if (m != null && m.getReturnType() == boolean.class) 893 return m; 894 895 return null; 896 } 897 898 899 903 public static Method findSetter(Class classObj, String attribute, 904 Class type) { 905 906 Method mth= findMethod(classObj, "set" + attribute, 1); 907 if (mth != null) { 908 Class [] pars = mth.getParameterTypes(); 909 if (pars[0].isAssignableFrom(type)) { 910 return mth; 911 } 912 } 913 return null; 914 } 915 916 920 public static Method findSetter(Class classObj, String attribute) { 921 return findMethod(classObj, "set" + attribute, 1) ; 922 } 923 924 928 public static Constructor findConstructor(Class theClass, 929 Class parameterTypes[]) { 930 Constructor mth = null; 932 933 try { 934 mth = theClass.getConstructor(parameterTypes); 935 } catch(Exception e) { 936 return null; 937 } 938 return mth; 939 } 940 941 945 public static Class findClassForPrim(String primName) { 946 return (Class ) primitiveClasses.get(primName); 947 } 948 949 953 public static Class findPrimForClass(Object value) { 954 if (value instanceof Boolean ) 955 return Boolean.TYPE; 956 else if (value instanceof Character ) 957 return Character.TYPE; 958 else if (value instanceof Byte ) 959 return Byte.TYPE; 960 else if (value instanceof Short ) 961 return Short.TYPE; 962 else if (value instanceof Integer ) 963 return Integer.TYPE; 964 else if (value instanceof Long ) 965 return Long.TYPE; 966 else if (value instanceof Float ) 967 return Float.TYPE; 968 else if (value instanceof Double ) 969 return Double.TYPE; 970 return null; 971 } 972 973 976 static String [] findSignatures(Class [] clz) { 977 String signers[] = new String [clz.length]; 978 for (int i = 0; i < clz.length; i++) { 979 signers[i] = findSignature(clz[i]); 980 } 981 return signers; 982 } 983 984 987 static String findSignature(Class clz) { 988 return clz.getName(); 989 } 990 991 private RuntimeException wrapRuntimeException(RuntimeException re, 992 String msg) { 993 if (wrapRuntimeExceptions) 994 return new RuntimeMBeanException(re, msg); 995 else 996 return re; 997 } 998 999 1000 1003 private static boolean isTraceOn() { 1004 return Trace.isSelected(Trace.LEVEL_TRACE, Trace.INFO_MBEANSERVER); 1005 } 1006 1007 private static void trace(String clz, String func, String info) { 1008 Trace.send(Trace.LEVEL_TRACE, Trace.INFO_MBEANSERVER, clz, func, info); 1009 } 1010 1011 private static void trace(String func, String info) { 1012 trace(dbgTag, func, info); 1013 } 1014 1015 private static boolean isDebugOn() { 1016 return Trace.isSelected(Trace.LEVEL_DEBUG, Trace.INFO_MBEANSERVER); 1017 } 1018 1019 private static void debug(String clz, String func, String info) { 1020 Trace.send(Trace.LEVEL_DEBUG, Trace.INFO_MBEANSERVER, clz, func, info); 1021 } 1022 1023 private static void debug(String func, String info) { 1024 debug(dbgTag, func, info); 1025 } 1026 1027 private static void debugX(String func,Throwable e) { 1028 if (isDebugOn()) { 1029 final StringWriter s = new StringWriter (); 1030 e.printStackTrace(new PrintWriter (s)); 1031 final String stack = s.toString(); 1032 1033 debug(dbgTag,func,"Exception caught in "+ func+"(): "+e); 1034 debug(dbgTag,func,stack); 1035 1036 } 1040 } 1041 1042} 1043 | Popular Tags |