• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RoutePolicy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.camel.spi.RoutePolicy的典型用法代码示例。如果您正苦于以下问题:Java RoutePolicy类的具体用法?Java RoutePolicy怎么用?Java RoutePolicy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RoutePolicy类属于org.apache.camel.spi包,在下文中一共展示了RoutePolicy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: execute

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
    LOG.debug("Running ScheduledJob: jobExecutionContext={}", jobExecutionContext);

    SchedulerContext schedulerContext = getSchedulerContext(jobExecutionContext);
    ScheduledJobState state = (ScheduledJobState) schedulerContext.get(jobExecutionContext.getJobDetail().getKey().toString());
    Action storedAction = state.getAction(); 
    Route storedRoute = state.getRoute();
    
    List<RoutePolicy> policyList = storedRoute.getRouteContext().getRoutePolicyList();
    for (RoutePolicy policy : policyList) {
        try {
            if (policy instanceof ScheduledRoutePolicy) {
                ((ScheduledRoutePolicy)policy).onJobExecute(storedAction, storedRoute);
            }
        } catch (Exception e) {
            throw new JobExecutionException("Failed to execute Scheduled Job for route " + storedRoute.getId()
                    + " with trigger name: " + jobExecutionContext.getTrigger().getKey(), e);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:ScheduledJob.java


示例2: after

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
@Override
public void after(Exchange exchange, Object data) throws Exception {
    // do not invoke it if Camel is stopping as we don't want
    // the policy to start a consumer during Camel is stopping
    if (isCamelStopping(exchange.getContext())) {
        return;
    }

    for (RoutePolicy policy : routePolicies) {
        try {
            if (isRoutePolicyRunAllowed(policy)) {
                policy.onExchangeDone(route, exchange);
            }
        } catch (Exception e) {
            LOG.warn("Error occurred during onExchangeDone on RoutePolicy: " + policy
                    + ". This exception will be ignored", e);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:CamelInternalProcessor.java


示例3: getRoutePolicyList

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
public String getRoutePolicyList() {
    List<RoutePolicy> policyList = route.getRouteContext().getRoutePolicyList();

    if (policyList == null || policyList.isEmpty()) {
        // return an empty string to have it displayed nicely in JMX consoles
        return "";
    }

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < policyList.size(); i++) {
        RoutePolicy policy = policyList.get(i);
        sb.append(policy.getClass().getSimpleName());
        sb.append("(").append(ObjectHelper.getIdentityHashCode(policy)).append(")");
        if (i < policyList.size() - 1) {
            sb.append(", ");
        }
    }
    return sb.toString();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:ManagedRoute.java


示例4: doStart

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
protected void doStart() throws Exception {
    warmUp();

    for (Route route : routes) {
        // start the route itself
        ServiceHelper.startService(route);

        // invoke callbacks on route policy
        if (route.getRouteContext().getRoutePolicyList() != null) {
            for (RoutePolicy routePolicy : route.getRouteContext().getRoutePolicyList()) {
                routePolicy.onStart(route);
            }
        }

        // fire event
        EventHelper.notifyRouteStarted(camelContext, route);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:RouteService.java


示例5: createRouteBuilder

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // create the flip route policy
            RoutePolicy policy = new FlipRoutePolicy("foo", "bar");

            // use the flip route policy in the foo route
            from("timer://foo")
                .routeId("foo").routePolicy(policy)
                .setBody().constant("Foo message")
                .to("log:foo")
                .to("mock:foo");

            // use the flip route policy in the bar route and do NOT start
            // this route on startup
            from("timer://bar")
                .routeId("bar").routePolicy(policy).noAutoStartup()
                .setBody().constant("Bar message")
                .to("log:bar")
                .to("mock:bar");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:FlipRoutePolicyTest.java


示例6: createRouteBuilder

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // create the flip route policy
            RoutePolicy policy = new FlipRoutePolicy("foo", "bar");

            // use the flip route policy in the foo route
            from("timer:foo?delay=500")
                .routeId("foo").routePolicy(policy)
                .setBody().constant("Foo message")
                .to("log:foo")
                .to("mock:foo");

            // use the flip route policy in the bar route and do NOT start
            // this route on startup
            from("timer:bar?delay=500")
                .routeId("bar").routePolicy(policy).noAutoStartup()
                .setBody().constant("Bar message")
                .to("log:bar")
                .to("mock:bar");
        }
    };
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:26,代码来源:FlipRoutePolicyJavaDSLTest.java


示例7: createRouteBuilder

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // create the flip route policy
            RoutePolicy policy = new FlipRoutePolicy("foo", "bar");

            // use the flip route policy in the foo route
            from("timer://foo?delay=500")
                .routeId("foo").routePolicy(policy)
                .setBody().constant("Foo message")
                .to("log:foo")
                .to("mock:foo");

            // use the flip route policy in the bar route and do NOT start
            // this route on startup
            from("timer://bar?delay=500")
                .routeId("bar").routePolicy(policy).noAutoStartup()
                .setBody().constant("Bar message")
                .to("log:bar")
                .to("mock:bar");
        }
    };
}
 
开发者ID:camelinaction,项目名称:camelinaction,代码行数:26,代码来源:FlipRoutePolicyJavaDSLTest.java


示例8: routePolicy

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
/**
 * Configures route policies for this route
 *
 * @param policies the route policies
 * @return the builder
 */
public RouteDefinition routePolicy(RoutePolicy... policies) {
    if (routePolicies == null) {
        routePolicies = new ArrayList<RoutePolicy>();
    }
    for (RoutePolicy policy : policies) {
        routePolicies.add(policy);
    }
    return this;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:RouteDefinition.java


示例9: isRoutePolicyRunAllowed

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
/**
 * Strategy to determine if this policy is allowed to run
 *
 * @param policy the policy
 * @return <tt>true</tt> to run
 */
protected boolean isRoutePolicyRunAllowed(RoutePolicy policy) {
    if (policy instanceof StatefulService) {
        StatefulService ss = (StatefulService) policy;
        return ss.isRunAllowed();
    }
    return true;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:CamelInternalProcessor.java


示例10: before

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
@Override
public Object before(Exchange exchange) throws Exception {
    // invoke begin
    for (RoutePolicy policy : routePolicies) {
        try {
            if (isRoutePolicyRunAllowed(policy)) {
                policy.onExchangeBegin(route, exchange);
            }
        } catch (Exception e) {
            LOG.warn("Error occurred during onExchangeBegin on RoutePolicy: " + policy
                    + ". This exception will be ignored", e);
        }
    }
    return null;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:CamelInternalProcessor.java


示例11: doSuspend

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
@Override
protected void doSuspend() throws Exception {
    // suspend and resume logic is provided by DefaultCamelContext which leverages ShutdownStrategy
    // to safely suspend and resume
    for (Route route : routes) {
        if (route.getRouteContext().getRoutePolicyList() != null) {
            for (RoutePolicy routePolicy : route.getRouteContext().getRoutePolicyList()) {
                routePolicy.onSuspend(route);
            }
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:RouteService.java


示例12: doResume

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
@Override
protected void doResume() throws Exception {
    // suspend and resume logic is provided by DefaultCamelContext which leverages ShutdownStrategy
    // to safely suspend and resume
    for (Route route : routes) {
        if (route.getRouteContext().getRoutePolicyList() != null) {
            for (RoutePolicy routePolicy : route.getRouteContext().getRoutePolicyList()) {
                routePolicy.onResume(route);
            }
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:RouteService.java


示例13: createRouteStartPolicy

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
private RoutePolicy createRouteStartPolicy() {
    SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
    long startTime = System.currentTimeMillis() + 3000L;
    policy.setRouteStartDate(new Date(startTime));
    policy.setRouteStartRepeatCount(1);
    policy.setRouteStartRepeatInterval(3000);
    
    return policy;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:MultiplePoliciesOnRouteTest.java


示例14: startRouteWithPolicy

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private CamelContext startRouteWithPolicy(String policyBeanName) throws Exception {
    CamelContext context = new DefaultCamelContext();
    List<RouteDefinition> routes = (List<RouteDefinition>)applicationContext.getBean("testRouteContext");
    RoutePolicy policy = applicationContext.getBean(policyBeanName, RoutePolicy.class);
    assertTrue(getTestType() == TestType.SIMPLE 
        ? policy instanceof SimpleScheduledRoutePolicy 
        : policy instanceof CronScheduledRoutePolicy);
    routes.get(0).routePolicy(policy);
    ((ModelCamelContext)context).addRouteDefinitions(routes);
    context.start();
    return context;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:SpringScheduledRoutePolicyTest.java


示例15: createRoutePolicy

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
@Override
public RoutePolicy createRoutePolicy(CamelContext camelContext, String routeId, RouteDefinition routeDefinition) {
    MetricsRoutePolicy answer = new MetricsRoutePolicy();
    answer.setMetricsRegistry(getMetricsRegistry());
    answer.setUseJmx(isUseJmx());
    answer.setJmxDomain(getJmxDomain());
    answer.setPrettyPrint(isPrettyPrint());
    answer.setRateUnit(getRateUnit());
    answer.setDurationUnit(getDurationUnit());
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:MetricsRoutePolicyFactory.java


示例16: createRoutePolicy

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
@Override
public RoutePolicy createRoutePolicy(CamelContext camelContext, String s, RouteDefinition routeDefinition) {
    return new SingleMessageRoutePolicy();
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:5,代码来源:SingleMessageRoutePolicyFactory.java


示例17: createRoutePolicy

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
@Override
public RoutePolicy createRoutePolicy(CamelContext camelContext, String routeId, RouteDefinition route) {
    return new SingleMessageRoutePolicy();
}
 
开发者ID:funktionio,项目名称:funktion-connectors,代码行数:5,代码来源:SingleMessageRoutePolicyFactory.java


示例18: getRoutePolicies

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
public List<RoutePolicy> getRoutePolicies() {
    return routePolicies;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:RouteDefinition.java


示例19: setRoutePolicies

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
@XmlTransient
public void setRoutePolicies(List<RoutePolicy> routePolicies) {
    this.routePolicies = routePolicies;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:RouteDefinition.java


示例20: RoutePolicyAdvice

import org.apache.camel.spi.RoutePolicy; //导入依赖的package包/类
public RoutePolicyAdvice(List<RoutePolicy> routePolicies) {
    this.routePolicies = routePolicies;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:CamelInternalProcessor.java



注:本文中的org.apache.camel.spi.RoutePolicy类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConflictException类代码示例发布时间:1970-01-01
下一篇:
Java AbstractTransformer类代码示例发布时间:1970-01-01
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap