Author: jstrachan
Date: Wed Dec 10 07:39:08 2008
New Revision: 725309

URL: http://svn.apache.org/viewvc?rev=725309&view=rev
Log:
added initial JAXB change for CAMEL-1171

Added:
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InOnlyType.java
   (with props)
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InOutType.java
   (contents, props changed)
      - copied, changed from r725059, 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SendType.java
   (with props)
Modified:
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
    
activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index

Added: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InOnlyType.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InOnlyType.java?rev=725309&view=auto
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InOnlyType.java
 (added)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InOnlyType.java
 Wed Dec 10 07:39:08 2008
@@ -0,0 +1,84 @@
+/**
+ * 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 org.apache.camel.Endpoint;
+import org.apache.camel.ExchangePattern;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * Represents an XML <inOnly/> element
+ *
+ * @version $Revision: 725058 $
+ */
[EMAIL PROTECTED](name = "inOnly")
[EMAIL PROTECTED](XmlAccessType.FIELD)
+public class InOnlyType extends SendType<InOnlyType> {
+    @XmlAttribute(required = false)
+    private String uri;
+    @XmlAttribute(required = false)
+    private String ref;
+
+    public InOnlyType() {
+    }
+
+    public InOnlyType(String uri) {
+        setUri(uri);
+    }
+
+    public InOnlyType(Endpoint endpoint) {
+        setEndpoint(endpoint);
+    }
+
+    @Override
+    public String toString() {
+        return "InOnly[" + getLabel() + "]";
+    }
+
+    @Override
+    public String getShortName() {
+        return "inOnly";
+    }
+
+    @Override
+    public ExchangePattern getPattern() {
+        return ExchangePattern.InOnly;
+    }
+
+
+    @Override
+    public String getRef() {
+        return ref;
+    }
+
+    public void setRef(String ref) {
+        this.ref = ref;
+    }
+
+    @Override
+    public String getUri() {
+        return uri;
+    }
+
+    public void setUri(String uri) {
+        this.uri = uri;
+    }
+}
\ No newline at end of file

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

Copied: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InOutType.java
 (from r725059, 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java)
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InOutType.java?p2=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InOutType.java&p1=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java&r1=725059&r2=725309&rev=725309&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InOutType.java
 Wed Dec 10 07:39:08 2008
@@ -16,125 +16,69 @@
  */
 package org.apache.camel.model;
 
-import java.util.Collections;
-import java.util.List;
+import org.apache.camel.Endpoint;
+import org.apache.camel.ExchangePattern;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.Processor;
-import org.apache.camel.processor.SendProcessor;
-import org.apache.camel.spi.RouteContext;
-import org.apache.camel.util.ObjectHelper;
 
 /**
- * Represents an XML &lt;to/&gt; element
+ * Represents an XML &lt;inOut/&gt; element
  *
  * @version $Revision$
  */
