You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2008/05/19 21:28:57 UTC

svn commit: r657931 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/model/ main/resources/org/apache/camel/model/ test/java/org/apache/camel/model/

Author: jstrachan
Date: Mon May 19 12:28:57 2008
New Revision: 657931

URL: http://svn.apache.org/viewvc?rev=657931&view=rev
Log:
patch for https://issues.apache.org/activemq/browse/CAMEL-529

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/Description.java   (with props)
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedType.java   (contents, props changed)
      - copied, changed from r657784, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdentifiedType.java
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java
    activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/GenerateXmlTest.java

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/Description.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/Description.java?rev=657931&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/Description.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/Description.java Mon May 19 12:28:57 2008
@@ -0,0 +1,56 @@
+/**
+ *
+ * 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.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
+
+/**
+ * Represents a description element which can be used on any element in the EIP route
+ * 
+ * @version $Revision: 1.1 $
+ */
+@XmlRootElement(name = "description")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class Description {
+    @XmlAttribute(required = false)
+    private String lang;
+
+    @XmlValue
+    private String text;
+
+    public String getLang() {
+        return lang;
+    }
+
+    public void setLang(String lang) {
+        this.lang = lang;
+    }
+
+    public String getText() {
+        return text;
+    }
+
+    public void setText(String text) {
+        this.text = text;
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/Description.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java?rev=657931&r1=657930&r2=657931&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java Mon May 19 12:28:57 2008
@@ -34,7 +34,7 @@
  */
 @XmlRootElement(name = "from")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class FromType {
+public class FromType extends OptionalIdentifiedType<FromType> {
     @XmlAttribute
     private String uri;
     @XmlAttribute

Copied: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedType.java (from r657784, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdentifiedType.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedType.java?p2=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedType.java&p1=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdentifiedType.java&r1=657784&r2=657931&rev=657931&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdentifiedType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedType.java Mon May 19 12:28:57 2008
@@ -19,39 +19,26 @@
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlID;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
 /**
- * The unique identifier for a bean. The scope of the identifier
- * is the enclosing bean factory.
- * <p/>
- * <p/>
- * <p>Java class for identifiedType complex type.
- * <p/>
- * <p>The following schema fragment specifies the expected content contained within this class.
- * <p/>
- * <pre>
- * &lt;complexType name="identifiedType">
- *   &lt;complexContent>
- *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       &lt;attribute name="id" type="{http://www.w3.org/2001/XMLSchema}ID" />
- *     &lt;/restriction>
- *   &lt;/complexContent>
- * &lt;/complexType>
- * </pre>
+ * Allows an element to have an optional ID specified
  *
  * @version $Revision$
  */
-@XmlType(name = "identifiedType")
+@XmlType(name = "optionalIdentifiedType")
 @XmlAccessorType(XmlAccessType.FIELD)
-public abstract class IdentifiedType {
-    @XmlAttribute
+public abstract class OptionalIdentifiedType<T extends OptionalIdentifiedType> {
+    @XmlAttribute(required = false)
     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
     @XmlID
     private String id;
+    @XmlElement(required = false)
+    private Description description;
 
     /**
      * Gets the value of the id property.
@@ -72,4 +59,33 @@
     public void setId(String value) {
         this.id = value;
     }
-}
+
+    public Description getDescription() {
+        return description;
+    }
+
+    public void setDescription(Description description) {
+        this.description = description;
+    }
+
+    // Fluent API
+    // -------------------------------------------------------------------------
+    public T description(String text) {
+        if (description == null) {
+            description = new Description();
+        }
+        description.setText(text);
+        return (T) this;
+    }
+
+    public T description(String text, String lang) {
+        description(text);
+        description.setLang(lang);
+        return (T) this;
+    }
+
+    public T id(String id) {
+        setId(id);
+        return (T) this;
+    }
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OptionalIdentifiedType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java?rev=657931&r1=657930&r2=657931&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java Mon May 19 12:28:57 2008
@@ -25,6 +25,8 @@
 
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAccessType;
 
 import org.apache.camel.CamelException;
 import org.apache.camel.Endpoint;
@@ -48,9 +50,11 @@
 import org.apache.camel.processor.ConvertBodyProcessor;
 import org.apache.camel.processor.DelegateProcessor;
 import org.apache.camel.processor.Pipeline;
+import org.apache.camel.processor.MulticastProcessor;
 import org.apache.camel.processor.aggregate.AggregationCollection;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
 import org.apache.camel.processor.idempotent.MessageIdRepository;
+import org.apache.camel.processor.idempotent.IdempotentConsumer;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.InterceptStrategy;
 import org.apache.camel.spi.Policy;
@@ -60,11 +64,11 @@
 /**
  * @version $Revision$
  */
-public abstract class ProcessorType<Type extends ProcessorType> implements Block {
+@XmlAccessorType(XmlAccessType.PROPERTY)
+public abstract class ProcessorType<Type extends ProcessorType> extends OptionalIdentifiedType<Type> implements Block {
     public static final String DEFAULT_TRACE_CATEGORY = "org.apache.camel.TRACE";
     private ErrorHandlerBuilder errorHandlerBuilder;
-    private Boolean inheritErrorHandlerFlag = Boolean.TRUE; // TODO not sure how
-    private DelegateProcessor lastInterceptor;
+    private Boolean inheritErrorHandlerFlag;
     private NodeFactory nodeFactory;
     private LinkedList<Block> blocks = new LinkedList<Block>();
     private ProcessorType<? extends ProcessorType> parent;
@@ -840,7 +844,7 @@
 
     public Type intercept(DelegateProcessor interceptor) {
         addInterceptor(new InterceptorRef(interceptor));
-        lastInterceptor = interceptor;
+        //lastInterceptor = interceptor;
         return (Type) this;
     }
 
@@ -1374,7 +1378,14 @@
 
     @XmlTransient
     public boolean isInheritErrorHandler() {
-        return ObjectConverter.toBoolean(getInheritErrorHandlerFlag());
+        return isInheritErrorHandler(getInheritErrorHandlerFlag());
+    }
+
+    /**
+     * Lets default the inherit value to be true if there is none specified
+     */
+    public static boolean isInheritErrorHandler(Boolean value) {
+        return value == null || value.booleanValue();
     }
 
     @XmlAttribute(name = "inheritErrorHandler", required = false)

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java?rev=657931&r1=657930&r2=657931&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java Mon May 19 12:28:57 2008
@@ -40,10 +40,10 @@
  */
 @XmlRootElement(name = "routes")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class RoutesType implements RouteContainer {
+public class RoutesType extends OptionalIdentifiedType<RoutesType> implements RouteContainer {
     // TODO: not sure how else to use an optional attribute in JAXB2
     @XmlAttribute
-    private Boolean inheritErrorHandlerFlag = Boolean.TRUE;
+    private Boolean inheritErrorHandlerFlag;
     @XmlElementRef
     private List<RouteType> routes = new ArrayList<RouteType>();
     @XmlElementRef
@@ -107,7 +107,7 @@
     }
 
     public boolean isInheritErrorHandler() {
-        return inheritErrorHandlerFlag != null && inheritErrorHandlerFlag.booleanValue();
+        return ProcessorType.isInheritErrorHandler(getInheritErrorHandlerFlag());
     }
 
     public Boolean getInheritErrorHandlerFlag() {

Modified: activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index?rev=657931&r1=657930&r2=657931&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index (original)
+++ activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index Mon May 19 12:28:57 2008
@@ -21,6 +21,7 @@
 CompletedPredicate
 ConvertBodyType
 DelayerType
+Description
 ExceptionType
 FilterType
 FinallyType
@@ -31,6 +32,7 @@
 LoadBalanceType
 MarshalType
 MulticastType
+OptionalIdentifiedType
 OtherwiseType
 PolicyRef
 ProceedType

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/GenerateXmlTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/GenerateXmlTest.java?rev=657931&r1=657930&r2=657931&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/GenerateXmlTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/GenerateXmlTest.java Mon May 19 12:28:57 2008
@@ -22,6 +22,8 @@
 import javax.xml.bind.Marshaller;
 
 import org.apache.camel.model.language.GroovyExpression;
+import org.apache.camel.model.language.ELExpression;
+import org.apache.camel.model.language.XQueryExpression;
 
 /**
  * @version $Revision$
@@ -31,8 +33,9 @@
         RoutesType context = new RoutesType();
         RouteType route = context.route();
         route.from("seda:a");
-        route.filter("juel", "in.header.foo == 'bar'").
+        route.filter(new XQueryExpression("in.header.foo == 'bar'")).
                 to("seda:b");
+        route.description("This is a description of the route");
 
         dump(context);
     }
@@ -57,5 +60,6 @@
         StringWriter buffer = new StringWriter();
         marshaller.marshal(context, buffer);
         log.info("Created: " + buffer);
+        System.out.println("Created: " + buffer);
     }
 }