Class KarafRunMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="run",
          defaultPhase=PREPARE_PACKAGE,
          requiresDependencyResolution=COMPILE_PLUS_RUNTIME)
    public class KarafRunMojo
    extends org.codehaus.mojo.exec.AbstractExecMojo
    Runs a CamelContext using OSGi Blueprint.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected String applicationContextUri
      The classpath based application context uri that spring want to gets.
      protected String[] arguments
      The class arguments.
      protected String basedPackages
      The basedPackages that spring java config want to gets.
      protected boolean cleanupDaemonThreads
      Whether to interrupt/join and possibly stop the daemon threads upon quitting.
      protected String configAdminFileName
      The configureAdmin persistent file name, it will be used when loading the camel context from blueprint.
      protected String configAdminPid
      The configureAdmin persistent id, it will be used when loading the camel context from blueprint.
      protected String configClasses
      The configClasses that spring java config want to gets.
      protected long daemonThreadJoinTimeout
      This defines the number of milliseconds to wait for daemon threads to quit following their interruption.
      This is only taken into account if cleanupDaemonThreads is true.
      protected String duration
      Sets the time duration (seconds) that the application will run for before terminating.
      protected String durationIdle
      Sets the idle time duration (seconds) duration that the application can be idle before terminating.
      protected String durationMaxMessages
      Sets the duration of maximum number of messages that the application will process before terminating.
      protected org.codehaus.mojo.exec.ExecutableDependency executableDependency
      If provided the ExecutableDependency identifies which of the plugin dependencies contains the executable class.
      protected String extendedPluginDependencyArtifactId  
      protected String fileApplicationContextUri
      The filesystem based application context uri that spring want to gets.
      protected String fileWatcherDirectory
      To watch the directory for file changes which triggers a live reload of the Camel routes on-the-fly.
      protected boolean includePluginDependencies
      Indicates if this plugin's dependencies should be used when executing the main class.
      protected boolean includeProjectDependencies
      Indicates if the project dependencies should be used when executing the main class.
      protected boolean keepAlive
      Deprecated; this is not needed anymore.
      protected boolean logClasspath
      Whether to log the classpath when starting
      protected String mainClass
      The main class to execute.
      protected org.apache.maven.project.MavenProject project
      The maven project.
      protected boolean stopUnresponsiveDaemonThreads
      Wether to call Thread.stop() following a timing out of waiting for an interrupted thread to finish.
      protected org.codehaus.mojo.exec.Property[] systemProperties
      A list of system properties to be passed.
      protected boolean trace
      Whether to enable the tracer or not
      protected Boolean useBlueprint
      Whether to use Blueprint when running, instead of Spring
      • Fields inherited from class org.codehaus.mojo.exec.AbstractExecMojo

        classpathScope
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Constructor Summary

      Constructors 
      Constructor Description
      KarafRunMojo()  
    • Field Detail

      • project

        @Parameter(property="project",
                   required=true,
                   readonly=true)
        protected org.apache.maven.project.MavenProject project
        The maven project.
      • duration

        @Parameter(property="camel.duration",
                   defaultValue="-1")
        protected String duration
        Sets the time duration (seconds) that the application will run for before terminating. A value <= 0 will run forever.
      • durationIdle

        @Parameter(property="camel.durationIdle",
                   defaultValue="-1")
        protected String durationIdle
        Sets the idle time duration (seconds) duration that the application can be idle before terminating. A value <= 0 will run forever.
      • durationMaxMessages

        @Parameter(property="camel.duration.maxMessages",
                   defaultValue="-1")
        protected String durationMaxMessages
        Sets the duration of maximum number of messages that the application will process before terminating.
      • logClasspath

        @Parameter(property="camel.logClasspath",
                   defaultValue="false")
        protected boolean logClasspath
        Whether to log the classpath when starting
      • useBlueprint

        @Parameter(property="camel.useBlueprint")
        protected Boolean useBlueprint
        Whether to use Blueprint when running, instead of Spring
      • trace

        @Parameter(property="camel.trace")
        protected boolean trace
        Whether to enable the tracer or not
      • mainClass

        @Parameter(property="camel.mainClass")
        protected String mainClass
        The main class to execute.
      • basedPackages

        @Parameter(property="camel.basedPackages")
        protected String basedPackages
        The basedPackages that spring java config want to gets.
      • configClasses

        @Parameter(property="camel.configClasses")
        protected String configClasses
        The configClasses that spring java config want to gets.
      • applicationContextUri

        @Parameter(property="camel.applicationContextUri")
        protected String applicationContextUri
        The classpath based application context uri that spring want to gets.
      • fileApplicationContextUri

        @Parameter(property="camel.fileApplicationContextUri")
        protected String fileApplicationContextUri
        The filesystem based application context uri that spring want to gets.
      • configAdminPid

        @Parameter(property="camel.configAdminPid")
        protected String configAdminPid
        The configureAdmin persistent id, it will be used when loading the camel context from blueprint.
      • configAdminFileName

        @Parameter(property="camel.configAdminFileName")
        protected String configAdminFileName
        The configureAdmin persistent file name, it will be used when loading the camel context from blueprint.
      • fileWatcherDirectory

        @Parameter(property="camel.fileWatcherDirectory")
        protected String fileWatcherDirectory
        To watch the directory for file changes which triggers a live reload of the Camel routes on-the-fly.
      • arguments

        @Parameter(property="camel.arguments")
        protected String[] arguments
        The class arguments.
      • systemProperties

        protected org.codehaus.mojo.exec.Property[] systemProperties
        A list of system properties to be passed. Note: as the execution is not forked, some system properties required by the JVM cannot be passed here. Use MAVEN_OPTS or the exec:exec instead. See the user guide for more information.
      • keepAlive

        @Parameter(property="camel.keepAlive")
        protected boolean keepAlive
        Deprecated; this is not needed anymore. Indicates if mojo should be kept running after the mainclass terminates. Usefull for serverlike apps with deamonthreads.
      • includeProjectDependencies

        @Parameter(property="camel.includeProjectDependencies",
                   defaultValue="true")
        protected boolean includeProjectDependencies
        Indicates if the project dependencies should be used when executing the main class.
      • includePluginDependencies

        @Parameter(property="camel.includePluginDependencies",
                   defaultValue="false")
        protected boolean includePluginDependencies
        Indicates if this plugin's dependencies should be used when executing the main class.

        This is useful when project dependencies are not appropriate. Using only the plugin dependencies can be particularly useful when the project is not a java project. For example a mvn project using the csharp plugins only expects to see dotnet libraries as dependencies.

      • executableDependency

        @Parameter(property="camel.executableDependency")
        protected org.codehaus.mojo.exec.ExecutableDependency executableDependency
        If provided the ExecutableDependency identifies which of the plugin dependencies contains the executable class. This will have the affect of only including plugin dependencies required by the identified ExecutableDependency.

        If includeProjectDependencies is set to true, all of the project dependencies will be included on the executable's classpath. Whether a particular project dependency is a dependency of the identified ExecutableDependency will be irrelevant to its inclusion in the classpath.

      • cleanupDaemonThreads

        @Parameter(property="camel.cleanupDaemonThreads",
                   defaultValue="true")
        protected boolean cleanupDaemonThreads
        Whether to interrupt/join and possibly stop the daemon threads upon quitting.
        If this is false, maven does nothing about the daemon threads. When maven has no more work to do, the VM will normally terminate any remaining daemon threads.

        In certain cases (in particular if maven is embedded), you might need to keep this enabled to make sure threads are properly cleaned up to ensure they don't interfere with subsequent activity. In that case, see daemonThreadJoinTimeout and stopUnresponsiveDaemonThreads for further tuning.

      • daemonThreadJoinTimeout

        @Parameter(property="camel.daemonThreadJoinTimeout",
                   defaultValue="15000")
        protected long daemonThreadJoinTimeout
        This defines the number of milliseconds to wait for daemon threads to quit following their interruption.
        This is only taken into account if cleanupDaemonThreads is true. A value <=0 means to not timeout (i.e. wait indefinitely for threads to finish). Following a timeout, a warning will be logged.

        Note: properly coded threads should terminate upon interruption but some threads may prove problematic: as the VM does interrupt daemon threads, some code may not have been written to handle interruption properly. For example java.util.Timer is known to not handle interruptions in JDK <= 1.6. So it is not possible for us to infinitely wait by default otherwise maven could hang. A sensible default value has been chosen, but this default value may change in the future based on user feedback.

      • stopUnresponsiveDaemonThreads

        @Parameter(property="camel.stopUnresponsiveDaemonThreads",
                   defaultValue="15000")
        protected boolean stopUnresponsiveDaemonThreads
        Wether to call Thread.stop() following a timing out of waiting for an interrupted thread to finish. This is only taken into account if cleanupDaemonThreads is true and the daemonThreadJoinTimeout threshold has been reached for an uncooperative thread. If this is false, or if Thread.stop() fails to get the thread to stop, then a warning is logged and Maven will continue on while the affected threads (and related objects in memory) linger on. Consider setting this to true if you are invoking problematic code that you can't fix. An example is Timer which doesn't respond to interruption. To have Timer fixed, vote for this bug.
      • extendedPluginDependencyArtifactId

        protected String extendedPluginDependencyArtifactId
    • Constructor Detail

      • KarafRunMojo

        public KarafRunMojo()
    • Method Detail

      • parseArguments

        protected List<String> parseArguments()
                                       throws org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoFailureException
      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Execute goal.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - execution of the main class or one of the threads it generated failed.
        org.apache.maven.plugin.MojoFailureException - something bad happened...
      • beforeBootstrapCamel

        protected void beforeBootstrapCamel()
                                     throws Exception
        Allows plugin extensions to do custom logic before bootstrapping Camel.
        Throws:
        Exception
      • afterBootstrapCamel

        protected void afterBootstrapCamel()
                                    throws Exception
        Allows plugin extensions to do custom logic after bootstrapping Camel.
        Throws:
        Exception
      • findExecutableArtifact

        protected org.apache.maven.artifact.Artifact findExecutableArtifact()
                                                                     throws org.apache.maven.plugin.MojoExecutionException
        Examine the plugin dependencies to find the executable artifact.
        Overrides:
        findExecutableArtifact in class org.codehaus.mojo.exec.AbstractExecMojo
        Returns:
        an artifact which refers to the actual executable tool (not a POM)
        Throws:
        org.apache.maven.plugin.MojoExecutionException