View Javadoc

1   /*
2    * $Id: MuleConfigProcessor.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 MuleConfigProcessor extends TagProcessor
23  {
24  
25      public MuleConfigProcessor(GraphEnvironment environment)
26      {
27          super(environment);
28      }
29  
30      public void process(Graph graph, Element currentElement, GraphNode parent)
31      {
32  
33          Element muleConfig = currentElement.getChild(MuleTag.ELEMENT_MULE_ENVIRONMENT_PROPERTIES);
34          if (muleConfig != null)
35          {
36              // Set whether the event flows are synchronous or not by default. This
37              // controls the style of arrows created
38              String twoway = muleConfig.getAttributeValue(MuleTag.ATTRIBUTE_SYNCHRONOUS);
39              getEnvironment().setDefaultTwoWay("true".equalsIgnoreCase(twoway));
40              if (!getEnvironment().getConfig().isShowConfig())
41              {
42                  return;
43              }
44  
45              GraphNode configNode = graph.addNode();
46              configNode.getInfo().setFillColor(ColorRegistry.COLOR_CONFIG);
47              configNode.getInfo().setHeader("Mule Config");
48  
49              StringBuffer caption = new StringBuffer();
50              appendAttribute(muleConfig, MuleTag.ATTRIBUTE_SYNCHRONOUS, caption);
51              appendAttribute(muleConfig, "serverUrl", caption);
52              appendAttribute(muleConfig, "clientMode", caption);
53              appendAttribute(muleConfig, "embedded", caption);
54              appendAttribute(muleConfig, "enableMessageEvents", caption);
55              appendAttribute(muleConfig, "encoding", caption);
56              appendAttribute(muleConfig, "osEncoding", caption);
57              appendAttribute(muleConfig, "recoverableMode", caption);
58              appendAttribute(muleConfig, "remoteSync", caption);
59              appendAttribute(muleConfig, "synchronousEventTimeout", caption);
60              appendAttribute(muleConfig, "transactionTimeout", caption);
61              appendAttribute(muleConfig, "workingDirectory", caption);
62  
63              ConnectionStrategyProcessor processor = new ConnectionStrategyProcessor(getEnvironment());
64              processor.process(graph, muleConfig, configNode);
65              appendProfiles(muleConfig, caption);
66              appendDescription(muleConfig, caption);
67  
68              configNode.getInfo().setCaption(caption.toString());
69          }
70      }
71  }