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 org.jdom.Element;
20
21 public class ShortestNotationHandler extends TagProcessor
22 {
23
24 public ShortestNotationHandler(GraphEnvironment environment)
25 {
26 super(environment);
27 }
28
29 public void process(Graph graph, Element currentElement, GraphNode parent)
30 {
31 String inbound = currentElement.getAttributeValue(MuleTag.ATTRIBUTE_INBOUNDENDPOINT);
32 if (inbound != null)
33 {
34 GraphNode in = getEnvironment().getEndpointRegistry().getEndpoint(inbound,
35 parent.getInfo().getHeader());
36 if (in == null)
37 {
38 in = graph.addNode();
39 in.getInfo().setCaption(inbound);
40 getEnvironment().getEndpointRegistry().addEndpoint(inbound, in);
41 }
42 addEdge(graph, in, parent, "in", isTwoWay(null));
43 }
44 String outbound = currentElement.getAttributeValue(MuleTag.ATTRIBUTE_OUTBOUNDENDPOINT);
45 if (outbound != null)
46 {
47 GraphNode out = getEnvironment().getEndpointRegistry().getEndpoint(outbound,
48 parent.getInfo().getHeader());
49 if (out == null)
50 {
51 out = graph.addNode();
52 out.getInfo().setCaption(outbound);
53 getEnvironment().getEndpointRegistry().addEndpoint(outbound, out);
54 }
55 addEdge(graph, parent, out, "out", isTwoWay(null));
56 }
57
58 String inboundTransformers = currentElement.getAttributeValue("inboundTransformer");
59 if (inboundTransformers != null)
60 {
61 String[] transformers = inboundTransformers.split(" ");
62 StringBuffer caption = new StringBuffer();
63 for (int i = 0; i < transformers.length; i++)
64 {
65 caption.append("transformer " + i + " : " + transformers[i] + "\n");
66 }
67 parent.getInfo().setCaption(parent.getInfo().getCaption() + "\n" + caption.toString());
68 }
69
70 GraphNode[] virtual = getEnvironment().getEndpointRegistry().getVirtualEndpoint(
71 parent.getInfo().getHeader());
72 if (virtual.length > 0)
73 {
74 for (int i = 0; i < virtual.length; i++)
75 {
76 addEdge(graph, parent, virtual[i], "out (dynamic)", false);
77 }
78 }
79 }
80 }