Class ContextProvider
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.deploy.providers.ScanningAppProvider
org.eclipse.jetty.deploy.providers.ContextProvider
- All Implemented Interfaces:
AppProvider
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
@ManagedObject("Provider for start-up deployment of webapps based on presence in directory")
public class ContextProvider
extends ScanningAppProvider
The webapps directory scanning provider.
This provider scans one or more directories (typically "webapps") for contexts 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
XmlConfiguration
format that configures aContextHandler
instance
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/ and foo.war) then the directory is assumed to be the unpacked WAR and only the WAR is deployed (which may reused the unpacked directory)
- If a directory and a matching XML file exist ( eg foo/ and foo.xml) then the directory is assumed to be an unpacked WAR and only the XML is deployed (which may used the directory in it's configuration)
- If a WAR file and a matching XML exist (eg foo.war and foo.xml) then the WAR is assumed to be configured by the XML and only the XML is deployed.
Only App
s discovered that report App.getEnvironmentName()
matching this providers
ScanningAppProvider.getEnvironmentName()
will be deployed.
For XML configured contexts, the ID map will contain a reference to the Server
instance called "Server" and
properties for the webapp file such as "jetty.webapp" and directory as "jetty.webapps".
The properties will be initialized with:
- The properties set on the application via
App.getProperties()
; otherwise: - The properties set on this provider via
getProperties()
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Object
createContextHandler
(App app) Create a ContextHandler for an Appprotected ClassLoader
String[]
This is equivalent to getting theDeployable.CONFIGURATION_CLASSES
property.Get the defaultsDescriptor.protected ContextHandler
protected void
initializeContextPath
(ContextHandler context, Path path) protected boolean
isDeployable
(Path path) boolean
Get the extractWars.boolean
Get the parentLoaderPriority.void
loadProperties
(Resource resource) void
loadPropertiesFromPath
(Path path) void
protected void
protected void
pathChanged
(Path path) void
setConfigurationClasses
(String configurations) This is equivalent to setting theDeployable.CONFIGURATION_CLASSES
property.void
setConfigurationClasses
(String[] configurations) This is equivalent to setting theDeployable.CONFIGURATION_CLASSES
property.void
setDefaultsDescriptor
(String defaultsDescriptor) Set the defaultsDescriptor.void
setExtractWars
(boolean extractWars) Set the extractWars.void
setParentLoaderPriority
(boolean parentLoaderPriority) Set the parentLoaderPriority.Methods inherited from class org.eclipse.jetty.deploy.providers.ScanningAppProvider
addScannerListener, createApp, doStart, doStop, exists, getDeployedApps, getDeploymentManager, getEnvironmentName, getMonitoredDirName, getMonitoredDirResource, getMonitoredResources, getScanInterval, isDeferInitialScan, isUseRealPaths, pathRemoved, scan, setDeferInitialScan, setDeploymentManager, setEnvironmentName, setFilenameFilter, setMonitoredDirectories, setMonitoredDirName, setMonitoredDirResource, setMonitoredResources, setScanInterval, setUseRealPaths, toString
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, 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, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListeners
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
-
Constructor Details
-
ContextProvider
public ContextProvider()
-
-
Method Details
-
getProperties
-
loadProperties
- Throws:
IOException
-
loadPropertiesFromPath
- Throws:
IOException
-
loadPropertiesFromString
- Throws:
IOException
-
isExtractWars
Get the extractWars. This is equivalent to getting theDeployable.EXTRACT_WARS
property.- Returns:
- the extractWars
-
setExtractWars
public void setExtractWars(boolean extractWars) Set the extractWars. This is equivalent to setting theDeployable.EXTRACT_WARS
property.- Parameters:
extractWars
- the extractWars to set
-
isParentLoaderPriority
Get the parentLoaderPriority. This is equivalent to getting theDeployable.PARENT_LOADER_PRIORITY
property.- Returns:
- the parentLoaderPriority
-
setParentLoaderPriority
public void setParentLoaderPriority(boolean parentLoaderPriority) Set the parentLoaderPriority. This is equivalent to setting theDeployable.PARENT_LOADER_PRIORITY
property.- Parameters:
parentLoaderPriority
- the parentLoaderPriority to set
-
getDefaultsDescriptor
Get the defaultsDescriptor. This is equivalent to getting theDeployable.DEFAULTS_DESCRIPTOR
property.- Returns:
- the defaultsDescriptor
-
setDefaultsDescriptor
Set the defaultsDescriptor. This is equivalent to setting theDeployable.DEFAULTS_DESCRIPTOR
property.- Parameters:
defaultsDescriptor
- the defaultsDescriptor to set
-
setConfigurationClasses
This is equivalent to setting theDeployable.CONFIGURATION_CLASSES
property.- Parameters:
configurations
- The configuration class names as a comma separated list
-
setConfigurationClasses
This is equivalent to setting theDeployable.CONFIGURATION_CLASSES
property.- Parameters:
configurations
- The configuration class names.
-
getConfigurationClasses
@ManagedAttribute("configuration classes for webapps to be processed through") public String[] getConfigurationClasses()This is equivalent to getting theDeployable.CONFIGURATION_CLASSES
property.- Returns:
- The configuration class names.
-
initializeContextHandler
-
createContextHandler
Description copied from interface:AppProvider
Create a ContextHandler for an App- Parameters:
app
- The App- Returns:
- A ContextHandler
- Throws:
IOException
- if unable to create contextException
- if unable to create context
-
applyXml
protected Object applyXml(Object context, Path xml, String environment, Map<String, String> properties) throws Exception- Throws:
Exception
-
findCoreContextClassLoader
- Throws:
IOException
-
initializeContextPath
-
isDeployable
-
pathAdded
- Overrides:
pathAdded
in classScanningAppProvider
- Throws:
Exception
-
pathChanged
- Overrides:
pathChanged
in classScanningAppProvider
- Throws:
Exception
-