concept dependency in category camel

appears as: dependencies, dependency, dependency, dependencies
Camel in Action

This is an excerpt from Manning's book Camel in Action.

The Maven POM in listing 1.3 is probably one of the shortest POMs you’ll ever see—almost everything uses the defaults provided by Maven. Besides those defaults, some settings are configured in the parent POM ❶. Probably the most important section to point out here is the dependency on the Camel library ❷. This dependency element tells Maven to do the following:

  • Create a search path based on the groupId, artifactId, and version. The version element is set to the camel-version property, which is defined in the POM referenced in the parent element ❶, and resolves to 2.20.1. The type of dependency isn’t specified, so the JAR file type is assumed. The search path is org/apache/camel/camel-core/2.20.1/camel-core-2.20.1.jar.
  • In the previous section, you built a Camel microservice using CDI. Now you want to take that application and run it on WildFly Swarm, so you choose Camel CDI and CDI as dependencies. You then need to make one other change, because you’re using Jetty as the HTTP server, but WildFly Swarm comes out of the box with its own HTTP server named Undertow. This requires you to change the source code, as shown in Listing 7.5.

    Figure 7.1 Creating a new WildFly Swarm project from the generator web page (http://wildfly-swarm.io/generator/). Here we’ve chosen Camel CDI and CDI as the dependencies we need. Clicking the view all dependencies link shows all the dependencies you can choose from. Clicking Generate Project downloads a zip file with the generated source code.

    c07_01.png
    Listing 7.5 Hello service using Undertow as HTTP server
    @Singleton public class HelloRoute extends RouteBuilder { @Inject private HelloBean hello; @Inject @Uri("undertow:http://localhost:8080/hello") private Endpoint undertow; @Override public void configure() throws Exception { from(undertow) .bean(hello, "sayHello"); } } Use Undertow as HTTP server as it comes out of the box with WildFly Swarm

    And you also need to add camel-undertow as a dependency to your Maven pom.xml file, as shown here:

    <dependency> <groupId>org.wildfly.swarm</groupId> <artifactId>camel-undertow</artifactId> </dependency>

    Notice that the groupId of the dependency isn’t org.apache.camel, but is org.wildfly.swarm. The reason is that WildFly Swarm provides numerous supported and curated dependencies. These dependencies are called fragments in WildFly Swarm. In this case, there’s a fragment for making Camel and Undertow work together, hence you must use this dependency.