Java源码示例:org.apache.camel.impl.engine.ExplicitCamelContextNameStrategy

示例1
@Scope(ConfigurableBeanFactory.SCOPE_SINGLETON)
@Bean(name = "verifier-context", initMethod = "start", destroyMethod = "stop")
public static CamelContext verifierContext() {
    CamelContext context = new DefaultCamelContext();
    context.setNameStrategy(new ExplicitCamelContextNameStrategy("verifier-context"));
    context.disableJMX();

    return context;
}
 
示例2
@Override
public void configure() throws Exception {
    getContext().setNameStrategy(new ExplicitCamelContextNameStrategy("camel-jms-context"));

    /**
     * This route generates a random order every 5 seconds
     */
    from("timer:order?period=5s&delay=0")
    .bean("orderGenerator", "generateOrder")
    .setHeader(Exchange.FILE_NAME).method("orderGenerator", "generateFileName")
    .to("file://{{jboss.server.data.dir}}/orders");

    /**
     * This route reads files placed within JBOSS_HOME/standalone/data/orders
     * and places them onto JMS queue 'ordersQueue' within the WildFly
     * internal ActiveMQ Artemis broker.
     */
    from("file://{{jboss.server.data.dir}}/orders")
    .convertBodyTo(String.class)
    // Remove headers to ensure we end up with unique file names being generated in the next route
    .removeHeaders("*")
    .to("jms:queue:OrdersQueue");

    /**
     * This route consumes messages from the 'ordersQueue'. Then, based on the
     * message payload XML content it uses a content based router to output
     * orders into appropriate country directories
     */
    from("jms:queue:OrdersQueue")
        .choice()
            .when(xpath("/order/customer/country = 'UK'"))
                .log("Sending order to the UK")
                .to("file:{{jboss.server.data.dir}}/orders/processed/UK")
            .when(xpath("/order/customer/country = 'US'"))
                .log("Sending order to the US")
                .to("file:{{jboss.server.data.dir}}/orders/processed/US")
            .otherwise()
                .log("Sending order to another country")
                .to("file://{{jboss.server.data.dir}}/orders/processed/Other");
}
 
示例3
@Override
public void configure() throws Exception {
    getContext().setNameStrategy(new ExplicitCamelContextNameStrategy("camel-activemq-context"));

    /**
     * This route generates a random order every 5 seconds
     */
    from("timer:order?period=5s&delay=0")
    .bean("orderGenerator", "generateOrder")
    .setHeader(Exchange.FILE_NAME).method("orderGenerator", "generateFileName")
    .to("file://{{jboss.server.data.dir}}/orders");

    /**
     * This route reads files placed within JBOSS_HOME/standalone/data/orders
     * and sends them to ActiveMQ queue 'ordersQueue'
     */
    from("file://{{jboss.server.data.dir}}/orders")
    .convertBodyTo(String.class)
    // Remove headers to ensure we end up with unique file names being generated in the next route
    .removeHeaders("*")
    .to("activemq:queue:OrdersQueue");

    /**
     * This route consumes messages from the 'ordersQueue'. Then, based on the
     * message payload XML content it uses a content based router to output
     * orders into appropriate country directories
     */
    from("activemq:queue:OrdersQueue")
        .choice()
            .when(xpath("/order/customer/country = 'UK'"))
                .log("Sending order to the UK")
                .to("file:{{jboss.server.data.dir}}/orders/processed/UK")
            .when(xpath("/order/customer/country = 'US'"))
                .log("Sending order to the US")
                .to("file:{{jboss.server.data.dir}}/orders/processed/US")
            .otherwise()
                .log("Sending order to another country")
                .to("file://{{jboss.server.data.dir}}/orders/processed/Other");
}
 
示例4
@Override
public RouteBuilder route() {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            getContext().setNameStrategy(new ExplicitCamelContextNameStrategy("javaConfigContext"));
            from("direct:start").transform(body().prepend("Hello "));
        }
    };
}
 
示例5
@Override
public void configure() throws Exception {
    getContext().setNameStrategy(new ExplicitCamelContextNameStrategy("secured-context"));
    from("direct:start")
    .policy(new DomainAuthorizationPolicy().roles("Role2"))
    .transform(body().prepend("Hello "));
}
 
示例6
@Override
public void configure() throws Exception {
    getContext().setNameStrategy(new ExplicitCamelContextNameStrategy("health-context"));

    from("direct:start")
        .to("log:end");
}
 
示例7
@Override
public void apply(CamelContext camelContexty) {
    camelContexty.adapt(ModelCamelContext.class).setNameStrategy(new ExplicitCamelContextNameStrategy(name));
}
 
示例8
@Override
public void configure() throws Exception {
    getContext().setNameStrategy(new ExplicitCamelContextNameStrategy("camel-mail-cdi-context"));
    from("direct:start").to("smtp://localhost:10025?session=#mailSession");
    from("pop3://[email protected]:10110?delay=30000&session=#mailSession&delete=true").to("mock:result");
}
 
示例9
@Override
public void configure() throws Exception {
    getContext().setNameStrategy(new ExplicitCamelContextNameStrategy("camel-sql-cdi-context"));
    from("sql:select name from information_schema.users?dataSource=wildFlyExampleDS")
    .to("seda:end");
}
 
示例10
@Override
public void configure() throws Exception {
    getContext().setNameStrategy(new ExplicitCamelContextNameStrategy("simple-camel-context"));
    from("direct:start").bean("helloBean");
}