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  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  String contextPath
          Deprecated. Use <webApp><contextPath> instead.
protected  String contextXml
          Location of a context xml configuration file whose contents will be applied to the webapp AFTER anything in <webApp>.Optional.
protected  boolean daemon
           Determines whether or not the server blocks when started.
protected  String[] excludedGoals
          List of goals that are NOT to be used
protected  String jettyXml
          Comma separated list of a jetty xml configuration files whose contents will be applied before any plugin configuration.
protected  org.eclipse.jetty.security.LoginService[] loginServices
          List of security realms to set up.
 String PORT_SYSPROPERTY
           
protected  org.apache.maven.project.MavenProject project
          The maven project.
protected  Set projectArtifacts
          The artifacts for the project.
protected  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  ArrayList<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  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
          Skip this mojo execution.
protected  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  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  File tmpDirectory
          Deprecated. Use %lt;webApp><tempDirectory> instead.
protected  boolean useProvidedScope
          Whether or not to include dependencies on the plugin's classpath with <scope>provided</scope> Use WITH CAUTION as you may wind up with duplicate jars/classes.
protected  JettyWebAppContext webApp
          An instance of org.eclipse.jetty.webapp.WebAppContext that represents the webapp.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractJettyMojo()
           
 
Method Summary
 void applyJettyXml()
           
abstract  void checkPomConfiguration()
           
 void configurePluginClasspath()
           
abstract  void configureScanner()
           
 void configureWebApplication()
          Subclasses should invoke this to setup basic info on the webapp
 void execute()
           
 File findJettyWebXmlFile(File webInfDir)
          Try and find a jetty-web.xml file, using some historical naming conventions if necessary.
 void finishConfigurationBeforeStart()
           
 org.eclipse.jetty.server.Connector[] getConnectors()
           
 org.eclipse.jetty.server.handler.ContextHandler[] getContextHandlers()
           
 String getContextPath()
           
 String getJettyConfig()
           
 List<File> getJettyXmlFiles()
           
 org.eclipse.jetty.security.LoginService[] getLoginServices()
           
 List getPluginArtifacts()
           
 org.apache.maven.project.MavenProject getProject()
           
 String getReload()
           
 org.eclipse.jetty.server.RequestLog getRequestLog()
           
 int getScanIntervalSeconds()
           
 ArrayList<File> getScanList()
           
 org.eclipse.jetty.util.Scanner getScanner()
           
 ArrayList getScannerListeners()
           
 JettyServer getServer()
           
 String getStopKey()
           
 int getStopPort()
           
 SystemProperties getSystemProperties()
           
 File getSystemPropertiesFile()
           
 File getTmpDirectory()
           
 JettyWebAppContext getWebAppConfig()
           
 String getWebAppXml()
           
 boolean isDaemon()
           
 boolean isExcluded(String goal)
           
 boolean isPluginArtifact(org.apache.maven.artifact.Artifact artifact)
           
 boolean isSkip()
           
abstract  void restartWebApp(boolean reconfigureScanner)
           
 void setConnectors(org.eclipse.jetty.server.Connector[] connectors)
           
 void setContextHandlers(org.eclipse.jetty.server.handler.ContextHandler[] contextHandlers)
           
 void setContextPath(String contextPath)
           
 void setDaemon(boolean daemon)
           
 void setJettyConfig(String jettyConfig)
           
 void setLoginServices(org.eclipse.jetty.security.LoginService[] loginServices)
           
 void setPluginArtifacts(List pluginArtifacts)
           
 void setProject(org.apache.maven.project.MavenProject project)
           
 void setReload(String reload)
           
 void setRequestLog(org.eclipse.jetty.server.RequestLog requestLog)
           
 void setScanIntervalSeconds(int scanIntervalSeconds)
           
 void setScanList(ArrayList<File> list)
           
 void setScannerListeners(ArrayList<org.eclipse.jetty.util.Scanner.BulkListener> listeners)
           
 void setServer(JettyServer server)
           
 void setSkip(boolean skip)
           
 void setStopKey(String stopKey)
           
 void setStopPort(int stopPort)
           
 void setSystemProperties(SystemProperties systemProperties)
           
 void setSystemPropertiesFile(File file)
           
 void setTmpDirectory(File tmpDirectory)
           
 void setWebAppConfig(JettyWebAppContext webAppConfig)
           
 void setWebAppXml(String webAppXml)
           
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

useProvidedScope

protected boolean useProvidedScope
Whether or not to include dependencies on the plugin's classpath with <scope>provided</scope> Use WITH CAUTION as you may wind up with duplicate jars/classes.

Since:
jetty-7.5.2

excludedGoals

protected String[] excludedGoals
List of goals that are NOT to be used

Since:
jetty-7.5.2

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. Consider using instead the <jettyXml> element to specify external jetty xml config file.


contextHandlers

protected org.eclipse.jetty.server.handler.ContextHandler[] contextHandlers
List of other contexts to set up. Consider using instead the <jettyXml> element to specify external jetty xml config file. Optional.


loginServices

