Anonymous avatar Anonymous committed 5d00045

webflow usage helper and manifest entry

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@565 573baa09-0c28-0410-bef9-dab3c582ae83

Comments (0)

Files changed (4)

             </fileset>
         </copy>
 
-        <jar basedir="${build.webflow}" jarfile="${build}/webflow-${version}.jar"/>
+        <jar basedir="${build.webflow}" jarfile="${build}/webflow-${version}.jar">
+            <manifest>
+                <attribute name="Main-Class" value="com.opensymphony.webwork.webFlow.WebFlow"/>
+            </manifest>
+        </jar>
     </target>
 
     <target name="jar" depends="java">

src/webflow/com/opensymphony/webwork/webFlow/WebFlow.java

     public static void main(String[] args) {
         LOG.info("WebFlow starting...");
 
+        if (args.length != 6) {
+            System.out.println("Usage: -config CONFIG_DIR -views VIEWS_DIRS -output OUTPUT");
+            System.out.println("       CONFIG_DIR => a directory containing xwork.xml");
+            System.out.println("       VIEWS_DIRS => comma seperated list of dirs containing JSPs, VMs, etc");
+            System.out.println("       OUPUT      => the directory where the output should go");
+            return;
+        }
+
         String configDir = getArg(args, "config");
         String views = getArg(args, "views");
 
         XWorkConfigRetriever.setConfiguration(configDir, views.split("[, ]+"));
-        Renderer renderer = new DOTRenderer("temp");
+        Renderer renderer = new DOTRenderer(getArg(args, "output"));
         renderer.render();
     }
 

src/webflow/com/opensymphony/webwork/webFlow/entities/XworkView.java

     private static final Log LOG = LogFactory.getLog(XworkView.class);
     private File file = null;
     private Set targets = null;
-    private static String actionRegex = "([A-Za-z0-9\\._\\-]+\\." + Configuration.get("webwork.action.extension") + ")";
+    private static String actionRegex = "([A-Za-z0-9\\._\\-\\!]+\\." + Configuration.get("webwork.action.extension") + ")";
     private static Pattern actionPattern = Pattern.compile(actionRegex);
 
     public XworkView() {

src/webflow/com/opensymphony/webwork/webFlow/renderers/DOTRenderer.java

 package com.opensymphony.webwork.webFlow.renderers;
 
 import com.opensymphony.webwork.config.Configuration;
-import com.opensymphony.webwork.dispatcher.ServletDispatcherResult;
-import com.opensymphony.webwork.dispatcher.ServletRedirectResult;
-import com.opensymphony.webwork.dispatcher.VelocityResult;
-import com.opensymphony.webwork.views.freemarker.FreemarkerResult;
-import com.opensymphony.webwork.views.jasperreports.JasperReportsResult;
-import com.opensymphony.webwork.views.xslt.XSLTResult;
 import com.opensymphony.webwork.webFlow.XWorkConfigRetriever;
 import com.opensymphony.webwork.webFlow.entities.View;
 import com.opensymphony.xwork.ActionChainResult;
 public class DOTRenderer implements Renderer {
 
     private static final Log LOG = LogFactory.getLog(DOTRenderer.class);
+
     private String output;
 
     public DOTRenderer(String output) {
 
                     if (resultClassName.equals(ActionChainResult.class.getName())) {
 
-                    } else if (resultClassName.equals(ServletDispatcherResult.class.getName())
-                            || resultClassName.equals(VelocityResult.class.getName())
-                            || resultClassName.equals(FreemarkerResult.class.getName())) {
+                    } else if (resultClassName.indexOf("Dispatcher") != -1
+                            || resultClassName.indexOf("Velocity") != -1
+                            || resultClassName.indexOf("Freemarker") != -1) {
                         String location = (String) resultConfig.getParams().get("location");
                         String view = getViewLocation(location, namespace);
                         graph.add_node("view", view, null);
                         if (viewFile != null) {
                             viewMap.put(view, viewFile);
                         }
-                    } else if (resultClassName.equals(JasperReportsResult.class.getName())) {
-
-                    } else if (resultClassName.equals(XSLTResult.class.getName())) {
+                    } else if (resultClassName.indexOf("Jasper") != -1) {
 
-                    } else if (resultClassName.equals(ServletRedirectResult.class.getName())) {
+                    } else if (resultClassName.indexOf("XSLT") != -1) {
 
+                    } else if (resultClassName.indexOf("Redirect") != -1 ) {
+                        // check if the redirect is to an action -- if so, link it
+                        String location = (String) resultConfig.getParams().get("location");
+                        System.out.println(location);
+                        if (location.endsWith((String) Configuration.get("webwork.action.extension"))) {
+                            addLink(action, location, resultConfig.getName(), graph);
+                        }
                     }
                 }
             }
             Set targets = viewFile.getTargets();
             for (Iterator iterator1 = targets.iterator(); iterator1.hasNext();) {
                 String viewTarget = (String) iterator1.next();
-                graph.add_link(view, "/" + viewTarget, null);
+                addLink(view, viewTarget, "", graph);
             }
         }
 
         }
     }
 
+    private void addLink(String view, String target, String label, DotGraph graph) {
+        int bang = target.indexOf('!');
+        if (bang != -1) {
+            // map the link back to the action using the command as the label
+            String command = target.substring(bang + 1, target.lastIndexOf('.'));
+            String action = target.substring(0, bang) + target.substring(target.lastIndexOf('.'));
+            graph.add_link(view, "/" + action, label + "\\n(!" + command + ")");
+        } else {
+            graph.add_link(view, "/" + target, label);
+        }
+    }
+
     private String getViewLocation(String location, String namespace) {
         String view = null;
         if (!location.startsWith("/")) {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.