Search in sources :

Example 1 with TimerComponent

use of org.apache.camel.component.timer.TimerComponent in project camel by apache.

the class TimerComponentAutoConfiguration method configureTimerComponent.

@Lazy
@Bean(name = "timer-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(TimerComponent.class)
public TimerComponent configureTimerComponent(CamelContext camelContext) throws Exception {
    TimerComponent component = new TimerComponent();
    component.setCamelContext(camelContext);
    return component;
}
Also used : TimerComponent(org.apache.camel.component.timer.TimerComponent) Lazy(org.springframework.context.annotation.Lazy) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnClass(org.springframework.boot.autoconfigure.condition.ConditionalOnClass) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with TimerComponent

use of org.apache.camel.component.timer.TimerComponent in project camel by apache.

the class TimerComponentConfigurationAndDocumentationTest method testComponentConfiguration.

@Test
public void testComponentConfiguration() throws Exception {
    TimerComponent comp = context.getComponent("timer", TimerComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("timer:foo?period=2000");
    assertEquals("2000", conf.getParameter("period"));
    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);
    assertTrue(json.contains("\"timerName\": { \"kind\": \"path\", \"displayName\": \"Timer Name\", \"group\": \"consumer\", \"required\": true"));
    assertTrue(json.contains("\"delay\": { \"kind\": \"parameter\", \"displayName\": \"Delay\", \"group\": \"consumer\", \"type\": \"integer\""));
    assertTrue(json.contains("\"timer\": { \"kind\": \"parameter\", \"displayName\": \"Timer\", \"group\": \"advanced\", \"label\": \"advanced\""));
}
Also used : ComponentConfiguration(org.apache.camel.ComponentConfiguration) EndpointConfiguration(org.apache.camel.EndpointConfiguration) TimerComponent(org.apache.camel.component.timer.TimerComponent) Test(org.junit.Test)

Example 3 with TimerComponent

use of org.apache.camel.component.timer.TimerComponent in project camel by apache.

the class AddComponentInConfigureBuilder method configure.

@Override
public void configure() throws Exception {
    ModelCamelContext context = getContext();
    TimerComponent timerComponent = new TimerComponent();
    getContext().addComponent("my-timer", timerComponent);
    from("my-timer://test-timer?period=1000").to("mock://result");
}
Also used : ModelCamelContext(org.apache.camel.model.ModelCamelContext) TimerComponent(org.apache.camel.component.timer.TimerComponent)

Aggregations

TimerComponent (org.apache.camel.component.timer.TimerComponent)3 ComponentConfiguration (org.apache.camel.ComponentConfiguration)1 EndpointConfiguration (org.apache.camel.EndpointConfiguration)1 ModelCamelContext (org.apache.camel.model.ModelCamelContext)1 Test (org.junit.Test)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1 Lazy (org.springframework.context.annotation.Lazy)1