Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #6021 - PoC for resolvePath within XmlConfiguration #6022

Merged
merged 10 commits into from
Mar 3, 2021

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Mar 2, 2021

This is a proposal / draft PR for simplifying the whole management of paths within our XmlConfiguration.

Signed-off-by: Joakim Erdfelt joakim.erdfelt@gmail.com

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime
Copy link
Contributor Author

joakime commented Mar 2, 2021

This could easily be done with a new element, but after discussion with @sbordet i felt doing via a static method was the minimal to prove the concept out.

This draft PoC looks like ...

<Set name="keystorePath">
  <Call name="resolvePath" class="org.eclipse.jetty.xml.XmlConfiguration">
    <Arg><Property name="jetty.base"/></Arg>
    <Arg><Property name="jetty.sslContext.keyStorePath" default="etc/keystore.p12"/></Arg>
  </Call>
</Set>

The XML element version could look like ...

<Set name="keystorePath">
  <Path base="${jetty.base}"><Property name="jetty.sslContext.keyStorePath" default="etc/keystore.p12"/></Path>
</Set>

Where the attribute base is optional and defaults to jetty.base internally (Note that jetty.base is always guaranteed to be defined when using the XmlConfiguration anyway)

@joakime
Copy link
Contributor Author

joakime commented Mar 2, 2021

We could have used the Paths.get(jetty.base).resolve(dest).toString() in the XML language, but there is a need to have a Path that can be unset/empty/null in configuration, which our current XML doesn't support really well, and the direct usage of Path.resolve doesn't address either.

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime
Copy link
Contributor Author

joakime commented Mar 2, 2021

This proposal works for absolute paths, relative paths, linux, windows, OSX, machine shares (aka \\machine\share\path), etc.
Pretty much anything that can be represented by a Java Path object and is supported by Java's FileSystem implementation.

@joakime joakime linked an issue Mar 2, 2021 that may be closed by this pull request
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime marked this pull request as ready for review March 3, 2021 14:29
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime requested review from sbordet and gregw March 3, 2021 14:44
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime merged commit 1cb0a49 into jetty-10.0.x Mar 3, 2021
@joakime joakime deleted the jetty-10.0.x-better-xml-path-resolution branch March 3, 2021 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Standardize Path resolution in XmlConfiguration
3 participants