You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/09/18 09:36:28 UTC
svn commit: r816501 - in /camel/trunk/camel-core/src:
main/java/org/apache/camel/component/timer/TimerEndpoint.java
test/java/org/apache/camel/component/timer/TimerNameTest.java
Author: davsclaus
Date: Fri Sep 18 07:36:28 2009
New Revision: 816501
URL: http://svn.apache.org/viewvc?rev=816501&view=rev
Log:
CAMEL-2018: Timer should be lazy created so its configuration can be set from properties.
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/component/timer/TimerNameTest.java (with props)
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java?rev=816501&r1=816500&r2=816501&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/timer/TimerEndpoint.java Fri Sep 18 07:36:28 2009
@@ -29,7 +29,7 @@
import org.springframework.jmx.export.annotation.ManagedResource;
/**
- * Represents a timer endpoint that can generate periodic inbound PojoExchanges.
+ * Represents a timer endpoint that can generate periodic inbound exchanges triggered by a timer.
*
* @version $Revision$
*/
@@ -48,7 +48,6 @@
public TimerEndpoint(String fullURI, TimerComponent component, String timerName) {
super(fullURI, component);
- this.timer = component.getTimer(this);
this.timerName = timerName;
}
@@ -141,7 +140,8 @@
public Timer getTimer() {
if (timer == null) {
- timer = new Timer();
+ TimerComponent tc = (TimerComponent) getComponent();
+ timer = tc.getTimer(this);
}
return timer;
}
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/timer/TimerNameTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/timer/TimerNameTest.java?rev=816501&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/timer/TimerNameTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/timer/TimerNameTest.java Fri Sep 18 07:36:28 2009
@@ -0,0 +1,47 @@
+/**
+ * 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.component.timer;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class TimerNameTest extends ContextTestSupport {
+
+ private String uri = "timer://foo?delay=2000&timerName=bar";
+
+ public void testTimerName() throws Exception {
+ getMockEndpoint("mock:result").expectedMinimumMessageCount(1);
+
+ assertMockEndpointsSatisfied();
+
+ TimerEndpoint te = context.getEndpoint(uri, TimerEndpoint.class);
+ assertEquals("bar", te.getTimerName());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from(uri).to("mock:result");
+ }
+ };
+ }
+}
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/timer/TimerNameTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/timer/TimerNameTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date