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