Available as of hawtio 1.2.1
hawtio offers a number of Maven Plugins, so that users can bootup Maven projects and have hawtio embedded in the running JVM.
hawtio offers the following Maven Goals, and each goal is further documented below:
All of the hawtio Maven Plugins provides the following common options:
Currently all of the hawtio Maven Plugins provides the following common options:
The spring goal extends the run goal and provides the following additional options:
The camel goal extends the run goal and provides the following additional options:
By default the camel plugin will assume the application is a Camel spring application and use the applicationContextUri or fileApplicationContextUri to use as Spring XML files. By configurign a custom mainClass, then the Camel application is using the custom mainClass to bootstrap the Camel application, and neither applicationContextUri, nor fileApplicationContextUri are in use.
The camel goal extends the run goal and provides the following additional options:
The test hawtio Maven Plugins provides the following common options:
If no className has been specified then hawtio is started up included the projects test classpath, and the junit plugin can be used to select tests to run from within hawtio console itself.
If a className has been specified then unit testing of the selected class happens when hawtio has been started, but the unit test will not tear down until the user press enter in the shell. This is on purpose allowing using hawtio to inspect the state of the JVM during and after testing. For example to look at the Camel plugin to see route diagrams and profiles with metrics from the completed unit tests.
Pressing enter in the shell runs the tear down of the unit tests, which for example could unregister Camel from JMX and therefore remove the CamelContext used during testing. When using the junit plugin to run unit tests, then these tests will tear down immediately when they complete, and therefore remove any CamelContexts during testing. This may change in the future, allows to keep the CamelContexts alive after testing, giving end users time to inspect the data; and then tear down by pressing a button.
In the Maven pom.xml file, the hawtio plugin is configured by adding the following in the <build><plugin>section:
<plugin> <groupId>io.hawt</groupId> <artifactId>hawtio-maven-plugin</artifactId> <version>1.4.14</version> <configuration> <!-- configuration options goes here --> </configuration> </plugin>
In the <configuration> section we can configure the plugin with any of the options mentioned before. For example to log the classpath:
<configuration> <logClasspath>true</logClasspath> </configuration>
And to change the port number from 8282 to 8090 do:
<configuration> <logClasspath>true</logClasspath> <port>8090</port> </configuration>
And to set a number of system properties to the JVM, such as the JVM http proxy settings is simply done within the nested <systemProperties> tag:
<configuration> <logClasspath>true</logClasspath> <port>8090</port> <systemProperties> <http.proxyHost>myproxyserver.org</http.proxyHost> <http.proxyPort>8081<http.proxyPort> </systemProperties> </configuration>
The Apache Camel distributons includes a number of examples, which you can try out using Maven plugins.
For example to try the Camel console from a shell type:
cd examples cd camel-example-console mvn compile mvn camel:run
To run the same example with hawtio embedded as a web console, you simply do
cd examples cd camel-example-console mvn compile mvn io.hawt:hawtio-maven-plugin:1.4.14:camel
Where 1.4.14 is the hawtio version to use.
In any Maven pom.xml file you can include the hawtio Maven plugin. For example to include the hawtio plugin in the Camel console example, you edit the pom.xml file in examples/camel-example-console directory.
In the <build><plugin>section add the following xml code:
<plugin> <groupId>io.hawt</groupId> <artifactId>hawtio-maven-plugin</artifactId> <version>1.4.14</version> </plugin>
And you can run the console example simply by typing
mvn hawtio:camel
And the example is started together with the embedded hawtio web console, such as the screenshot below illustrates: