package org.jboss.mx.util;
import java.lang.reflect.Method;
import javax.management.InstanceNotFoundException;
import javax.management.AttributeNotFoundException;
import javax.management.InvalidAttributeValueException;
import javax.management.MBeanException;
import javax.management.ReflectionException;
import javax.management.RuntimeOperationsException;
import javax.management.RuntimeMBeanException;
import javax.management.RuntimeErrorException;
public class DefaultExceptionHandler
implements ProxyExceptionHandler
{
public Object handleInstanceNotFound(ProxyContext ctx,
InstanceNotFoundException e,
Method m, Object[] args)
throws Exception
{
throw new RuntimeProxyException("Instance not found: " + e.toString());
}
public Object handleAttributeNotFound(ProxyContext ctx,
AttributeNotFoundException e,
Method m, Object[] args)
throws Exception
{
throw new RuntimeProxyException("Attribute not found: " + e.toString());
}
public Object handleInvalidAttributeValue(ProxyContext ctx,
InvalidAttributeValueException e,
Method m, Object[] args)
throws Exception
{
throw new RuntimeProxyException("Invalid attribute value: " + e.toString());
}
public Object handleMBeanException(ProxyContext ctx, MBeanException e,
Method m, Object[] args)
throws Exception
{
throw e.getTargetException();
}
public Object handleReflectionException(ProxyContext ctx,
ReflectionException e,
Method m, Object[] args)
throws Exception
{
Exception target = e.getTargetException();
if (target instanceof RuntimeException)
throw target;
else
throw new RuntimeProxyException(target.toString());
}
public Object handleRuntimeOperationsException(ProxyContext ctx,
RuntimeOperationsException e,
Method m, Object[] args)
throws Exception
{
throw e.getTargetException();
}
public Object handleRuntimeMBeanException(ProxyContext ctx,
RuntimeMBeanException e,
Method m, Object[] args)
throws Exception
{
throw e.getTargetException();
}
public Object handleRuntimeError(ProxyContext ctx, RuntimeErrorException e,
Method m, Object[] args)
throws Exception
{
throw e.getTargetError();
}
}