camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject svn commit: r801784 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/loadbalancer/ components/camel-web/src/main/java/org/apache/camel/web/resources/ components/camel-web/src/main/j...
Date Thu, 06 Aug 2009 19:28:39 GMT
Author: janstey
Date: Thu Aug  6 19:28:38 2009
New Revision: 801784

URL: http://svn.apache.org/viewvc?rev=801784&view=rev
Log:
CAMEL-1392 - Latest update for the Groovy renderer. Thanks to Xueqiang for this.

Added:
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnCompletionDefinitionRenderer.java
  (with props)
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnExceptionDefinitionRenderer.java
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/AOPDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/FailOverLoadBalancer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/RouteResource.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionNodeRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/GroovyRenderer.java
    camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OutputDefinitionRenderer.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTestSupport.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/LoadBalanceDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/RoutingSlipDSLTest.java
    camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/TransformDSLTest.java
    camel/trunk/components/camel-web/src/test/resources/route.txt
    camel/trunk/components/camel-web/src/test/resources/testedRoutes.txt

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/AOPDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/AOPDefinition.java?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/AOPDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/AOPDefinition.java Thu Aug
 6 19:28:38 2009
@@ -51,6 +51,18 @@
         return "AOP[" + getOutputs() + "]";
     }
 
+    public String getBeforeUri() {
+        return beforeUri;
+    }
+
+    public String getAfterUri() {
+        return afterUri;
+    }
+
+    public String getAfterFinallyUri() {
+        return afterFinallyUri;
+    }
+
     @Override
     public String getShortName() {
         return "aop";

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequenceDefinition.java
Thu Aug  6 19:28:38 2009
@@ -195,6 +195,10 @@
         return expressions;
     }
 
+    public List<Expression> getExpressionList() {
+        return expressionList;
+    }
+
     public List<ProcessorDefinition> getOutputs() {
         return outputs;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/FailOverLoadBalancer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/FailOverLoadBalancer.java?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/FailOverLoadBalancer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/loadbalancer/FailOverLoadBalancer.java
Thu Aug  6 19:28:38 2009
@@ -42,6 +42,10 @@
         }
     }
 
