View Javadoc

1   /*
2    * $Id: EndpointIdentifiersProcessor.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  
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 EndpointIdentifiersProcessor extends TagProcessor
25  {
26      public EndpointIdentifiersProcessor(GraphEnvironment environment)
27      {
28          super(environment);
29      }
30  
31      public void process(Graph graph, Element currentElement, GraphNode parent)
32      {
33          Element endpointIdentifiers = currentElement.getChild("endpoint-identifiers");
34  
35          if (endpointIdentifiers == null)
36          {
37              getEnvironment().log("no endpoint-identifiers tag");
38              return;
39          }
40  
41          List namedChildren = endpointIdentifiers.getChildren("endpoint-identifier");
42  
43          for (Iterator iter = namedChildren.iterator(); iter.hasNext();)
44          {
45              Element endpoint = (Element) iter.next();
46              GraphNode node = graph.addNode();
47              node.getInfo().setFillColor(ColorRegistry.COLOR_DEFINED_ENDPOINTS);
48              String name = endpoint.getAttributeValue("name");
49  
50              String value = lookupPropertyTemplate(endpoint.getAttributeValue("value"));
51              node.getInfo().setHeader(name);
52              node.getInfo().setCaption(value);
53              getEnvironment().getEndpointRegistry().addEndpoint(name, node);
54              getEnvironment().getProperties().setProperty(name, value);
55  
56          }
57      }
58  }