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 java.util.Iterator;
21 import java.util.List;
22
23 import org.jdom.Element;
24
25 public class InboundRoutersProcessor extends TagProcessor
26 {
27
28 public InboundRoutersProcessor(GraphEnvironment environment)
29 {
30 super(environment);
31
32 }
33
34 public void process(Graph graph, Element currentElement, GraphNode parent)
35 {
36 Element inboundRouter = currentElement.getChild(MuleTag.ELEMENT_INBOUND_ROUTER);
37
38 if (inboundRouter != null)
39 {
40
41 GraphNode endpointsLink = parent;
42
43 Element router = inboundRouter.getChild(MuleTag.ELEMENT_ROUTER);
44 if (router != null)
45 {
46 GraphNode routerNode = graph.addNode();
47 routerNode.getInfo().setHeader(router.getAttributeValue(MuleTag.ATTRIBUTE_CLASS_NAME));
48 routerNode.getInfo().setFillColor(ColorRegistry.COLOR_ROUTER);
49
50 addEdge(graph, routerNode, parent, "inbound router", isTwoWay(router));
51 endpointsLink = routerNode;
52 }
53
54 List inbounEndpoints = inboundRouter.getChildren(MuleTag.ELEMENT_ENDPOINT);
55 for (Iterator iterator = inbounEndpoints.iterator(); iterator.hasNext();)
56 {
57 Element inEndpoint = (Element) iterator.next();
58 String url = inEndpoint.getAttributeValue(MuleTag.ATTRIBUTE_ADDRESS);
59 if (url != null)
60 {
61 GraphNode in = getEnvironment().getEndpointRegistry().getEndpoint(url,
62 parent.getInfo().getHeader());
63 StringBuffer caption = new StringBuffer();
64 if (in == null)
65 {
66 in = graph.addNode();
67 in.getInfo().setFillColor(ColorRegistry.COLOR_ENDPOINT);
68 caption.append(url).append("\n");
69 appendProperties(inEndpoint, caption);
70 appendDescription(inEndpoint, caption);
71 in.getInfo().setCaption(caption.toString());
72 }
73 else
74 {
75
76
77
78 caption.append(url).append("\n");
79 appendProperties(inEndpoint, caption);
80 appendDescription(inEndpoint, caption);
81 in.getInfo().setCaption(caption.toString());
82
83
84
85
86 }
87
88 if (in != null)
89 {
90 InboundFilterProcessor processor = new InboundFilterProcessor(getEnvironment(),
91 endpointsLink);
92 processor.processInboundFilter(graph, inEndpoint, in, endpointsLink);
93 }
94 }
95 }
96
97 }
98 }
99
100 }