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
56 Map<String, Object> info = new HashMap<String, Object>();
57 final Name remainingName = e.getRemainingName();
58 final Name resolvedName = e.getResolvedName();
59 info.put("Remaining Name", remainingName == null ?
60 MISSING_NAME_DISPLAY_VALUE : remainingName.toString());
61 info.put("Resolved Name", resolvedName == null ?
62 MISSING_NAME_DISPLAY_VALUE : resolvedName.toString());
63 return info;
64 }
65 else
66 {
67 return Collections.EMPTY_MAP;
68 }
69 }
70 }