Search in sources :

Example 1 with BeanComponent

use of org.apache.camel.component.bean.BeanComponent in project camel by apache.

the class BeanComponentAutoConfiguration method configureBeanComponent.

@Lazy
@Bean(name = "bean-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(BeanComponent.class)
public BeanComponent configureBeanComponent(CamelContext camelContext) throws Exception {
    BeanComponent component = new BeanComponent();
    component.setCamelContext(camelContext);
    return component;
}
Also used : BeanComponent(org.apache.camel.component.bean.BeanComponent) 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 BeanComponent

use of org.apache.camel.component.bean.BeanComponent in project camel by apache.

the class BeanComponentConfigurationAndDocumentationTest method testComponentConfiguration.

@Test
public void testComponentConfiguration() throws Exception {
    BeanComponent comp = context.getComponent("bean", BeanComponent.class);
    EndpointConfiguration conf = comp.createConfiguration("bean:foo?method=bar");
    assertEquals("bar", conf.getParameter("method"));
    ComponentConfiguration compConf = comp.createComponentConfiguration();
    String json = compConf.createParameterJsonSchema();
    assertNotNull(json);
    assertTrue(json.contains("\"method\": { \"kind\": \"parameter\", \"displayName\": \"Method\", \"group\": \"producer\", \"type\": \"string\""));
    assertTrue(json.contains("\"cache\": { \"kind\": \"parameter\", \"displayName\": \"Cache\", \"group\": \"advanced\", \"label\": \"advanced\", \"type\": \"boolean\""));
}
Also used : ComponentConfiguration(org.apache.camel.ComponentConfiguration) BeanComponent(org.apache.camel.component.bean.BeanComponent) EndpointConfiguration(org.apache.camel.EndpointConfiguration) Test(org.junit.Test)

Example 3 with BeanComponent

use of org.apache.camel.component.bean.BeanComponent in project camel by apache.

the class DefaultCamelContextTest method testAutoStartComponentsOn.

public void testAutoStartComponentsOn() throws Exception {
    DefaultCamelContext ctx = new DefaultCamelContext();
    ctx.disableJMX();
    ctx.start();
    BeanComponent component = (BeanComponent) ctx.getComponent("bean", true, true);
    // should be started
    assertTrue(component.getStatus().isStarted());
}
Also used : BeanComponent(org.apache.camel.component.bean.BeanComponent)

Example 4 with BeanComponent

use of org.apache.camel.component.bean.BeanComponent in project camel by apache.

the class DefaultCamelContextTest method testAutoStartComponentsOff.

public void testAutoStartComponentsOff() throws Exception {
    DefaultCamelContext ctx = new DefaultCamelContext();
    ctx.disableJMX();
    ctx.start();
    BeanComponent component = (BeanComponent) ctx.getComponent("bean", true, false);
    // should be stopped
    assertTrue(component.getStatus().isStopped());
}
Also used : BeanComponent(org.apache.camel.component.bean.BeanComponent)

Aggregations

BeanComponent (org.apache.camel.component.bean.BeanComponent)4 ComponentConfiguration (org.apache.camel.ComponentConfiguration)1 EndpointConfiguration (org.apache.camel.EndpointConfiguration)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