FileDocCategorySizeDatePackage
JMXExceptionTranslator.javaAPI DocGlassfish v2 API5462Fri May 04 22:33:16 BST 2007com.sun.enterprise.admin.common

JMXExceptionTranslator

public class JMXExceptionTranslator extends Object

Fields Summary
private static final String
NULL_ARGUMENT
Constructors Summary
Methods Summary
private static java.lang.StringconvertInstanceNotFoundExceptionMessage(java.lang.Exception e)

        /* Here we are trying to extract type and name from exception
         if message is valid ObjectName string representation */
        String type = null;
        String name = null;
        try
        {
            ObjectName objectName = new ObjectName(e.getMessage());
            type = ObjectNameHelper.getType(objectName);
            name = ObjectNameHelper.getName(objectName);
        }
        catch (MalformedObjectNameException mfone)
        {
        }
        String msg;
        if(type!=null)
        {
            if(name!=null)
                msg = type + " '" + name +"' is not found.";
            else
                msg = type + " is not found.";
        }
        else
        {
            //object name is malformed - leave original message
            msg = e.getLocalizedMessage();
        }
        return msg;
    
public static AFExceptiontranslate(java.lang.Exception e)


        
    
        ArgChecker.check((e != null), NULL_ARGUMENT);

        AFException afe = new AFException(e.getMessage());
        if (e instanceof javax.management.MBeanException)
        {
            Exception targetException = 
                ((javax.management.MBeanException)e).getTargetException();
            if (targetException instanceof AFException)
            {
                afe = (AFException) targetException;
            }
            // <addition> srini@sun.com server.xml verifier
            else if(targetException instanceof AFRuntimeException)
            {
                   throw (AFRuntimeException)targetException;
            }
	    else if (targetException instanceof javax.management.MBeanException)
	    {
                Exception excpn = 
			((javax.management.MBeanException)targetException).getTargetException();
		if (excpn != null) {
                   if (excpn instanceof javax.management.InvalidAttributeValueException) {
                      afe = new com.sun.enterprise.admin.common.exception.InvalidAttributeValueException(
				excpn.getLocalizedMessage());
		   }
		}
	    }
            // </addition>		
            else
            {
                afe = new AFOtherException(targetException);
            }
        }
        else if (e instanceof javax.management.InstanceNotFoundException)
        {
            String msg = convertInstanceNotFoundExceptionMessage(e);
            afe = new AFTargetNotFoundException(msg);
        }
        else if (e instanceof javax.management.ReflectionException)
        {
            afe = new AFOtherException(e);
        }
        else if (e instanceof javax.management.AttributeNotFoundException)
        {
            afe = new AttributeNotFoundException(e.getLocalizedMessage());
        }
        else if (e instanceof javax.management.InvalidAttributeValueException)
        {
            afe = new InvalidAttributeValueException(e.getLocalizedMessage());
        }
        else if (e instanceof java.lang.RuntimeException)
        {
            throw (java.lang.RuntimeException) e;
        }
        return afe;