Coverage Report - org.mule.tools.visualizer.processor.ExceptionStrategyProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
ExceptionStrategyProcessor
32%
9/28
14%
2/14
4.5
 
 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  10
         super(environment);
 28  10
     }
 29  
 
 30  
     public void process(Graph graph, Element currentElement, GraphNode parent)
 31  
     {
 32  12
         String edgeCaption = MuleTag.ELEMENT_CATCH_ALL_STRATEGY;
 33  12
         Element exceptionStrategy = currentElement.getChild(edgeCaption);
 34  12
         if (exceptionStrategy == null)
 35  
         {
 36  12
             edgeCaption = MuleTag.ELEMENT_EXCEPTION_STRATEGY;
 37  12
             exceptionStrategy = currentElement.getChild(edgeCaption);
 38  
 
 39  
         }
 40  
 
 41  12
         if (exceptionStrategy != null)
 42  
         {
 43  0
             String className = exceptionStrategy.getAttributeValue(MuleTag.ATTRIBUTE_CLASS_NAME);
 44  0
             GraphNode exceptionNode = graph.addNode();
 45  0
             exceptionNode.getInfo().setHeader(className);
 46  0
             exceptionNode.getInfo().setFillColor(ColorRegistry.COLOR_EXCEPTION_STRATEGY);
 47  
 
 48  0
             addEdge(graph, parent, exceptionNode, edgeCaption, false);
 49  0
             Element endpoint = exceptionStrategy.getChild(MuleTag.ELEMENT_ENDPOINT);
 50  0
             if (endpoint == null)
 51  
             {
 52  0
                 endpoint = exceptionStrategy.getChild(MuleTag.ELEMENT_GLOBAL_ENDPOINT);
 53  
             }
 54  0
             if (endpoint != null)
 55  
             {
 56  0
                 String url = endpoint.getAttributeValue(MuleTag.ATTRIBUTE_ADDRESS);
 57  0
                 if (url == null)
 58  
                 {
 59  0
                     url = endpoint.getAttributeValue(MuleTag.ATTRIBUTE_NAME);
 60  
                 }
 61  0
                 if (url != null)
 62  
                 {
 63  0
                     GraphNode out = getEnvironment().getEndpointRegistry().getEndpoint(url,
 64  
                         parent.getInfo().getHeader());
 65  0
                     if (out == null)
 66  
                     {
 67  0
                         out = graph.addNode();
 68  0
                         out.getInfo().setCaption(url);
 69  0
                         getEnvironment().getEndpointRegistry().addEndpoint(url, out);
 70  
                     }
 71  0
                     addEdge(graph, exceptionNode, out, "out", false);
 72  
                 }
 73  
             }
 74  
         }
 75  
 
 76  12
     }
 77  
 }