protected org.eclipse.jetty.security.LoginService[] loginServices
List of security realms to set up. Consider using instead the <jettyXml> element to specify external jetty xml config file. Optional.


requestLog

protected org.eclipse.jetty.server.RequestLog requestLog
A RequestLog implementation to use for the webapp at runtime. Consider using instead the <jettyXml> element to specify external jetty xml config file. Optional.


webApp

protected JettyWebAppContext webApp
An instance of org.eclipse.jetty.webapp.WebAppContext that represents the webapp. Use any of its setters to configure the webapp. This is the preferred and most flexible method of configuration, rather than using the (deprecated) individual parameters like "tmpDirectory", "contextPath" etc.


contextPath

protected String contextPath
Deprecated. Use <webApp><contextPath> instead.
The context path for the webapp. Defaults to the name of the webapp's artifact.


tmpDirectory

protected File tmpDirectory
Deprecated. Use %lt;webApp><tempDirectory> instead.
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 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 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.


jettyXml

protected String jettyXml
Comma separated list of a jetty xml configuration files 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 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
Skip this mojo execution.


contextXml

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


project

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


projectArtifacts

protected Set projectArtifacts
The artifacts for the project.


server

protected JettyServer server
A wrapper for the Server object


scanner

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


scanList

protected ArrayList<File> scanList
List of files and directories to scan


scannerListeners

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


consoleScanner

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


PORT_SYSPROPERTY

public String PORT_SYSPROPERTY
Constructor Detail

AbstractJettyMojo

public AbstractJettyMojo()
Method Detail

restartWebApp

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

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

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

configurePluginClasspath

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

isPluginArtifact

public boolean isPluginArtifact(org.apache.maven.artifact.Artifact artifact)

finishConfigurationBeforeStart

public void finishConfigurationBeforeStart()
                                    throws Exception
Throws:
Exception

applyJettyXml

public void applyJettyXml()
                   throws Exception
Throws:
Exception

startJetty

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

configureWebApplication

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

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

startConsoleScanner

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

Throws:
Exception

findJettyWebXmlFile

public File findJettyWebXmlFile(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

getScanner

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

getProject

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

setProject

public void setProject(org.apache.maven.project.MavenProject project)

getTmpDirectory

public File getTmpDirectory()

setTmpDirectory

public void setTmpDirectory(File tmpDirectory)

getContextPath

public String getContextPath()
Returns:
Returns the contextPath.

setContextPath

public void setContextPath(String contextPath)

getScanIntervalSeconds

public int getScanIntervalSeconds()
Returns:
Returns the scanIntervalSeconds.

setScanIntervalSeconds

public void setScanIntervalSeconds(int scanIntervalSeconds)

getSystemPropertiesFile

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

setSystemPropertiesFile

public void setSystemPropertiesFile(File file)
                             throws Exception
Throws:
Exception

setSystemProperties

public void setSystemProperties(SystemProperties systemProperties)

getSystemProperties

public SystemProperties getSystemProperties()

getJettyXmlFiles

public List<File> getJettyXmlFiles()

getServer

public JettyServer getServer()

setServer

public void setServer(JettyServer server)

setScanList

public void setScanList(ArrayList<File> list)

getScanList

public ArrayList<File> getScanList()

setScannerListeners

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

getScannerListeners

public ArrayList getScannerListeners()

getWebAppConfig

public JettyWebAppContext getWebAppConfig()

setWebAppConfig

public void setWebAppConfig(JettyWebAppContext webAppConfig)

getRequestLog

public org.eclipse.jetty.server.RequestLog getRequestLog()

setRequestLog

public void setRequestLog(org.eclipse.jetty.server.RequestLog requestLog)

getLoginServices

public org.eclipse.jetty.security.LoginService[] getLoginServices()

setLoginServices

public void setLoginServices(org.eclipse.jetty.security.LoginService[] loginServices)

getContextHandlers

public org.eclipse.jetty.server.handler.ContextHandler[] getContextHandlers()

setContextHandlers

public void setContextHandlers(org.eclipse.jetty.server.handler.ContextHandler[] contextHandlers)

getConnectors

public org.eclipse.jetty.server.Connector[] getConnectors()

setConnectors

public void setConnectors(org.eclipse.jetty.server.Connector[] connectors)

getReload

public String getReload()

setReload

public void setReload(String reload)

getJettyConfig

public String getJettyConfig()

setJettyConfig

public void setJettyConfig(String jettyConfig)

getWebAppXml

public String getWebAppXml()

setWebAppXml

public void setWebAppXml(String webAppXml)

isSkip

public boolean isSkip()

setSkip

public void setSkip(boolean skip)

isDaemon

public boolean isDaemon()

setDaemon

public void setDaemon(boolean daemon)

getStopKey

public String getStopKey()

setStopKey

public void setStopKey(String stopKey)

getStopPort

public int getStopPort()

setStopPort

public void setStopPort(int stopPort)

getPluginArtifacts

public List getPluginArtifacts()

setPluginArtifacts

public void setPluginArtifacts(List pluginArtifacts)

isExcluded

public boolean isExcluded(String goal)


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