Package org.apache.camel.model

Examples of org.apache.camel.model.ProcessorDefinition


            TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();

            // get the list of intercepted nodes
            List<ProcessorDefinition> list = tuow.getInterceptedNodes();
            // get the 2nd last as the last is me (MyErrorProcessor)
            ProcessorDefinition last = list.get(list.size() - 2);

            // set error message
            exchange.getFault().setBody("Failed at: " + last.getLabel());
        }
View Full Code Here


    }

    private String extractPreviousNode(Exchange exchange) {
        if (exchange.getUnitOfWork() instanceof TraceableUnitOfWork) {
            TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();
            ProcessorDefinition last = tuow.getLastInterceptedNode();
            return last != null ? extractNode(last) : null;
        }
        return null;
    }
View Full Code Here

        // compute from and to
        String from = "";
        if (showNode && exchange.getUnitOfWork() instanceof TraceableUnitOfWork) {
            TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();
            ProcessorDefinition prev = tuow.getLastInterceptedNode();
            if (prev != null) {
                from = getNodeMessage(prev);
            } else if (exchange.getFromEndpoint() != null) {
                from = exchange.getFromEndpoint().getEndpointUri();
            }
View Full Code Here

            TraceableUnitOfWork tuow = (TraceableUnitOfWork) exchange.getUnitOfWork();

            // get the list of intercepted nodes
            List<ProcessorDefinition> list = tuow.getInterceptedNodes();
            // get the 2nd last as the last is me (MyErrorProcessor)
            ProcessorDefinition last = list.get(list.size() - 2);

            // set error message
            exchange.getFault().setBody("Failed at: " + last.getLabel());
        }
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

   * Returns true if this node can have output added so that a new Flow can be
   * added from this node to something else
   */
  public boolean canAcceptOutput() {
    Class<?> aClass = getCamelDefinitionClass();
    ProcessorDefinition def = createCamelDefinition();
    return CamelModelUtils.canAcceptOutput(aClass, def);
  }
View Full Code Here

   *
   * However sometimes we don't want to do that for certain nodes as they can already accept input
   */
  public boolean isNextSiblingStepAddedAsNodeChild() {
    Class<?> aClass = getCamelDefinitionClass();
    ProcessorDefinition def = createCamelDefinition();
    return CamelModelUtils.isNextSiblingStepAddedAsNodeChild(aClass, def);
  }
View Full Code Here

   * @return a random id
   */
  public String getNewID() {
    String answer = null;
    if (useCamelIds) {
      ProcessorDefinition definition = createCamelDefinition();
      if (definition != null) {
        answer = definition.idOrCreate(getNodeIdFactory());
      }
    }
    if (answer == null) {
      answer = UUID.randomUUID().toString();
    }
View Full Code Here

        return "load balance";
      }
    }

    String answer = null;
    @SuppressWarnings("rawtypes")
    ProcessorDefinition camelDef = createCamelDefinition();
    if (camelDef != null) {
      try {
        answer = camelDef.getLabel();
      } catch (Exception e) {
        // ignore errors in Camel
      }
    }
    if (Strings.isBlank(answer)) {
View Full Code Here

      When node = (When) this;
      return "when " + Expressions.getExpressionOrElse(node.getExpression());
    }
    String answer = Tooltips.tooltip(getPatternName());
    if (answer == null) {
      ProcessorDefinition camelDef = createCamelDefinition();
      if (camelDef != null) {
        if (camelDef instanceof RouteDefinition) {
          RouteDefinition route = (RouteDefinition) camelDef;
          return "Route " + (route.getId() != null ? route.getId() : "");
        } else if (camelDef instanceof ToDefinition && isNotTarget()) {
          // if its the first in the route and its an endpoint, then use From instead of To
          // (notice that createCamelDefinition returns a ToDefinition for all kind of Endpoints)
          return "From " + camelDef.getLabel();
        }
        return camelDef.getShortName() + " " + camelDef.getLabel();
      }
      return getDescription();
    }
    return answer;
  }
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.