Java 类org.apache.camel.component.direct.DirectComponent 实例源码

项目:Camel    文件:DirectComponentAutoConfiguration.java   
@Bean
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(DirectComponent.class)
public DirectComponent configureDirectComponent(CamelContext camelContext,
        DirectComponentConfiguration configuration) throws Exception {
    DirectComponent component = new DirectComponent();
    component.setCamelContext(camelContext);
    Map<String, Object> parameters = new HashMap<>();
    IntrospectionSupport.getProperties(configuration, parameters, null,
            false);
    IntrospectionSupport.setProperties(camelContext,
            camelContext.getTypeConverter(), component, parameters);
    return component;
}
项目:Camel    文件:DefaultCamelContextTest.java   
public void testGetComponent() {
    DefaultCamelContext ctx = new DefaultCamelContext();
    ctx.disableJMX();
    ctx.addComponent("log", new LogComponent());

    LogComponent log = ctx.getComponent("log", LogComponent.class);
    assertNotNull(log);
    try {
        ctx.addComponent("direct", new DirectComponent());
        ctx.getComponent("log", DirectComponent.class);
        fail("Should have thrown exception");
    } catch (IllegalArgumentException e) {
        // expected
    }
}
项目:Camel    文件:RefComponentTest.java   
private void bindToRegistry(JndiRegistry jndi) throws Exception {
    Component comp = new DirectComponent();
    comp.setCamelContext(context);

    Endpoint slow = comp.createEndpoint("direct:somename");
    Consumer consumer = slow.createConsumer(new Processor() {
        public void process(Exchange exchange) throws Exception {
            template.send("mock:result", exchange);
        }
    });
    consumer.start();

    // bind our endpoint to the registry for ref to lookup
    jndi.bind("foo", slow);
}
项目:camel-dynamic-loadbalancer    文件:MBeanRouteStatisticsCollectorTest.java   
@Test
public void queryGets1ValueBack() throws Exception {
    setupManagementStrategy();

    Set<ObjectName> objectNames = new HashSet<ObjectName>();
    objectNames.add(new ObjectName("org.apache.camel:type=routes,name=route1,*"));
    objectNames.add(new ObjectName("org.apache.camel:type=routes,name=route2,*"));

    MBeanServer mBeanServerMocked = Mockito.mock(MBeanServer.class);
    provideRouteStats(mBeanServerMocked, objectNames);
    provideAllRoutes(mBeanServerMocked, objectNames);

    //TODO: update as failing test

    DirectComponent component = new DirectComponent();
    component.setCamelContext(context);

    DefaultChannel processor1 = new DefaultChannel();
    processor1.setChildDefinition(new ToDefinition(new DirectEndpoint("direct:lb1", component)));

    DefaultChannel processor2 = new DefaultChannel();
    processor2.setChildDefinition(new ToDefinition(new DirectEndpoint("direct:lb2", component)));

    List<Processor> processors = new LinkedList<Processor>();
    processors.add(processor1);
    processors.add(processor2);

    MBeanRouteStatisticsCollector collector = new MBeanRouteStatisticsCollector(context, mBeanServerMocked, "route", false, false);
    List<RouteStatistics> stats = collector.query(processors, createExchange());

    Assert.assertNotNull(stats);
    Assert.assertEquals(2, stats.size());

    RouteStatistics first = stats.get(0);
    Assert.assertEquals(new Long(1), new Long(first.getInflightExchange()));
    Assert.assertEquals(new Long(20L), new Long(first.getMeanProcessingTime()));
    Assert.assertEquals(new Long(30L), new Long(first.getLastProcessingTime()));
    Assert.assertEquals("1", first.getLoad01());
    Assert.assertEquals("5", first.getLoad05());
    Assert.assertEquals("15", first.getLoad15());
}