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