[EMAIL PROTECTED](name = "to")
[EMAIL PROTECTED](name = "inOut")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class ToType extends ProcessorType<ProcessorType> {
-    @XmlAttribute
+public class InOutType extends SendType<InOutType> {
+    @XmlAttribute(required = false)
     private String uri;
-    @XmlAttribute
+    @XmlAttribute(required = false)
     private String ref;
-    @XmlTransient
-    private Endpoint endpoint;
 
-    public ToType() {
+    public InOutType() {
     }
 
-    public ToType(String uri) {
+    public InOutType(String uri) {
         setUri(uri);
     }
 
-    public ToType(Endpoint endpoint) {
+    public InOutType(Endpoint endpoint) {
         setEndpoint(endpoint);
     }
 
     @Override
     public String toString() {
-        return "To[" + getLabel() + "]";
+        return "InOut[" + getLabel() + "]";
     }
 
     @Override
     public String getShortName() {
-        return "to";
+        return "inOut";
     }
 
     @Override
-    public String getLabel() {
-        return FromType.description(getUri(), getRef(), getEndpoint());
+    public ExchangePattern getPattern() {
+        return ExchangePattern.InOut;
     }
 
-    @Override
-    public Processor createProcessor(RouteContext routeContext) throws 
Exception {
-        Endpoint endpoint = resolveEndpoint(routeContext);
-        return new SendProcessor(endpoint);
-    }
-
-    public Endpoint resolveEndpoint(RouteContext context) {
-        if (endpoint == null) {
-            endpoint = context.resolveEndpoint(getUri(), getRef());
-        }
-        return endpoint;
-    }
-
-    // Properties
-    // -----------------------------------------------------------------------
-    public String getUri() {
-        return uri;
-    }
-
-    /**
-     * Sets the URI of the endpoint to use
-     *
-     * @param uri the endpoint URI to use
-     */
-    public void setUri(String uri) {
-        this.uri = uri;
-    }
 
+    @Override
     public String getRef() {
         return ref;
     }
 
-    /**
-     * Sets the name of the endpoint within the registry (such as the Spring
-     * ApplicationContext or JNDI) to use
-     *
-     * @param ref the reference name to use
-     */
     public void setRef(String ref) {
         this.ref = ref;
     }
 
-    public Endpoint getEndpoint() {
-        return endpoint;
-    }
-
-    public void setEndpoint(Endpoint endpoint) {
-        this.endpoint = endpoint;
-    }
-
-    public List<ProcessorType<?>> getOutputs() {
-        return Collections.EMPTY_LIST;
+    @Override
+    public String getUri() {
+        return uri;
     }
 
-    /**
-     * Returns the endpoint URI or the name of the reference to it
-     */
-    public Object getUriOrRef() {
-        if (ObjectHelper.isEmpty(uri)) {
-            return uri;
-        } else if (endpoint != null) {
-            return endpoint.getEndpointUri();
-        }
-        return ref;
+    public void setUri(String uri) {
+        this.uri = uri;
     }
-}
+}
\ No newline at end of file

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

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

Propchange: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InOutType.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SendType.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SendType.java?rev=725309&view=auto
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SendType.java
 (added)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SendType.java
 Wed Dec 10 07:39:08 2008
@@ -0,0 +1,102 @@
+/**
+ *
+ * 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 org.apache.camel.Endpoint;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Processor;
+import org.apache.camel.processor.SendProcessor;
+import org.apache.camel.spi.RouteContext;
+import org.apache.camel.util.ObjectHelper;
+
+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 javax.xml.bind.annotation.XmlType;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Base class for sending to an endpoint with an optional [EMAIL PROTECTED] 
ExchangePattern}
+ *
+ * @version $Revision: 1.1 $
+ */
+//@XmlType(name = "sendType")
[EMAIL PROTECTED](XmlAccessType.FIELD)
+public class SendType<Type extends ProcessorType> extends ProcessorType<Type> {
+    @XmlTransient
+    private Endpoint endpoint;
+
+    @Override
+    public Processor createProcessor(RouteContext routeContext) throws 
Exception {
+        Endpoint endpoint = resolveEndpoint(routeContext);
+        return new SendProcessor(endpoint, getPattern());
+    }
+
+    public Endpoint resolveEndpoint(RouteContext context) {
+        if (endpoint == null) {
+            endpoint = context.resolveEndpoint(getUri(), getRef());
+        }
+        return endpoint;
+    }
+
+    // Properties
+    // -----------------------------------------------------------------------
+    public String getUri() {
+        return null;
+    }
+
+    public String getRef() {
+        return null;
+    }
+
+    public Endpoint getEndpoint() {
+        return endpoint;
+    }
+
+    public void setEndpoint(Endpoint endpoint) {
+        this.endpoint = endpoint;
+    }
+
+    public ExchangePattern getPattern() {
+        return null;
+    }
+
+    public List<ProcessorType<?>> getOutputs() {
+        return Collections.EMPTY_LIST;
+    }
+
+    /**
+     * Returns the endpoint URI or the name of the reference to it
+     */
+    public Object getUriOrRef() {
+        String uri = getUri();
+        if (ObjectHelper.isEmpty(uri)) {
+            return uri;
+        } else if (endpoint != null) {
+            return endpoint.getEndpointUri();
+        }
+        return getRef();
+    }
+
+    @Override
+    public String getLabel() {
+        return FromType.description(getUri(), getRef(), getEndpoint());
+    }
+}

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

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java?rev=725309&r1=725308&r2=725309&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
 Wed Dec 10 07:39:08 2008
@@ -27,6 +27,7 @@
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Processor;
+import org.apache.camel.ExchangePattern;
 import org.apache.camel.processor.SendProcessor;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.util.ObjectHelper;
@@ -38,13 +39,13 @@
  */
 @XmlRootElement(name = "to")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class ToType extends ProcessorType<ProcessorType> {
-    @XmlAttribute
+public class ToType extends SendType<ToType> {
+    @XmlAttribute(required = false)
     private String uri;
-    @XmlAttribute
+    @XmlAttribute(required = false)
     private String ref;
-    @XmlTransient
-    private Endpoint endpoint;
+    @XmlAttribute(required = false)
+    private ExchangePattern pattern;
 
     public ToType() {
     }
@@ -68,73 +69,32 @@
     }
 
     @Override
-    public String getLabel() {
-        return FromType.description(getUri(), getRef(), getEndpoint());
-    }
-
-    @Override
-    public Processor createProcessor(RouteContext routeContext) throws 
Exception {
-        Endpoint endpoint = resolveEndpoint(routeContext);
-        return new SendProcessor(endpoint);
-    }
-
-    public Endpoint resolveEndpoint(RouteContext context) {
-        if (endpoint == null) {
-            endpoint = context.resolveEndpoint(getUri(), getRef());
-        }
-        return endpoint;
-    }
-
-    // Properties
-    // -----------------------------------------------------------------------
-    public String getUri() {
-        return uri;
+    public ExchangePattern getPattern() {
+        return pattern;
     }
 
     /**
-     * Sets the URI of the endpoint to use
-     *
-     * @param uri the endpoint URI to use
+     * Sets the optional [EMAIL PROTECTED] ExchangePattern} used to invoke 
this endpoint
      */
-    public void setUri(String uri) {
-        this.uri = uri;
+    public void setPattern(ExchangePattern pattern) {
+        this.pattern = pattern;
     }
 
+    @Override
     public String getRef() {
         return ref;
     }
 
-    /**
-     * Sets the name of the endpoint within the registry (such as the Spring
-     * ApplicationContext or JNDI) to use
-     *
-     * @param ref the reference name to use
-     */
     public void setRef(String ref) {
         this.ref = ref;
     }
 
-    public Endpoint getEndpoint() {
-        return endpoint;
-    }
-
-    public void setEndpoint(Endpoint endpoint) {
-        this.endpoint = endpoint;
-    }
-
-    public List<ProcessorType<?>> getOutputs() {
-        return Collections.EMPTY_LIST;
+    @Override
+    public String getUri() {
+        return uri;
     }
 
-    /**
-     * Returns the endpoint URI or the name of the reference to it
-     */
-    public Object getUriOrRef() {
-        if (ObjectHelper.isEmpty(uri)) {
-            return uri;
-        } else if (endpoint != null) {
-            return endpoint.getEndpointUri();
-        }
-        return ref;
+    public void setUri(String uri) {
+        this.uri = uri;
     }
 }

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java?rev=725309&r1=725308&r2=725309&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SendProcessor.java
 Wed Dec 10 07:39:08 2008
@@ -22,6 +22,7 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Producer;
 import org.apache.camel.Service;
+import org.apache.camel.ExchangePattern;
 import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.impl.converter.AsyncProcessorTypeConverter;
 import org.apache.camel.util.ObjectHelper;
@@ -38,15 +39,21 @@
     private Endpoint destination;
     private Producer producer;
     private AsyncProcessor processor;
+    private ExchangePattern pattern;
 
     public SendProcessor(Endpoint destination) {
         ObjectHelper.notNull(destination, "destination");
         this.destination = destination;
     }
 
+    public SendProcessor(Endpoint destination, ExchangePattern pattern) {
+        this(destination);
+        this.pattern = pattern;
+    }
+
     @Override
     public String toString() {
-        return "sendTo(" + destination + ")";
+        return "sendTo(" + destination + (pattern != null ? " " + pattern : 
"") + ")";
     }
 
     public void process(Exchange exchange) throws Exception {
@@ -57,6 +64,7 @@
                 throw new IllegalStateException("No producer, this processor 
has not been started!");
             }
         } else {
+            configureExchange(exchange);
             producer.process(exchange);
         }
     }
@@ -71,10 +79,11 @@
             callback.done(true);
             return true;
         } else {
+            configureExchange(exchange);
             return processor.process(exchange, callback);
         }
     }
-    
+
     public Endpoint getDestination() {
         return destination;
     }
@@ -96,4 +105,9 @@
         }
     }
 
+    protected void configureExchange(Exchange exchange) {
+        if (pattern != null) {
+            exchange.setPattern(pattern);
+        }
+    }
 }

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=725309&r1=725308&r2=725309&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
 Wed Dec 10 07:39:08 2008
@@ -28,6 +28,8 @@
 FinallyType
 FromType
 IdempotentConsumerType
+InOnlyType
+InOutType
 InterceptType
 InterceptorRef
 InterceptorType


Reply via email to