Merged branch 'jetty-9.4.x' into 'jetty-10.0.x'.
This commit is contained in:
commit
41663d8e5c
|
@ -10,7 +10,8 @@
|
|||
<url>http://www.eclipse.org/jetty</url>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<bundle-symbolic-name>${project.groupId}.${project.artifactId}</bundle-symbolic-name>
|
||||
<bundle-symbolic-name>${project.groupId}.apache-jsp</bundle-symbolic-name>
|
||||
<jpms-module-name>${project.groupId}.apache.jsp</jpms-module-name>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
|
@ -9,3 +9,7 @@ plus
|
|||
[lib]
|
||||
lib/jetty-annotations-${jetty.version}.jar
|
||||
lib/annotations/*.jar
|
||||
|
||||
[jpms]
|
||||
add-modules:org.objectweb.asm
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
import org.eclipse.jetty.util.JavaVersion;
|
||||
import org.eclipse.jetty.util.Loader;
|
||||
import org.eclipse.jetty.util.ManifestUtils;
|
||||
import org.eclipse.jetty.util.MultiException;
|
||||
import org.eclipse.jetty.util.MultiReleaseJarFile;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -85,53 +86,49 @@ public class AnnotationParser
|
|||
public static int asmVersion ()
|
||||
{
|
||||
int asmVersion = ASM_OPCODE_VERSION;
|
||||
Package asm = Opcodes.class.getPackage();
|
||||
if (asm == null)
|
||||
LOG.warn("Unknown asm runtime version, assuming version {}", ASM_OPCODE_VERSION_STR);
|
||||
String version = ManifestUtils.getVersion(Opcodes.class).orElse(null);
|
||||
if (version == null)
|
||||
{
|
||||
LOG.warn("Unknown ASM version, assuming {}", ASM_OPCODE_VERSION_STR);
|
||||
}
|
||||
else
|
||||
{
|
||||
String s = asm.getImplementationVersion();
|
||||
if (s==null)
|
||||
LOG.info("Unknown asm implementation version, assuming version {}", ASM_OPCODE_VERSION_STR);
|
||||
else
|
||||
int dot = version.indexOf('.');
|
||||
version = version.substring(0, (dot < 0 ? version.length() : dot)).trim();
|
||||
try
|
||||
{
|
||||
int dot = s.indexOf('.');
|
||||
s = s.substring(0, (dot < 0 ? s.length() : dot)).trim();
|
||||
try
|
||||
int v = Integer.parseInt(version);
|
||||
switch (v)
|
||||
{
|
||||
int v = Integer.parseInt(s);
|
||||
switch (v)
|
||||
case 4:
|
||||
{
|
||||
case 4:
|
||||
{
|
||||
asmVersion = Opcodes.ASM4;
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
asmVersion = Opcodes.ASM5;
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
asmVersion = Opcodes.ASM6;
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
asmVersion = Opcodes.ASM7;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
LOG.warn("Unrecognized runtime asm version, assuming {}", ASM_OPCODE_VERSION_STR);
|
||||
}
|
||||
asmVersion = Opcodes.ASM4;
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
asmVersion = Opcodes.ASM5;
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
asmVersion = Opcodes.ASM6;
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
asmVersion = Opcodes.ASM7;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
LOG.warn("Unrecognized ASM version, assuming {}", ASM_OPCODE_VERSION_STR);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
LOG.warn("Unable to parse runtime asm version, assuming version {}", ASM_OPCODE_VERSION_STR);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
LOG.warn("Unable to parse ASM version, assuming {}", ASM_OPCODE_VERSION_STR);
|
||||
}
|
||||
}
|
||||
return asmVersion;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<name>Jetty :: Ant Plugin</name>
|
||||
|
||||
<properties>
|
||||
<bundle-symbolic-name>org.eclipse.jetty.ant</bundle-symbolic-name>
|
||||
<bundle-symbolic-name>${project.groupId}.ant</bundle-symbolic-name>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
|
@ -28,3 +28,4 @@ include::custom-modules.adoc[]
|
|||
include::startup-xml-config.adoc[]
|
||||
include::startup-unix-service.adoc[]
|
||||
include::startup-windows-service.adoc[]
|
||||
include::startup-jpms.adoc[]
|
||||
|
|
|
@ -170,7 +170,7 @@ Note: order presented here is how they would appear on the classpath.
|
|||
13: {VERSION} | ${jetty.home}/lib/jetty-jndi-{VERSION}.jar
|
||||
14: 1.1.0.v201105071233 | ${jetty.home}/lib/jndi/javax.activation-1.1.0.v201105071233.jar
|
||||
15: 1.4.1.v201005082020 | ${jetty.home}/lib/jndi/javax.mail.glassfish-1.4.1.v201005082020.jar
|
||||
16: 1.2 | ${jetty.home}/lib/jndi/javax.transaction-api-1.2.jar
|
||||
16: 1.3 | ${jetty.home}/lib/jndi/javax.transaction-api-1.3.jar
|
||||
17: {VERSION} | ${jetty.home}/lib/jetty-rewrite-{VERSION}.jar
|
||||
18: {VERSION} | ${jetty.home}/lib/jetty-security-{VERSION}.jar
|
||||
19: {VERSION} | ${jetty.home}/lib/jetty-servlet-{VERSION}.jar
|
||||
|
|
|
@ -80,7 +80,7 @@ Note: order presented here is how they would appear on the classpath.
|
|||
13: {VERSION} | ${jetty.home}/lib/jetty-jndi-{VERSION}.jar
|
||||
14: 1.1.0.v201105071233 | ${jetty.home}/lib/jndi/javax.activation-1.1.0.v201105071233.jar
|
||||
15: 1.4.1.v201005082020 | ${jetty.home}/lib/jndi/javax.mail.glassfish-1.4.1.v201005082020.jar
|
||||
16: 1.2 | ${jetty.home}/lib/jndi/javax.transaction-api-1.2.jar
|
||||
16: 1.3 | ${jetty.home}/lib/jndi/javax.transaction-api-1.3.jar
|
||||
17: {VERSION} | ${jetty.home}/lib/jetty-rewrite-{VERSION}.jar
|
||||
18: {VERSION} | ${jetty.home}/lib/jetty-security-{VERSION}.jar
|
||||
19: {VERSION} | ${jetty.home}/lib/jetty-servlet-{VERSION}.jar
|
||||
|
|
|
@ -0,0 +1,190 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd.
|
||||
// ========================================================================
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
[[startup-overview]]
|
||||
=== Startup using the Java Platform Module System (JPMS)
|
||||
|
||||
Jetty modules are also automatic https://en.wikipedia.org/wiki/Java_Platform_Module_System[JPMS]
|
||||
modules via the `Automatic-Module-Name` attribute in the jar's `MANIFEST.MF` file.
|
||||
|
||||
This makes possible to run Jetty from the module-path, rather than the class-path.
|
||||
|
||||
We recommend to use JDK 11 or greater due to the fact that JDK 11 removed all the
|
||||
"enterprise" modules from the JDK.
|
||||
The classes in these "enterprise" modules were bundled with JDK 8, and present in
|
||||
"enterprise" modules in JDK 9 and JDK 10.
|
||||
With JDK 11, these "enterprise" classes are either not available in the JDK (because
|
||||
their corresponding module was removed), or they are present in a different module.
|
||||
|
||||
Some of these "enterprise" classes are required by Jetty or by applications running
|
||||
in Jetty, so it is better to use a stable source for those classes by using JDK 11
|
||||
or greater.
|
||||
|
||||
==== Starting Jetty on the module-path
|
||||
|
||||
To start Jetty on the module-path, rather than the class-path, it is enough to add
|
||||
the `--jpms` option to the command line, for example:
|
||||
|
||||
[source, screen, subs="{sub-order}"]
|
||||
....
|
||||
$ mkdir my-jetty-base
|
||||
$ cd my-jetty-base
|
||||
$ java -jar $JETTY_HOME/start.jar --add-to-start=http
|
||||
INFO : server transitively enabled, ini template available with --add-to-start=server
|
||||
INFO : http initialized in ${jetty.base}/start.ini
|
||||
INFO : threadpool transitively enabled, ini template available with --add-to-start=threadpool
|
||||
INFO : Base directory was modified
|
||||
$ java -jar $JETTY_HOME/start.jar --jpms
|
||||
....
|
||||
|
||||
The example above creates a link:#startup-base-and-home[Jetty base directory] and
|
||||
enables the `http` module using `--add-to-start`.
|
||||
Then starts Jetty on the module-path using the `--jpms` option.
|
||||
|
||||
----
|
||||
[NOTE]
|
||||
When running on the module-path using the `--jpms` option, the Jetty start mechanism
|
||||
will fork a second JVM passing it the right JVM options to run on the module-path.
|
||||
|
||||
You will have two JVMs running: one that runs `start.jar` and one that runs Jetty on
|
||||
the module-path.
|
||||
----
|
||||
|
||||
If you are interested in the details of how the command line to run Jetty on the
|
||||
module-path looks like, you can add the `--dry-run` option:
|
||||
|
||||
[source, screen, subs="{sub-order}"]
|
||||
....
|
||||
$ java -jar $JETTY_HOME/start.jar --jpms --dry-run
|
||||
....
|
||||
|
||||
You will see something like this (broken in sections for clarity):
|
||||
|
||||
[source, screen, subs="{sub-order}"]
|
||||
....
|
||||
/opt/openjdk-11+28/bin/java
|
||||
--module-path /opt/jetty/lib/servlet-api-3.1.jar:/opt/jetty/lib/jetty-schemas-3.1.jar:/opt/jetty/lib/jetty-http-9.4.13-SNAPSHOT.jar:...
|
||||
--patch-module servlet.api=/opt/jetty/lib/jetty-schemas-3.1.jar
|
||||
--module org.eclipse.jetty.xml/org.eclipse.jetty.xml.XmlConfiguration /opt/jetty/etc/jetty-threadpool.xml /opt/jetty/etc/jetty.xml ...
|
||||
....
|
||||
|
||||
The `--module-path` option specifies the list of Jetty jars. This list depends
|
||||
on the Jetty modules that have been enabled via `--add-to-start`.
|
||||
|
||||
The `--patch-module` option is necessary for Servlet and JSP Containers to find XML DTDs
|
||||
and XML Schemas required to validate the various XML files present in web applications
|
||||
(such as `web.xml` and others).
|
||||
|
||||
The `--module` option tells the JVM to run main class `XmlConfiguration` from the
|
||||
`org.eclipse.jetty.xml` module, with the given XML files as program arguments.
|
||||
|
||||
When the JVM starts, module `org.eclipse.jetty.xml` is added to the set of JPMS
|
||||
_root modules_; all other Jetty modules, being automatic, will be resolved and added
|
||||
to the module graph; jars that are not modules such as `servlet-api-3.1.jar` are on
|
||||
the module-path and therefore will be made automatic modules by the JVM (hence the
|
||||
derived module name `servlet.api` for this jar, referenced by the `--patch-module`
|
||||
command line option above).
|
||||
|
||||
==== Advanced JPMS Configuration
|
||||
|
||||
Web applications may need additional services from the Servlet Container, such as
|
||||
JDBC `DataSource` references or JTA `UserTransaction` references.
|
||||
|
||||
For example, for JDBC it is typical to store in JNDI a reference to the connection
|
||||
pool's `DataSource` (for example `com.zaxxer.hikari.HikariDataSource`) or a
|
||||
reference directly to the JDBC driver's `DataSource` (for example
|
||||
`com.mysql.jdbc.jdbc2.optional.MysqlDataSource`).
|
||||
Jetty needs to be able to instantiate those classes and therefore needs to be able
|
||||
to load those classes and all their super-classes, among which `javax.sql.DataSource`.
|
||||
|
||||
When Jetty runs on the class-path, this is easily achieved by using a
|
||||
link:#custom-modules[custom module]:
|
||||
|
||||
[source, screen, subs="{sub-order}"]
|
||||
.mysql.mod
|
||||
....
|
||||
[description]
|
||||
MySQL module
|
||||
|
||||
[lib]
|
||||
lib/mysql/mysql-connector-java-*.jar
|
||||
....
|
||||
|
||||
However, when running on the module-path, things are quite different.
|
||||
|
||||
Class `javax.sql.DataSource` is in a JDK bundled module named `java.sql`, which is
|
||||
not automatic (it's a proper JPMS module) and it is not in the _root modules_ set;
|
||||
because it is not an automatic module, it is not added to the module graph, and
|
||||
therefore needs to be added explicitly using the JVM command line `--add-modules`.
|
||||
|
||||
To add the JPMS module `java.sql` to the module graph, you need to modify
|
||||
`mysql.mod` in the following way:
|
||||
|
||||
[source, screen, subs="{sub-order}"]
|
||||
.mysql.mod
|
||||
....
|
||||
[description]
|
||||
MySQL module
|
||||
|
||||
[lib]
|
||||
lib/mysql/mysql-connector-java-*.jar
|
||||
|
||||
[jpms]
|
||||
add-modules: java.sql
|
||||
....
|
||||
|
||||
The new `[jpms]` section is only used when Jetty is started on the module-path
|
||||
via the `--jpms` command line option.
|
||||
|
||||
Assuming that `mysql-connector-java-*.jar` is a non JPMS modular jar, or an
|
||||
automatic JPMS modular jar, the Jetty start mechanism will add
|
||||
`mysql-connector-java-*.jar` to the module-path, and will add the JVM command
|
||||
line option `--add-modules java.sql`.
|
||||
|
||||
If `mysql-connector-java-*.jar` were a proper JPMS modular jar with name
|
||||
(for example) `com.mysql.jdbc`, then it would need to be explicitly added to
|
||||
the module graph, in this way:
|
||||
|
||||
[source, screen, subs="{sub-order}"]
|
||||
.mysql.mod
|
||||
....
|
||||
[description]
|
||||
MySQL module
|
||||
|
||||
[lib]
|
||||
lib/mysql/mysql-connector-java-*.jar
|
||||
|
||||
[jpms]
|
||||
add-modules: com.mysql.jdbc
|
||||
....
|
||||
|
||||
Now we don't need to add JPMS module `java.sql` explicitly because it would be
|
||||
a dependency of the `com.mysql.jdbc` module and therefore automatically added
|
||||
to the module graph.
|
||||
|
||||
The `[jpms]` section has the following format:
|
||||
|
||||
[source, screen, subs="{sub-order}"]
|
||||
....
|
||||
[jpms]
|
||||
add-modules: <module name>(,<module name>)*
|
||||
patch-module: <module>=<file>(:<file>)*
|
||||
add-opens: <module>/<package>=<target-module>(,<target-module>)*
|
||||
add-exports: <module>/<package>=<target-module>(,<target-module>)*
|
||||
add-reads: <module>=<target-module>(,<target-module>)*
|
||||
....
|
|
@ -324,7 +324,7 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<includeGroupIds>javax.annotation,org.eclipse.jetty.orbit,org.ow2.asm</includeGroupIds>
|
||||
<includeArtifactIds>javax.annotation-api,asm,asm-commons</includeArtifactIds>
|
||||
<includeArtifactIds>javax.annotation-api,asm,asm-commons,asm-tree,asm-analysis</includeArtifactIds>
|
||||
<includeTypes>jar</includeTypes>
|
||||
<outputDirectory>${assembly-directory}/lib/annotations</outputDirectory>
|
||||
</configuration>
|
||||
|
@ -337,7 +337,7 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<includeGroupIds>javax.annotation,org.eclipse.jetty.orbit,org.ow2.asm</includeGroupIds>
|
||||
<includeArtifactIds>javax.annotation-api,asm,asm-commons</includeArtifactIds>
|
||||
<includeArtifactIds>javax.annotation-api,asm,asm-commons,asm-tree,asm-analysis</includeArtifactIds>
|
||||
<includeTypes>jar</includeTypes>
|
||||
<classifier>sources</classifier>
|
||||
<outputDirectory>${source-assembly-directory}/lib/annotations</outputDirectory>
|
||||
|
@ -547,6 +547,14 @@
|
|||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-tree</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-analysis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- jetty deps -->
|
||||
<dependency>
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
<!-- always include the sources to be able to prepare the eclipse-jetty-SDK feature
|
||||
with a snapshot. -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
|
@ -44,7 +44,7 @@
|
|||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Import-Package>javax.transaction*;version="[1.1,1.3)",*</Import-Package>
|
||||
<Import-Package>javax.transaction.*;version="1.1",*</Import-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -72,7 +72,6 @@
|
|||
<dependency>
|
||||
<groupId>javax.transaction</groupId>
|
||||
<artifactId>javax.transaction-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
<dependency>
|
||||
<groupId>javax.transaction</groupId>
|
||||
<artifactId>javax.transaction-api</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -49,7 +48,6 @@
|
|||
<dependency>
|
||||
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||
<artifactId>javax.mail.glassfish</artifactId>
|
||||
<version>1.4.1.v201005082020</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -24,6 +24,9 @@ lib/jetty-io-${jetty.version}.jar
|
|||
[xml]
|
||||
etc/jetty.xml
|
||||
|
||||
[jpms]
|
||||
patch-module: servlet.api=lib/jetty-schemas-3.1.jar
|
||||
|
||||
[ini-template]
|
||||
### Common HTTP configuration
|
||||
## Scheme to use to build URIs for secure redirects
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
<artifact>org.eclipse.jetty:jetty-util</artifact>
|
||||
<includes>
|
||||
<include>org/eclipse/jetty/util/JavaVersion*</include>
|
||||
<include>org/eclipse/jetty/util/ManifestUtils*</include>
|
||||
<include>org/eclipse/jetty/util/TopologicalSort*</include>
|
||||
</includes>
|
||||
</filter>
|
||||
|
|
|
@ -18,11 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.start;
|
||||
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_BAD_STOP_PROPS;
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_INVOKE_MAIN;
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_NOT_STOPPED;
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_UNKNOWN;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -44,6 +39,11 @@ import org.eclipse.jetty.start.Props.Prop;
|
|||
import org.eclipse.jetty.start.config.CommandLineConfigSource;
|
||||
import org.eclipse.jetty.start.config.ConfigSource;
|
||||
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_BAD_STOP_PROPS;
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_INVOKE_MAIN;
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_NOT_STOPPED;
|
||||
import static org.eclipse.jetty.start.UsageException.ERR_UNKNOWN;
|
||||
|
||||
/**
|
||||
* Main start class.
|
||||
* <p>
|
||||
|
@ -353,9 +353,13 @@ public class Main
|
|||
// ------------------------------------------------------------
|
||||
// 6) Resolve Extra XMLs
|
||||
args.resolveExtraXmls();
|
||||
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// 9) Resolve Property Files
|
||||
// 7) JPMS Expansion
|
||||
args.expandJPMS(activeModules);
|
||||
|
||||
// ------------------------------------------------------------
|
||||
// 8) Resolve Property Files
|
||||
args.resolvePropertyFiles();
|
||||
|
||||
return args;
|
||||
|
|
|
@ -59,7 +59,7 @@ import org.eclipse.jetty.start.Props.Prop;
|
|||
*/
|
||||
public class Module implements Comparable<Module>
|
||||
{
|
||||
private static final String VERSION_UNSPECIFIED = "9.2";
|
||||
private static final String VERSION_UNSPECIFIED = "0.0";
|
||||
static Pattern MOD_NAME = Pattern.compile("^(.*)\\.mod",Pattern.CASE_INSENSITIVE);
|
||||
static Pattern SET_PROPERTY = Pattern.compile("^(#?)\\s*([^=\\s]+)=(.*)$");
|
||||
|
||||
|
@ -89,6 +89,9 @@ public class Module implements Comparable<Module>
|
|||
|
||||
/** List of library options for this Module */
|
||||
private final List<String> _libs=new ArrayList<>();
|
||||
|
||||
/** List of JPMS options for this Module */
|
||||
private final List<String> _jpms=new ArrayList<>();
|
||||
|
||||
/** List of files for this Module */
|
||||
private final List<String> _files=new ArrayList<>();
|
||||
|
@ -229,6 +232,11 @@ public class Module implements Comparable<Module>
|
|||
{
|
||||
return _xmls;
|
||||
}
|
||||
|
||||
public List<String> getJPMS()
|
||||
{
|
||||
return _jpms;
|
||||
}
|
||||
|
||||
public Version getVersion()
|
||||
{
|
||||
|
@ -350,6 +358,9 @@ public class Module implements Comparable<Module>
|
|||
case "LIBS":
|
||||
_libs.add(line);
|
||||
break;
|
||||
case "JPMS":
|
||||
_jpms.add(line);
|
||||
break;
|
||||
case "LICENSE":
|
||||
case "LICENSES":
|
||||
case "LICENCE":
|
||||
|
|
|
@ -154,6 +154,10 @@ public class Modules implements Iterable<Module>
|
|||
{
|
||||
System.out.printf(" XML: %s%n",xml);
|
||||
}
|
||||
for (String jpms : module.getJPMS())
|
||||
{
|
||||
System.out.printf(" JPMS: %s%n",jpms);
|
||||
}
|
||||
for (String jvm : module.getJvmArgs())
|
||||
{
|
||||
System.out.printf(" JVM: %s%n",jvm);
|
||||
|
|
|
@ -27,21 +27,28 @@ import java.net.URL;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.eclipse.jetty.start.Props.Prop;
|
||||
import org.eclipse.jetty.start.config.ConfigSource;
|
||||
import org.eclipse.jetty.start.config.ConfigSources;
|
||||
import org.eclipse.jetty.start.config.DirConfigSource;
|
||||
import org.eclipse.jetty.util.JavaVersion;
|
||||
import org.eclipse.jetty.util.ManifestUtils;
|
||||
|
||||
/**
|
||||
* The Arguments required to start Jetty.
|
||||
|
@ -59,15 +66,11 @@ public class StartArgs
|
|||
// Use META-INF/MANIFEST.MF versions
|
||||
if (ver == null)
|
||||
{
|
||||
Package pkg = StartArgs.class.getPackage();
|
||||
if ((pkg != null) && "Eclipse.org - Jetty".equals(pkg.getImplementationVendor()) && (pkg.getImplementationVersion() != null))
|
||||
{
|
||||
ver = pkg.getImplementationVersion();
|
||||
if (tag == null)
|
||||
{
|
||||
tag = "jetty-" + ver;
|
||||
}
|
||||
}
|
||||
ver = ManifestUtils.getManifest(StartArgs.class)
|
||||
.map(Manifest::getMainAttributes)
|
||||
.filter(attributes -> "Eclipse.org - Jetty".equals(attributes.getValue("Implementation-Vendor")))
|
||||
.map(attributes -> attributes.getValue("Implementation-Version"))
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
// Use jetty-version.properties values
|
||||
|
@ -82,9 +85,9 @@ public class StartArgs
|
|||
props.load(in);
|
||||
ver = props.getProperty("jetty.version");
|
||||
}
|
||||
catch (IOException ignore)
|
||||
catch (IOException x)
|
||||
{
|
||||
StartLog.debug(ignore);
|
||||
StartLog.debug(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,23 +97,25 @@ public class StartArgs
|
|||
{
|
||||
ver = "0.0";
|
||||
if (tag == null)
|
||||
{
|
||||
tag = "master";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tag == null)
|
||||
tag = "jetty-" + ver;
|
||||
}
|
||||
|
||||
// Set Tag Defaults
|
||||
if (tag == null || tag.contains("-SNAPSHOT"))
|
||||
{
|
||||
if (tag.contains("-SNAPSHOT"))
|
||||
tag = "master";
|
||||
}
|
||||
|
||||
VERSION = ver;
|
||||
System.setProperty("jetty.version",VERSION);
|
||||
System.setProperty("jetty.tag.version",tag);
|
||||
System.setProperty("jetty.version", VERSION);
|
||||
System.setProperty("jetty.tag.version", tag);
|
||||
}
|
||||
|
||||
private static final String SERVER_MAIN = "org.eclipse.jetty.xml.XmlConfiguration";
|
||||
private static final String MAIN_CLASS = "org.eclipse.jetty.xml.XmlConfiguration";
|
||||
private static final String MODULE_MAIN_CLASS = "org.eclipse.jetty.xml/org.eclipse.jetty.xml.XmlConfiguration";
|
||||
|
||||
private final BaseHome baseHome;
|
||||
|
||||
|
@ -132,6 +137,13 @@ public class StartArgs
|
|||
/** List of all active [xml] sections from enabled modules */
|
||||
private List<Path> xmls = new ArrayList<>();
|
||||
|
||||
/** List of all active [jpms] sections for enabled modules */
|
||||
private Set<String> jmodAdds = new LinkedHashSet<>();
|
||||
private Map<String, Set<String>> jmodPatch = new LinkedHashMap<>();
|
||||
private Map<String, Set<String>> jmodOpens = new LinkedHashMap<>();
|
||||
private Map<String, Set<String>> jmodExports = new LinkedHashMap<>();
|
||||
private Map<String, Set<String>> jmodReads = new LinkedHashMap<>();
|
||||
|
||||
/** JVM arguments, found via command line and in all active [exec] sections from enabled modules */
|
||||
private List<String> jvmArgs = new ArrayList<>();
|
||||
|
||||
|
@ -174,6 +186,7 @@ public class StartArgs
|
|||
private boolean listConfig = false;
|
||||
private boolean version = false;
|
||||
private boolean dryRun = false;
|
||||
private boolean jpms = false;
|
||||
private boolean createStartd = false;
|
||||
private boolean updateIni = false;
|
||||
private String mavenBaseUri;
|
||||
|
@ -403,8 +416,7 @@ public class StartArgs
|
|||
return;
|
||||
}
|
||||
|
||||
List<String> sortedKeys = new ArrayList<>();
|
||||
sortedKeys.addAll(systemPropertySource.keySet());
|
||||
List<String> sortedKeys = new ArrayList<>(systemPropertySource.keySet());
|
||||
Collections.sort(sortedKeys);
|
||||
|
||||
for (String key : sortedKeys)
|
||||
|
@ -446,11 +458,8 @@ public class StartArgs
|
|||
|
||||
/**
|
||||
* Expand any command line added {@code --lib} lib references.
|
||||
*
|
||||
* @throws IOException
|
||||
* if unable to expand the libraries
|
||||
*/
|
||||
public void expandSystemProperties() throws IOException
|
||||
public void expandSystemProperties()
|
||||
{
|
||||
StartLog.debug("Expanding System Properties");
|
||||
|
||||
|
@ -467,7 +476,7 @@ public class StartArgs
|
|||
}
|
||||
|
||||
/**
|
||||
* Expand any command line added <code>--lib</code> lib references.
|
||||
* Expand any command line added {@code --lib} lib references.
|
||||
*
|
||||
* @throws IOException
|
||||
* if unable to expand the libraries
|
||||
|
@ -541,6 +550,70 @@ public class StartArgs
|
|||
}
|
||||
}
|
||||
|
||||
void expandJPMS(List<Module> activeModules) throws IOException
|
||||
{
|
||||
for (Module module : activeModules)
|
||||
{
|
||||
for (String line : module.getJPMS())
|
||||
{
|
||||
line = properties.expand(line);
|
||||
String directive;
|
||||
if (line.startsWith(directive = "add-modules:"))
|
||||
{
|
||||
String[] names = line.substring(directive.length()).split(",");
|
||||
Arrays.stream(names).map(String::trim).collect(Collectors.toCollection(() -> jmodAdds));
|
||||
}
|
||||
else if (line.startsWith(directive = "patch-module:"))
|
||||
{
|
||||
parseJPMSKeyValue(module, line, directive, true, jmodPatch);
|
||||
}
|
||||
else if (line.startsWith(directive = "add-opens:"))
|
||||
{
|
||||
parseJPMSKeyValue(module, line, directive, false, jmodOpens);
|
||||
}
|
||||
else if (line.startsWith(directive = "add-exports:"))
|
||||
{
|
||||
parseJPMSKeyValue(module, line, directive, false, jmodExports);
|
||||
}
|
||||
else if (line.startsWith(directive = "add-reads:"))
|
||||
{
|
||||
parseJPMSKeyValue(module, line, directive, false, jmodReads);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid [jpms] directive " + directive + " in module " + module.getName() + ": " + line);
|
||||
}
|
||||
}
|
||||
}
|
||||
StartLog.debug("Expanded JPMS directives:%nadd-modules: %s%npatch-modules: %s%nadd-opens: %s%nadd-exports: %s%nadd-reads: %s",
|
||||
jmodAdds, jmodPatch, jmodOpens, jmodExports, jmodReads);
|
||||
}
|
||||
|
||||
private void parseJPMSKeyValue(Module module, String line, String directive, boolean valueIsFile, Map<String, Set<String>> output) throws IOException
|
||||
{
|
||||
String valueString = line.substring(directive.length());
|
||||
int equals = valueString.indexOf('=');
|
||||
if (equals <= 0)
|
||||
throw new IllegalArgumentException("Invalid [jpms] directive " + directive + " in module " + module.getName() + ": " + line);
|
||||
String delimiter = valueIsFile ? File.pathSeparator : ",";
|
||||
String key = valueString.substring(0, equals).trim();
|
||||
String[] values = valueString.substring(equals + 1).split(delimiter);
|
||||
Set<String> result = output.computeIfAbsent(key, k -> new LinkedHashSet<>());
|
||||
for (String value : values)
|
||||
{
|
||||
value = value.trim();
|
||||
if (valueIsFile)
|
||||
{
|
||||
List<Path> paths = baseHome.getPaths(value);
|
||||
paths.stream().map(Path::toAbsolutePath).map(Path::toString).collect(Collectors.toCollection(() -> result));
|
||||
}
|
||||
else
|
||||
{
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getStartModules()
|
||||
{
|
||||
return startModules;
|
||||
|
@ -588,7 +661,7 @@ public class StartArgs
|
|||
cmd.addRawArg("-Djetty.home=" + baseHome.getHome());
|
||||
cmd.addRawArg("-Djetty.base=" + baseHome.getBase());
|
||||
|
||||
for (String x : jvmArgs)
|
||||
for (String x : getJvmArgs())
|
||||
{
|
||||
if (x.startsWith("-D"))
|
||||
{
|
||||
|
@ -612,9 +685,64 @@ public class StartArgs
|
|||
cmd.addEqualsArg("-D" + propKey,value);
|
||||
}
|
||||
|
||||
cmd.addRawArg("-cp");
|
||||
cmd.addRawArg(classpath.toString());
|
||||
cmd.addRawArg(getMainClassname());
|
||||
if (isJPMS())
|
||||
{
|
||||
Map<Boolean, List<File>> dirsAndFiles = StreamSupport.stream(classpath.spliterator(), false)
|
||||
.collect(Collectors.groupingBy(File::isDirectory));
|
||||
List<File> files = dirsAndFiles.get(false);
|
||||
if (files != null && !files.isEmpty())
|
||||
{
|
||||
cmd.addRawArg("--module-path");
|
||||
String modules = files.stream()
|
||||
.map(File::getAbsolutePath)
|
||||
.collect(Collectors.joining(File.pathSeparator));
|
||||
cmd.addRawArg(modules);
|
||||
}
|
||||
List<File> dirs = dirsAndFiles.get(true);
|
||||
if (dirs != null && !dirs.isEmpty())
|
||||
{
|
||||
cmd.addRawArg("--class-path");
|
||||
String directories = dirs.stream()
|
||||
.map(File::getAbsolutePath)
|
||||
.collect(Collectors.joining(File.pathSeparator));
|
||||
cmd.addRawArg(directories);
|
||||
}
|
||||
|
||||
if (!jmodAdds.isEmpty())
|
||||
{
|
||||
cmd.addRawArg("--add-modules");
|
||||
cmd.addRawArg(String.join(",", jmodAdds));
|
||||
}
|
||||
for (Map.Entry<String, Set<String>> entry : jmodPatch.entrySet())
|
||||
{
|
||||
cmd.addRawArg("--patch-module");
|
||||
cmd.addRawArg(entry.getKey() + "=" + String.join(File.pathSeparator, entry.getValue()));
|
||||
}
|
||||
for (Map.Entry<String, Set<String>> entry : jmodOpens.entrySet())
|
||||
{
|
||||
cmd.addRawArg("--add-opens");
|
||||
cmd.addRawArg(entry.getKey() + "=" + String.join(",", entry.getValue()));
|
||||
}
|
||||
for (Map.Entry<String, Set<String>> entry : jmodExports.entrySet())
|
||||
{
|
||||
cmd.addRawArg("--add-exports");
|
||||
cmd.addRawArg(entry.getKey() + "=" + String.join(",", entry.getValue()));
|
||||
}
|
||||
for (Map.Entry<String, Set<String>> entry : jmodReads.entrySet())
|
||||
{
|
||||
cmd.addRawArg("--add-reads");
|
||||
cmd.addRawArg(entry.getKey() + "=" + String.join(",", entry.getValue()));
|
||||
}
|
||||
|
||||
cmd.addRawArg("--module");
|
||||
cmd.addRawArg(getMainClassname());
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.addRawArg("-cp");
|
||||
cmd.addRawArg(classpath.toString());
|
||||
cmd.addRawArg(getMainClassname());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -657,8 +785,8 @@ public class StartArgs
|
|||
|
||||
public String getMainClassname()
|
||||
{
|
||||
String mainclass = System.getProperty("jetty.server",SERVER_MAIN);
|
||||
return System.getProperty("main.class",mainclass);
|
||||
String mainClass = System.getProperty("jetty.server", isJPMS() ? MODULE_MAIN_CLASS : MAIN_CLASS);
|
||||
return System.getProperty("main.class", mainClass);
|
||||
}
|
||||
|
||||
public String getMavenLocalRepoDir()
|
||||
|
@ -765,6 +893,11 @@ public class StartArgs
|
|||
return createFiles;
|
||||
}
|
||||
|
||||
public boolean isJPMS()
|
||||
{
|
||||
return jpms;
|
||||
}
|
||||
|
||||
public boolean isDryRun()
|
||||
{
|
||||
return dryRun;
|
||||
|
@ -782,7 +915,7 @@ public class StartArgs
|
|||
|
||||
public boolean isNormalMainClass()
|
||||
{
|
||||
return SERVER_MAIN.equals(getMainClassname());
|
||||
return MAIN_CLASS.equals(getMainClassname());
|
||||
}
|
||||
|
||||
public boolean isHelp()
|
||||
|
@ -974,6 +1107,14 @@ public class StartArgs
|
|||
return;
|
||||
}
|
||||
|
||||
if ("--jpms".equals(arg))
|
||||
{
|
||||
jpms = true;
|
||||
// Need to fork because we cannot use JDK 9 Module APIs.
|
||||
exec = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if ("--dry-run".equals(arg) || "--exec-print".equals(arg))
|
||||
{
|
||||
dryRun = true;
|
||||
|
@ -1084,10 +1225,7 @@ public class StartArgs
|
|||
if (arg.startsWith("--skip-file-validation="))
|
||||
{
|
||||
List<String> moduleNames = Props.getValues(arg);
|
||||
for (String moduleName : moduleNames)
|
||||
{
|
||||
skipFileValidationModules.add(moduleName);
|
||||
}
|
||||
skipFileValidationModules.addAll(moduleNames);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1231,12 +1369,7 @@ public class StartArgs
|
|||
for (String moduleName : moduleNames)
|
||||
{
|
||||
modules.add(moduleName);
|
||||
List<String> list = sources.get(moduleName);
|
||||
if (list == null)
|
||||
{
|
||||
list = new ArrayList<>();
|
||||
sources.put(moduleName,list);
|
||||
}
|
||||
List<String> list = sources.computeIfAbsent(moduleName, k -> new ArrayList<>());
|
||||
list.add(source);
|
||||
}
|
||||
}
|
||||
|
@ -1327,17 +1460,7 @@ public class StartArgs
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("StartArgs [enabledModules=");
|
||||
builder.append(modules);
|
||||
builder.append(", xmlRefs=");
|
||||
builder.append(xmlRefs);
|
||||
builder.append(", properties=");
|
||||
builder.append(properties);
|
||||
builder.append(", jvmArgs=");
|
||||
builder.append(jvmArgs);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
return String.format("%s[enabledModules=%s, xmlRefs=%s, properties=%s, jvmArgs=%s]",
|
||||
getClass().getSimpleName(), modules, xmlRefs, properties, jvmArgs);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2018 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.security.CodeSource;
|
||||
import java.util.Optional;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
public class ManifestUtils
|
||||
{
|
||||
private ManifestUtils()
|
||||
{
|
||||
}
|
||||
|
||||
public static Optional<Manifest> getManifest(Class<?> klass)
|
||||
{
|
||||
try
|
||||
{
|
||||
CodeSource codeSource = klass.getProtectionDomain().getCodeSource();
|
||||
if (codeSource != null)
|
||||
{
|
||||
URL location = codeSource.getLocation();
|
||||
if (location != null)
|
||||
{
|
||||
try (JarFile jarFile = new JarFile(new File(location.toURI())))
|
||||
{
|
||||
return Optional.of(jarFile.getManifest());
|
||||
}
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Attempts to return the version of the jar/module for the given class.</p>
|
||||
* <p>First, retrieves the {@code Implementation-Version} main attribute of the manifest;
|
||||
* if that is missing, retrieves the JPMS module version (via reflection);
|
||||
* if that is missing, returns an empty Optional.</p>
|
||||
*
|
||||
* @param klass the class of the jar/module to retrieve the version
|
||||
* @return the jar/module version, or an empty Optional
|
||||
*/
|
||||
public static Optional<String> getVersion(Class<?> klass)
|
||||
{
|
||||
Optional<String> version = getManifest(klass).map(Manifest::getMainAttributes)
|
||||
.map(attributes -> attributes.getValue("Implementation-Version"));
|
||||
if (version.isPresent())
|
||||
return version;
|
||||
|
||||
try
|
||||
{
|
||||
Object module = klass.getClass().getMethod("getModule").invoke(klass);
|
||||
Object descriptor = module.getClass().getMethod("getDescriptor").invoke(module);
|
||||
return (Optional<String>)descriptor.getClass().getMethod("rawVersion").invoke(descriptor);
|
||||
}
|
||||
catch (Throwable x)
|
||||
{
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,3 +30,6 @@ lib/jetty-webapp-${jetty.version}.jar
|
|||
##
|
||||
#jetty.webapp.addSystemClasses+=,org.example.
|
||||
#jetty.webapp.addServerClasses+=,org.example.
|
||||
|
||||
[jpms]
|
||||
add-modules:java.instrument
|
||||
|
|
|
@ -83,8 +83,7 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
|||
public static final String CONTAINER_JAR_PATTERN = "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern";
|
||||
public static final String WEBINF_JAR_PATTERN = "org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern";
|
||||
public static final List<String> __allScanTypes = (List<String>) Arrays.asList(METAINF_TLDS, METAINF_RESOURCES, METAINF_FRAGMENTS);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ContainerPathNameMatcher
|
||||
*
|
||||
|
@ -105,20 +104,13 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
|||
_pattern = pattern;
|
||||
}
|
||||
|
||||
|
||||
public void match (List<URI> uris)
|
||||
throws Exception
|
||||
public void match (List<URI> uris) throws Exception
|
||||
{
|
||||
if (uris == null)
|
||||
return;
|
||||
match(_pattern, uris.toArray(new URI[uris.size()]), false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.util.PatternMatcher#matched(java.net.URI)
|
||||
*/
|
||||
@Override
|
||||
public void matched(URI uri) throws Exception
|
||||
{
|
||||
|
@ -126,7 +118,6 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* WebAppPathNameMatcher
|
||||
*
|
||||
|
@ -153,15 +144,11 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
|||
match(_pattern, uris.toArray(new URI[uris.size()]), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.jetty.util.PatternMatcher#matched(java.net.URI)
|
||||
*/
|
||||
@Override
|
||||
public void matched(URI uri) throws Exception
|
||||
{
|
||||
_context.getMetaData().addWebInfJar(Resource.newResource(uri));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,15 +157,11 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
|||
*/
|
||||
public static final String RESOURCE_DIRS = "org.eclipse.jetty.resources";
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
public MetaInfConfiguration()
|
||||
{
|
||||
addDependencies(WebXmlConfiguration.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
@Override
|
||||
public void preConfigure(final WebAppContext context) throws Exception
|
||||
{
|
||||
|
@ -194,8 +177,6 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
|||
scanJars(context);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Find jars and directories that are on the container's classpath
|
||||
* and apply an optional filter. The filter is a pattern applied to the
|
||||
|
@ -212,78 +193,77 @@ public class MetaInfConfiguration extends AbstractConfiguration
|
|||
* @param context the WebAppContext being deployed
|
||||
* @throws Exception
|
||||
*/
|
||||
public void findAndFilterContainerPaths (final WebAppContext context)
|
||||
throws Exception
|
||||
public void findAndFilterContainerPaths(final WebAppContext context) throws Exception
|
||||
{
|
||||
//assume the target jvm is the same as that running
|
||||
int targetPlatform = JavaVersion.VERSION.getPlatform();
|
||||
int currentPlatform = JavaVersion.VERSION.getPlatform();
|
||||
//allow user to specify target jvm different to current runtime
|
||||
int targetPlatform = currentPlatform;
|
||||
Object target = context.getAttribute(JavaVersion.JAVA_TARGET_PLATFORM);
|
||||
if (target!=null)
|
||||
targetPlatform = Integer.valueOf(target.toString()).intValue();
|
||||
targetPlatform = Integer.parseInt(target.toString());
|
||||
|
||||
//Apply an initial name filter to the jars to select which will be eventually
|
||||
//scanned for META-INF info and annotations. The filter is based on inclusion patterns.
|
||||
ContainerPathNameMatcher containerPathNameMatcher = new ContainerPathNameMatcher(context, (String)context.getAttribute(CONTAINER_JAR_PATTERN));
|
||||
List<URI> containerUris = getAllContainerJars(context);
|
||||
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Matching container urls {}", containerUris);
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Matching container urls {}", containerUris);
|
||||
containerPathNameMatcher.match(containerUris);
|
||||
|
||||
//if running on jvm 9 or above, we we won't be able to look at the application classloader
|
||||
//to extract urls, so we need to examine the classpath instead.
|
||||
if (JavaVersion.VERSION.getPlatform() >= 9)
|
||||
// When running on jvm 9 or above, we we won't be able to look at the application
|
||||
// classloader to extract urls, so we need to examine the classpath instead.
|
||||
String tmp = System.getProperty("java.class.path");
|
||||
if (tmp != null)
|
||||
{
|
||||
String tmp = System.getProperty("java.class.path");
|
||||
if (tmp != null)
|
||||
List<URI> cpUris = new ArrayList<>();
|
||||
String[] entries = tmp.split(File.pathSeparator);
|
||||
for (String entry:entries)
|
||||
{
|
||||
List<URI> cpUris = new ArrayList<>();
|
||||
String[] entries = tmp.split(File.pathSeparator);
|
||||
for (String entry:entries)
|
||||
{
|
||||
File f = new File(entry);
|
||||
cpUris.add(f.toURI());
|
||||
}
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Matching java.class.path {}", cpUris);
|
||||
containerPathNameMatcher.match(cpUris);
|
||||
File f = new File(entry);
|
||||
cpUris.add(f.toURI());
|
||||
}
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Matching java.class.path {}", cpUris);
|
||||
containerPathNameMatcher.match(cpUris);
|
||||
}
|
||||
|
||||
//if we're targetting jdk 9 or above, we also need to examine the
|
||||
//module path
|
||||
if (targetPlatform >= 9)
|
||||
|
||||
// We also need to examine the module path.
|
||||
// TODO need to consider the jdk.module.upgrade.path - how to resolve
|
||||
// which modules will be actually used. If its possible, it can
|
||||
// only be attempted in jetty-10 with jdk-9 specific apis.
|
||||
tmp = System.getProperty("jdk.module.path");
|
||||
if (tmp != null)
|
||||
{
|
||||
//TODO need to consider the jdk.module.upgrade.path - how to resolve
|
||||
//which modules will be actually used. If its possible, it can
|
||||
//only be attempted in jetty-10 with jdk-9 specific apis.
|
||||
String tmp = System.getProperty("jdk.module.path");
|
||||
if (tmp != null)
|
||||
List<URI> moduleUris = new ArrayList<>();
|
||||
String[] entries = tmp.split(File.pathSeparator);
|
||||
for (String entry : entries)
|
||||
{
|
||||
List<URI> moduleUris = new ArrayList<>();
|
||||
String[] entries = tmp.split(File.pathSeparator);
|
||||
for (String entry:entries)
|
||||
File file = new File(entry);
|
||||
if (file.isDirectory())
|
||||
{
|
||||
File dir = new File(entry);
|
||||
File[] files = dir.listFiles();
|
||||
File[] files = file.listFiles();
|
||||
if (files != null)
|
||||
{
|
||||
for (File f:files)
|
||||
{
|
||||
for (File f : files)
|
||||
moduleUris.add(f.toURI());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Matching jdk.module.path {}", moduleUris);
|
||||
containerPathNameMatcher.match(moduleUris);
|
||||
else
|
||||
{
|
||||
moduleUris.add(file.toURI());
|
||||
}
|
||||
}
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Matching jdk.module.path {}", moduleUris);
|
||||
containerPathNameMatcher.match(moduleUris);
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled()) LOG.debug("Container paths selected:{}", context.getMetaData().getContainerResources());
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Container paths selected:{}", context.getMetaData().getContainerResources());
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/**
|
||||
* Finds the jars that are either physically or virtually in
|
||||
* WEB-INF/lib, and applies an optional filter to their full
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
# Setup default logging implementation for during testing
|
||||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||
org.eclipse.jetty.LEVEL=INFO
|
||||
# org.eclipse.jetty.LEVEL=DEBUG
|
||||
# org.eclipse.jetty.webapp.LEVEL=DEBUG
|
||||
# org.eclipse.jetty.util.LEVEL=DEBUG
|
||||
# org.eclipse.jetty.util.PathWatcher.Noisy.LEVEL=OFF
|
||||
|
|
14
pom.xml
14
pom.xml
|
@ -53,6 +53,7 @@
|
|||
<unix.socket.tmp></unix.socket.tmp>
|
||||
<!-- enable or not TestTracker junit5 extension i.e log message when test method is starting -->
|
||||
<jetty.testtracker.log>false</jetty.testtracker.log>
|
||||
<jpms-module-name>${bundle-symbolic-name}</jpms-module-name>
|
||||
|
||||
<!-- some maven plugins versions -->
|
||||
<maven.surefire.version>2.22.0</maven.surefire.version>
|
||||
|
@ -484,6 +485,7 @@
|
|||
<archive>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
<manifestEntries>
|
||||
<Automatic-Module-Name>${jpms-module-name}</Automatic-Module-Name>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
<Implementation-Vendor>Eclipse.org - Jetty</Implementation-Vendor>
|
||||
<url>${jetty.url}</url>
|
||||
|
@ -949,6 +951,16 @@
|
|||
<artifactId>asm-commons</artifactId>
|
||||
<version>${asm.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-tree</artifactId>
|
||||
<version>${asm.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-analysis</artifactId>
|
||||
<version>${asm.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||
<artifactId>javax.security.auth.message</artifactId>
|
||||
|
@ -991,7 +1003,7 @@
|
|||
<dependency>
|
||||
<groupId>javax.transaction</groupId>
|
||||
<artifactId>javax.transaction-api</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- maven deps -->
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
<dependency>
|
||||
<groupId>javax.transaction</groupId>
|
||||
<artifactId>javax.transaction-api</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.tests</groupId>
|
||||
|
|
Loading…
Reference in New Issue