Package org.apache.camel.model

Examples of org.apache.camel.model.ProcessorDefinition


        // add onCompletion *after* intercept, as its important intercept is first
        if (!hasRouteScope) {
            int index = 0;
            for (int i = 0; i < route.getOutputs().size(); i++) {
                index = i;
                ProcessorDefinition out = route.getOutputs().get(i);
                if (out instanceof InterceptDefinition || out instanceof InterceptSendToEndpointDefinition) {
                    continue;
                } else {
                    // we found the spot
                    break;
View Full Code Here


        // instrument the route endpoint
        final Endpoint endpoint = routeContext.getEndpoint();

        // register route on the first suitable output
        ProcessorDefinition out = null;
        for (ProcessorDefinition processor : routeContext.getRoute().getOutputs()) {
            // skip processors that should not be registered
            if (!registerProcessor(processor)) {
                continue;
            }
            out = processor;
            break;
        }

        // add an intercept strategy that counts when the route sends to any of its outputs
        if (out != null) {
            out.addInterceptStrategy(new InterceptStrategy() {
                public Processor wrapProcessorInInterceptors(CamelContext context, ProcessorDefinition definition,
                                                             Processor target, Processor nextTarget) throws Exception {
                    if (registeredRoutes.containsKey(endpoint)) {
                        // do not double wrap
                        return target;
View Full Code Here

    public NodeData(String id, Object node, String imagePrefix) {
        this.id = id;
        this.imagePrefix = imagePrefix;

        if (node instanceof ProcessorDefinition) {
            ProcessorDefinition processorType = (ProcessorDefinition)node;
            this.edgeLabel = processorType.getLabel();
        }
        if (node instanceof FromDefinition) {
            FromDefinition fromType = (FromDefinition)node;
            this.tooltop = fromType.getLabel();
            this.label = removeQueryString(this.tooltop);
            this.url = "http://camel.apache.org/message-endpoint.html";
        } else if (node instanceof ToDefinition) {
            ToDefinition toType = (ToDefinition)node;
            this.tooltop = toType.getLabel();
            this.label = removeQueryString(this.tooltop);
            this.edgeLabel = "";
            this.url = "http://camel.apache.org/message-endpoint.html";
        } else if (node instanceof FilterDefinition) {
            this.image = imagePrefix + "MessageFilterIcon.png";
            this.label = "Filter";
            this.nodeType = "Message Filter";
        } else if (node instanceof WhenDefinition) {
            this.image = imagePrefix + "MessageFilterIcon.png";
            this.nodeType = "When Filter";
            this.label = "When";
            this.url = "http://camel.apache.org/content-based-router.html";
        } else if (node instanceof OtherwiseDefinition) {
            this.nodeType = "Otherwise";
            this.edgeLabel = "";
            this.url = "http://camel.apache.org/content-based-router.html";
            this.tooltop = "Otherwise";
        } else if (node instanceof ChoiceDefinition) {
            this.image = imagePrefix + "ContentBasedRouterIcon.png";
            this.nodeType = "Content Based Router";
            this.label = "Choice";
            this.edgeLabel = "";

            ChoiceDefinition choice = (ChoiceDefinition)node;
            List<ProcessorDefinition> outputs = new ArrayList<ProcessorDefinition>(choice.getWhenClauses());
            if (choice.getOtherwise() != null) {
                outputs.add(choice.getOtherwise());
            }
            this.outputs = outputs;
        } else if (node instanceof RecipientListDefinition) {
            this.image = imagePrefix + "RecipientListIcon.png";
            this.nodeType = "Recipient List";
        } else if (node instanceof RoutingSlipDefinition) {
            this.image = imagePrefix + "RoutingTableIcon.png";
            this.nodeType = "Routing Slip";
            this.url = "http://camel.apache.org/routing-slip.html";
            this.tooltop = ((RoutingSlipDefinition) node).getHeaderName();
        } else if (node instanceof SplitDefinition) {
            this.image = imagePrefix + "SplitterIcon.png";
            this.nodeType = "Splitter";
        } else if (node instanceof AggregateDefinition) {
            this.image = imagePrefix + "AggregatorIcon.png";
            this.nodeType = "Aggregator";
        } else if (node instanceof ResequenceDefinition) {
            this.image = imagePrefix + "ResequencerIcon.png";
            this.nodeType = "Resequencer";
        } else if (node instanceof BeanDefinition) {
            BeanDefinition beanRef = (BeanDefinition) node;

            // TODO
            //this.image = imagePrefix + "Bean.png";
            this.nodeType = "Bean Ref";
            this.label = beanRef.getLabel() + " Bean";
            this.shape = "box";
        }

        // lets auto-default as many values as we can
        if (isEmpty(this.nodeType) && node != null) {
            // TODO we could add this to the model?
            String name = node.getClass().getName();
            int idx = name.lastIndexOf('.');
            if (idx > 0) {
                name = name.substring(idx + 1);
            }
            if (name.endsWith("Type")) {
                name = name.substring(0, name.length() - 4);
            }
            this.nodeType = insertSpacesBetweenCamelCase(name);
        }
        if (this.label == null) {
            if (isEmpty(this.image)) {
                this.label = this.nodeType;
                this.shape = "box";
            } else if (isNotEmpty(this.edgeLabel)) {
                this.label = "";
            } else {
                this.label = node.toString();
            }
        }
        if (isEmpty(this.tooltop)) {
            if (isNotEmpty(this.nodeType)) {
                String description = isNotEmpty(this.edgeLabel) ? this.edgeLabel : this.label;
                this.tooltop = this.nodeType + ": " + description;
            } else {
                this.tooltop = this.label;
            }
        }
        if (isEmpty(this.url) && isNotEmpty(this.nodeType)) {
            this.url = "http://camel.apache.org/" + this.nodeType.toLowerCase().replace(' ', '-') + ".html";
        }
        if (node instanceof ProcessorDefinition && this.outputs == null) {
            ProcessorDefinition processorType = (ProcessorDefinition)node;
            this.outputs = processorType.getOutputs();
        }
    }
View Full Code Here

        for (Processor child : nav.next()) {

            if (child instanceof Channel) {
                Channel channel = (Channel) child;
                ProcessorDefinition def = channel.getProcessorDefinition();
                navigateDefinition(def, sb);
            }
        }
    }
View Full Code Here

        for (Processor child : nav.next()) {

            if (child instanceof DefaultChannel) {
                DefaultChannel channel = (DefaultChannel) child;
                ProcessorDefinition def = channel.getProcessorDefinition();
                navigateDefinition(def, sb);
            }
        }
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    private void navigateDefinition(ProcessorDefinition<?> def, StringBuilder sb) {

        // must do this ugly cast to avoid compiler error on HP-UX
        ProcessorDefinition defn = (ProcessorDefinition) def;

        if (defn instanceof LoadBalanceDefinition) {
            sb.append(".loadBalance()");

            LoadBalanceDefinition lbd = (LoadBalanceDefinition) defn;
            LoadBalancer balancer = lbd.getLoadBalancerType().getLoadBalancer(null);
            if (balancer instanceof RandomLoadBalancer) {
                sb.append(".random()");
            }
        }

        if (defn instanceof SendDefinition) {
            SendDefinition send = (SendDefinition) defn;
            sb.append(".to(\"" + send.getUri() + "\")");
        }

        List<ProcessorDefinition> children = defn.getOutputs();
        if (children == null || children.isEmpty()) {
            return;
        }

        for (ProcessorDefinition child : children) {
View Full Code Here

        // add onCompletion *after* intercept, as its important intercept is first
        if (!hasRouteScope) {
            int index = 0;
            for (int i = 0; i < route.getOutputs().size(); i++) {
                index = i;
                ProcessorDefinition out = route.getOutputs().get(i);
                if (out instanceof InterceptDefinition || out instanceof InterceptSendToEndpointDefinition) {
                    continue;
                } else {
                    // we found the spot
                    break;
View Full Code Here

        // add onCompletion *after* intercept, as its important intercept is first
        if (!hasRouteScope) {
            int index = 0;
            for (int i = 0; i < route.getOutputs().size(); i++) {
                index = i;
                ProcessorDefinition out = route.getOutputs().get(i);
                if (out instanceof InterceptDefinition || out instanceof InterceptSendToEndpointDefinition) {
                    continue;
                } else {
                    // we found the spot
                    break;
View Full Code Here

                                            final Iterator<ProcessorDefinition> it) {
        return new AdviceWithTask() {
            public void task() throws Exception {
                boolean match = false;
                while (it.hasNext()) {
                    ProcessorDefinition output = it.next();
                    if (matchBy.match(output)) {
                        ProcessorDefinition parent = output.getParent();
                        if (parent != null) {
                            int index = parent.getOutputs().indexOf(output);
                            if (index != -1) {
                                match = true;
                                parent.getOutputs().add(index + 1, replace);
                                Object old = parent.getOutputs().remove(index);
                                LOG.info("AdviceWith (" + matchBy.getId() + ") : [" + old + "] --> replace [" + replace + "]");
                            }
                        }
                    }
                }
View Full Code Here

                                           final Iterator<ProcessorDefinition> it) {
        return new AdviceWithTask() {
            public void task() throws Exception {
                boolean match = false;
                while (it.hasNext()) {
                    ProcessorDefinition output = it.next();
                    if (matchBy.match(output)) {
                        ProcessorDefinition parent = output.getParent();
                        if (parent != null) {
                            int index = parent.getOutputs().indexOf(output);
                            if (index != -1) {
                                match = true;
                                Object old = parent.getOutputs().remove(index);
                                LOG.info("AdviceWith (" + matchBy.getId() + ") : [" + old + "] --> remove");
                            }
                        }
                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.camel.model.ProcessorDefinition

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.