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.GraphEnvironment; |
14 | |
import org.mule.tools.visualizer.util.MuleTag; |
15 | |
|
16 | |
import com.oy.shared.lm.graph.Graph; |
17 | |
import com.oy.shared.lm.graph.GraphNode; |
18 | |
|
19 | |
import java.util.Iterator; |
20 | |
import java.util.List; |
21 | |
|
22 | |
import org.jdom.Element; |
23 | |
|
24 | |
public class OutBoundRouterEndpointsHandler extends TagProcessor |
25 | |
{ |
26 | |
|
27 | |
private String componentName; |
28 | |
|
29 | |
public OutBoundRouterEndpointsHandler(GraphEnvironment environment, String componentName) |
30 | |
{ |
31 | 6 | super(environment); |
32 | 6 | this.componentName = componentName; |
33 | 6 | } |
34 | |
|
35 | |
public void process(Graph graph, Element currentElement, GraphNode parent) |
36 | |
{ |
37 | 6 | List epList = currentElement.getChildren(MuleTag.ELEMENT_ENDPOINT); |
38 | 6 | process(graph, epList, parent); |
39 | |
|
40 | 6 | epList = currentElement.getChildren(MuleTag.ELEMENT_GLOBAL_ENDPOINT); |
41 | 6 | process(graph, epList, parent); |
42 | 6 | } |
43 | |
|
44 | |
public void process(Graph graph, List epList, GraphNode parent) |
45 | |
{ |
46 | 12 | int x = 1; |
47 | 18 | for (Iterator iterator = epList.iterator(); iterator.hasNext(); x++) |
48 | |
{ |
49 | 6 | Element outEndpoint = (Element) iterator.next(); |
50 | |
|
51 | 6 | String url = outEndpoint.getAttributeValue(MuleTag.ATTRIBUTE_ADDRESS); |
52 | 6 | if (url == null) |
53 | |
{ |
54 | 0 | url = outEndpoint.getAttributeValue(MuleTag.ATTRIBUTE_NAME); |
55 | |
} |
56 | |
|
57 | 6 | if (url != null) |
58 | |
{ |
59 | 6 | GraphNode out = getEnvironment().getEndpointRegistry().getEndpoint(url, componentName); |
60 | 6 | if (out == null) |
61 | |
{ |
62 | 4 | out = graph.addNode(); |
63 | 4 | StringBuffer caption = new StringBuffer(); |
64 | |
|
65 | 4 | appendProperties(outEndpoint, caption); |
66 | 4 | appendDescription(outEndpoint, caption); |
67 | 4 | out.getInfo().setCaption(caption.toString()); |
68 | 4 | getEnvironment().getEndpointRegistry().addEndpoint(url, out); |
69 | 4 | processOutboundFilter(graph, outEndpoint, out, parent); |
70 | 4 | } |
71 | |
else |
72 | |
{ |
73 | 2 | String caption = "out"; |
74 | 2 | if (epList.size() > 1) |
75 | |
{ |
76 | 0 | caption += " (" + x + " of " + epList.size() + ")"; |
77 | |
} |
78 | 2 | addEdge(graph, parent, out, caption, isTwoWay(outEndpoint)); |
79 | |
|
80 | |
} |
81 | |
} |
82 | |
|
83 | 6 | GraphNode[] virtual = getEnvironment().getEndpointRegistry().getVirtualEndpoint(componentName); |
84 | 6 | if (virtual.length > 0) |
85 | |
{ |
86 | 0 | for (int i = 0; i < virtual.length; i++) |
87 | |
{ |
88 | 0 | addEdge(graph, parent, virtual[i], "out (dynamic)", isTwoWay(outEndpoint)); |
89 | |
} |
90 | |
} |
91 | |
} |
92 | 12 | } |
93 | |
|
94 | |
private void processOutboundFilter(Graph graph, Element outEndpoint, GraphNode out, GraphNode routerNode) |
95 | |
{ |
96 | |
|
97 | 4 | OutboundFilterProcessor processor = new OutboundFilterProcessor(getEnvironment(), out); |
98 | 4 | processor.process(graph, outEndpoint, routerNode); |
99 | 4 | } |
100 | |
|
101 | |
} |