camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r554978 - in /activemq/camel/trunk/components/camel-spring/src: main/java/org/apache/camel/spring/model/ main/java/org/apache/camel/spring/model/language/ main/resources/org/apache/camel/spring/model/ test/java/org/apache/camel/spring/model/
Date Tue, 10 Jul 2007 15:33:56 GMT
Author: jstrachan
Date: Tue Jul 10 08:33:54 2007
New Revision: 554978

URL: http://svn.apache.org/viewvc?view=rev&rev=554978
Log:
improved the JAXB mappings, using @XmlElementRef to clean thing up; also now supporting languages

Added:
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/GroovyExpression.java
  (with props)
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/language/
Removed:
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ExpressionType.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/GenerateXmlTestTest.java
Modified:
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FilterType.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpression.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpressionSupport.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/OutputType.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorRef.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorType.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/RouteType.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ToType.java
    activemq/camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/model/jaxb.index
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/GenerateXmlTest.java

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FilterType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FilterType.java?view=diff&rev=554978&r1=554977&r2=554978
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FilterType.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/FilterType.java
Tue Jul 10 08:33:54 2007
@@ -24,14 +24,15 @@
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElements;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlElementRef;
 
 /**
  * @version $Revision: 1.1 $
  */
 @XmlRootElement(name = "filter")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class FilterType extends OutputType implements ProcessorType {
-    @XmlElements({@XmlElement(name = "expression", type = LanguageExpression.class)})
+public class FilterType extends OutputType {
+    @XmlElementRef
     private LanguageExpressionSupport expression;
 
     @Override

Added: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/GroovyExpression.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/GroovyExpression.java?view=auto&rev=554978
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/GroovyExpression.java
(added)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/GroovyExpression.java
Tue Jul 10 08:33:54 2007
@@ -0,0 +1,40 @@
+/**
+ *
+ * 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.spring.model;
+
+import org.apache.camel.spring.model.LanguageExpression;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+@XmlRootElement(name = "groovy")
+public class GroovyExpression extends LanguageExpressionSupport {
+
+    public GroovyExpression() {
+    }
+
+    public GroovyExpression(String expression) {
+        super(expression);
+    }
+
+    public String getLanguage() {
+        return "groovy";
+    }
+}

Propchange: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/GroovyExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpression.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpression.java?view=diff&rev=554978&r1=554977&r2=554978
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpression.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpression.java
Tue Jul 10 08:33:54 2007
@@ -27,9 +27,8 @@
  * @version $Revision: 1.1 $
  */
 @XmlRootElement(name = "expression")
-public class LanguageExpression implements LanguageExpressionSupport{
+public class LanguageExpression extends LanguageExpressionSupport{
     private String language;
-    private String expression;
 
     public LanguageExpression() {
     }
@@ -39,11 +38,6 @@
         setExpression(expression);
     }
 
-    @Override
-    public String toString() {
-        return getLanguage() + "Expression[" + getExpression() + "]";
-    }
-
     @XmlAttribute
     public String getLanguage() {
         return language;
@@ -51,14 +45,5 @@
 
     public void setLanguage(String language) {
         this.language = language;
-    }
-
-    @XmlValue
-    public String getExpression() {
-        return expression;
-    }
-
-    public void setExpression(String expression) {
-        this.expression = expression;
     }
 }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpressionSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpressionSupport.java?view=diff&rev=554978&r1=554977&r2=554978
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpressionSupport.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/LanguageExpressionSupport.java
Tue Jul 10 08:33:54 2007
@@ -27,9 +27,29 @@
  * 
  * @version $Revision: 1.1 $
  */
-public interface LanguageExpressionSupport  {
-
-    public abstract String getExpression();
+public abstract class LanguageExpressionSupport  {
+    private String expression;
 
     public abstract String getLanguage();
+
+    protected LanguageExpressionSupport() {
+    }
+
+    protected LanguageExpressionSupport(String expression) {
+        this.expression = expression;
+    }
+
+    @Override
+    public String toString() {
+        return getLanguage() + "Expression[" + getExpression() + "]";
+    }
+
+    @XmlValue
+    public String getExpression() {
+        return expression;
+    }
+
+    public void setExpression(String expression) {
+        this.expression = expression;
+    }
 }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/OutputType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/OutputType.java?view=diff&rev=554978&r1=554977&r2=554978
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/OutputType.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/OutputType.java
Tue Jul 10 08:33:54 2007
@@ -21,6 +21,7 @@
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlElementRef;
 import java.util.List;
 import java.util.ArrayList;
 
@@ -29,14 +30,10 @@
  * 
  * @version $Revision: 1.1 $
  */
-@XmlAccessorType(XmlAccessType.FIELD)
-public abstract class OutputType {
-    @XmlElements({
-    @XmlElement(name = "filter", type = FilterType.class),
-    @XmlElement(name = "process", type = ProcessorRef.class),
-    @XmlElement(name = "to", type = ToType.class)})
+public abstract class OutputType extends ProcessorType {
     protected List<ProcessorType> processor = new ArrayList<ProcessorType>();
 
+    @XmlElementRef
     public List<ProcessorType> getProcessor() {
         return processor;
     }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorRef.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorRef.java?view=diff&rev=554978&r1=554977&r2=554978
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorRef.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorRef.java
Tue Jul 10 08:33:54 2007
@@ -27,7 +27,7 @@
  */
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlRootElement(name = "process")
-public class ProcessorRef implements ProcessorType {
+public class ProcessorRef extends OutputType {
     @XmlAttribute(required = true)
     private String ref;
 

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorType.java?view=diff&rev=554978&r1=554977&r2=554978
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorType.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ProcessorType.java
Tue Jul 10 08:33:54 2007
@@ -20,5 +20,5 @@
 /**
  * @version $Revision: 1.1 $
  */
-public interface ProcessorType {
+public abstract class ProcessorType {
 }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/RouteType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/RouteType.java?view=diff&rev=554978&r1=554977&r2=554978
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/RouteType.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/RouteType.java
Tue Jul 10 08:33:54 2007
@@ -27,6 +27,7 @@
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlElementRef;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -38,11 +39,8 @@
  * @version $Revision: $
  */
 @XmlRootElement(name = "root")
-@XmlAccessorType(XmlAccessType.FIELD)
 public class RouteType extends OutputType implements CamelContextAware, ProcessorFactory
{
-    @XmlTransient
     private CamelContext camelContext;
-    @XmlElement(required = true)
     private List<FromType> from = new ArrayList<FromType>();
 
 /*
@@ -60,6 +58,7 @@
     // Properties
     //-----------------------------------------------------------------------
 
+    @XmlElement(required = true)
     public List<FromType> getFrom() {
         return from;
     }
@@ -68,6 +67,7 @@
         this.from = from;
     }
 
+    @XmlTransient
     public CamelContext getCamelContext() {
         return camelContext;
     }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ToType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ToType.java?view=diff&rev=554978&r1=554977&r2=554978
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ToType.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/model/ToType.java
Tue Jul 10 08:33:54 2007
@@ -28,7 +28,7 @@
  */
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlRootElement(name = "to")
-public class ToType implements ProcessorType {
+public class ToType extends OutputType {
     @XmlAttribute
     private String uri;
 

Modified: activemq/camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/model/jaxb.index
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/model/jaxb.index?view=diff&rev=554978&r1=554977&r2=554978
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/model/jaxb.index
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/model/jaxb.index
Tue Jul 10 08:33:54 2007
@@ -1,6 +1,7 @@
 CamelContextType
 FilterType
 FromType
+GroovyExpression
 LanguageExpression
 ProcessorRef
 RouteType

Modified: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/GenerateXmlTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/GenerateXmlTest.java?view=diff&rev=554978&r1=554977&r2=554978
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/GenerateXmlTest.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/model/GenerateXmlTest.java
Tue Jul 10 08:33:54 2007
@@ -19,17 +19,31 @@
 
 import javax.xml.bind.Marshaller;
 import java.io.StringWriter;
+import java.util.List;
 
 /**
  * @version $Revision: 1.1 $
  */
 public class GenerateXmlTest extends XmlTestSupport {
-    
-    public void testCreateXml() throws Exception {
+    public void testCreateSimpleXml() throws Exception {
         CamelContextType context = new CamelContextType();
         RouteType route = context.route();
         route.from("seda:a");
-        route.filter("juel", "in.header.foo == 'bar'").to("seda:b");
+        route.filter("juel", "in.header.foo == 'bar'").
+                to("seda:b");
+
+        dump(context);
+    }
+
+    public void testGroovyFilterXml() throws Exception {
+        CamelContextType context = new CamelContextType();
+        RouteType route = context.route();
+        route.from("seda:a");
+        route.filter(new GroovyExpression("in.headers.any { h -> h.startsWith('foo') }")).
+                to("seda:b");
+
+        List<ProcessorType> list = route.getProcessor();
+        assertEquals("Size of list: "+ list, 1, list.size());
 
         dump(context);
     }



Mime
View raw message