1 10 11 package org.mule.config; 12 13 import javax.naming.Name ; 14 import javax.naming.NamingException ; 15 16 import java.util.Collections ; 17 import java.util.HashMap ; 18 import java.util.Map ; 19 20 public class NamingExceptionReader implements ExceptionReader 21 { 22 25 protected static final String MISSING_NAME_DISPLAY_VALUE = "<none>"; 26 27 public String getMessage(Throwable t) 28 { 29 return (t instanceof NamingException ? ((NamingException )t).toString(true) : "<unknown>"); 30 } 31 32 public Throwable getCause(Throwable t) 33 { 34 return (t instanceof NamingException ? ((NamingException )t).getCause() : null); 35 } 36 37 public Class getExceptionType() 38 { 39 return NamingException .class; 40 } 41 42 48 public Map getInfo(Throwable t) 49 { 50 if (t instanceof NamingException ) 51 { 52 NamingException e = (NamingException )t; 53 Map info = new HashMap (); 54 final Name remainingName = e.getRemainingName(); 55 final Name resolvedName = e.getResolvedName(); 56 info.put("Remaining Name", remainingName == null 57 ? MISSING_NAME_DISPLAY_VALUE : remainingName.toString()); 58 info.put("Resolved Name", resolvedName == null ? MISSING_NAME_DISPLAY_VALUE : resolvedName.toString()); 59 return info; 60 } 61 else 62 { 63 return Collections.EMPTY_MAP; 64 } 65 } 66 } 67 | Popular Tags |