1
2
3
4
5
6
7
8
9
10
11 package org.mule.tools.visualizer.processor;
12
13 import org.mule.tools.visualizer.config.ColorRegistry;
14 import org.mule.tools.visualizer.config.GraphEnvironment;
15 import org.mule.tools.visualizer.util.MuleTag;
16
17 import com.oy.shared.lm.graph.Graph;
18 import com.oy.shared.lm.graph.GraphNode;
19
20 import org.jdom.Element;
21
22 public class ExceptionStrategyProcessor extends TagProcessor
23 {
24
25 public ExceptionStrategyProcessor(GraphEnvironment environment)
26 {
27 super(environment);
28 }
29
30 public void process(Graph graph, Element currentElement, GraphNode parent)
31 {
32 String edgeCaption = MuleTag.ELEMENT_CATCH_ALL_STRATEGY;
33 Element exceptionStrategy = currentElement.getChild(edgeCaption);
34 if (exceptionStrategy == null)
35 {
36 edgeCaption = MuleTag.ELEMENT_EXCEPTION_STRATEGY;
37 exceptionStrategy = currentElement.getChild(edgeCaption);
38
39 }
40
41 if (exceptionStrategy != null)
42 {
43 String className = exceptionStrategy.getAttributeValue(MuleTag.ATTRIBUTE_CLASS_NAME);
44 GraphNode exceptionNode = graph.addNode();
45 exceptionNode.getInfo().setHeader(className);
46 exceptionNode.getInfo().setFillColor(ColorRegistry.COLOR_EXCEPTION_STRATEGY);
47
48 addEdge(graph, parent, exceptionNode, edgeCaption, false);
49 Element endpoint = exceptionStrategy.getChild(MuleTag.ELEMENT_ENDPOINT);
50 if (endpoint == null)
51 {
52 endpoint = exceptionStrategy.getChild(MuleTag.ELEMENT_GLOBAL_ENDPOINT);
53 }
54 if (endpoint != null)
55 {
56 String url = endpoint.getAttributeValue(MuleTag.ATTRIBUTE_ADDRESS);
57 if (url == null)
58 {
59 url = endpoint.getAttributeValue(MuleTag.ATTRIBUTE_NAME);
60 }
61 if (url != null)
62 {
63 GraphNode out = getEnvironment().getEndpointRegistry().getEndpoint(url,
64 parent.getInfo().getHeader());
65 if (out == null)
66 {
67 out = graph.addNode();
68 out.getInfo().setCaption(url);
69 getEnvironment().getEndpointRegistry().addEndpoint(url, out);
70 }
71 addEdge(graph, exceptionNode, out, "out", false);
72 }
73 }
74 }
75
76 }
77 }