Class DeploymentScanner
- All Implemented Interfaces:
 Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle, Scanner.BulkListener, Scanner.Listener
Jetty WebApp Hot Deployment Scanner.
This class scans one or more directories (typically "webapps") for web applications to deploy, which may be:
- A standard WAR file (must end in ".war")
 - A directory containing an expanded WAR file
 - A directory containing static content
 - An XML descriptor in 
XmlConfigurationformat that configures aContextHandlerinstance 
ContextHandlerFactory
is used to create a ContextHandler, which is then deployed/undeployed via a Deployer instance.
The instances of the Deployer and ContextHandlerFactory used can either be:
- Passed into a constructor of this class
 - Discovered as a {
Container.getBean(Class)bean} of theServerinstance - Default implementations instantiated by this class.
 
To avoid double deployments and allow flexibility of the content of the scanned directories, the provider implements some heuristics to ignore some files found in the scans:
- Hidden files (starting with 
".") are ignored - Directories with names ending in 
".d"are ignored - Property files with names ending in 
".properties"are not deployed. - If a directory and a WAR file exist (eg: 
foo/andfoo.war) then the directory is assumed to be the unpacked WAR and only the WAR file is deployed (which may reuse the unpacked directory) - If a directory and a matching XML file exist (eg: 
foo/andfoo.xml) then the directory is assumed to be an unpacked WAR and only the XML file is deployed (which may use the directory in its configuration) - If a WAR file and a matching XML file exist (eg: 
foo.warandfoo.xml) then the WAR file is assumed to be configured by the XML file and only the XML file is deployed. 
For XML configured contexts, the following is available.
- The XML Object ID Map will have a reference to the 
Serverinstance via the ID name"Server" - The Default XML Properties are populated from a call to 
XmlConfiguration.setJettyStandardIdsAndProperties(Object, Path)(for things likejetty.homeandjetty.base) - An extra XML Property named 
"jetty.webapps"is available, and points to the webapps path. 
Context Deployment properties will be initialized with:
- The properties set on the application via embedded calls modifying 
DeploymentScanner.PathsApp.getAttributes() - The app specific properties file 
webapps/<webapp-name>.properties - The environment specific properties file 
webapps/<environment-name>[-zzz].properties - The 
Attributesfrom theEnvironment 
To configure Environment specific deployment Attributes,
either set the appropriate Deployable attribute via Attributes.setAttribute(String, Object),
or use the convenience class DeploymentScanner.EnvironmentConfig.
DeploymentScanner provider = new DeploymentScanner();
EnvironmentConfig env10config = provider.configureEnvironment("ee10");
env10config.setExtractWars(true);
env10config.setParentLoaderPriority(false);
- 
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic classBuilder of a deployment configuration for a specificEnvironment.Nested classes/interfaces inherited from class AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface Dumpable
Dumpable.DumpableContainer, Dumpable.DumpAppendableNested classes/interfaces inherited from interface LifeCycle
LifeCycle.Listener - 
Field Summary
 - 
