concept classpath in category camel

appears as: classpath, classpath
Camel in Action

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

From this point on, though, we won’t be using the distribution at all. All the examples in the book’s source use Apache Maven, which means that Camel libraries will be downloaded automatically for you—there’s no need to make sure the Camel distribution’s libraries are on the classpath.

The file consumer picks up new files and routes them to the XSLT component, which transforms the payload by using the stylesheet. After the transformation, the message is routed to a JMS producer, which sends the message to the JMS queue. Notice in the preceding code how the URI for the XSLT component is defined: xslt://camelinaction/transform.xsl. The part after the scheme is the URI location of the stylesheet to use. Camel will look in the classpath by default. To look elsewhere, you can prefix the resource name with any of the prefixes listed in table 3.2.

Table 3.2 Prefixes supported by the XSLT component for loading stylesheets
Prefix Example Description
<none> xslt://camelinaction/transform.xsl If no prefix is provided, Camel loads the resource from the classpath.
file: xslt://file:/rider/config/transform.xml Loads the resource from the filesystem.
http: xslt://http://rider.com/styles/transform.xsl Loads the resource from a URL.
ref: xslt://ref:resourceId Look up the resource from the registry.
bean: xslt://bean:nameOfBean.methodName Look up a bean in the registry and call a method which returns the resource.

Figure 6.2 To autodiscover a component named “bean,” the component resolver searches for a file named “bean” in a specific directory on the classpath. This file specifies that the component class that will be created is BeanComponent.

c06_02.png
Listing 20.11 Initializing the list of games
private void initGames() { try { InputStream is = LiveScoreVerticle.class.getClassLoader() .getResourceAsStream("games.csv"); String text = IOHelper.loadText(is);     #1 Stream<String> games = Arrays.stream(text.split("\n")); games.forEach(game -> vertx.eventBus().publish("games", game));     #2 } catch (Exception e) { System.out.println("Error reading games.csv file"); } if (clockRunning.get()) {     #3 vertx.eventBus().publish("clock", "" + gameTime.get());     #3 } else {     #3 vertx.eventBus().publish("clock", "Stopped");     #3 }     #3 }     #3 #1 Loads list of games from classpath #2 Publishes each game to the event bus #3 Publishes game clock time