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