Package org.wildfly.plugin.server

## Class AbstractStartMojo

- java.lang.Object
- - org.apache.maven.plugin.AbstractMojo
  - - org.wildfly.plugin.common.AbstractServerConnection
    - - org.wildfly.plugin.server.AbstractStartMojo

- All Implemented Interfaces:
    `org.apache.maven.plugin.ContextEnabled`, `org.apache.maven.plugin.Mojo`
  Direct Known Subclasses:
    `AbstractServerStartMojo`, `StartJarMojo`

      public abstract class AbstractStartMojo
      extends AbstractServerConnection

  Author:
    James R. Perkins

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected boolean` | `debug` | Starts the server with debugging enabled.
    `protected String` | `debugHost` | Sets the hostname to listen on for debugging.
    `protected int` | `debugPort` | Sets the port the debugger should listen on.
    `protected boolean` | `debugSuspend` | Indicates whether the server should suspend itself until a debugger is attached.
    `protected String` | `javaHome` | The `JAVA_HOME` to use for launching the server.
    `protected String[]` | `javaOpts` | The JVM options to use.
    `protected org.jboss.galleon.universe.maven.repo.MavenRepoManager` | `mavenRepoManager` |
    `protected org.apache.maven.execution.MavenSession` | `mavenSession` |
    `protected org.apache.maven.project.MavenProject` | `project` |
    `protected String` | `propertiesFile` | The path to the system properties file to load.
    `protected List<org.eclipse.aether.repository.RemoteRepository>` | `repositories` |
    `protected org.eclipse.aether.RepositorySystem` | `repoSystem` |
    `protected String[]` | `serverArgs` | The arguments to be passed to the server.
    `protected ServerManager` | `serverManager` |
    `protected org.eclipse.aether.RepositorySystemSession` | `session` |
    `protected boolean` | `skip` | Set to `true` if you want to skip this goal, otherwise `false`.

    - ### Fields inherited from class org.wildfly.plugin.common.AbstractServerConnection

      `DEBUG_MESSAGE_NO_CREDS, DEBUG_MESSAGE_NO_ID, DEBUG_MESSAGE_NO_SERVER_SECTION, DEBUG_MESSAGE_NO_SETTINGS_FILE, DEBUG_MESSAGE_POM_HAS_CREDS, DEBUG_MESSAGE_SETTINGS_HAS_CREDS, DEBUG_MESSAGE_SETTINGS_HAS_ID, timeout`

    - ### Fields inherited from interface org.apache.maven.plugin.Mojo

      `ROLE`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `AbstractStartMojo()` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected ServerContext` | `actOnServerState​(org.jboss.as.controller.client.ModelControllerClient client, ServerContext context)` | Checks the current state of the server.
    `protected abstract org.wildfly.core.launcher.CommandBuilder` | `createCommandBuilder​(Path jbossHome)` |
    `protected org.jboss.galleon.universe.maven.repo.MavenRepoManager` | `createMavenRepoManager()` |
    `protected String` | `getManagementHostName()` |
    `protected int` | `getManagementPort()` |
    `protected abstract Path` | `getServerHome()` |
    `protected void` | `init()` |
    `void` | `setJavaOpts​(String value)` | Allows the `javaOpts` to be set as a string.
    `protected StandardOutput` | `standardOutput()` |
    `protected ServerContext` | `startServer​(ServerType serverType)` |

    - ### Methods inherited from class org.wildfly.plugin.common.AbstractServerConnection

      `createClient, getClientConfiguration, goal`

    - ### Methods inherited from class org.apache.maven.plugin.AbstractMojo

      `getLog, getPluginContext, setLog, setPluginContext`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.maven.plugin.Mojo

      `execute`

