Annotation Type ImportResource


  • @Retention(RUNTIME)
    @Target(TYPE)
    public @interface ImportResource
    Indicates one or more resources representing Camel XML configuration to import. Resources are currently loaded from the classpath.

    CamelContext elements and other Camel primitives are automatically deployed as CDI beans during the container bootstrap so that they become available for injection at runtime. If such an element has an explicit id attribute set, the corresponding CDI bean is qualified with the @Named qualifier, e.g., given the following Camel XML configuration:

     
     <camelContext id="foo">
         <endpoint id="bar" uri="seda:inbound">
             <property key="queue" value="#queue"/>
             <property key="concurrentConsumers" value="10"/>
         </endpoint>
     <camelContext/>
     
     
    Corresponding CDI beans are automatically deployed and can be injected, e.g.:
     
     @Inject
     @ContextName("foo")
      CamelContext context;
     
     
     
     @Inject
     @Named("bar")
      Endpoint endpoint;
     
     
    Note that CamelContext beans are automatically qualified with both the Named and ContextName qualifiers. If the imported CamelContext element doesn't have an id attribute, the corresponding bean is deployed with the built-in Default qualifier.

    Conversely, CDI beans deployed in the application can be referred to from the Camel XML configuration, usually using the ref attribute, e.g., given the following bean declared:

     
     @Produces
     @Named("baz")
      Processor processor = exchange-> exchange.getIn().setHeader("qux", "quux");
     
     
    A reference to that bean can be declared in the imported Camel XML configuration, e.g.:
     
     <camelContext id="foo">
         <route>
             <from uri="..."/>
             <process ref="baz"/>
         </route>
     <camelContext/>
     
     
    Since:
    2.18.0
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String[] value
      Resource locations from which to import Camel XML configuration.
    • Element Detail

      • value

        String[] value
        Resource locations from which to import Camel XML configuration.
        Returns:
        the locations of the resources to import
        Default:
        {}