org.mortbay.jetty.plugin
Class AbstractJettyMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.mortbay.jetty.plugin.AbstractJettyMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
JettyRunMojo, JettyRunWarExplodedMojo, JettyRunWarMojo

public abstract class AbstractJettyMojo
extends org.apache.maven.plugin.AbstractMojo

AbstractJettyMojo


Field Summary
protected  org.eclipse.jetty.server.Connector[] connectors
          List of connectors to use.
protected  java.lang.Thread consoleScanner
          A scanner to check ENTER hits on the console
protected  org.eclipse.jetty.server.handler.ContextHandler[] contextHandlers
          List of other contexts to set up.
protected  java.lang.String contextPath
          The context path for the webapp.
protected  boolean daemon
           Determines whether or not the server blocks when started.
protected  java.io.File jettyConfig
          Location of a jetty xml configuration file whose contents will be applied before any plugin configuration.
protected  org.eclipse.jetty.security.LoginService[] loginServices
          List of security realms to set up.
 java.lang.String PORT_SYSPROPERTY
           
protected  org.apache.maven.project.MavenProject project
          The maven project.
protected  java.lang.String reload
          reload can be set to either 'automatic' or 'manual' if 'manual' then the context can be reloaded by a linefeed in the console if 'automatic' then traditional reloading on changed files is enabled.
protected  org.eclipse.jetty.server.RequestLog requestLog
          A RequestLog implementation to use for the webapp at runtime.
protected  int scanIntervalSeconds
          The interval in seconds to scan the webapp for changes and restart the context if necessary.
protected  java.util.ArrayList<java.io.File> scanList
          List of files and directories to scan
protected  org.eclipse.jetty.util.Scanner scanner
          A scanner to check for changes to the webapp
protected  java.util.ArrayList<org.eclipse.jetty.util.Scanner.BulkListener> scannerListeners
          List of Listeners for the scanner
protected  JettyServer server
          A wrapper for the Server object
protected  boolean skip
           
protected  java.lang.String stopKey
          Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> -DSTOP.PORT=<stopPort> -jar start.jar --stop
protected  int stopPort
          Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort> -DSTOP.KEY=<stopKey> -jar start.jar --stop
protected  SystemProperties systemProperties
          System properties to set before execution.
protected  java.io.File systemPropertiesFile
          File containing system properties to be set before execution Note that these properties will NOT override System properties that have been set on the command line, by the JVM, or directly in the POM via systemProperties.
protected  java.io.File tmpDirectory
          The temporary directory to use for the webapp.
protected  JettyWebAppContext webAppConfig
          The "virtual" webapp created by the plugin
protected  java.lang.String webAppXml
          Location of a context xml configuration file whose contents will be applied to the webapp AFTER anything in <webAppConfig>.Optional.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractJettyMojo()
           
 
Method Summary
abstract  void applyJettyXml()
           
abstract  void checkPomConfiguration()
           
abstract  void configureScanner()
           
 void configureWebApplication()
          Subclasses should invoke this to setup basic info on the webapp
 void execute()
           
 java.io.File findJettyWebXmlFile(java.io.File webInfDir)
          Try and find a jetty-web.xml file, using some historical naming conventions if necessary.
abstract  void finishConfigurationBeforeStart()
           
 java.lang.String getContextPath()
           
 java.io.File getJettyXmlFile()
           
 org.apache.maven.project.MavenProject getProject()
           
 int getScanIntervalSeconds()
           
 java.util.ArrayList<java.io.File> getScanList()
           
 org.eclipse.jetty.util.Scanner getScanner()
           
 java.util.ArrayList getScannerListeners()
           
 JettyServer getServer()
           
 java.io.File getSystemPropertiesFile()
           
 java.io.File getTmpDirectory()
           
abstract  void restartWebApp(boolean reconfigureScanner)
           
 void setScanList(java.util.ArrayList<java.io.File> list)
           
 void setScannerListeners(java.util.ArrayList<org.eclipse.jetty.util.Scanner.BulkListener> listeners)
           
 void setServer(JettyServer server)
           
 void setSystemProperties(SystemProperties systemProperties)
           
 void setSystemPropertiesFile(java.io.File file)
           
protected  void startConsoleScanner()
          Run a thread that monitors the console input to detect ENTER hits.
 void startJetty()
           
 
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
 

Field Detail

server

protected JettyServer server
A wrapper for the Server object


connectors

protected org.eclipse.jetty.server.Connector[] connectors
List of connectors to use. If none are configured then the default is a single SelectChannelConnector at port 8080. You can override this default port number by using the system property jetty.port on the command line, eg: mvn -Djetty.port=9999 jetty:run


contextHandlers

protected org.eclipse.jetty.server.handler.ContextHandler[] contextHandlers
List of other contexts to set up. Optional.


loginServices

protected org.eclipse.jetty.security.LoginService[] loginServices
List of security realms to set up. Optional.


requestLog

protected org.eclipse.jetty.server.RequestLog requestLog
A RequestLog implementation to use for the webapp at runtime. Optional.


webAppConfig

protected JettyWebAppContext webAppConfig
The "virtual" webapp created by the plugin


project

protected org.apache.maven.project.MavenProject project
The maven project.


