You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by gg...@apache.org on 2025/06/06 19:21:57 UTC
(juneau) 02/02: org.apache.juneau.microservice.Microservice.Builder.manifest(Object) now handles java.nio.file.Path
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
commit 9debdd613b9121803fabc67ed6a42dd3815ff139
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Jun 6 15:21:49 2025 -0400
org.apache.juneau.microservice.Microservice.Builder.manifest(Object) now
handles java.nio.file.Path
---
RELEASE-NOTES.txt | 3 +-
.../java/org/apache/juneau/utils/ManifestFile.java | 67 +++++++++++++++-------
.../apache/juneau/microservice/Microservice.java | 46 ++++++++-------
3 files changed, 72 insertions(+), 44 deletions(-)
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 3e7618739..7ebcd2707 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -16,6 +16,7 @@ Release Notes - Juneau - Version 9.1.0
** Changes
+ * Bump Java platform requirement from Java 11 to 17.
* [JUNEAU-253] - Bump springboot.version from 3.2.2 to 3.4.4.
* [JUNEAU-254] - Bump jetty.version from 11.0.16 to 11.0.21, #207, #208.
* [JUNEAU-255] - Bump org.apache:apache from 29 to 31.
@@ -26,7 +27,6 @@ Release Notes - Juneau - Version 9.1.0
* [JUNEAU-260] - Bump maven-surefire-report-plugin from 2.22.2 to 3.1.2.
* [JUNEAU-261] - Bump org.apache.derby:derby from 10.16.1.1 to 10.17.1.0 #118.
* [JUNEAU-263] - Remove Google Analytics from the Juneau Website.
- * Bump Java platform requirement from Java 11 to 17.
* [JUNEAU-262] Port Jetty from 11.0.20 to 12.0.20 #148, #156, #160, #165, #169, #175, #183, #201.
* [JUNEAU-252] Bump org.eclipse.jgit:org.eclipse.jgit from 6.6.1.202309021850-r to 7.2.1.202505142326-r #112, #123, #137, #152, #166, #184, #191, #209.
* [JUNEAU-253] Bump springboot.version from 3.1.3 to 3.4.5 #136, #138, #142, #146, #153, #158, #162, #167, #172, #177, #186, #187, #188, #193, #198.
@@ -51,6 +51,7 @@ Release Notes - Juneau - Version 9.1.0
* org.apache.juneau.microservice.jetty.JettyMicroservice.Builder.jettyXml(Object, boolean) now handles java.nio.file.Path.
* Add org.apache.juneau.common.internal.PathReaderBuilder
* Add org.apache.juneau.common.internal.IOUtils.read(Path)
+ * org.apache.juneau.microservice.Microservice.Builder.manifest(Object) now handles java.nio.file.Path.
Release Notes - Juneau - Version 9.0.1
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ManifestFile.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ManifestFile.java
index bbedf0ca7..c38c903b9 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ManifestFile.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ManifestFile.java
@@ -12,14 +12,23 @@
// ***************************************************************************************************************************
package org.apache.juneau.utils;
-import static org.apache.juneau.common.internal.IOUtils.*;
+import static org.apache.juneau.common.internal.IOUtils.UTF8;
+import static org.apache.juneau.common.internal.IOUtils.read;
-import java.io.*;
-import java.net.*;
-import java.util.jar.*;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.jar.Manifest;
-import org.apache.juneau.collections.*;
-import org.apache.juneau.common.internal.*;
+import org.apache.juneau.collections.JsonMap;
+import org.apache.juneau.common.internal.ThrowableUtils;
/**
* Utility class for working with Jar manifest files.
@@ -37,21 +46,37 @@ public class ManifestFile extends JsonMap {
private static final long serialVersionUID = 1L;
- /**
- * Create an instance of this class from a manifest file on the file system.
- *
- * @param f The manifest file.
- * @throws IOException If a problem occurred while trying to read the manifest file.
- */
- public ManifestFile(File f) throws IOException {
- Manifest mf = new Manifest();
- try (FileInputStream fis = new FileInputStream(f)) {
- mf.read(fis);
- load(mf);
- } catch (IOException e) {
- throw new IOException("Problem detected in MANIFEST.MF. Contents below:\n"+read(f), e);
- }
- }
+ /**
+ * Create an instance of this class from a manifest file on the file system.
+ *
+ * @param f The manifest file.
+ * @throws IOException If a problem occurred while trying to read the manifest file.
+ */
+ public ManifestFile(File f) throws IOException {
+ Manifest mf = new Manifest();
+ try (FileInputStream fis = new FileInputStream(f)) {
+ mf.read(fis);
+ load(mf);
+ } catch (IOException e) {
+ throw new IOException("Problem detected in MANIFEST.MF. Contents below:\n"+read(f), e);
+ }
+ }
+
+ /**
+ * Create an instance of this class from a manifest path on the file system.
+ *
+ * @param path The manifest path.
+ * @throws IOException If a problem occurred while trying to read the manifest path.
+ */
+ public ManifestFile(Path path) throws IOException {
+ Manifest mf = new Manifest();
+ try (InputStream fis = Files.newInputStream(path)) {
+ mf.read(fis);
+ load(mf);
+ } catch (IOException e) {
+ throw new IOException("Problem detected in MANIFEST.MF. Contents below:\n"+read(path), e);
+ }
+ }
/**
* Create an instance of this class from a {@link Manifest} object.
diff --git a/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/Microservice.java b/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/Microservice.java
index 72c2d0d8c..2277ade12 100755
--- a/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/Microservice.java
+++ b/juneau-microservice/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/Microservice.java
@@ -263,28 +263,30 @@ public class Microservice implements ConfigEventListener {
* @return This object.
* @throws IOException Thrown by underlying stream.
*/
- public Builder manifest(Object value) throws IOException {
- if (value == null)
- this.manifest = null;
- else if (value instanceof ManifestFile)
- this.manifest = (ManifestFile)value;
- else if (value instanceof Manifest)
- this.manifest = new ManifestFile((Manifest)value);
- else if (value instanceof Reader)
- this.manifest = new ManifestFile((Reader)value);
- else if (value instanceof InputStream)
- this.manifest = new ManifestFile((InputStream)value);
- else if (value instanceof File)
- this.manifest = new ManifestFile((File)value);
- else if (value instanceof String)
- this.manifest = new ManifestFile(resolveFile((String)value));
- else if (value instanceof Class)
- this.manifest = new ManifestFile((Class<?>)value);
- else
- throw new BasicRuntimeException("Invalid type passed to Builder.manifest(Object). Type=[{0}]", className(value));
-
- return this;
- }
+ public Builder manifest(Object value) throws IOException {
+ if (value == null)
+ this.manifest = null;
+ else if (value instanceof ManifestFile manifestFile)
+ this.manifest = manifestFile;
+ else if (value instanceof Manifest manifest)
+ this.manifest = new ManifestFile(manifest);
+ else if (value instanceof Reader reader)
+ this.manifest = new ManifestFile(reader);
+ else if (value instanceof InputStream inputStream)
+ this.manifest = new ManifestFile(inputStream);
+ else if (value instanceof File file)
+ this.manifest = new ManifestFile(file);
+ else if (value instanceof Path path)
+ this.manifest = new ManifestFile(path);
+ else if (value instanceof String string)
+ this.manifest = new ManifestFile(resolveFile(string));
+ else if (value instanceof Class clazz)
+ this.manifest = new ManifestFile(clazz);
+ else
+ throw new BasicRuntimeException("Invalid type passed to Builder.manifest(Object). Type=[{0}]", className(value));
+
+ return this;
+ }
/**
* Specifies the logger used by the microservice and returned by the {@link Microservice#getLogger()} method.