Package com.alibaba.cobar.client.router.support

Examples of com.alibaba.cobar.client.router.support.RoutingResult


    public RoutingResult doRoute(IBatisRoutingFact routingFact) throws RoutingException {
        if (enableCache) {
            synchronized (localCache) {
                if (localCache.containsKey(routingFact)) {
                    RoutingResult result = (RoutingResult) localCache.get(routingFact);
                    logger.info("return routing result:{} from cache for fact:{}", result, routingFact);
                    return result;
                }
            }
        }

        RoutingResult result = new RoutingResult();
        result.setResourceIdentities(new ArrayList<String>());

        IRoutingRule<IBatisRoutingFact, List<String>> ruleToUse = null;
        if (!CollectionUtils.isEmpty(getRuleSequences())) {
            for (Set<IRoutingRule<IBatisRoutingFact, List<String>>> ruleSet : getRuleSequences()) {
                ruleToUse = searchMatchedRuleAgainst(ruleSet, routingFact);
                if (ruleToUse != null) {
                    break;
                }
            }
        }

        if (ruleToUse != null) {
            logger.info("matched with rule:{} with fact:{}", ruleToUse, routingFact);
            result.getResourceIdentities().addAll(ruleToUse.action());
        } else {
            logger.info("No matched rule found for routing fact:{}", routingFact);
        }

        if (enableCache) {
View Full Code Here


        Validate.notEmpty(action);
        String namespace = StringUtils.substringBeforeLast(action, ".");
        List<Set<IRoutingRule<IBatisRoutingFact, List<String>>>> rules = getRulesGroupByNamespaces()
                .get(namespace);

        RoutingResult result = new RoutingResult();
        result.setResourceIdentities(new ArrayList<String>());

        if (!CollectionUtils.isEmpty(rules)) {
            IRoutingRule<IBatisRoutingFact, List<String>> ruleToUse = null;
            for (Set<IRoutingRule<IBatisRoutingFact, List<String>>> ruleSet : rules) {
                ruleToUse = searchMatchedRuleAgainst(ruleSet, routingFact);
                if (ruleToUse != null) {
                    break;
                }
            }

            if (ruleToUse != null) {
                logger.info("matched with rule:{} with fact:{}", ruleToUse, routingFact);
                result.getResourceIdentities().addAll(ruleToUse.action());
            } else {
                logger.info("No matched rule found for routing fact:{}", routingFact);
            }
        }
View Full Code Here

TOP

Related Classes of com.alibaba.cobar.client.router.support.RoutingResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.