View Javadoc

1   /*
2    * $Id: ExceptionStrategyProcessor.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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 org.jdom.Element;
21  
22  public class ExceptionStrategyProcessor extends TagProcessor
23  {
24  
25      public ExceptionStrategyProcessor(GraphEnvironment environment)
26      {
27          super(environment);
28      }
29  
30      public void process(Graph graph, Element currentElement, GraphNode parent)
31      {
32          String edgeCaption = MuleTag.ELEMENT_CATCH_ALL_STRATEGY;
33          Element exceptionStrategy = currentElement.getChild(edgeCaption);
34          if (exceptionStrategy == null)
35          {
36              edgeCaption = MuleTag.ELEMENT_EXCEPTION_STRATEGY;
37              exceptionStrategy = currentElement.getChild(edgeCaption);
38  
39          }
40  
41          if (exceptionStrategy != null)
42          {
43              String className = exceptionStrategy.getAttributeValue(MuleTag.ATTRIBUTE_CLASS_NAME);
44              GraphNode exceptionNode = graph.addNode();
45              exceptionNode.getInfo().setHeader(className);
46              exceptionNode.getInfo().setFillColor(ColorRegistry.COLOR_EXCEPTION_STRATEGY);
47  
48              addEdge(graph, parent, exceptionNode, edgeCaption, false);
49              Element endpoint = exceptionStrategy.getChild(MuleTag.ELEMENT_ENDPOINT);
50              if (endpoint == null)
51              {
52                  endpoint = exceptionStrategy.getChild(MuleTag.ELEMENT_GLOBAL_ENDPOINT);
53              }
54              if (endpoint != null)
55              {
56                  String url = endpoint.getAttributeValue(MuleTag.ATTRIBUTE_ADDRESS);
57                  if (url == null)
58                  {
59                      url = endpoint.getAttributeValue(MuleTag.ATTRIBUTE_NAME);
60                  }
61                  if (url != null)
62                  {
63                      GraphNode out = getEnvironment().getEndpointRegistry().getEndpoint(url,
64                          parent.getInfo().getHeader());
65                      if (out == null)
66                      {
67                          out = graph.addNode();
68                          out.getInfo().setCaption(url);
69                          getEnvironment().getEndpointRegistry().addEndpoint(url, out);
70                      }
71                      addEdge(graph, exceptionNode, out, "out", false);
72                  }
73              }
74          }
75  
76      }
77  }