📄 abstractjettymojo.java
字号:
//========================================================================//$Id: AbstractJettyMojo.java 4648 2009-02-24 08:56:03Z ayao $//Copyright 2000-2004 Mort Bay Consulting Pty. Ltd.//------------------------------------------------------------------------//Licensed 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.mortbay.jetty.plugin;import java.io.File;import java.io.FileInputStream;import java.util.ArrayList;import java.util.Enumeration;import java.util.Iterator;import java.util.List;import java.util.Properties;import org.apache.maven.plugin.AbstractMojo;import org.apache.maven.plugin.MojoExecutionException;import org.apache.maven.plugin.MojoFailureException;import org.apache.maven.project.MavenProject;import org.mortbay.jetty.Server;import org.mortbay.jetty.plugin.util.ConsoleScanner;import org.mortbay.jetty.plugin.util.JettyPluginServer;import org.mortbay.jetty.plugin.util.PluginLog;import org.mortbay.jetty.plugin.util.SystemProperties;import org.mortbay.jetty.plugin.util.SystemProperty;import org.mortbay.util.Scanner;/** * AbstractJettyMojo * * */public abstract class AbstractJettyMojo extends AbstractMojo{ /** * The proxy for the Server object */ protected JettyPluginServer server; /** * The "virtual" webapp created by the plugin * @parameter */ protected Jetty6PluginWebAppContext webAppConfig; /** * The maven project. * * @parameter expression="${executedProject}" * @required * @readonly */ protected MavenProject project; /** * The context path for the webapp. Defaults to the * name of the webapp's artifact. * * @parameter expression="/${project.artifactId}" * @required */ protected String contextPath; /** * The temporary directory to use for the webapp. * Defaults to target/jetty-tmp * * @parameter expression="${project.build.directory}/work" * @required */ protected File tmpDirectory; /** * A webdefault.xml file to use instead * of the default for the webapp. Optional. * * @parameter */ protected File webDefaultXml; /** * A web.xml file to be applied AFTER * the webapp's web.xml file. Useful for * applying different build profiles, eg * test, production etc. Optional. * @parameter */ protected File overrideWebXml; /** * The interval in seconds to scan the webapp for changes * and restart the context if necessary. Ignored if reload * is enabled. Disabled by default. * * @parameter expression="${jetty.scanIntervalSeconds}" default-value="0" * @required */ protected int scanIntervalSeconds; /** * 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. * * @parameter expression="${jetty.reload}" default-value="automatic" */ protected String reload; /** * 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. * * @parameter expression="${jetty.systemPropertiesFile}" */ protected File systemPropertiesFile; /** * 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. * @parameter */ protected SystemProperties systemProperties; /** * Location of a jetty xml configuration file whose contents * will be applied before any plugin configuration. Optional. * @parameter */ protected File jettyConfig; /** * Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort> * -DSTOP.KEY=<stopKey> -jar start.jar --stop * @parameter */ protected int stopPort; /** * Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> * -DSTOP.PORT=<stopPort> -jar start.jar --stop * @parameter */ protected String stopKey; /** * <p> * 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. * </p><p> * 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. * </p> * @parameter expression="${jetty.daemon}" default-value="false" */ protected boolean daemon; /** * A scanner to check for changes to the webapp */ protected Scanner scanner; /** * List of files and directories to scan */ protected ArrayList scanList; /** * List of Listeners for the scanner */ protected ArrayList scannerListeners; /** * A scanner to check ENTER hits on the console */ protected Thread consoleScanner; public String PORT_SYSPROPERTY = "jetty.port"; /** * @return Returns the realms configured in the pom */ public abstract Object[] getConfiguredUserRealms(); /** * @return Returns the connectors configured in the pom */ public abstract Object[] getConfiguredConnectors(); public abstract Object getConfiguredRequestLog(); public abstract void checkPomConfiguration() throws MojoExecutionException; public abstract void configureScanner () throws MojoExecutionException; public abstract void applyJettyXml () throws Exception; /** * create a proxy that wraps a particular jetty version Server object * @return */ public abstract JettyPluginServer createServer() throws Exception; public abstract void finishConfigurationBeforeStart() throws Exception; public MavenProject getProject() { return this.project; } public File getTmpDirectory() { return this.tmpDirectory; } public File getWebDefaultXml() { return this.webDefaultXml; } public File getOverrideWebXml() { return this.overrideWebXml; } /** * @return Returns the contextPath. */ public String getContextPath() { return this.contextPath; } /** * @return Returns the scanIntervalSeconds. */ public int getScanIntervalSeconds() { return this.scanIntervalSeconds; } /** * @return returns the path to the systemPropertiesFile */ public File getSystemPropertiesFile() { return this.systemPropertiesFile; } public void setSystemPropertiesFile(File file) throws Exception { this.systemPropertiesFile = file; FileInputStream propFile = new FileInputStream(systemPropertiesFile); Properties properties = new Properties(); properties.load(propFile); if (this.systemProperties == null )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -