* Fixed resource leak in `App` when reading the web application properties file.
* Small updates to the deploy documentation. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
c8fd1a198a
commit
bd80297f7e
|
@ -22,11 +22,11 @@ The available environments are:
|
|||
* Java EE 8 -- Supports Servlet 4.0 (and associated specifications) in the `+javax.*+` packages.
|
||||
* Jakarta EE 9 -- Supports Servlet 5.0 (and associated specifications) in the `+jakarta.*+` packages.
|
||||
* Jakarta EE 10 -- Supports Servlet 6.0 (and associated specifications) in the `+jakarta.*+` packages.
|
||||
* Jetty core -- Supports web applications written against the Jetty `Handler` APIs, without any Servlet dependencies.
|
||||
* Jetty Core -- Supports web applications written against the Jetty `Handler` APIs, without any Servlet dependencies.
|
||||
|
||||
This means that you can simultaneously deploy an old Java EE 8 web application, say `old-ee8.war`, alongside a new Jakarta {ee-current-caps} web application, say `new-{ee-current}.war`, alongside a web application that only uses the Jetty `Handler` APIs, say `app-jetty.xml`.
|
||||
|
||||
The customization is performed by processing xref:og-deploy-jetty[Jetty context XML files].
|
||||
The customization of the deployment (for example, web application context path, etc.) is performed by processing xref:og-deploy-jetty[Jetty context XML files].
|
||||
|
||||
The `deploy` module contains the `DeploymentManager` component that scans the `$JETTY_BASE/webapps` directory for changes, following the deployment rules described in xref:og-deploy-rules[this section].
|
||||
|
||||
|
@ -35,7 +35,7 @@ For each specific environment there is a specific deploy module that you must en
|
|||
* For Java EE 8, xref:og-module-eeN-deploy[`ee8-deploy`]
|
||||
* For Java EE 9, xref:og-module-eeN-deploy[`ee9-deploy`]
|
||||
* For Java {ee-current-caps}, xref:og-module-eeN-deploy[`{ee-current}-deploy`]
|
||||
* For Jetty core, xref:og-module-core-deploy[`core-deploy`]
|
||||
* For Jetty Core, xref:og-module-core-deploy[`core-deploy`]
|
||||
|
||||
Each of these modules provide the environment specific features, and depend on the `deploy` module that provides the scanning features.
|
||||
|
||||
|
|
|
@ -44,20 +44,33 @@ A web application is always deployed to a specific environment.
|
|||
|
||||
If you enabled only one specific deployer module, for example `{ee-current}-deploy`, then the web applications and the Jetty context XML files in `$JETTY_BASE/webapps` will be deployed to the `{ee-current}` environment.
|
||||
|
||||
You can enable multiple deployer modules if you need to deploy multiple web applications each to a specific environment.
|
||||
You can enable simultaneously multiple deployer modules if you need to deploy multiple web applications each to a specific environment.
|
||||
|
||||
For example, you have an `old-ee9.war` web application that you want to deploy to the Jakarta EE 9 environment, and a `new-{ee-current}.war` web application that you want to deploy to the Jakarta {ee-current-caps} environment.
|
||||
First, you must enable both the `ee9-deploy` and the `{ee-current}-deploy` modules.
|
||||
Then, you add a `+*.properties+` file with the same name of the web application, in the example above `$JETTY_BASE/webapps/old-ee9.properties`, with the following content:
|
||||
|
||||
.old-ee9.properties
|
||||
[source,properties]
|
||||
====
|
||||
----
|
||||
environment=ee9
|
||||
----
|
||||
|
||||
In case of simultaneous multiple environments, it is good practice to always specify the `+*.properties+` file for your web applications.
|
||||
|
||||
[CAUTION]
|
||||
====
|
||||
If you do *not* specify the `+*.properties+` file for your web applications, then the deployer for the most recent EE version will be used.
|
||||
|
||||
You may also add a `+*.properties+` file for `new-{ee-current}.war`, but it is not necessary because the most recent environment is used by default.
|
||||
// TODO: verify the statement above. For an ee8 and an ee9 webapp, is it true that ee9 will be used by default (or ee10 will)?
|
||||
For example, if you have enabled the EE deployer Jetty module for all EE versions, and you deploy an EE 9 web application _without_ the `+*.properties+` file, then it will be deployed by the {ee-current-caps} deployer, with unspecified results.
|
||||
|
||||
This unspecified deployment may not work as the EE 9 web application may use APIs that have been removed in {ee-current-caps}, causing an error at runtime.
|
||||
====
|
||||
|
||||
// TODO: add section about the work directory from
|
||||
// old_docs/contexts/temporary-directories.adoc
|
||||
|
||||
// rules for temp dir
|
||||
// 1) add XML file and call setTempDirectory() on ContextHandler
|
||||
// 2) if not 1, then you can add-modules=work.mod
|
||||
// 3) if not 2, then you can specify java.io.tmpdir
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
package org.eclipse.jetty.deploy;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
|
@ -57,9 +57,12 @@ public class App
|
|||
Path properties = path.getParent().resolve(basename + ".properties");
|
||||
if (Files.exists(properties))
|
||||
{
|
||||
Properties p = new Properties();
|
||||
p.load(new FileInputStream(properties.toFile()));
|
||||
p.keySet().stream().map(Object::toString).forEach(k -> _properties.put(k, p.getProperty(k)));
|
||||
try (InputStream stream = Files.newInputStream(properties))
|
||||
{
|
||||
Properties p = new Properties();
|
||||
p.load(stream);
|
||||
p.stringPropertyNames().forEach(k -> _properties.put(k, p.getProperty(k)));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
Loading…
Reference in New Issue