- - ### Field Detail

    - #### repoSystem

          @Component
          protected org.eclipse.aether.RepositorySystem repoSystem

    - #### session

          @Parameter(defaultValue="${repositorySystemSession}",
                     readonly=true,
                     required=true)
          protected org.eclipse.aether.RepositorySystemSession session

    - #### repositories

          @Parameter(defaultValue="${project.remoteProjectRepositories}",
                     readonly=true,
                     required=true)
          protected List<org.eclipse.aether.repository.RemoteRepository> repositories

    - #### project

          @Parameter(defaultValue="${project}",
                     readonly=true,
                     required=true)
          protected org.apache.maven.project.MavenProject project

    - #### mavenSession

          @Parameter(defaultValue="${session}",
                     readonly=true,
                     required=true)
          protected org.apache.maven.execution.MavenSession mavenSession

    - #### javaOpts

          @Parameter(alias="java-opts",
                     property="wildfly.javaOpts")
          protected String[] javaOpts

      The JVM options to use.

    - #### javaHome

          @Parameter(alias="java-home",
                     property="java.home")
          protected String javaHome

      The `JAVA_HOME` to use for launching the server.

    - #### debug

          @Parameter(property="wildfly.debug",
                     defaultValue="false")
          protected boolean debug

      Starts the server with debugging enabled.

    - #### debugHost

          @Parameter(property="wildfly.debug.host",
                     defaultValue="*")
          protected String debugHost

      Sets the hostname to listen on for debugging. An `*` means all hosts.

    - #### debugPort

          @Parameter(property="wildfly.debug.port",
                     defaultValue="8787")
          protected int debugPort

      Sets the port the debugger should listen on.

    - #### debugSuspend

          @Parameter(property="wildfly.debug.suspend",
                     defaultValue="false")
          protected boolean debugSuspend

      Indicates whether the server should suspend itself until a debugger is attached.

    - #### propertiesFile

          @Parameter(alias="properties-file",
                     property="wildfly.propertiesFile")
          protected String propertiesFile

      The path to the system properties file to load.

    - #### serverArgs

          @Parameter(alias="server-args",
                     property="wildfly.serverArgs")
          protected String[] serverArgs

      The arguments to be passed to the server.

    - #### skip

          @Parameter(defaultValue="false",
                     property="wildfly.skip")
          protected boolean skip

      Set to `true` if you want to skip this goal, otherwise `false`.

    - #### serverManager

          protected ServerManager serverManager

    - #### mavenRepoManager

          protected org.jboss.galleon.universe.maven.repo.MavenRepoManager mavenRepoManager

  - ### Constructor Detail

    - #### AbstractStartMojo

          public AbstractStartMojo()

  - ### Method Detail

    - #### init

          protected void init()
                       throws org.apache.maven.plugin.MojoExecutionException

      Throws:
        `org.apache.maven.plugin.MojoExecutionException`

    - #### createMavenRepoManager

          protected org.jboss.galleon.universe.maven.repo.MavenRepoManager createMavenRepoManager()
                                                                                           throws org.apache.maven.plugin.MojoExecutionException

      Throws:
        `org.apache.maven.plugin.MojoExecutionException`

    - #### getServerHome

          protected abstract Path getServerHome()
                                         throws org.apache.maven.plugin.MojoExecutionException,
                                                org.apache.maven.plugin.MojoFailureException

      Throws:
        `org.apache.maven.plugin.MojoExecutionException`
        `org.apache.maven.plugin.MojoFailureException`

    - #### startServer

          protected ServerContext startServer​(ServerType serverType)
                                       throws org.apache.maven.plugin.MojoExecutionException,
                                              org.apache.maven.plugin.MojoFailureException

      Throws:
        `org.apache.maven.plugin.MojoExecutionException`
        `org.apache.maven.plugin.MojoFailureException`

    - #### createCommandBuilder

          protected abstract org.wildfly.core.launcher.CommandBuilder createCommandBuilder​(Path jbossHome)
                                                                                    throws org.apache.maven.plugin.MojoExecutionException

      Throws:
        `org.apache.maven.plugin.MojoExecutionException`

    - #### standardOutput

          protected StandardOutput standardOutput()
                                           throws IOException

      Throws:
        `IOException`

    - #### setJavaOpts

          public void setJavaOpts​(String value)

      Allows the `javaOpts` to be set as a string. The string is assumed to be space delimited.
      Parameters:
        `value` - a spaced delimited value of JVM options

    - #### actOnServerState

          protected ServerContext actOnServerState​(org.jboss.as.controller.client.ModelControllerClient client,
                                                   ServerContext context)
                                            throws IOException,
                                                   org.apache.maven.plugin.MojoExecutionException,
                                                   org.apache.maven.plugin.MojoFailureException

      Checks the current state of the server. If the server is in a state of `ClientConstants.CONTROLLER_PROCESS_STATE_RESTART_REQUIRED`, the process is restarted and a new `ServerContext` is returned. If the server is in a stat of `ClientConstants.CONTROLLER_PROCESS_STATE_RELOAD_REQUIRED`, the server will be reloaded and wait until the server is running. If the server is in any other state, other than `ClientConstants.CONTROLLER_PROCESS_STATE_RUNNING`, a warning message is logged to let the user know the state is unknown.
      Parameters:
        `client` - the client used to communicate with the server
        `context` - the current server context
      Returns:
        a new context if a restart was required, otherwise the same context
      Throws:
        `IOException` - if an error occurs communicating with the server
        `org.apache.maven.plugin.MojoExecutionException` - if a failure occurs checking the state or reloading the server
        `org.apache.maven.plugin.MojoFailureException` - if a failure occurs checking the state or reloading the server

    - #### getManagementPort

          protected int getManagementPort()

      Overrides:
        `getManagementPort` in class `AbstractServerConnection`

    - #### getManagementHostName

          protected String getManagementHostName()

      Overrides:
        `getManagementHostName` in class `AbstractServerConnection`