contextPath

protected java.lang.String contextPath
The context path for the webapp. Defaults to the name of the webapp's artifact.


tmpDirectory

protected java.io.File tmpDirectory
The temporary directory to use for the webapp. Defaults to target/tmp


scanIntervalSeconds

protected int scanIntervalSeconds
The interval in seconds to scan the webapp for changes and restart the context if necessary. Ignored if reload is enabled. Disabled by default.


reload

protected java.lang.String reload
reload can be set to either 'automatic' or 'manual' if 'manual' then the context can be reloaded by a linefeed in the console if 'automatic' then traditional reloading on changed files is enabled.


systemPropertiesFile

protected java.io.File systemPropertiesFile
File containing system properties to be set before execution Note that these properties will NOT override System properties that have been set on the command line, by the JVM, or directly in the POM via systemProperties. Optional.


systemProperties

protected SystemProperties systemProperties
System properties to set before execution. Note that these properties will NOT override System properties that have been set on the command line or by the JVM. They WILL override System properties that have been set via systemPropertiesFile. Optional.


jettyConfig

protected java.io.File jettyConfig
Location of a jetty xml configuration file whose contents will be applied before any plugin configuration. Optional.


stopPort

protected int stopPort
Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort> -DSTOP.KEY=<stopKey> -jar start.jar --stop


stopKey

protected java.lang.String stopKey
Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> -DSTOP.PORT=<stopPort> -jar start.jar --stop


daemon

protected boolean daemon

Determines whether or not the server blocks when started. The default behavior (daemon = false) will cause the server to pause other processes while it continues to handle web requests. This is useful when starting the server with the intent to work with it interactively.

Often, it is desirable to let the server start and continue running subsequent processes in an automated build environment. This can be facilitated by setting daemon to true.


skip

protected boolean skip

webAppXml

protected java.lang.String webAppXml
Location of a context xml configuration file whose contents will be applied to the webapp AFTER anything in <webAppConfig>.Optional.


scanner

protected org.eclipse.jetty.util.Scanner scanner
A scanner to check for changes to the webapp


scanList

protected java.util.ArrayList<java.io.File> scanList
List of files and directories to scan


scannerListeners

protected java.util.ArrayList<org.eclipse.jetty.util.Scanner.BulkListener> scannerListeners
List of Listeners for the scanner


consoleScanner

protected java.lang.Thread consoleScanner
A scanner to check ENTER hits on the console


PORT_SYSPROPERTY

public java.lang.String PORT_SYSPROPERTY
Constructor Detail

AbstractJettyMojo

public AbstractJettyMojo()
Method Detail

checkPomConfiguration

public abstract void checkPomConfiguration()
                                    throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

configureScanner

public abstract void configureScanner()
                               throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

applyJettyXml

public abstract void applyJettyXml()
                            throws java.lang.Exception
Throws:
java.lang.Exception

finishConfigurationBeforeStart

public abstract void finishConfigurationBeforeStart()
                                             throws java.lang.Exception
Throws:
java.lang.Exception

getProject

public org.apache.maven.project.MavenProject getProject()

getTmpDirectory

public java.io.File getTmpDirectory()

getContextPath

public java.lang.String getContextPath()
Returns:
Returns the contextPath.

getScanIntervalSeconds

public int getScanIntervalSeconds()
Returns:
Returns the scanIntervalSeconds.

getSystemPropertiesFile

public java.io.File getSystemPropertiesFile()
Returns:
returns the path to the systemPropertiesFile

setSystemPropertiesFile

public void setSystemPropertiesFile(java.io.File file)
                             throws java.lang.Exception
Throws:
java.lang.Exception

setSystemProperties

public void setSystemProperties(SystemProperties systemProperties)

getJettyXmlFile

public java.io.File getJettyXmlFile()

getServer

public JettyServer getServer()

setServer

public void setServer(JettyServer server)

setScanList

public void setScanList(java.util.ArrayList<java.io.File> list)

getScanList

public java.util.ArrayList<java.io.File> getScanList()

setScannerListeners

public void setScannerListeners(java.util.ArrayList<org.eclipse.jetty.util.Scanner.BulkListener> listeners)

getScannerListeners

public java.util.ArrayList getScannerListeners()

getScanner

public org.eclipse.jetty.util.Scanner getScanner()

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException,
                    org.apache.maven.plugin.MojoFailureException
Throws:
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException

startJetty

public void startJetty()
                throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

restartWebApp

public abstract void restartWebApp(boolean reconfigureScanner)
                            throws java.lang.Exception
Throws:
java.lang.Exception

configureWebApplication

public void configureWebApplication()
                             throws java.lang.Exception
Subclasses should invoke this to setup basic info on the webapp

Throws:
org.apache.maven.plugin.MojoExecutionException
java.lang.Exception

startConsoleScanner

protected void startConsoleScanner()
Run a thread that monitors the console input to detect ENTER hits.


findJettyWebXmlFile

public java.io.File findJettyWebXmlFile(java.io.File webInfDir)
Try and find a jetty-web.xml file, using some historical naming conventions if necessary.

Parameters:
webInfDir -
Returns:
the jetty web xml file


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.