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 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 if (isMissingParser(problem))
32 {
33 problem = extendProblemDetails(problem);
34 }
35 super.fatal(problem);
36 }
37
38 protected boolean isMissingParser(Problem problem)
39 {
40
41 String message = problem.getMessage();
42 return (null != message && message.startsWith(NO_PARSER_PREFIX));
43 }
44
45 protected Problem extendProblemDetails(Problem problem)
46 {
47 try
48 {
49 String element = ((Element) problem.getLocation().getSource()).getLocalName();
50 String namespace = ((Element) problem.getLocation().getSource()).getNamespaceURI();
51 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 return new Problem(message, problem.getLocation(), problem.getParseState(), problem.getRootCause());
54 }
55 catch (Exception e)
56 {
57
58 return problem;
59 }
60 }
61
62 }