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