1 22 package org.jboss.mx.util; 23 24 import java.lang.reflect.Method ; 25 26 import javax.management.InstanceNotFoundException ; 27 import javax.management.AttributeNotFoundException ; 28 import javax.management.InvalidAttributeValueException ; 29 import javax.management.MBeanException ; 30 import javax.management.ReflectionException ; 31 import javax.management.RuntimeOperationsException ; 32 import javax.management.RuntimeMBeanException ; 33 import javax.management.RuntimeErrorException ; 34 35 42 public class DefaultExceptionHandler 43 implements ProxyExceptionHandler 44 { 45 46 51 public Object handleInstanceNotFound(ProxyContext ctx, 52 InstanceNotFoundException e, 53 Method m, Object [] args) 54 throws Exception 55 { 56 throw new RuntimeProxyException("Instance not found: " + e.toString()); 57 } 58 59 public Object handleAttributeNotFound(ProxyContext ctx, 60 AttributeNotFoundException e, 61 Method m, Object [] args) 62 throws Exception 63 { 64 throw new RuntimeProxyException("Attribute not found: " + e.toString()); 65 } 66 67 public Object handleInvalidAttributeValue(ProxyContext ctx, 68 InvalidAttributeValueException e, 69 Method m, Object [] args) 70 throws Exception 71 { 72 throw new RuntimeProxyException("Invalid attribute value: " + e.toString()); 73 } 74 75 public Object handleMBeanException(ProxyContext ctx, MBeanException e, 76 Method m, Object [] args) 77 throws Exception 78 { 79 throw e.getTargetException(); 83 } 84 85 public Object handleReflectionException(ProxyContext ctx, 86 ReflectionException e, 87 Method m, Object [] args) 88 throws Exception 89 { 90 93 Exception target = e.getTargetException(); 94 if (target instanceof RuntimeException ) 95 throw target; 96 else 97 throw new RuntimeProxyException(target.toString()); 98 } 99 100 public Object handleRuntimeOperationsException(ProxyContext ctx, 101 RuntimeOperationsException e, 102 Method m, Object [] args) 103 throws Exception 104 { 105 throw e.getTargetException(); 107 } 108 109 public Object handleRuntimeMBeanException(ProxyContext ctx, 110 RuntimeMBeanException e, 111 Method m, Object [] args) 112 throws Exception 113 { 114 throw e.getTargetException(); 116 } 117 118 public Object handleRuntimeError(ProxyContext ctx, RuntimeErrorException e, 119 Method m, Object [] args) 120 throws Exception 121 { 122 throw e.getTargetError(); 124 } 125 126 } 127 128 129 130 131 | Popular Tags |