Coverage Report - org.mule.tools.visualizer.processor.InboundRoutersProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
InboundRoutersProcessor
86%
30/35
67%
8/12
4
 
 1  
 /*
 2  
  * $Id: InboundRoutersProcessor.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 java.util.Iterator;
 21  
 import java.util.List;
 22  
 
 23  
 import org.jdom.Element;
 24  
 
 25  
 public class InboundRoutersProcessor extends TagProcessor
 26  
 {
 27  
 
 28  
     public InboundRoutersProcessor(GraphEnvironment environment)
 29  
     {
 30  4
         super(environment);
 31  
 
 32  4
     }
 33  
 
 34  
     public void process(Graph graph, Element currentElement, GraphNode parent)
 35  
     {
 36  6
         Element inboundRouter = currentElement.getChild(MuleTag.ELEMENT_INBOUND_ROUTER);
 37  
 
 38  6
         if (inboundRouter != null)
 39  
         {
 40  
 
 41  6
             GraphNode endpointsLink = parent;
 42  
 
 43  6
             Element router = inboundRouter.getChild(MuleTag.ELEMENT_ROUTER);
 44  6
             if (router != null)
 45  
             {
 46  0
                 GraphNode routerNode = graph.addNode();
 47  0
                 routerNode.getInfo().setHeader(router.getAttributeValue(MuleTag.ATTRIBUTE_CLASS_NAME));
 48  0
                 routerNode.getInfo().setFillColor(ColorRegistry.COLOR_ROUTER);
 49  
 
 50  0
                 addEdge(graph, routerNode, parent, "inbound router", isTwoWay(router));
 51  0
                 endpointsLink = routerNode;
 52  
             }
 53  
 
 54  6
             List inbounEndpoints = inboundRouter.getChildren(MuleTag.ELEMENT_ENDPOINT);
 55  6
             for (Iterator iterator = inbounEndpoints.iterator(); iterator.hasNext();)
 56  
             {
 57  8
                 Element inEndpoint = (Element) iterator.next();
 58  8
                 String url = inEndpoint.getAttributeValue(MuleTag.ATTRIBUTE_ADDRESS);
 59  8
                 if (url != null)
 60  
                 {
 61  8
                     GraphNode in = getEnvironment().getEndpointRegistry().getEndpoint(url,
 62  
                         parent.getInfo().getHeader());
 63  8
                     StringBuffer caption = new StringBuffer();
 64  8
                     if (in == null)
 65  
                     {
 66  6
                         in = graph.addNode();
 67  6
                         in.getInfo().setFillColor(ColorRegistry.COLOR_ENDPOINT);
 68  6
                         caption.append(url).append("\n");
 69  6
                         appendProperties(inEndpoint, caption);
 70  6
                         appendDescription(inEndpoint, caption);
 71  6
                         in.getInfo().setCaption(caption.toString());
 72  
                     }
 73  
                     else
 74  
                     {
 75  
                         // rewrite the properties
 76  
                         // TODO really we need a cleaner way of handling in/out
 77  
                         // endpoints between components
 78  2
                         caption.append(url).append("\n");
 79  2
                         appendProperties(inEndpoint, caption);
 80  2
                         appendDescription(inEndpoint, caption);
 81  2
                         in.getInfo().setCaption(caption.toString());
 82  
                         // Mark boundary endpoints between configurations
 83  
                         // if(environment.getConfig().isCombineFiles()) {
 84  
                         // in.getInfo().setLineColor("red");
 85  
                         // }
 86  
                     }
 87  
 
 88  8
                     if (in != null)
 89  
                     {
 90  8
                         InboundFilterProcessor processor = new InboundFilterProcessor(getEnvironment(),
 91  
                             endpointsLink);
 92  8
                         processor.processInboundFilter(graph, inEndpoint, in, endpointsLink);
 93  
                     }
 94  
                 }
 95  8
             }
 96  
 
 97  
         }
 98  6
     }
 99  
 
 100  
 }