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