Class BeanDefinition

  • All Implemented Interfaces:
    org.apache.camel.CamelContextAware, org.apache.camel.LineNumberAware, Block, org.apache.camel.NamedNode, org.apache.camel.spi.HasId, org.apache.camel.spi.IdAware

    @Metadata(label="eip,endpoint")
    public class BeanDefinition
    extends NoOutputDefinition<BeanDefinition>
    Calls a Java bean
    • Constructor Detail

      • BeanDefinition

        public BeanDefinition()
      • BeanDefinition

        public BeanDefinition​(String ref)
      • BeanDefinition

        public BeanDefinition​(String ref,
                              String method)
    • Method Detail

      • description

        public String description()
      • getShortName

        public String getShortName()
      • getRef

        public String getRef()
      • setRef

        public void setRef​(String ref)
        Sets a reference to an exiting bean to use, which is looked up from the registry
      • getMethod

        public String getMethod()
      • setMethod

        public void setMethod​(String method)
        Sets the method name on the bean to use
      • setBean

        public void setBean​(Object bean)
        Sets an existing instance of the bean to use
      • getBean

        public Object getBean()
      • getBeanType

        public String getBeanType()
      • setBeanType

        public void setBeanType​(String beanType)
        Sets the class name (fully qualified) of the bean to use
      • getBeanClass

        public Class<?> getBeanClass()
      • setBeanType

        public void setBeanType​(Class<?> beanType)
        Sets the class name (fully qualified) of the bean to use
      • setCache

        @Deprecated
        public void setCache​(String cache)
        Deprecated.
        Use singleton option instead
      • getScope

        public String getScope()
      • setScope

        public void setScope​(String scope)
      • setScope

        public void setScope​(org.apache.camel.BeanScope scope)
        Scope of bean. When using singleton scope (default) the bean is created or looked up only once and reused for the lifetime of the endpoint. The bean should be thread-safe in case concurrent threads is calling the bean at the same time. When using request scope the bean is created or looked up once per request (exchange). This can be used if you want to store state on a bean while processing a request and you want to call the same bean instance multiple times while processing the request. The bean does not have to be thread-safe as the instance is only called from the same request. When using prototype scope, then the bean will be looked up or created per call. However in case of lookup then this is delegated to the bean registry such as Spring or CDI (if in use), which depends on their configuration can act as either singleton or prototype scope. So when using prototype scope then this depends on the bean registry implementation.