Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
JDK 17 jdk.jpackage.jmod - JPackage Tool
JDK 17 jdk.jpackage.jmod is the JMOD file for JDK 17 JPackage tool,
which can be invoked by the "jpackage" command.
JDK 17 JPackage tool compiled class files are stored in \fyicenter\jdk-17.0.5\jmods\jdk.jpackage.jmod.
JDK 17 JPackage tool compiled class files are also linked and stored in the \fyicenter\jdk-17.0.5\lib\modules JImage file.
JDK 17 JPackage tool source code files are stored in \fyicenter\jdk-17.0.5\lib\src.zip\jdk.jpackage.
You can click and view the content of each source code file in the list below.
✍: FYIcenter
⏎ jdk/jpackage/internal/OverridableResource.java
/* * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package jdk.jpackage.internal; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; import static jdk.jpackage.internal.StandardBundlerParam.RESOURCE_DIR; import jdk.jpackage.internal.resources.ResourceLocator; /** * Resource file that may have the default value supplied by jpackage. It can be * overridden by a file from resource directory set with {@code --resource-dir} * jpackage parameter. * * Resource has default name and public name. Default name is the name of a file * in {@code jdk.jpackage.internal.resources} package that provides the default * value of the resource. * * Public name is a path relative to resource directory to a file with custom * value of the resource. * * Use #setPublicName to set the public name. * * If #setPublicName was not called, name of file passed in #saveToFile function * will be used as a public name. * * Use #setExternal to set arbitrary file as a source of resource. If non-null * value was passed in #setExternal call that value will be used as a path to file * to copy in the destination file passed in #saveToFile function call. */ final class OverridableResource { OverridableResource(String defaultName) { this.defaultName = defaultName; setSourceOrder(Source.values()); } OverridableResource setSubstitutionData(Map<String, String> v) { if (v != null) { // Disconnect `v` substitutionData = new HashMap<>(v); } else { substitutionData = null; } return this; } OverridableResource setCategory(String v) { category = v; return this; } OverridableResource setResourceDir(Path v) { resourceDir = v; return this; } OverridableResource setResourceDir(File v) { return setResourceDir(toPath(v)); } enum Source { External, ResourceDir, DefaultResource }; OverridableResource setSourceOrder(Source... v) { sources = Stream.of(v) .map(source -> Map.entry(source, getHandler(source))) .toList(); return this; } /** * Set name of file to look for in resource dir. * * @return this */ OverridableResource setPublicName(Path v) { publicName = v; return this; } OverridableResource setPublicName(String v) { return setPublicName(Path.of(v)); } /** * Set name of file to look for in resource dir to put in verbose log. * * @return this */ OverridableResource setLogPublicName(Path v) { logPublicName = v; return this; } OverridableResource setLogPublicName(String v) { return setLogPublicName(Path.of(v)); } OverridableResource setExternal(Path v) { externalPath = v; return this; } OverridableResource setExternal(File v) { return setExternal(toPath(v)); } Source saveToStream(OutputStream dest) throws IOException { if (dest == null) { return sendToConsumer(null); } return sendToConsumer(new ResourceConsumer() { @Override public Path publicName() { throw new UnsupportedOperationException(); } @Override public void consume(InputStream in) throws IOException { in.transferTo(dest); } }); } Source saveToFile(Path dest) throws IOException { if (dest == null) { return sendToConsumer(null); } return sendToConsumer(new ResourceConsumer() { @Override public Path publicName() { return dest.getFileName(); } @Override public void consume(InputStream in) throws IOException { Files.createDirectories(IOUtils.getParent(dest)); Files.copy(in, dest, StandardCopyOption.REPLACE_EXISTING); } }); } Source saveToFile(File dest) throws IOException { return saveToFile(toPath(dest)); } static InputStream readDefault(String resourceName) { return ResourceLocator.class.getResourceAsStream(resourceName); } static OverridableResource createResource(String defaultName, Map<String, ? super Object> params) { return new OverridableResource(defaultName).setResourceDir( RESOURCE_DIR.fetchFrom(params)); } private Source sendToConsumer(ResourceConsumer consumer) throws IOException { for (var source: sources) { if (source.getValue().apply(consumer)) { return source.getKey(); } } return null; } private String getPrintableCategory() { if (category != null) { return String.format("[%s]", category); } return ""; } private boolean useExternal(ResourceConsumer dest) throws IOException { boolean used = externalPath != null && Files.exists(externalPath); if (used && dest != null) { Log.verbose(MessageFormat.format(I18N.getString( "message.using-custom-resource-from-file"), getPrintableCategory(), externalPath.toAbsolutePath().normalize())); try (InputStream in = Files.newInputStream(externalPath)) { processResourceStream(in, dest); } } return used; } private boolean useResourceDir(ResourceConsumer dest) throws IOException { boolean used = false; if (dest == null && publicName == null) { throw new IllegalStateException(); } final Path resourceName = Optional.ofNullable(publicName).orElseGet( () -> dest.publicName()); if (resourceDir != null) { final Path customResource = resourceDir.resolve(resourceName); used = Files.exists(customResource); if (used && dest != null) { final Path logResourceName; if (logPublicName != null) { logResourceName = logPublicName.normalize(); } else { logResourceName = resourceName.normalize(); } Log.verbose(MessageFormat.format(I18N.getString( "message.using-custom-resource"), getPrintableCategory(), logResourceName)); try (InputStream in = Files.newInputStream(customResource)) { processResourceStream(in, dest); } } } return used; } private boolean useDefault(ResourceConsumer dest) throws IOException { boolean used = defaultName != null; if (used && dest != null) { final Path resourceName = Optional .ofNullable(logPublicName) .orElse(Optional .ofNullable(publicName) .orElseGet(() -> dest.publicName())); Log.verbose(MessageFormat.format( I18N.getString("message.using-default-resource"), defaultName, getPrintableCategory(), resourceName)); try (InputStream in = readDefault(defaultName)) { processResourceStream(in, dest); } } return used; } private static Stream<String> substitute(Stream<String> lines, Map<String, String> substitutionData) { // Order substitution data by the length of keys. // Longer keys go first. // This is needed to properly handle cases when one key is // a subtring of another and try the later first. var orderedEntries = substitutionData.entrySet().stream() .sorted(Map.Entry.<String, String>comparingByKey( Comparator.comparingInt(String::length)).reversed()) .toList(); return lines.map(line -> { String result = line; var workEntries = orderedEntries; var it = workEntries.listIterator(); while (it.hasNext()) { var entry = it.next(); String newResult = result.replace(entry.getKey(), Optional.ofNullable(entry.getValue()).orElse("")); if (!newResult.equals(result)) { // Substitution occured. // Remove the matching substitution key from the list and // go over the list of substitution entries again. if (workEntries == orderedEntries) { workEntries = new ArrayList<>(orderedEntries); it = workEntries.listIterator(it.nextIndex() - 1); it.next(); } it.remove(); it = workEntries.listIterator(); result = newResult; } } return result; }); } private static Path toPath(File v) { if (v != null) { return v.toPath(); } return null; } private void processResourceStream(InputStream rawResource, ResourceConsumer dest) throws IOException { if (substitutionData == null) { dest.consume(rawResource); } else { // Utf8 in and out try (BufferedReader reader = new BufferedReader( new InputStreamReader(rawResource, StandardCharsets.UTF_8))) { String data = substitute(reader.lines(), substitutionData).collect( Collectors.joining("\n", "", "\n")); try (InputStream in = new ByteArrayInputStream(data.getBytes( StandardCharsets.UTF_8))) { dest.consume(in); } } } } private SourceHandler getHandler(Source sourceType) { switch (sourceType) { case DefaultResource: return this::useDefault; case External: return this::useExternal; case ResourceDir: return this::useResourceDir; default: throw new IllegalArgumentException(); } } private Map<String, String> substitutionData; private String category; private Path resourceDir; private Path publicName; private Path logPublicName; private Path externalPath; private final String defaultName; private List<Map.Entry<Source, SourceHandler>> sources; @FunctionalInterface private static interface SourceHandler { public boolean apply(ResourceConsumer dest) throws IOException; } private static interface ResourceConsumer { public Path publicName(); public void consume(InputStream in) throws IOException; } }
⏎ jdk/jpackage/internal/OverridableResource.java
Or download all of them as a single archive file:
File name: jdk.jpackage-17.0.5-src.zip File size: 92069 bytes Release date: 2022-09-13 Download
⇒ JDK 17 jdk.jshell.jmod - JShell Tool
2023-08-03, 3960👍, 0💬
Popular Posts:
JRE 8 deploy.jar is the JAR file for JRE 8 Java Control Panel and other deploy tools. JRE (Java Runt...
iText is an ideal library for developers looking to enhance web- and other applications with dynamic...
JDK 6 tools.jar is the JAR file for JDK 6 tools. It contains Java classes to support different JDK t...
Apache Log4j Core Implementation provides the functional components of the logging system. Users are...
xml-commons Resolver Source Code Files are provided in the source package file, xml-commons-resolver...