Class BeanExpression

  • All Implemented Interfaces:
    org.apache.camel.AfterPropertiesConfigured, org.apache.camel.Expression, org.apache.camel.Predicate

    public class BeanExpression
    extends Object
    implements org.apache.camel.Expression, org.apache.camel.Predicate, org.apache.camel.AfterPropertiesConfigured
    Evaluates an expression using a bean method invocation
    • Constructor Detail

      • BeanExpression

        public BeanExpression​(Object bean,
                              String method)
      • BeanExpression

        public BeanExpression​(String beanName,
                              String method)
      • BeanExpression

        public BeanExpression​(Class<?> type,
                              String method)
    • Method Detail

      • getBean

        public Object getBean()
      • setBean

        public void setBean​(Object bean)
      • getBeanName

        public String getBeanName()
      • setBeanName

        public void setBeanName​(String beanName)
      • getType

        public Class<?> getType()
      • setType

        public void setType​(Class<?> type)
      • getMethod

        public String getMethod()
      • setMethod

        public void setMethod​(String method)
      • init

        public void init​(org.apache.camel.CamelContext context)
        Specified by:
        init in interface org.apache.camel.Expression
        Specified by:
        init in interface org.apache.camel.Predicate
      • evaluate

        public Object evaluate​(org.apache.camel.Exchange exchange)
      • evaluate

        public <T> T evaluate​(org.apache.camel.Exchange exchange,
                              Class<T> type)
        Specified by:
        evaluate in interface org.apache.camel.Expression
      • matches

        public boolean matches​(org.apache.camel.Exchange exchange)
        Specified by:
        matches in interface org.apache.camel.Predicate
      • afterPropertiesConfigured

        public void afterPropertiesConfigured​(org.apache.camel.CamelContext camelContext)
        Specified by:
        afterPropertiesConfigured in interface org.apache.camel.AfterPropertiesConfigured
      • validateHasMethod

        protected void validateHasMethod​(org.apache.camel.CamelContext context,
                                         Object bean,
                                         Class<?> type,
                                         String method)
        Validates the given bean has the method.

        This implementation will skip trying to validate OGNL method name expressions.

        Parameters:
        context - camel context
        bean - the bean instance
        type - the bean type
        method - the method, can be null if no method name provided
        Throws:
        org.apache.camel.RuntimeCamelException - is thrown if bean does not have the method