Agreed. I'm also -1 on this commit.
On Thu, Nov 28, 2013 at 8:32 AM, Daniel Kulp <dk...@apache.org> wrote: > > I’m -1 to this commit. I don’t think we should be adding a bunch of targets > for all the various container/platform integrations. This starts going down > the road of adding targets for karaf, glassfish, etc… We should just provide > standard packaging that the hawtio:run command or whatever would pick up. > (like tomcat:run, jetty:run, etc…) > > Dan > > > On Nov 28, 2013, at 7:46 AM, davscl...@apache.org wrote: > >> Updated Branches: >> refs/heads/camel-2.12.x 628b34c0d -> ae5a770e0 >> >> >> CAMEL-7023: Added hawtio goal to camel maven plugin. >> >> Conflicts: >> parent/pom.xml >> >> >> Project: http://git-wip-us.apache.org/repos/asf/camel/repo >> Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ae5a770e >> Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ae5a770e >> Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ae5a770e >> >> Branch: refs/heads/camel-2.12.x >> Commit: ae5a770e01a1a2512412be97e62b18cb7578d640 >> Parents: 628b34c >> Author: Claus Ibsen <davscl...@apache.org> >> Authored: Thu Nov 28 13:47:25 2013 +0100 >> Committer: Claus Ibsen <davscl...@apache.org> >> Committed: Thu Nov 28 13:48:16 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/ae5a770e/parent/pom.xml >> ---------------------------------------------------------------------- >> diff --git a/parent/pom.xml b/parent/pom.xml >> index 95f2a9e..d3229bc 100644 >> --- a/parent/pom.xml >> +++ b/parent/pom.xml >> @@ -173,6 +173,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>2.6</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/ae5a770e/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 160b8ab..940ab77 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/ae5a770e/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/ae5a770e/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 6f3921d..510333b6 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()); >> > > -- > Daniel Kulp > dk...@apache.org - http://dankulp.com/blog > Talend Community Coder - http://coders.talend.com >