[ 
https://issues.apache.org/jira/browse/CAMEL-5554?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

james strachan updated CAMEL-5554:
----------------------------------

    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?

{code}
public class MyConfiguration {
  // loads some routes for injection into the CamelContext
  @Produces
  List<RouteDefinitions>  loadRoutes() {
     return XmlRouteLoader.loadFromClassPath("com/acme/something/blah.xml");
  }
}
{code}
or maybe we should allow routes to be injected so that they could be used to 
create a CamelContext...

{code}
public class MyConfiguration {
  @Inject @RouteXml(classpath="com/acme/something/blah.xml")
  List<RouteDefinitions> routes;

  @Produces
  CamelContext  createContext() {
     return new CdiCamelContext(routes);
  }
}
{code}


  was:
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?

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



    
> allow XML DSL to work in CDI
> ----------------------------
>
>                 Key: CAMEL-5554
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5554
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-cdi
>            Reporter: james strachan
>
> 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?
> {code}
> public class MyConfiguration {
>   // loads some routes for injection into the CamelContext
>   @Produces
>   List<RouteDefinitions>  loadRoutes() {
>      return XmlRouteLoader.loadFromClassPath("com/acme/something/blah.xml");
>   }
> }
> {code}
> or maybe we should allow routes to be injected so that they could be used to 
> create a CamelContext...
> {code}
> public class MyConfiguration {
>   @Inject @RouteXml(classpath="com/acme/something/blah.xml")
>   List<RouteDefinitions> routes;
>   @Produces
>   CamelContext  createContext() {
>      return new CdiCamelContext(routes);
>   }
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to