Skip to content

Commit 69c94c9

Browse files
authored
Merge 4d27c8d into 7c0ffb2
2 parents 7c0ffb2 + 4d27c8d commit 69c94c9

File tree

9 files changed

+716
-542
lines changed

9 files changed

+716
-542
lines changed

documentation/jetty/modules/operations-guide/pages/deploy/index.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ However, you can configure the `deployment-scanner` module to deploy web applica
6262
[[monitored-directories]]
6363
== Monitored Directories
6464

65-
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.
65+
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.
6666

6767
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.
6868

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

814-
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.
814+
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.

documentation/jetty/modules/operations-guide/pages/modules/standard.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ include::{jetty-home}/modules/deployment-scanner.mod[tags=documentation]
220220
Among the configurable properties, the most relevant are:
221221

222222
`jetty.deploy.webappsDir`::
223-
The name of the directory to deploy web applications.
223+
The name of the directory, or a comma-separated list of directories, that is scanned to deploy web applications.
224224
`jetty.deploy.scanInterval`::
225225
The scan period in seconds, that is how frequently the `DeploymentScanner` wakes up to scan the monitored directories for changes.
226226
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).

jetty-core/jetty-deploy/src/main/config/etc/jetty-deployment-scanner.xml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,16 @@
1515
<New id="deploymentScanner" class="org.eclipse.jetty.deploy.DeploymentScanner">
1616
<Arg name="server"><Ref refid="Server"/></Arg>
1717
<Arg name="deployer"><Ref refid="Deployer"/></Arg>
18-
<Call name="addWebappsDirectory">
19-
<Arg>
20-
<Call name="resolvedPath" class="org.eclipse.jetty.xml.XmlConfiguration">
21-
<Arg>
22-
<Property name="jetty.base" />
23-
</Arg>
24-
<Arg>
25-
<Property name="jetty.deploy.webappsDir" default="webapps" />
26-
</Arg>
27-
</Call>
28-
</Arg>
29-
</Call>
18+
<Set name="webappsDirectories">
19+
<Call name="csvSplitAndResolvePaths" class="org.eclipse.jetty.xml.XmlConfiguration">
20+
<Arg>
21+
<Property name="jetty.base" />
22+
</Arg>
23+
<Arg>
24+
<Property name="jetty.deploy.webappsDir" default="webapps" />
25+
</Arg>
26+
</Call>
27+
</Set>
3028
<Set name="environmentsDirectory">
3129
<Call name="resolvedPath" class="org.eclipse.jetty.xml.XmlConfiguration">
3230
<Arg>

jetty-core/jetty-deploy/src/main/config/modules/deployment-scanner.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ etc/jetty-deployment-scanner.xml
2020

2121
[ini-template]
2222
#tag::documentation[]
23-
## The web application deploy directory name (relative to $JETTY_BASE)
23+
## The web application deploy directory name, or a comma-separated
24+
## list of directories (relative to $JETTY_BASE).
2425
# jetty.deploy.webappsDir=webapps
2526

2627
## The environments directory name (relative to $JETTY_BASE).
2728
## This is where environment specific configuration files are stored.
2829
# jetty.deploy.environmentsDir=environments
2930

3031
## Monitored directories scan period (seconds).
31-
## This applies to both the webappsDir and environmentsDir
32+
## This applies to both the webappsDir and environmentsDir.
3233
## The value of 0 (default) disables hot deploy/redeploy/undeploy.
3334
## Positive values enable hot deploy/redeploy/undeploy.
3435
# jetty.deploy.scanInterval=0
@@ -38,4 +39,4 @@ etc/jetty-deployment-scanner.xml
3839
## In this way, deploy failures do not fail the Server startup.
3940
## Set it to false (default) to have initial scan occur during Server startup.
4041
# jetty.deploy.deferInitialScan=false
41-
#end::documentation[]
42+
#end::documentation[]

jetty-core/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentScanner.java

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public class DeploymentScanner extends ContainerLifeCycle implements Scanner.Bul
131131

132132
private final Server server;
133133
private final FilenameFilter filenameFilter;
134-
private final List<Path> webappDirs = new CopyOnWriteArrayList<>();
134+
private final List<Path> webappsDirs = new CopyOnWriteArrayList<>();
135135
private final ContextHandlerFactory contextHandlerFactory;
136136
private final Map<String, PathsApp> scannedApps = new HashMap<>();
137137
private final Map<String, Attributes> environmentAttributesMap = new HashMap<>();
@@ -257,7 +257,7 @@ public void addWebappsDirectory(Path dir)
257257
LOG.debug("Adding webapps directory: {}", dir);
258258
if (isStarted())
259259
throw new IllegalStateException("Unable to add webapps directory while running");
260-
webappDirs.add(Objects.requireNonNull(dir));
260+
webappsDirs.add(Objects.requireNonNull(dir));
261261
}
262262

263263
/**
@@ -293,7 +293,7 @@ public EnvironmentConfig configureEnvironment(String name)
293293
public void dump(Appendable out, String indent) throws IOException
294294
{
295295
Dumpable.dumpObjects(out, indent, this,
296-
new DumpableCollection("webappDirs", webappDirs),
296+
new DumpableCollection("webappDirs", webappsDirs),
297297
Dumpable.named("environmentsDir", environmentsDir),
298298
Dumpable.named("scanInterval", this.scanInterval),
299299
new DumpableCollection("enabledEnvironments", this.enabledEnvironments),
@@ -376,18 +376,41 @@ public void setEnvironmentsDirectory(Path dir)
376376

377377
/**
378378
* @return The {@link List} of {@link Path}s scanned for files to deploy.
379+
* @deprecated use {@link #getWebappsDirectories()} instead
379380
*/
381+
@Deprecated(since = "12.1.2", forRemoval = true)
380382
public List<Path> getWebappDirectories()
381383
{
382-
return webappDirs;
384+
return getWebappsDirectories();
383385
}
384386

