author | sspitsyn |
Fri, 25 May 2018 00:18:47 -0700 | |
changeset 50263 | 42165815ee40 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
38320 | 1 |
/* |
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
package jdk.tools.jlink.plugin; |
|
26 |
||
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 | 34 |
|
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 | 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 | 40 |
* <ul> |
41 |
* <li>For jimage content: /{module name}/{package1}/.../{packageN}/{file |
|
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 | 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 | 46 |
* </ul> |
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 | 49 |
|
50 |
/** |
|
51 |
* Type of module data. |
|
52 |
* <li> |
|
53 |
* <ul>CLASS_OR_RESOURCE: A java class or resource file.</ul> |
|
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 | 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 | 61 |
* </li> |
62 |
*/ |
|
63 |
public enum Type { |
|
64 |
CLASS_OR_RESOURCE, |
|
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 | 69 |
NATIVE_CMD, |
70 |
NATIVE_LIB, |
|
42697 | 71 |
TOP |
38320 | 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 | 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 | 76 |
* |
77 |
* @return The module name. |
|
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 | 80 |
|
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 | 83 |
* |
84 |
* @return The module path. |
|
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 | 87 |
|
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 | 90 |
* |
91 |
* @return The data type. |
|
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 | 94 |
|
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 | 122 |
* |
123 |
* @return An Array of bytes. |
|
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 | 132 |
|
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 | 145 |
|
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 | 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 | 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 | 155 |
} |
156 |
||
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 | 183 |
* |
184 |
* @param path The resource path. |
|
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 | 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 | 190 |
} |
191 |
||
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 | 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 | 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 | 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 | 232 |
} |