1
2
3
4
5
6
7
8
9
10 package org.mule.tools.visualizer.processor;
11
12 import org.mule.tools.visualizer.config.ColorRegistry;
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 DescriptorProcessor extends TagProcessor
25 {
26
27 private final ExceptionStrategyProcessor exceptionStrategyProcessor;
28
29 private final ShortestNotationHandler shortestNotationHandler;
30
31 private final InboundRoutersProcessor inboundRoutersProcessor;
32
33 private final ResponseRouterProcessor responseRouterProcessor;
34
35 private final OutBoundRoutersProcessor outBoundRoutersProcessor;
36
37 public DescriptorProcessor(GraphEnvironment environment)
38 {
39 super(environment);
40 this.shortestNotationHandler = new ShortestNotationHandler(environment);
41 this.inboundRoutersProcessor = new InboundRoutersProcessor(environment);
42 this.responseRouterProcessor = new ResponseRouterProcessor(environment);
43 exceptionStrategyProcessor = new ExceptionStrategyProcessor(environment);
44
45 this.outBoundRoutersProcessor = new OutBoundRoutersProcessor(environment);
46
47 }
48
49 public void process(Graph graph, Element currentElement, GraphNode parent)
50 {
51 if (currentElement == null)
52 {
53 System.err.println("model is null");
54 return;
55 }
56
57 List descriptors = currentElement.getChildren(MuleTag.ELEMENT_MULE_DESCRIPTOR);
58 for (Iterator iter = descriptors.iterator(); iter.hasNext();)
59 {
60 Element descriptor = (Element) iter.next();
61 String name = descriptor.getAttributeValue(MuleTag.ATTRIBUTE_NAME);
62 GraphNode node = graph.addNode();
63 node.getInfo().setHeader(name);
64 node.getInfo().setFillColor(ColorRegistry.COLOR_COMPONENT);
65
66 StringBuffer caption = new StringBuffer();
67
68
69
70
71
72
73 appendProfiles(descriptor, caption);
74 appendProperties(descriptor, caption);
75 appendDescription(descriptor, caption);
76
77 node.getInfo().setCaption(caption.toString());
78
79 shortestNotationHandler.process(graph, descriptor, node);
80
81 exceptionStrategyProcessor.process(graph, descriptor, node);
82
83 inboundRoutersProcessor.process(graph, descriptor, node);
84
85 outBoundRoutersProcessor.process(graph, descriptor, node);
86
87 responseRouterProcessor.process(graph, descriptor, node);
88
89 }
90
91 }
92
93 }