You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ha...@apache.org on 2008/08/11 19:41:01 UTC
svn commit: r684835 - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/model/
components/camel-spring/src/main/java/org/apache/camel/spring/
components/camel-spring/src/test/java/org/apache/camel/spring/processor/
components/camel-sp...
Author: hadrian
Date: Mon Aug 11 10:40:57 2008
New Revision: 684835
URL: http://svn.apache.org/viewvc?rev=684835&view=rev
Log:
CAMEL-811. Patch applied with many thanks!
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDelayerTest.java
activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/delayer.xml
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java?rev=684835&r1=684834&r2=684835&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java Mon Aug 11 10:40:57 2008
@@ -18,6 +18,7 @@
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.camel.Expression;
@@ -25,6 +26,7 @@
import org.apache.camel.model.language.ExpressionType;
import org.apache.camel.processor.Delayer;
import org.apache.camel.spi.RouteContext;
+import org.apache.camel.util.ObjectHelper;
/**
* Represents an XML <delayer/> element
@@ -34,6 +36,7 @@
@XmlRootElement(name = "delayer")
@XmlAccessorType(XmlAccessType.FIELD)
public class DelayerType extends ExpressionNode {
+ @XmlElement
private Long delay = 0L;
public DelayerType() {
@@ -73,7 +76,17 @@
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
Processor childProcessor = routeContext.createProcessor(this);
- Expression processAtExpression = getExpression() != null ? getExpression().createExpression(routeContext) : null;
+ Expression processAtExpression = createAbsoluteTimeDelayExpression(routeContext);
return new Delayer(childProcessor, processAtExpression, delay);
}
+
+ private Expression createAbsoluteTimeDelayExpression(RouteContext routeContext) {
+ ExpressionType expr = getExpression();
+ if (expr != null) {
+ if (ObjectHelper.isNotNullAndNonEmpty(expr.getLanguage())) {
+ return expr.createExpression(routeContext);
+ }
+ }
+ return null;
+ }
}
Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java?rev=684835&r1=684834&r2=684835&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java Mon Aug 11 10:40:57 2008
@@ -97,7 +97,7 @@
if (event instanceof ContextRefreshedEvent) {
// now lets start the CamelContext so that all its possible
- // dependencies are initailized
+ // dependencies are initialized
try {
LOG.debug("Starting the CamelContext now that the ApplicationContext has started");
start();
Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDelayerTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDelayerTest.java?rev=684835&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDelayerTest.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDelayerTest.java Mon Aug 11 10:40:57 2008
@@ -0,0 +1,28 @@
+/**
+ * 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.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.DelayerTest;
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringDelayerTest extends DelayerTest {
+ protected CamelContext createCamelContext() throws Exception {
+ return createSpringCamelContext(this,
+ "org/apache/camel/spring/processor/delayer.xml");
+ }
+}
Added: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/delayer.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/delayer.xml?rev=684835&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/delayer.xml (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/delayer.xml Mon Aug 11 10:40:57 2008
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+ <!--
+ from("seda:a").delayer(header("JMSTimestamp"), 3000).to("mock:result");
+ from("seda:b").delayer(3000).to("mock:result");
+ -->
+ <!-- START SNIPPET: example -->
+ <camelContext id="camel"
+ xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="seda:a"/>
+ <delayer>
+ <simple>header.JMSTimestamp</simple>
+ <delay>3000</delay>
+ </delayer>
+ <to uri="mock:result"/>
+ </route>
+ <route>
+ <from uri="seda:b"/>
+ <delayer>
+ <expression/>
+ <delay>3000</delay>
+ </delayer>
+ <to uri="mock:result"/>
+ </route>
+ </camelContext>
+ <!-- END SNIPPET: example -->
+
+</beans>