src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ResourcePoolEntry.java
author sspitsyn
Fri, 25 May 2018 00:18:47 -0700
changeset 50263 42165815ee40
parent 47216 71c04702a3d5
permissions -rw-r--r--
8203816: add tests failed because of 8203174 to the ProblemList-graal Summary: add tests to the ProblemList-graal.txt Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
     1
/*
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
     4
 *
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    10
 *
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    15
 * accompanied this code).
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    16
 *
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    20
 *
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    23
 * questions.
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    24
 */
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    25
package jdk.tools.jlink.plugin;
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    26
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    27
import java.io.InputStream;
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
    28
import java.io.IOException;
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
    29
import java.io.OutputStream;
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
    30
import java.io.UncheckedIOException;
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
    31
import java.nio.file.Path;
41561
0c6942d13f2e 8167558: Add new JMOD section for header files and man pages
mchung
parents: 39894
diff changeset
    32
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    33
import jdk.tools.jlink.internal.ResourcePoolEntryFactory;
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    34
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    35
/**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    36
 * A ResourcePoolEntry is the elementary unit of data inside an image. It is
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
    37
 * generally a file. e.g.: a java class file, a resource file, a shared library.
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    38
 * <br>
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    39
 * A ResourcePoolEntry is identified by a path of the form:
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    40
 * <ul>
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    41
 * <li>For jimage content: /{module name}/{package1}/.../{packageN}/{file
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    42
 * name}</li>
39894
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
    43
 * <li>For top-level files:/{module name}/{file name}</li>
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    44
 * <li>For other files (shared lib, launchers, config, ...):/{module name}/
38558
b98ed607dbc9 8157801: spurious > character in the javadoc comment for ModuleEntry.java
sundar
parents: 38320
diff changeset
    45
 * {@literal bin|conf|native}/{dir1}/.../{dirN}/{file name}</li>
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    46
 * </ul>
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    47
 */
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    48
public interface ResourcePoolEntry {
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    49
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    50
    /**
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    51
     * Type of module data.
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    52
     * <li>
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    53
     * <ul>CLASS_OR_RESOURCE: A java class or resource file.</ul>
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    54
     * <ul>CONFIG: A configuration file.</ul>
42670
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
    55
     * <ul>HEADER_FILE: A header file.</ul>
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
    56
     * <ul>LEGAL_NOTICE: A legal notice.</ul>
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
    57
     * <ul>MAN_PAGE: A man page.</ul>
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
    58
     * <ul>NATIVE_CMD: A native executable launcher.</ul>
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    59
     * <ul>NATIVE_LIB: A native library.</ul>
39894
cd4f403f9618 8162782: jlink ResourcePool.releaseProperties should be removed
sundar
parents: 39834
diff changeset
    60
     * <ul>TOP: A top-level file in the jdk run-time image directory.</ul>
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    61
     * </li>
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    62
     */
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    63
    public enum Type {
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    64
        CLASS_OR_RESOURCE,
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    65
        CONFIG,
42670
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
    66
        HEADER_FILE,
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
    67
        LEGAL_NOTICE,
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
    68
        MAN_PAGE,
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    69
        NATIVE_CMD,
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    70
        NATIVE_LIB,
42697
d8fe893519b9 8171138: Remove FileCopierPlugin
sundar
parents: 42670
diff changeset
    71
        TOP
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    72
    }
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    73
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    74
    /**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    75
     * The module name of this ResourcePoolEntry.
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    76
     *
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    77
     * @return The module name.
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    78
     */
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    79
    public String moduleName();
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    80
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    81
    /**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    82
     * The path of this ResourcePoolEntry.
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    83
     *
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    84
     * @return The module path.
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    85
     */
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    86
    public String path();
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    87
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    88
    /**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    89
     * The ResourcePoolEntry's type.
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    90
     *
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    91
     * @return The data type.
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    92
     */
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    93
    public Type type();
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    94
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
    95
    /**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    96
     * The ResourcePoolEntry content length.
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    97
     *
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    98
     * @return The content length.
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
    99
     */
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   100
    public long contentLength();
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   101
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   102
    /**
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   103
     * The ResourcePoolEntry content as an InputStream.
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   104
     *
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   105
     * @return The resource content as an InputStream.
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   106
     */
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   107
    public InputStream content();
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   108
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   109
    /**
42670
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   110
     * Returns a target linked with this entry.
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   111
     *
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   112
     * @implSpec The default implementation returns {@code null}.
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   113
     *
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   114
     * @return the target ResourcePoolEntry linked with this entry.
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   115
     */
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   116
    public default ResourcePoolEntry linkedTarget() {
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   117
        return null;
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   118
    }
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   119
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   120
    /**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   121
     * The ResourcePoolEntry content as an array of bytes.
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   122
     *
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   123
     * @return An Array of bytes.
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   124
     */
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   125
    public default byte[] contentBytes() {
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   126
        try (InputStream is = content()) {
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   127
            return is.readAllBytes();
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   128
        } catch (IOException ex) {
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   129
            throw new UncheckedIOException(ex);
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   130
        }
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   131
    }
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   132
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   133
    /**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   134
     * Write the content of this ResourcePoolEntry to an OutputStream.
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   135
     *
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   136
     * @param out the output stream
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   137
     */
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   138
    public default void write(OutputStream out) {
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   139
        try {
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   140
            out.write(contentBytes());
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   141
        } catch (IOException ex) {
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   142
            throw new UncheckedIOException(ex);
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   143
        }
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   144
    }
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   145
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   146
    /**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   147
     * Create a ResourcePoolEntry with new content but other information
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   148
     * copied from this ResourcePoolEntry.
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   149
     *
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   150
     * @param content The new resource content.
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   151
     * @return A new ResourcePoolEntry.
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   152
     */
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   153
    public default ResourcePoolEntry copyWithContent(byte[] content) {
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   154
        return ResourcePoolEntryFactory.create(this, content);
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   155
    }
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   156
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   157
    /**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   158
     * Create a ResourcePoolEntry with new content but other information
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   159
     * copied from this ResourcePoolEntry.
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   160
     *
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   161
     * @param file The new resource content.
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   162
     * @return A new ResourcePoolEntry.
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   163
     */
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   164
    public default ResourcePoolEntry copyWithContent(Path file) {
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   165
        return ResourcePoolEntryFactory.create(this, file);
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   166
    }
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   167
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   168
    /**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   169
     * Create a ResourcePoolEntry for a resource of the given type.
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   170
     *
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   171
     * @param path The resource path.
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   172
     * @param type The ResourcePoolEntry type.
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   173
     * @param content The resource content.
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   174
     * @return A new ResourcePoolEntry.
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   175
     */
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   176
    public static ResourcePoolEntry create(String path,
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   177
            ResourcePoolEntry.Type type, byte[] content) {
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   178
        return ResourcePoolEntryFactory.create(path, type, content);
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   179
    }
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   180
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   181
    /**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   182
     * Create a ResourcePoolEntry for a resource of type {@link Type#CLASS_OR_RESOURCE}.
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   183
     *
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   184
     * @param path The resource path.
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   185
     * @param content The resource content.
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   186
     * @return A new ResourcePoolEntry.
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   187
     */
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   188
    public static ResourcePoolEntry create(String path, byte[] content) {
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   189
        return create(path, Type.CLASS_OR_RESOURCE, content);
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   190
    }
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   191
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   192
    /**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   193
     * Create a ResourcePoolEntry for a resource of the given type.
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   194
     *
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   195
     * @param path The resource path.
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   196
     * @param type The ResourcePoolEntry type.
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   197
     * @param file The resource file.
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   198
     * @return A new ResourcePoolEntry.
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   199
     */
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   200
    public static ResourcePoolEntry create(String path,
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   201
            ResourcePoolEntry.Type type, Path file) {
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   202
        return ResourcePoolEntryFactory.create(path, type, file);
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   203
    }
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   204
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   205
    /**
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   206
     * Create a ResourcePoolEntry for a resource of type {@link Type#CLASS_OR_RESOURCE}.
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   207
     *
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   208
     * @param path The resource path.
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   209
     * @param file The resource file.
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   210
     * @return A new ResourcePoolEntry.
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   211
     */
39834
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39151
diff changeset
   212
    public static ResourcePoolEntry create(String path, Path file) {
39151
34455cc82f5e 8147794: Jlink's ModuleEntry.stream can't be consumed more than once and ModuleEntry content should be read only if needed
sundar
parents: 38558
diff changeset
   213
        return create(path, Type.CLASS_OR_RESOURCE, file);
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   214
    }
42670
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   215
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   216
    /**
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   217
     * Create a ResourcePoolEntry for a resource the given path and type.
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   218
     * If the target platform supports symbolic links, it will be created
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   219
     * as a symbolic link to the given target entry; otherwise, the
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   220
     * ResourcePoolEntry contains the relative path to the target entry.
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   221
     *
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   222
     * @param path The resource path.
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   223
     * @param type The ResourcePoolEntry type.
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   224
     * @param target The target entry
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   225
     * @return A new ResourcePoolEntry
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   226
     */
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   227
    public static ResourcePoolEntry createSymLink(String path,
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   228
                                                  ResourcePoolEntry.Type type,
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   229
                                                  ResourcePoolEntry target) {
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   230
        return ResourcePoolEntryFactory.createSymbolicLink(path, type, target);
d833113eb7d7 8169925: Organize licenses by module in source, JMOD file, and run-time image
mchung
parents: 41561
diff changeset
   231
    }
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents:
diff changeset
   232
}