+    public List<Class> getExceptions() {
+        return exceptions;
+    }
+
     /**
      * Should the given failed Exchange failover?
      *

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/RouteResource.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/RouteResource.java?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/RouteResource.java
(original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/resources/RouteResource.java
Thu Aug  6 19:28:38 2009
@@ -118,7 +118,7 @@
             }
         } else if (language.equalsIgnoreCase(LANGUAGE_GROOVY)) {
             StringBuilder buffer = new StringBuilder();
-            new GroovyRenderer().renderRoute(buffer, route);
+            GroovyRenderer.renderRoute(buffer, route);
             return GroovyRenderer.header + buffer.toString() + GroovyRenderer.footer;
         } else {
             return "Unsupported language!";

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionNodeRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionNodeRenderer.java?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionNodeRenderer.java
(original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionNodeRenderer.java
Thu Aug  6 19:28:38 2009
@@ -113,10 +113,7 @@
             }
         } else if (expNode instanceof TransformDefinition) {
             String expValue = expression.getExpressionValue().toString();
-            if (expValue.matches("\\w+")) {
-                buffer.append("()");
-                ExpressionRenderer.renderConstant(buffer, expression);
-            } else if (expValue.startsWith("append")) {
+            if (expValue.startsWith("append") || expValue.startsWith("prepend") || expValue.startsWith("to"))
{
                 buffer.append("(");
                 ExpressionRenderer.render(buffer, expression);
                 buffer.append(")");
@@ -124,9 +121,7 @@
                 buffer.append("()");
                 ExpressionRenderer.render(buffer, expression);
             } else {
-                buffer.append("(");
-                ExpressionRenderer.render(buffer, expression);
-                buffer.append(")");
+                buffer.append("(constant(\"").append(expression.getExpressionValue().toString()).append("\"))");
             }
         } else if (expNode instanceof WhenDefinition) {
             if (expression.getPredicate() != null) {

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionRenderer.java?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionRenderer.java
(original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/ExpressionRenderer.java
Thu Aug  6 19:28:38 2009
@@ -136,6 +136,11 @@
             String words[] = expression.split("\\(|, |\\)");
 
             buffer.append(words[1]).append("().").append("append(\"").append(words[2]).append("\")");
+        } else if (expression.startsWith("prepend")) {
+            // prepend(body, World!) -> body().prepend(" World!")
+            String words[] = expression.split("\\(|, |\\)");
+
+            buffer.append(words[1]).append("().").append("prepend(\"").append(words[2]).append("\")");
         }
     }
 }

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/GroovyRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/GroovyRenderer.java?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/GroovyRenderer.java
(original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/GroovyRenderer.java
Thu Aug  6 19:28:38 2009
@@ -19,62 +19,27 @@
 import java.io.IOException;
 import java.util.List;
 
-import javax.xml.bind.annotation.XmlRootElement;
-
+import org.apache.camel.Expression;
 import org.apache.camel.builder.DeadLetterChannelBuilder;
 import org.apache.camel.builder.ErrorHandlerBuilderRef;
-import org.apache.camel.builder.ExpressionBuilder;
-import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.model.AggregateDefinition;
-import org.apache.camel.model.BeanDefinition;
 import org.apache.camel.model.ChoiceDefinition;
 import org.apache.camel.model.ConvertBodyDefinition;
-import org.apache.camel.model.DataFormatDefinition;
-import org.apache.camel.model.DelayDefinition;
-import org.apache.camel.model.EnrichDefinition;
 import org.apache.camel.model.ExpressionNode;
-import org.apache.camel.model.FilterDefinition;
-import org.apache.camel.model.FinallyDefinition;
 import org.apache.camel.model.FromDefinition;
-import org.apache.camel.model.IdempotentConsumerDefinition;
-import org.apache.camel.model.InterceptDefinition;
-import org.apache.camel.model.InterceptSendToEndpointDefinition;
 import org.apache.camel.model.LoadBalanceDefinition;
-import org.apache.camel.model.LoopDefinition;
-import org.apache.camel.model.MarshalDefinition;
-import org.apache.camel.model.MulticastDefinition;
+import org.apache.camel.model.OnCompletionDefinition;
+import org.apache.camel.model.OnExceptionDefinition;
 import org.apache.camel.model.OtherwiseDefinition;
 import org.apache.camel.model.OutputDefinition;
-import org.apache.camel.model.PipelineDefinition;
-import org.apache.camel.model.PolicyDefinition;
-import org.apache.camel.model.PollEnrichDefinition;
-import org.apache.camel.model.ProcessDefinition;
 import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.model.RecipientListDefinition;
-import org.apache.camel.model.RemoveHeaderDefinition;
-import org.apache.camel.model.RemovePropertyDefinition;
 import org.apache.camel.model.ResequenceDefinition;
 import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.model.RoutesDefinition;
 import org.apache.camel.model.RoutingSlipDefinition;
 import org.apache.camel.model.SendDefinition;
-import org.apache.camel.model.SetBodyDefinition;
-import org.apache.camel.model.SetExchangePatternDefinition;
-import org.apache.camel.model.SetHeaderDefinition;
-import org.apache.camel.model.SetOutHeaderDefinition;
-import org.apache.camel.model.SetPropertyDefinition;
-import org.apache.camel.model.SortDefinition;
-import org.apache.camel.model.SplitDefinition;
-import org.apache.camel.model.StopDefinition;
-import org.apache.camel.model.ThreadsDefinition;
 import org.apache.camel.model.ThrottleDefinition;
-import org.apache.camel.model.TransactedDefinition;
-import org.apache.camel.model.TransformDefinition;
-import org.apache.camel.model.TryDefinition;
-import org.apache.camel.model.UnmarshalDefinition;
 import org.apache.camel.model.WhenDefinition;
-import org.apache.camel.model.language.ConstantExpression;
-import org.apache.camel.model.language.ExpressionDefinition;
 import org.apache.camel.processor.loadbalancer.FailOverLoadBalancer;
 import org.apache.camel.processor.loadbalancer.LoadBalancer;
 import org.apache.camel.processor.loadbalancer.RandomLoadBalancer;
@@ -85,7 +50,7 @@
 /**
  * Render routes in Groovy language
  */