Constructor Summary
ConstructorsConstructorDescriptionDeploymentScanner(Server server) Construct a raw DeploymentScanner that will (periodically) scan specific directories for paths that can be used to construct webapps that will be submitted to theDeployerfor eventual deployment to its configured destination.DeploymentScanner(Server server, Deployer deployer) Construct a raw DeploymentScanner that will (periodically) scan specific directories for paths that can be used to construct webapps that will be submitted to theDeployerfor eventual deployment to its configured destination.DeploymentScanner(Server server, Deployer deployer, FilenameFilter filter) Construct a raw DeploymentScanner that will (periodically) scan specific directories for paths that can be used to construct webapps that will be submitted to theDeployerfor eventual deployment to its configured destination.DeploymentScanner(Server server, Deployer deployer, FilenameFilter filter, ContextHandlerFactory contextHandlerFactory) Construct a raw DeploymentScanner that will (periodically) scan specific directories for paths that can be used to construct webapps that will be submitted to theDeployerfor eventual deployment to its configured destination.DeploymentScanner(Server server, Deployer deployer, ContextHandlerFactory contextHandlerFactory) Construct a raw DeploymentScanner that will (periodically) scan specific directories for paths that can be used to construct webapps that will be submitted to theDeployerfor eventual deployment to its configured destination. - 
Method Summary
Modifier and TypeMethodDescriptionvoidaddWebappsDirectory(Path dir) configureEnvironment(String name) Configure the Environment specific Deploy settings.protected voiddoStart()Starts the managed lifecycle beans in the order they were added.protected voiddoStop()Stops the managed lifecycle beans in the reverse order they were added.voiddump(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.intDeprecated, for removal: This API element is subject to removal in a future version.booleanTest if initial scan should be deferred.booleanIfScanneris configured toreportRealPaths.voidpathsChanged(Map<Path, Scanner.Notification> changeSet) This is the listener event for Scanner to report changes.voidscan()voidsetActionComparator(Comparator<DeploymentScanner.DeployAction> actionComparator) voidsetDeferInitialScan(boolean defer) Flag to control initial scan behavior.voidvoidsetEnvironmentsOrder(List<String> environmentsOrder) voidsetScanInterval(int scanInterval) voidsetUseRealPaths(boolean useRealPaths) TellsScannertoreportRealPaths.voidsetWebappDirectories(Collection<Path> directories) Deprecated, for removal: This API element is subject to removal in a future version.usesetWebappsDirectories(Collection)insteadvoidsetWebappsDirectories(Collection<Path> directories) toString()Methods inherited from class ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeansMethods inherited from class AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stopMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Container
getCachedBeans, getEventListenersMethods inherited from interface Dumpable.DumpableContainer
isDumpableMethods inherited from interface Scanner.BulkListener
filesChanged, pathsChanged 
- 
Constructor Details
- 
DeploymentScanner
Construct a raw DeploymentScanner that will (periodically) scan specific directories for paths that can be used to construct webapps that will be submitted to the
Deployerfor eventual deployment to its configured destination.- Parameters:
 server- the server reference to use for any XML based deployments.
 - 
DeploymentScanner
Construct a raw DeploymentScanner that will (periodically) scan specific directories for paths that can be used to construct webapps that will be submitted to the
Deployerfor eventual deployment to its configured destination.- Parameters:
 server- the server reference to use for any XML based deployments.deployer- theDeployerto use for deploying the createdContextHandlers, ornullfor a default.
 - 
DeploymentScanner
public DeploymentScanner(@Name("server") Server server, @Name("deployer") Deployer deployer, @Name("filenameFilter") FilenameFilter filter) Construct a raw DeploymentScanner that will (periodically) scan specific directories for paths that can be used to construct webapps that will be submitted to the
Deployerfor eventual deployment to its configured destination.- Parameters:
 server- the server reference to use for any XML based deployments.deployer- theDeployerto use for deploying the createdContextHandlers, ornullfor a default.filter- A customFilenameFilterto control what files theScannermonitors for changes, ornullfor a default.
 - 
DeploymentScanner
public DeploymentScanner(@Name("server") Server server, @Name("deployer") Deployer deployer, @Name("contextHandlerFactory") ContextHandlerFactory contextHandlerFactory) Construct a raw DeploymentScanner that will (periodically) scan specific directories for paths that can be used to construct webapps that will be submitted to the
Deployerfor eventual deployment to its configured destination.- Parameters:
 server- the server reference to use for any XML based deployments.deployer- theDeployerto use for deploying the createdContextHandlers, ornullfor a default.contextHandlerFactory- The factory to use to createContextHandlers, ornullfor a default.
 - 
DeploymentScanner
public DeploymentScanner(@Name("server") Server server, @Name("deployer") Deployer deployer, @Name("filenameFilter") FilenameFilter filter, @Name("contextHandlerFactory") ContextHandlerFactory contextHandlerFactory) Construct a raw DeploymentScanner that will (periodically) scan specific directories for paths that can be used to construct webapps that will be submitted to the
Deployerfor eventual deployment to its configured destination.- Parameters:
 server- the server reference to use for any XML based deployments.deployer- theDeployerto use for deploying the createdContextHandlers, ornullfor a default.filter- A customFilenameFilterto control what files theScannermonitors for changes, ornullfor a defaultcontextHandlerFactory- The factory to use to createContextHandlers, ornullfor a default.
 
 - 
 - 
Method Details
- 
addWebappsDirectory
- Parameters:
 dir- Directory to scan for deployable artifacts
 - 
configureEnvironment
Configure the Environment specific Deploy settings.- Parameters:
 name- the name of the environment.- Returns:
 - the deployment configuration for the 
Environment. 
 - 
dump
Description copied from interface:DumpableDump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
 dumpin interfaceDumpable- Overrides:
 dumpin classContainerLifeCycle- Parameters:
 out- The appendable to dump toindent- The indent to apply after any new lines.- Throws:
 IOException- if unable to write to Appendable
 - 
getActionComparator
- Returns:
 - The 
Comparatorused to sort theDeploymentScanner.DeployActions before acting on them. 
 - 
setActionComparator
 - 
getEnvironmentsOrder
 - 
setEnvironmentsOrder
 - 
getEnvironmentsDirectory
 - 
setEnvironmentsDirectory
 - 
getWebappDirectories
Deprecated, for removal: This API element is subject to removal in a future version.usegetWebappsDirectories()instead - 
getWebappsDirectories
 - 
setWebappDirectories
@Deprecated(since="12.1.2", forRemoval=true) public void setWebappDirectories(Collection<Path> directories) Deprecated, for removal: This API element is subject to removal in a future version.usesetWebappsDirectories(Collection)instead - 
setWebappsDirectories
 - 
getScanInterval
@ManagedAttribute("scanning interval to detect changes which need reloaded") public int getScanInterval()- Returns:
 - scan interval (in seconds) to detect changes which need reloaded
 - See Also:
 
 - 
setScanInterval
public void setScanInterval(int scanInterval) - Parameters:
 scanInterval- scan interval (in seconds) to detect changes which need reloaded- See Also:
 
 - 
isDeferInitialScan
public boolean isDeferInitialScan()Test if initial scan should be deferred.- Returns:
 - true if initial scan is deferred, false to have initial scan occur on startup of 
DeploymentScanner. 
 - 
setDeferInitialScan
public void setDeferInitialScan(boolean defer) Flag to control initial scan behavior.true- to have initial scan deferred until theServercomponent has reached its STARTED state.
Note: any failures in a deployment will not fail the Server startup in this mode.false- (default value) to have initial scan occur as normal onDeploymentScannerstartup.
- Parameters:
 defer- true to defer initial scan, false to have initial scan occur on startup ofDeploymentScanner.
 - 
isUseRealPaths
public boolean isUseRealPaths()IfScanneris configured toreportRealPaths.- Returns:
 - True if the real path of the scanned files should be used for deployment.
 - See Also:
 
 - 
setUseRealPaths
public void setUseRealPaths(boolean useRealPaths) TellsScannertoreportRealPaths.- Parameters:
 useRealPaths- True if the real path of the scanned files should be used for deployment.- See Also:
 
 - 
pathsChanged
This is the listener event for Scanner to report changes.- Specified by:
 pathsChangedin interfaceScanner.BulkListener- Parameters:
 changeSet- the changeset from the Scanner.
 - 
scan
 - 
doStart
Description copied from class:ContainerLifeCycleStarts the managed lifecycle beans in the order they were added.- Overrides:
 doStartin classContainerLifeCycle- Throws:
 Exception- If there was a problem starting. Will cause a transition to FAILED state
 - 
doStop
Description copied from class:ContainerLifeCycleStops the managed lifecycle beans in the reverse order they were added.- Overrides:
 doStopin classContainerLifeCycle- Throws:
 Exception- If there was a problem stopping. Will cause a transition to FAILED state
 - 
toString
- Overrides:
 toStringin classAbstractLifeCycle
 
 - 
 
getWebappsDirectories()instead