Class BeanFactoryDefinition<P>

java.lang.Object
org.apache.camel.model.BeanFactoryDefinition<P>
All Implemented Interfaces:
org.apache.camel.spi.ResourceAware

@Metadata(label="configuration") public class BeanFactoryDefinition<P> extends Object implements org.apache.camel.spi.ResourceAware
Define custom beans that can be used in your Camel routes and in general.
  • Constructor Details

    • BeanFactoryDefinition

      public BeanFactoryDefinition()
  • Method Details

    • setParent

      public void setParent(P parent)
    • setBeanType

      public void setBeanType(Class<?> beanType)
      To set the type (fully qualified class name) to use for creating the bean.
    • getBeanClass

      public Class<?> getBeanClass()
    • getBeanSupplier

      public org.apache.camel.RouteTemplateContext.BeanSupplier<Object> getBeanSupplier()
    • setBeanSupplier

      public void setBeanSupplier(org.apache.camel.RouteTemplateContext.BeanSupplier<Object> beanSupplier)
      Bean supplier that uses lambda style to create the local bean
    • getName

      public String getName()
    • setName

      public void setName(String name)
      The name of the bean (bean id)
    • getType

      public String getType()
    • setType

      public void setType(String type)
      The class name (fully qualified) of the bean
    • getInitMethod

      public String getInitMethod()
    • setInitMethod

      public void setInitMethod(String initMethod)
      The name of the custom initialization method to invoke after setting bean properties. The method must have no arguments, but may throw any exception.
    • getDestroyMethod

      public String getDestroyMethod()
    • setDestroyMethod

      public void setDestroyMethod(String destroyMethod)
      The name of the custom destroy method to invoke on bean shutdown, such as when Camel is shutting down. The method must have no arguments, but may throw any exception.
    • getFactoryMethod

      public String getFactoryMethod()
    • setFactoryMethod

      public void setFactoryMethod(String factoryMethod)
      Name of method to invoke when creating the bean via a factory bean.
    • getFactoryBean

      public String getFactoryBean()
    • setFactoryBean

      public void setFactoryBean(String factoryBean)
      Name of factory bean (bean id) to use for creating the bean.
    • getBuilderClass

      public String getBuilderClass()
    • setBuilderClass

      public void setBuilderClass(String builderClass)
      Fully qualified class name of builder class to use for creating and configuring the bean. The builder will use the properties values to configure the bean.
    • getBuilderMethod

      public String getBuilderMethod()
    • setBuilderMethod

      public void setBuilderMethod(String builderMethod)
      Name of method when using builder class. This method is invoked after configuring to create the actual bean. This method is often named build (used by default).
    • getConstructors

      public Map<Integer,Object> getConstructors()
    • setConstructors

      public void setConstructors(Map<Integer,Object> constructors)
      Optional constructor arguments for creating the bean. Arguments correspond to specific index of the constructor argument list, starting from zero.
    • getProperties

      public Map<String,Object> getProperties()
    • setProperties

      public void setProperties(Map<String,Object> properties)
      Optional properties to set on the created bean.
    • getScriptLanguage

      public String getScriptLanguage()
    • setScriptLanguage

      public void setScriptLanguage(String scriptLanguage)
      The script language to use when using inlined script for creating the bean, such as groovy, java, javascript etc.
    • setScript

      public void setScript(String script)
      The script to execute that creates the bean when using scripting languages. If the script use the prefix resource: such as resource:classpath:com/foo/myscript.groovy, resource:file:/var/myscript.groovy, then its loaded from the external resource.
    • getScript

      public String getScript()
    • type

      public BeanFactoryDefinition<P> type(String prefix, Class<?> type)
      What type to use for creating the bean. Can be one of: #class or #type #class or #type then the bean is created via the fully qualified classname, such as #class:com.foo.MyBean
    • type

      public BeanFactoryDefinition<P> type(String type)
      What type to use for creating the bean. Can be one of: #class or #type #class or #type then the bean is created via the fully qualified classname, such as #class:com.foo.MyBean
    • typeClass

      public BeanFactoryDefinition<P> typeClass(Class<?> type)
      Creates the bean from the given class type
      Parameters:
      type - the type of the class to create as bean
    • typeClass

      public BeanFactoryDefinition<P> typeClass(String type)
      Creates the bean from the given class type
      Parameters:
      type - the type of the class to create as bean
    • beanType

      public BeanFactoryDefinition<P> beanType(Class<?> type)
      To set the type (fully qualified class name) to use for creating the bean.
      Parameters:
      type - the fully qualified type of the returned bean
    • bean

      public P bean(Class<?> type)
      Calls a method on a bean for creating the local bean
      Parameters:
      type - the bean class to call
    • bean

      public P bean(Class<?> type, String method)
      Calls a method on a bean for creating the local bean
      Parameters:
      type - the bean class to call
      method - the name of the method to call
    • initMethod

      public BeanFactoryDefinition<P> initMethod(String initMethod)
      The name of the custom initialization method to invoke after setting bean properties. The method must have no arguments, but may throw any exception.
    • destroyMethod

      public BeanFactoryDefinition<P> destroyMethod(String destroyMethod)
      The name of the custom destroy method to invoke on bean shutdown, such as when Camel is shutting down. The method must have no arguments, but may throw any exception.
    • factoryMethod

      public BeanFactoryDefinition<P> factoryMethod(String factoryMethod)
      Name of method to invoke when creating the bean via a factory bean.
    • factoryBean

      public BeanFactoryDefinition<P> factoryBean(String factoryBean)
      Name of factory bean (bean id) to use for creating the bean.
    • builderClass

      public BeanFactoryDefinition<P> builderClass(String builderClass)
      Fully qualified class name of builder class to use for creating and configuring the bean. The builder will use the properties values to configure the bean.
    • builderMethod

      public BeanFactoryDefinition<P> builderMethod(String builderMethod)
      Name of method when using builder class. This method is invoked after configuring to create the actual bean. This method is often named build (used by default).
    • groovy

      public P groovy(String script)
      Calls a groovy script for creating the local bean If the script use the prefix resource: such as resource:classpath:com/foo/myscript.groovy, resource:file:/var/myscript.groovy, then its loaded from the external resource.
      Parameters:
      script - the script
    • joor

      public P joor(String script)
      Calls joor script (Java source that is runtime compiled to Java bytecode) for creating the local bean If the script use the prefix resource: such as resource:classpath:com/foo/myscript.groovy, resource:file:/var/myscript.groovy, then its loaded from the external resource.
      Parameters:
      script - the script
    • java

      public P java(String script)
      Calls java (Java source that is runtime compiled to Java bytecode) for creating the local bean If the script use the prefix resource: such as resource:classpath:com/foo/myscript.groovy, resource:file:/var/myscript.groovy, then its loaded from the external resource.
      Parameters:
      script - the script
    • language

      public P language(String language, String script)
      Calls a custom language for creating the local bean If the script use the prefix resource: such as resource:classpath:com/foo/myscript.groovy, resource:file:/var/myscript.groovy, then its loaded from the external resource.
      Parameters:
      language - the language
      script - the script
    • mvel

      public P mvel(String script)
      Calls a MvEL script for creating the local bean If the script use the prefix resource: such as resource:classpath:com/foo/myscript.groovy, resource:file:/var/myscript.groovy, then its loaded from the external resource.
      Parameters:
      script - the script
    • ognl

      public P ognl(String script)
      Calls a OGNL script for creating the local bean If the script use the prefix resource: such as resource:classpath:com/foo/myscript.groovy, resource:file:/var/myscript.groovy, then its loaded from the external resource.
      Parameters:
      script - the script
    • constructor

      public BeanFactoryDefinition<P> constructor(Integer index, String value)
      Sets a constructor for creating the bean. Arguments correspond to specific index of the constructor argument list, starting from zero.
      Parameters:
      index - the constructor index (starting from zero)
      value - the constructor value
    • constructors

      public BeanFactoryDefinition<P> constructors(Map<Integer,Object> constructors)
      Optional constructor arguments for creating the bean. Arguments correspond to specific index of the constructor argument list, starting from zero.
    • property

      public BeanFactoryDefinition<P> property(String key, String value)
      Sets a property to set on the created local bean
      Parameters:
      key - the property name
      value - the property value
    • properties

      public BeanFactoryDefinition<P> properties(Map<String,Object> properties)
      Sets properties to set on the created local bean
    • end

      public P end()
    • getResource

      public org.apache.camel.spi.Resource getResource()
      Specified by:
      getResource in interface org.apache.camel.spi.ResourceAware
    • setResource

      public void setResource(org.apache.camel.spi.Resource resource)
      Specified by:
      setResource in interface org.apache.camel.spi.ResourceAware