-public class GroovyRenderer implements TextRenderer {
+public class GroovyRenderer {
 
     public static final String header = "import org.apache.camel.language.groovy.GroovyRouteBuilder;\nclass
GroovyRoute extends GroovyRouteBuilder {\nvoid configure() {\n";
 
@@ -96,8 +61,7 @@
      * 
      * @throws IOException
      */
-    public void renderRoute(StringBuilder buffer, RouteDefinition route) {
-        // TODO Auto-generated method stub
+    public static void renderRoute(StringBuilder buffer, RouteDefinition route) {
         List<FromDefinition> inputs = route.getInputs();
         List<ProcessorDefinition> outputs = route.getOutputs();
 
@@ -113,6 +77,15 @@
             }
         }
 
+        // render the global dsl not started with from, like global
+        // onCompletion, onException, intercept
+        for (ProcessorDefinition processor : outputs) {
+            if (processor.getParent() == null) {
+                renderProcessor(buffer, processor);
+                buffer.append(";");
+            }
+        }
+
         // render the inputs of the router
         buffer.append("from(");
         for (FromDefinition input : inputs) {
@@ -125,14 +98,16 @@
 
         // render the outputs of the router
         for (ProcessorDefinition processor : outputs) {
-            renderProcessor(buffer, processor);
+            if (processor.getParent() == route) {
+                renderProcessor(buffer, processor);
+            }
         }
     }
 
     /**
      * render a RoutesDefinition
      */
-    public void renderRoutes(StringBuilder buffer, RoutesDefinition routes) {
+    public static void renderRoutes(StringBuilder buffer, RoutesDefinition routes) {
         // TODO Auto-generated method stub
 
     }
@@ -140,7 +115,7 @@
     /**
      * render a ProcessorDefiniton
      */
-    private void renderProcessor(StringBuilder buffer, ProcessorDefinition processor) {
+    private static void renderProcessor(StringBuilder buffer, ProcessorDefinition processor)
{
         if (processor instanceof AggregateDefinition) {
             AggregateDefinitionRenderer.render(buffer, processor);
         } else if (processor instanceof ChoiceDefinition) {
@@ -176,7 +151,15 @@
 
             LoadBalancer lb = loadB.getLoadBalancerType().getLoadBalancer(null);
             if (lb instanceof FailOverLoadBalancer) {
-                buffer.append(".failover()");
+                buffer.append(".failover(");
+                List<Class> exceptions = ((FailOverLoadBalancer)lb).getExceptions();
+                for (Class excep : exceptions) {
+                    buffer.append(excep.getSimpleName()).append(".class");
+                    if (excep != exceptions.get(exceptions.size() - 1)) {
+                        buffer.append(", ");
+                    }
+                }
+                buffer.append(")");
             } else if (lb instanceof RandomLoadBalancer) {
                 buffer.append(".random()");
             } else if (lb instanceof RoundRobinLoadBalancer) {
@@ -192,14 +175,24 @@
                 renderProcessor(buffer, branch);
             }
             return;
+        } else if (processor instanceof OnCompletionDefinition) {
+            OnCompletionDefinitionRenderer.render(buffer, processor);
+            return;
+        } else if (processor instanceof OnExceptionDefinition) {
+            OnExceptionDefinitionRenderer.render(buffer, processor);
+            return;
         } else if (processor instanceof OutputDefinition) {
             OutputDefinitionRenderer.render(buffer, processor);
         } else if (processor instanceof ResequenceDefinition) {
             ResequenceDefinition resequence = (ResequenceDefinition)processor;
             buffer.append(".").append(processor.getShortName()).append("(");
-            List<ExpressionBuilder> exps = null;
-            for (ExpressionBuilder exp : exps) {
-                buffer.append(exp.toString()).append("(),");
+
+            List<Expression> exps = resequence.getExpressionList();
+            for (Expression exp : exps) {
+                buffer.append(exp.toString()).append("()");
+                if (exp != exps.get(exps.size() - 1)) {
+                    buffer.append(", ");
+                }
             }
             buffer.append(")");
         } else if (processor instanceof RoutingSlipDefinition) {
@@ -219,9 +212,9 @@
         }
 
         List<ProcessorDefinition> outputs = processor.getOutputs();
+
         for (ProcessorDefinition nextProcessor : outputs) {
             renderProcessor(buffer, nextProcessor);
         }
     }
-
 }

Added: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnCompletionDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnCompletionDefinitionRenderer.java?rev=801784&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnCompletionDefinitionRenderer.java
(added)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnCompletionDefinitionRenderer.java
Thu Aug  6 19:28:38 2009
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.web.util;
+
+import java.util.List;
+
+import org.apache.camel.model.OnCompletionDefinition;
+import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.WhenDefinition;
+
+/**
+ * 
+ */
+public class OnCompletionDefinitionRenderer {
+
+    public static void render(StringBuilder buffer, ProcessorDefinition processor) {
+        // if not a global onCompletion, add a period
+        boolean notGlobal = buffer.toString().endsWith(")");
+        if (notGlobal) {
+            buffer.append(".");
+        }
+
+        OnCompletionDefinition onComplete = (OnCompletionDefinition)processor;
+        buffer.append(processor.getShortName()).append("()");
+        if (onComplete.getOnWhen() != null) {
+            WhenDefinition when = onComplete.getOnWhen();
+            buffer.append(".onWhen");
+            if (when.getExpression().getPredicate() != null) {
+                PredicateRenderer.renderPredicate(buffer, when.getExpression().getPredicate());
+            } else {
+                buffer.append("Unsupported Expression!");
+            }
+        }
+        if (onComplete.getOnCompleteOnly()) {
+            buffer.append(".onCompleteOnly()");
+        }
+        if (onComplete.getOnFailureOnly()) {
+            buffer.append(".onFailureOnly()");
+        }
+        List<ProcessorDefinition> branches = onComplete.getOutputs();
+        for (ProcessorDefinition branch : branches) {
+            SendDefinitionRenderer.render(buffer, branch);
+        }
+
+
+        // if not a global onCompletion, using end() at the end
+        if (notGlobal) {
+            buffer.append(".end()");
+        }
+    }
+}

Propchange: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnCompletionDefinitionRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnExceptionDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnExceptionDefinitionRenderer.java?rev=801784&view=auto
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnExceptionDefinitionRenderer.java
(added)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnExceptionDefinitionRenderer.java
Thu Aug  6 19:28:38 2009
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.web.util;
+
+import java.util.List;
+
+import org.apache.camel.model.OnExceptionDefinition;
+import org.apache.camel.model.ProcessorDefinition;
+
+/**
+ * 
+ */
+public class OnExceptionDefinitionRenderer {
+
+    public static void render(StringBuilder buffer, ProcessorDefinition processor) {
+        // if not a global onCompletion, add a period
+        boolean notGlobal = buffer.toString().endsWith(")");
+        if (notGlobal) {
+            buffer.append(".");
+        }
+
+        OnExceptionDefinition onException = (OnExceptionDefinition)processor;
+        buffer.append(processor.getShortName()).append("(");
+        List<Class> exceptions = onException.getExceptionClasses();
+        for (Class excep : exceptions) {
+            buffer.append(excep.getSimpleName()).append(".class");
+            if (excep != exceptions.get(exceptions.size() - 1)) {
+                buffer.append(", ");
+            }
+        }
+        buffer.append(")");
+
+        List<ProcessorDefinition> branches = onException.getOutputs();
+        for (ProcessorDefinition branch : branches) {
+            SendDefinitionRenderer.render(buffer, branch);
+        }
+    }
+}

Propchange: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OnExceptionDefinitionRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OutputDefinitionRenderer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OutputDefinitionRenderer.java?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OutputDefinitionRenderer.java
(original)
+++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/OutputDefinitionRenderer.java
Thu Aug  6 19:28:38 2009
@@ -19,6 +19,7 @@
 
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.apache.camel.model.AOPDefinition;
 import org.apache.camel.model.BeanDefinition;
 import org.apache.camel.model.DataFormatDefinition;
 import org.apache.camel.model.EnrichDefinition;
@@ -43,7 +44,6 @@
 import org.apache.camel.model.TransactedDefinition;
 import org.apache.camel.model.TryDefinition;
 import org.apache.camel.model.UnmarshalDefinition;
-import org.apache.camel.model.language.ExpressionDefinition;
 
 /**
  * 
@@ -52,17 +52,38 @@
 
     public static void render(StringBuilder buffer, ProcessorDefinition processor) {
         OutputDefinition out = (OutputDefinition)processor;
-        buffer.append(".").append(out.getShortName());
-        if (out instanceof BeanDefinition) {
+
+        boolean notGlobal = buffer.toString().endsWith(")");
+        if (notGlobal) {
+            buffer.append(".");
+        }
+        buffer.append(out.getShortName());
+
+        if (out instanceof AOPDefinition) {
+            buffer.append("()");
+            AOPDefinition aop = (AOPDefinition)out;
+
+            if (aop.getBeforeUri() != null && aop.getAfterUri() != null) {
+                buffer.append(".around(\"").append(aop.getBeforeUri());
+                buffer.append("\", \"").append(aop.getAfterUri()).append("\")");
+            } else if (aop.getBeforeUri() != null) {
+                buffer.append(".before(\"").append(aop.getBeforeUri()).append("\")");
+            } else if (aop.getAfterUri() != null) {
+                buffer.append(".after(\"").append(aop.getAfterUri()).append("\")");
+            } else if (aop.getAfterFinallyUri() != null) {
+                buffer.append(".afterFinally(\"").append(aop.getAfterUri()).append("\")");
+            }
+
+        } else if (out instanceof BeanDefinition) {
 
         } else if (out instanceof EnrichDefinition) {
             String enrich = out.toString();
             String resourceUri = enrich.substring(enrich.indexOf('[') + 1, enrich.indexOf('
'));
             buffer.append("(\"").append(resourceUri).append("\")");
         } else if (out instanceof FinallyDefinition) {
-
+            
         } else if (out instanceof InterceptDefinition) {
-
+            buffer.append("()");
         } else if (out instanceof InterceptSendToEndpointDefinition) {
 
         } else if (out instanceof MarshalDefinition) {

Modified: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTestSupport.java?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTestSupport.java
(original)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/GroovyRendererTestSupport.java
Thu Aug  6 19:28:38 2009
@@ -67,7 +67,7 @@
         assertNotNull(route);
 
         StringBuilder sb = new StringBuilder();
-        new GroovyRenderer().renderRoute(sb, route);
+        GroovyRenderer.renderRoute(sb, route);
         return sb.toString();
     }
 

Modified: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/LoadBalanceDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/LoadBalanceDSLTest.java?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/LoadBalanceDSLTest.java
(original)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/LoadBalanceDSLTest.java
Thu Aug  6 19:28:38 2009
@@ -22,11 +22,18 @@
  */
 public class LoadBalanceDSLTest extends GroovyRendererTestSupport {
 
-    public void testFromTo() throws Exception {
+    public void testLoadBalanceRandom() throws Exception {
         String DSL = "from(\"direct:start\").loadBalance().random().to(\"mock:x\", \"mock:y\",
\"mock:z\")";
         String expectedDSL = "from(\"direct:start\").loadBalance().random().to(\"mock:x\").to(\"mock:y\").to(\"mock:z\")";
 
         assertEquals(expectedDSL, render(DSL));
     }
 
+    public void testLoadBalanceFailover() throws Exception {
+        String DSL = "from(\"direct:start\").loadBalance().failover(IOException.class).to(\"direct:x\",
\"direct:y\")";
+        String expectedDSL = "from(\"direct:start\").loadBalance().failover(IOException.class).to(\"direct:x\").to(\"direct:y\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
 }

Modified: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/RoutingSlipDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/RoutingSlipDSLTest.java?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/RoutingSlipDSLTest.java
(original)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/RoutingSlipDSLTest.java
Thu Aug  6 19:28:38 2009
@@ -22,15 +22,22 @@
  */
 public class RoutingSlipDSLTest extends GroovyRendererTestSupport {
 
+    public void testRoutingSlip() throws Exception {
+        String DSL = "from(\"direct:a\").routingSlip(\"myHeader\").to(\"mock:end\")";
+        String expectedDSL = "from(\"direct:a\").routingSlip(\"myHeader\", \",\").to(\"mock:end\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
     public void testRoutingSlip1() throws Exception {
-        String DSL = "from(\"direct:start\").routingSlip(\"headerName\")";
-        String expectedDSL = "from(\"direct:start\").routingSlip(\"headerName\", \",\")";
+        String DSL = "from(\"direct:b\").routingSlip(\"aRoutingSlipHeader\")";
+        String expectedDSL = "from(\"direct:b\").routingSlip(\"aRoutingSlipHeader\", \",\")";
 
         assertEquals(expectedDSL, render(DSL));
     }
 
     public void testRoutingSlip2() throws Exception {
-        String DSL = "from(\"direct:start\").routingSlip(\"aRoutingSlipHeader\", \"#\")";
+        String DSL = "from(\"direct:c\").routingSlip(\"aRoutingSlipHeader\", \"#\")";
         String expectedDSL = DSL;
 
         assertEquals(expectedDSL, render(DSL));

Modified: camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/TransformDSLTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/TransformDSLTest.java?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/TransformDSLTest.java
(original)
+++ camel/trunk/components/camel-web/src/test/java/org/apache/camel/web/groovy/TransformDSLTest.java
Thu Aug  6 19:28:38 2009
@@ -22,8 +22,15 @@
  */
 public class TransformDSLTest extends GroovyRendererTestSupport {
 
-    public void testTransformToConstant() throws Exception {
+    public void testTransformToConstant1() throws Exception {
         String DSL = "from(\"direct:start\").transform().constant(\"London\").to(\"mock:result\")";
+        String expectedDSL = "from(\"direct:start\").transform(constant(\"London\")).to(\"mock:result\")";
+
+        assertEquals(expectedDSL, render(DSL));
+    }
+
+    public void testTransformToConstant2() throws Exception {
+        String DSL = "from(\"direct:start\").transform(constant(\"London\")).to(\"mock:result\")";
         String expectedDSL = DSL;
 
         assertEquals(expectedDSL, render(DSL));

Modified: camel/trunk/components/camel-web/src/test/resources/route.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/resources/route.txt?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/resources/route.txt (original)
+++ camel/trunk/components/camel-web/src/test/resources/route.txt Thu Aug  6 19:28:38 2009
@@ -1 +1 @@
-from("direct:start").filter().method("myBean", "matches").to("mock:result")
\ No newline at end of file
+onCompletion().to("log:global").to("mock:global");from("direct:start").onCompletion().to("log:route").to("mock:sync").end().to("mock:result")
\ No newline at end of file

Modified: camel/trunk/components/camel-web/src/test/resources/testedRoutes.txt
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/test/resources/testedRoutes.txt?rev=801784&r1=801783&r2=801784&view=diff
==============================================================================
--- camel/trunk/components/camel-web/src/test/resources/testedRoutes.txt (original)
+++ camel/trunk/components/camel-web/src/test/resources/testedRoutes.txt Thu Aug  6 19:28:38
2009
@@ -49,8 +49,7 @@
 #########################recipientList#########################
 from("direct:start").recipientList(header("recipientListHeader").tokenize(","))
 #########################resequencer#########################
-#from("direct:start").resequence(body()).to("mock:result")  // No getExceptionList method
for ResequenceDefinition
-#from("direct:start").resequencer(body()).to("mock:result") // No getExceptionList method
for ResequenceDefinition
+#from("direct:start").resequence(body()).to("mock:result")
 #########################routingSlip#########################
 from("direct:start").routingSlip("headerName")
 from("direct:start").routingSlip("aRoutingSlipHeader", "#")



Mime
View raw message