387+
/**
388+
* @return the {@link List} of {@link Path}s that are scanned to deploy web applications
389+
*/
390+
public List<Path> getWebappsDirectories()
391+
{
392+
return webappsDirs;
393+
}
394+
395+
/**
396+
* @param directories The {@link List} of {@link Path}s scanned for files to deploy.
397+
* @deprecated use {@link #setWebappsDirectories(Collection)} instead
398+
*/
399+
@Deprecated(since = "12.1.2", forRemoval = true)
385400
public void setWebappDirectories(Collection<Path> directories)
401+
{
402+
setWebappsDirectories(directories);
403+
}
404+
405+
/**
406+
* @param directories the {@link List} of {@link Path}s that are scanned to deploy web applications
407+
*/
408+
public void setWebappsDirectories(Collection<Path> directories)
386409
{
387410
if (isStarted())
388411
throw new IllegalStateException("Unable to add webapp directories while running");
389412

390-
webappDirs.clear();
413+
webappsDirs.clear();
391414

392415
for (Path dir : directories)
393416
{
@@ -601,7 +624,7 @@ void resetAppState(String name)
601624
public void scan()
602625
{
603626
LOG.info("Performing scan of webapps directories: {}",
604-
webappDirs.stream()
627+
webappsDirs.stream()
605628
.map(Path::toUri)
606629
.map(URI::toASCIIString)
607630
.collect(Collectors.joining(", ", "[", "]"))
@@ -665,10 +688,10 @@ protected void doStart() throws Exception
665688
throw new IllegalStateException("No deployer available");
666689
}
667690

668-
if (webappDirs.isEmpty())
691+
if (webappsDirs.isEmpty())
669692
throw new IllegalStateException("No webapps dir specified");
670693

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

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

690713
List<Path> dirs = new ArrayList<>();
691-
for (Path dir : webappDirs)
714+
for (Path dir : webappsDirs)
692715
{
693716
if (validDir.test(dir))
694717
dirs.add(dir);
@@ -767,7 +790,7 @@ private boolean isEnvironmentConfigPath(Path path)
767790
private boolean isWebappsPath(Path path)
768791
{
769792
Path parentDir = path.getParent();
770-
for (Path dir : webappDirs)
793+
for (Path dir : webappsDirs)
771794
{
772795
if (isSameDir(dir, parentDir))
773796
return true;
@@ -1052,7 +1075,7 @@ private void stopTracking(PathsApp app)
10521075
@Override
10531076
public String toString()
10541077
{
1055-
return String.format("%s@%x[webappsDirs=%s]", this.getClass(), hashCode(), webappDirs);
1078+
return String.format("%s@%x[webappsDirs=%s]", TypeUtil.toShortName(getClass()), hashCode(), webappsDirs);
10561079
}
10571080

10581081
public record DeployAction(DeployAction.Type type, String name)

jetty-core/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,22 @@ public static Path resolvedPath(String dir, String destPath)
458458
return Paths.get(dir).resolve(destPath).normalize();
459459
}
460460

461+
/**
462+
* <p>Utility method to split a comma-separated list of paths
463+
* and resolve them against a directory.</p>
464+
*
465+
* @param dir the directory (should be a directory reference, does not have to exist)
466+
* @param csvList a CSV list of paths (can be relative or absolute, syntax depends
467+
* on OS + FileSystem in use, and does not need to exist)
468+
* @return a list of resolved and normalized paths
469+
*/
470+
public static List<Path> csvSplitAndResolvePaths(String dir, String csvList)
471+
{
472+
return Arrays.stream(StringUtil.csvSplit(csvList))
473+
.map(s -> resolvedPath(dir, s))
474+
.toList();
475+
}
476+
461477
private static class JettyXmlConfiguration implements ConfigurationProcessor
462478
{
463479
XmlParser.Node _root;

jetty-core/jetty-xml/src/test/java/org/eclipse/jetty/xml/ExampleConfiguration.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import java.net.URL;
1717
import java.util.ArrayList;
18+
import java.util.Collection;
1819
import java.util.HashMap;
1920
import java.util.LinkedList;
2021
import java.util.List;
@@ -44,6 +45,7 @@ public class ExampleConfiguration extends HashMap<String, Object>
4445
public int testField1;
4546
public int testField2;
4647
public int propValue;
48+
private Collection<?> collection;
4749
@SuppressWarnings("rawtypes")
4850
private List list;
4951
@SuppressWarnings("rawtypes")
@@ -166,6 +168,16 @@ public void call(int[] ia)
166168
this.ia = ia;
167169
}
168170

171+
public Collection<?> getCollection()
172+
{
173+
return collection;
174+
}
175+
176+
public void setCollection(Collection<?> collection)
177+
{
178+
this.collection = collection;
179+
}
180+
169181
@SuppressWarnings("rawtypes")
170182
public List getList()
171183
{

0 commit comments

Comments
 (0)