1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.config.spring; |
12 | |
|
13 | |
import org.springframework.beans.factory.parsing.FailFastProblemReporter; |
14 | |
import org.springframework.beans.factory.parsing.Problem; |
15 | |
import org.w3c.dom.Element; |
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | 0 | public class MissingParserProblemReporter extends FailFastProblemReporter |
24 | |
{ |
25 | |
|
26 | |
public static final String NO_PARSER_PREFIX = "Cannot locate BeanDefinitionParser"; |
27 | |
|
28 | |
|
29 | |
public void fatal(Problem problem) |
30 | |
{ |
31 | 0 | if (isMissingParser(problem)) |
32 | |
{ |
33 | 0 | problem = extendProblemDetails(problem); |
34 | |
} |
35 | 0 | super.fatal(problem); |
36 | 0 | } |
37 | |
|
38 | |
protected boolean isMissingParser(Problem problem) |
39 | |
{ |
40 | |
|
41 | 0 | String message = problem.getMessage(); |
42 | 0 | return (null != message && message.startsWith(NO_PARSER_PREFIX)); |
43 | |
} |
44 | |
|
45 | |
protected Problem extendProblemDetails(Problem problem) |
46 | |
{ |
47 | |
try |
48 | |
{ |
49 | 0 | String element = ((Element) problem.getLocation().getSource()).getLocalName(); |
50 | 0 | String namespace = ((Element) problem.getLocation().getSource()).getNamespaceURI(); |
51 | 0 | String message = "The element '" + element + "' does not have an associated Bean Definition Parser." |
52 | |
+" Is the module or transport associated with " + namespace + " present on the classpath?"; |
53 | 0 | return new Problem(message, problem.getLocation(), problem.getParseState(), problem.getRootCause()); |
54 | |
} |
55 | 0 | catch (Exception e) |
56 | |
{ |
57 | |
|
58 | 0 | return problem; |
59 | |
} |
60 | |
} |
61 | |
|
62 | |
} |