Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ However, you can configure the `deployment-scanner` module to deploy web applica
[[monitored-directories]]
== Monitored Directories

The `deployment-scanner` module scans the web applications deploy directory specified by the `jetty.deploy.webappsDir` property, by default `$JETTY_BASE/webapps`, for web applications to deploy.
The `deployment-scanner` module scans the web applications deploy directory (or directories) specified by the `jetty.deploy.webappsDir` property, by default `$JETTY_BASE/webapps`, for web applications to deploy.

The directory specified by the `jetty.deploy.environmentsDir` property, by default `$JETTY_BASE/environments`, is also scanned for configuration files that apply to each environment, and therefore to all web applications deployed to that environment.

Expand Down Expand Up @@ -811,4 +811,4 @@ The format of the additional `web.xml` is exactly the same as a standard `web.xm
</web-app>
----

In the example above, you configured the `my-servlet` Servlet (defined in the web application `web.xml`), adding a host-specific `init-param` with the IP address of the host.
In the example above, you configured the `my-servlet` Servlet (defined in the web application `web.xml`), adding a host-specific `init-param` with the IP address of the host.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ include::{jetty-home}/modules/deployment-scanner.mod[tags=documentation]
Among the configurable properties, the most relevant are:

`jetty.deploy.webappsDir`::
The name of the directory to deploy web applications.
The name of the directory, or a comma-separated list of directories, that is scanned to deploy web applications.
`jetty.deploy.scanInterval`::
The scan period in seconds, that is how frequently the `DeploymentScanner` wakes up to scan the monitored directories for changes.
By default, `jetty.deploy.scanInterval=0` so that _hot_ deployment is disabled and only _cold_ deployment is possible (see also xref:deploy/index.adoc#hot-cold[here] for more information).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@
<New id="deploymentScanner" class="org.eclipse.jetty.deploy.DeploymentScanner">
<Arg name="server"><Ref refid="Server"/></Arg>
<Arg name="deployer"><Ref refid="Deployer"/></Arg>
<Call name="addWebappsDirectory">
<Arg>
<Call name="resolvedPath" class="org.eclipse.jetty.xml.XmlConfiguration">
<Arg>
<Property name="jetty.base" />
</Arg>
<Arg>
<Property name="jetty.deploy.webappsDir" default="webapps" />
</Arg>
</Call>
</Arg>
</Call>
<Set name="webappsDirectories">
<Call name="csvSplitAndResolvePaths" class="org.eclipse.jetty.xml.XmlConfiguration">
<Arg>
<Property name="jetty.base" />
</Arg>
<Arg>
<Property name="jetty.deploy.webappsDir" default="webapps" />
</Arg>
</Call>
</Set>
<Set name="environmentsDirectory">
<Call name="resolvedPath" class="org.eclipse.jetty.xml.XmlConfiguration">
<Arg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ etc/jetty-deployment-scanner.xml

[ini-template]
#tag::documentation[]
## The web application deploy directory name (relative to $JETTY_BASE)
## The web application deploy directory name, or a comma-separated
## list of directories (absolute paths, or relative to $JETTY_BASE).
# jetty.deploy.webappsDir=webapps

## The environments directory name (relative to $JETTY_BASE).
## The environments directory name (absolute path, or relative to $JETTY_BASE).
## This is where environment specific configuration files are stored.
# jetty.deploy.environmentsDir=environments

## Monitored directories scan period (seconds).
## This applies to both the webappsDir and environmentsDir
## This applies to both the webappsDir and environmentsDir.
## The value of 0 (default) disables hot deploy/redeploy/undeploy.
## Positive values enable hot deploy/redeploy/undeploy.
# jetty.deploy.scanInterval=0
Expand All @@ -38,4 +39,4 @@ etc/jetty-deployment-scanner.xml
## In this way, deploy failures do not fail the Server startup.
## Set it to false (default) to have initial scan occur during Server startup.
# jetty.deploy.deferInitialScan=false
#end::documentation[]
#end::documentation[]
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public class DeploymentScanner extends ContainerLifeCycle implements Scanner.Bul

private final Server server;
private final FilenameFilter filenameFilter;
private final List<Path> webappDirs = new CopyOnWriteArrayList<>();
private final List<Path> webappsDirs = new CopyOnWriteArrayList<>();
private final ContextHandlerFactory contextHandlerFactory;
private final Map<String, PathsApp> scannedApps = new HashMap<>();
private final Map<String, Attributes> environmentAttributesMap = new HashMap<>();
Expand Down Expand Up @@ -257,7 +257,7 @@ public void addWebappsDirectory(Path dir)
LOG.debug("Adding webapps directory: {}", dir);
if (isStarted())
throw new IllegalStateException("Unable to add webapps directory while running");
webappDirs.add(Objects.requireNonNull(dir));
webappsDirs.add(Objects.requireNonNull(dir));
}

/**
Expand Down Expand Up @@ -293,7 +293,7 @@ public EnvironmentConfig configureEnvironment(String name)
public void dump(Appendable out, String indent) throws IOException
{
Dumpable.dumpObjects(out, indent, this,
new DumpableCollection("webappDirs", webappDirs),
new DumpableCollection("webappDirs", webappsDirs),
Dumpable.named("environmentsDir", environmentsDir),
Dumpable.named("scanInterval", this.scanInterval),
new DumpableCollection("enabledEnvironments", this.enabledEnvironments),
Expand Down Expand Up @@ -376,18 +376,41 @@ public void setEnvironmentsDirectory(Path dir)

/**
* @return The {@link List} of {@link Path}s scanned for files to deploy.
* @deprecated use {@link #getWebappsDirectories()} instead
*/
@Deprecated(since = "12.1.2", forRemoval = true)
public List<Path> getWebappDirectories()
{
return webappDirs;
return getWebappsDirectories();
}

/**
* @return the {@link List} of {@link Path}s that are scanned to deploy web applications
*/
public List<Path> getWebappsDirectories()
{
return webappsDirs;
}

/**
* @param directories The {@link List} of {@link Path}s scanned for files to deploy.
* @deprecated use {@link #setWebappsDirectories(Collection)} instead
*/
@Deprecated(since = "12.1.2", forRemoval = true)
public void setWebappDirectories(Collection<Path> directories)
{
setWebappsDirectories(directories);
}

/**
* @param directories the {@link List} of {@link Path}s that are scanned to deploy web applications
*/
public void setWebappsDirectories(Collection<Path> directories)
{
if (isStarted())
throw new IllegalStateException("Unable to add webapp directories while running");

webappDirs.clear();
webappsDirs.clear();

for (Path dir : directories)
{
Expand Down Expand Up @@ -601,7 +624,7 @@ void resetAppState(String name)
public void scan()
{
LOG.info("Performing scan of webapps directories: {}",
webappDirs.stream()
webappsDirs.stream()
.map(Path::toUri)
.map(URI::toASCIIString)
.collect(Collectors.joining(", ", "[", "]"))
Expand Down Expand Up @@ -665,10 +688,10 @@ protected void doStart() throws Exception
throw new IllegalStateException("No deployer available");
}

if (webappDirs.isEmpty())
if (webappsDirs.isEmpty())
throw new IllegalStateException("No webapps dir specified");

LOG.info("Deployment monitoring of {} at intervals {}s {}", webappDirs, getScanInterval(), getScanInterval() <= 0 ? "(hot-redeploy disabled)" : "");
LOG.info("Deployment monitoring of {} at intervals {}s {}", webappsDirs, getScanInterval(), getScanInterval() <= 0 ? "(hot-redeploy disabled)" : "");

Predicate<Path> validDir = (path) ->
{
Expand All @@ -688,7 +711,7 @@ protected void doStart() throws Exception
};

List<Path> dirs = new ArrayList<>();
for (Path dir : webappDirs)
for (Path dir : webappsDirs)
{
if (validDir.test(dir))
dirs.add(dir);
Expand Down Expand Up @@ -767,7 +790,7 @@ private boolean isEnvironmentConfigPath(Path path)
private boolean isWebappsPath(Path path)
{
Path parentDir = path.getParent();
for (Path dir : webappDirs)
for (Path dir : webappsDirs)
{
if (isSameDir(dir, parentDir))
return true;
Expand Down Expand Up @@ -1052,7 +1075,7 @@ private void stopTracking(PathsApp app)
@Override
public String toString()
{
return String.format("%s@%x[webappsDirs=%s]", this.getClass(), hashCode(), webappDirs);
return String.format("%s@%x[webappsDirs=%s]", TypeUtil.toShortName(getClass()), hashCode(), webappsDirs);
}

public record DeployAction(DeployAction.Type type, String name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ etc/jetty-debuglog.xml

[ini-template]
#tag::documentation[]
## Logging directory (relative to $JETTY_BASE)
## Logging directory (absolute path, or relative to $JETTY_BASE)
# jetty.debuglog.dir=logs

## Whether to append to existing file
Expand Down
4 changes: 2 additions & 2 deletions jetty-core/jetty-server/src/main/config/modules/jaas.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ deployment-scanner
etc/jetty-jaas.xml

[ini-template]
## The file location (relative to $JETTY_BASE) for the
## JAAS "java.security.auth.login.config" system property
## The file location (absolute path, or relative to $JETTY_BASE)
## for the JAAS "java.security.auth.login.config" system property.
# jetty.jaas.login.conf=etc/login.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jetty.requestlog.dir?=logs
## Format string
# jetty.requestlog.formatString=%{client}a - %u %{dd/MMM/yyyy:HH:mm:ss ZZZ|GMT}t "%r" %s %O "%{Referer}i" "%{User-Agent}i"

## Logging directory (relative to $JETTY_BASE)
## Logging directory (absolute path, or relative to $JETTY_BASE).
# jetty.requestlog.dir=logs

## File path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ etc/well-known.xml

[ini-template]
# tag::documentation[]
## Well Known Directory (relative to $JETTY_BASE if relative path, otherwise it is an absolute path).
## Well Known Directory (absolute path, or relative to $JETTY_BASE).
# jetty.wellknown.dir=.well-known

## Allow contents of the well-known directory to be listed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ logs/

[ini-template]
# tag::documentation[]
## Logging directory (relative to $JETTY_BASE).
## Logging directory (absolute path, or relative to $JETTY_BASE).
# jetty.console-capture.dir=./logs

## Whether to append to existing file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,22 @@ public static Path resolvedPath(String dir, String destPath)
return Paths.get(dir).resolve(destPath).normalize();
}

/**
* <p>Utility method to split a comma-separated list of paths
* and resolve them against a directory.</p>
*
* @param dir the directory (should be a directory reference, does not have to exist)
* @param csvList a CSV list of paths (can be relative or absolute, syntax depends
* on OS + FileSystem in use, and does not need to exist)
* @return a list of resolved and normalized paths
*/
public static List<Path> csvSplitAndResolvePaths(String dir, String csvList)
{
return Arrays.stream(StringUtil.csvSplit(csvList))
.map(s -> resolvedPath(dir, s))
.toList();
}

private static class JettyXmlConfiguration implements ConfigurationProcessor
{
XmlParser.Node _root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -44,6 +45,7 @@ public class ExampleConfiguration extends HashMap<String, Object>
public int testField1;
public int testField2;
public int propValue;
private Collection<?> collection;
@SuppressWarnings("rawtypes")
private List list;
@SuppressWarnings("rawtypes")
Expand Down Expand Up @@ -166,6 +168,16 @@ public void call(int[] ia)
this.ia = ia;
}

public Collection<?> getCollection()
{
return collection;
}

public void setCollection(Collection<?> collection)
{
this.collection = collection;
}

@SuppressWarnings("rawtypes")
public List getList()
{
Expand Down
Loading