Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-5554

allow XML DSL to work in CDI

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.11.0
    • camel-cdi
    • None
    • Unknown

    Description

      I can see folks wanting to also use CDI with the XML DSL for Camel route definitions (e.g. so they can use round tripping visual editors rather than using the Java DSL, but use CDI for all dependency injection to minimise XML use for configuration).

      Maybe we could have some simple way to import routes into a CDI @Produces method using some helper class; so the routes can then be injected via CDI into a CamelContext?

      public class MyConfiguration {
        // loads some routes for injection into the CamelContext
        @Produces
        List<RouteDefinitions>  loadRoutes() {
           return XmlRouteLoader.loadFromClassPath("com/acme/something/blah.xml");
        }
      }
      

      or maybe we should allow routes to be injected so that they could be used to create a CamelContext...

      public class MyConfiguration {
        @Inject @RouteXml(classpath="com/acme/something/blah.xml")
        List<RouteDefinitions> routes;
      
        @Produces
        CamelContext  createContext() {
           return new CdiCamelContext(routes);
        }
      }
      

      Attachments

        Issue Links

          Activity

            People

              jstrachan James Strachan
              jstrachan James Strachan
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: