camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject git commit: CAMEL-7023: Added hawtio goal to camel maven plugin.
Date Thu, 28 Nov 2013 12:46:58 GMT
Updated Branches:
  refs/heads/master dbbcf9b2f -> be843eeac


CAMEL-7023: Added hawtio goal to camel maven plugin.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/be843eea
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/be843eea
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/be843eea

Branch: refs/heads/master
Commit: be843eeacbd5ff73fab796a7c17ad781255f4123
Parents: dbbcf9b
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Nov 28 13:47:25 2013 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Nov 28 13:49:07 2013 +0100

----------------------------------------------------------------------
 parent/pom.xml                                  |  1 +
 tooling/maven/camel-maven-plugin/pom.xml        |  7 +++
 .../java/org/apache/camel/maven/HawtioMojo.java | 58 ++++++++++++++++++++
 .../java/org/apache/camel/maven/RunMojo.java    | 21 +++++--
 4 files changed, 83 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/be843eea/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 2298000..6dbbde3 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -174,6 +174,7 @@
     <hawtbuf-version>1.9</hawtbuf-version>
     <hawtdb-version>1.6</hawtdb-version>
     <hawtdispatch-version>1.18</hawtdispatch-version>
+    <hawtio-version>1.2.0</hawtio-version>
     <hazelcast-version>3.0.2</hazelcast-version>
     <hbase-version>0.94.10</hbase-version>
     <hbase-bundle-version>0.94.6_1</hbase-bundle-version>

http://git-wip-us.apache.org/repos/asf/camel/blob/be843eea/tooling/maven/camel-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-maven-plugin/pom.xml b/tooling/maven/camel-maven-plugin/pom.xml
index ebd7b78..d4d160b 100644
--- a/tooling/maven/camel-maven-plugin/pom.xml
+++ b/tooling/maven/camel-maven-plugin/pom.xml
@@ -53,6 +53,13 @@
       <artifactId>camel-cdi</artifactId>
     </dependency>
 
+    <!--for the hawtio goal -->
+    <dependency>
+      <groupId>io.hawt</groupId>
+      <artifactId>hawtio-app</artifactId>
+      <version>${hawtio-version}</version>
+    </dependency>
+
     <dependency>
       <groupId>org.codehaus.mojo</groupId>
       <artifactId>exec-maven-plugin</artifactId>

http://git-wip-us.apache.org/repos/asf/camel/blob/be843eea/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/HawtioMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/HawtioMojo.java
b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/HawtioMojo.java
new file mode 100644
index 0000000..1c8f697
--- /dev/null
+++ b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/HawtioMojo.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven;
+
+import java.lang.reflect.Method;
+
+/**
+ * Runs a CamelContext using any Spring or Blueprint XML configuration files found in
+ * <code>META-INF/spring/*.xml</code>, and <code>OSGI-INF/blueprint/*.xml</code>,
+ * and <code>camel-*.xml</code> and starting up the context together with
+ * <a href="http://hawt.io/">hawtio</a> as web console.
+ *
+ * @goal hawtio
+ * @requiresDependencyResolution compile+runtime
+ * @execute phase="test-compile"
+ */
+public class HawtioMojo extends RunMojo {
+
+    /**
+     * The port number to use for the hawtio web console.
+     *
+     * @parameter property="camel.port"
+     *            default-value="8080"
+     */
+    private int port = 8080;
+
+    public HawtioMojo() {
+        extendedPluginDependencyArtifactId = "hawtio-app";
+    }
+
+    @Override
+    void beforeBootstrapCamel() throws Exception {
+        getLog().info("Starting hawtio ...");
+        Method hawtioMain = Thread.currentThread().getContextClassLoader().loadClass("io.hawt.app.App")
+                .getMethod("main", new Class[] {String[].class});
+        if (!hawtioMain.isAccessible()) {
+            getLog().debug("Setting accessibility to true in order to invoke main().");
+            hawtioMain.setAccessible(true);
+        }
+        String[] args = new String[]{"--port", "" + port, "--join", "false"};
+        hawtioMain.invoke(hawtioMain, new Object[]{args});
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/be843eea/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
index b0531d8..bb2fdcb 100644
--- a/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
+++ b/tooling/maven/camel-maven-plugin/src/main/java/org/apache/camel/maven/RunMojo.java
@@ -369,6 +369,7 @@ public class RunMojo extends AbstractExecMojo {
     private Properties originalSystemProperties;
 
     private String extraPluginDependencyArtifactId;
+    protected String extendedPluginDependencyArtifactId;
 
     /**
      * Execute goal.
@@ -455,7 +456,7 @@ public class RunMojo extends AbstractExecMojo {
             getLog().info("Using org.apache.camel.spring.Main to initiate a CamelContext");
             mainClass = "org.apache.camel.spring.Main";
         }
-        
+
         arguments = new String[args.size()];
         args.toArray(arguments);
         
@@ -474,9 +475,12 @@ public class RunMojo extends AbstractExecMojo {
         }
 
         IsolatedThreadGroup threadGroup = new IsolatedThreadGroup(mainClass /* name */);
-        Thread bootstrapThread = new Thread(threadGroup, new Runnable() {
+        final Thread bootstrapThread = new Thread(threadGroup, new Runnable() {
             public void run() {
                 try {
+                    beforeBootstrapCamel();
+
+                    getLog().info("Starting Camel ...");
                     Method main = Thread.currentThread().getContextClassLoader().loadClass(mainClass)
                         .getMethod("main", new Class[] {String[].class});
                     if (!main.isAccessible()) {
@@ -494,6 +498,7 @@ public class RunMojo extends AbstractExecMojo {
                 }
             }
         }, mainClass + ".main()");
+
         bootstrapThread.setContextClassLoader(getClassLoader());
         setSystemProperties();
 
@@ -532,6 +537,13 @@ public class RunMojo extends AbstractExecMojo {
         registerSourceRoots();
     }
 
+    /**
+     * Allows plugin extensions to do custom logic before bootstrapping Camel.
+     */
+    void beforeBootstrapCamel() throws Exception {
+        // noop
+    }
+
     class IsolatedThreadGroup extends ThreadGroup {
         Throwable uncaughtException; // synchronize access to this
 
@@ -743,7 +755,7 @@ public class RunMojo extends AbstractExecMojo {
      * @throws MojoExecutionException
      */
     private void addExtraPluginDependenciesToClasspath(Set<URL> path) throws MojoExecutionException
{
-        if (extraPluginDependencyArtifactId == null) {
+        if (extraPluginDependencyArtifactId == null && extendedPluginDependencyArtifactId
== null) {
             return;
         }
 
@@ -751,7 +763,8 @@ public class RunMojo extends AbstractExecMojo {
             Set<Artifact> artifacts = new HashSet<Artifact>(this.pluginDependencies);
             for (Artifact artifact : artifacts) {
                 // must
-                if (artifact.getArtifactId().equals(extraPluginDependencyArtifactId)) {
+                if (artifact.getArtifactId().equals(extraPluginDependencyArtifactId)
+                        || artifact.getArtifactId().equals(extendedPluginDependencyArtifactId))
{
                     getLog().debug("Adding extra plugin dependency artifact: " + artifact.getArtifactId()
                             + " to classpath");
                     path.add(artifact.getFile().toURI().toURL());


Mime
View raw message