jdk/test/tools/jlink/plugins/LastSorterTest.java
author chegar
Wed, 18 Jan 2017 09:36:24 +0000
changeset 43185 d75d9ff8d4e7
parent 41559 5b33f33df1fb
permissions -rw-r--r--
8171380: Remove all exports from jdk.jlink Reviewed-by: alanb, mchung, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * accompanied this code).
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * questions.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    23
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    24
/*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    25
 * @test
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    26
 * @summary Test last sorter property
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    27
 * @author Jean-Francois Denise
43185
d75d9ff8d4e7 8171380: Remove all exports from jdk.jlink
chegar
parents: 41559
diff changeset
    28
 * @modules jdk.jlink/jdk.tools.jlink
d75d9ff8d4e7 8171380: Remove all exports from jdk.jlink
chegar
parents: 41559
diff changeset
    29
 *          jdk.jlink/jdk.tools.jlink.internal
d75d9ff8d4e7 8171380: Remove all exports from jdk.jlink
chegar
parents: 41559
diff changeset
    30
 *          jdk.jlink/jdk.tools.jlink.plugin
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    31
 * @run main/othervm LastSorterTest
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    32
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    33
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    34
import java.util.ArrayList;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    35
import java.util.Collections;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    36
import java.util.HashMap;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    37
import java.util.List;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    38
import java.util.Map;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    39
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    40
import jdk.tools.jlink.internal.ImagePluginConfiguration;
41559
5b33f33df1fb 8168091: jlink should check security permission early when programmatic access is used
sundar
parents: 39834
diff changeset
    41
import jdk.tools.jlink.internal.ImagePluginStack;
5b33f33df1fb 8168091: jlink should check security permission early when programmatic access is used
sundar
parents: 39834
diff changeset
    42
import jdk.tools.jlink.internal.Jlink;
5b33f33df1fb 8168091: jlink should check security permission early when programmatic access is used
sundar
parents: 39834
diff changeset
    43
import jdk.tools.jlink.internal.Jlink.PluginsConfiguration;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    44
import jdk.tools.jlink.internal.PluginRepository;
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: 39321
diff changeset
    45
import jdk.tools.jlink.internal.ResourcePoolManager;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    46
import jdk.tools.jlink.plugin.Plugin;
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: 39321
diff changeset
    47
import jdk.tools.jlink.plugin.ResourcePool;
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
    48
import jdk.tools.jlink.plugin.ResourcePoolBuilder;
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
    49
import jdk.tools.jlink.plugin.ResourcePoolEntry;
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    50
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    51
public class LastSorterTest {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    52
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    53
    public LastSorterTest() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    54
        for (int i = 1; i <= 6; i++) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    55
            PluginRepository.registerPlugin(new SorterPlugin("sorterplugin" + i));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    56
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    57
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    58
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    59
    public static void main(String[] args) throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    60
        new LastSorterTest().test();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    61
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    62
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    63
    public void test() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    64
        checkUnknownPlugin();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    65
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    66
        checkOrderAfterLastSorter();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    67
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    68
        checkPositiveCase();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    69
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    70
        checkTwoLastSorters();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    71
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    72
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    73
    private void checkTwoLastSorters() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    74
        List<Plugin> plugins = new ArrayList<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    75
        plugins.add(createPlugin("sorterplugin5", "/a"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    76
        plugins.add(createPlugin("sorterplugin6", "/a"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    77
        PluginsConfiguration config = new Jlink.PluginsConfiguration(plugins,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    78
                null, "sorterplugin5");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    79
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    80
        ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(config);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    81
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    82
        // check order
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: 39321
diff changeset
    83
        ResourcePoolManager res = fillOutResourceResourcePool();
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    84
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    85
        try {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    86
            stack.visitResources(res);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    87
            throw new AssertionError("Exception expected: Order of resources is already frozen." +
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    88
                    "Plugin sorterplugin6 is badly located");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    89
        } catch (Exception e) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    90
            // expected
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    91
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    92
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    93
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: 39321
diff changeset
    94
    private ResourcePoolManager fillOutResourceResourcePool() throws Exception {
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
    95
        ResourcePoolManager res = new ResourcePoolManager();
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
    96
        res.add(ResourcePoolEntry.create("/eee/bbb/res1.class", new byte[90]));
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
    97
        res.add(ResourcePoolEntry.create("/aaaa/bbb/res2.class", new byte[90]));
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
    98
        res.add(ResourcePoolEntry.create("/bbb/aa/res1.class", new byte[90]));
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
    99
        res.add(ResourcePoolEntry.create("/aaaa/bbb/res3.class", new byte[90]));
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
   100
        res.add(ResourcePoolEntry.create("/bbb/aa/res2.class", new byte[90]));
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
   101
        res.add(ResourcePoolEntry.create("/fff/bbb/res1.class", new byte[90]));
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
   102
        res.add(ResourcePoolEntry.create("/aaaa/bbb/res1.class", new byte[90]));
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
   103
        res.add(ResourcePoolEntry.create("/bbb/aa/res3.class", new byte[90]));
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
   104
        res.add(ResourcePoolEntry.create("/ccc/bbb/res1.class", new byte[90]));
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
   105
        res.add(ResourcePoolEntry.create("/ddd/bbb/res1.class", new byte[90]));
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   106
        return res;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   107
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   108
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   109
    private static Plugin createPlugin(String name, String arg) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   110
        Map<String, String> conf = new HashMap<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   111
        conf.put(name, arg);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   112
        return Jlink.newPlugin(name, conf, null);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   113
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   114
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   115
    private void checkPositiveCase() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   116
        List<Plugin> plugins = new ArrayList<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   117
        plugins.add(createPlugin("sorterplugin1", "/c"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   118
        plugins.add(createPlugin("sorterplugin2", "/b"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   119
        plugins.add(createPlugin("sorterplugin3", "/a"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   120
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   121
        PluginsConfiguration config = new Jlink.PluginsConfiguration(plugins,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   122
                null, "sorterplugin3");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   123
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   124
        ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(config);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   125
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   126
        // check order
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: 39321
diff changeset
   127
        ResourcePoolManager res = fillOutResourceResourcePool();
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   128
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   129
        stack.visitResources(res);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   130
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   131
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   132
    private void checkUnknownPlugin() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   133
        List<Plugin> plugins = new ArrayList<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   134
        plugins.add(createPlugin("sorterplugin1", "/1"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   135
        plugins.add(createPlugin("sorterplugin2", "/1"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   136
        plugins.add(createPlugin("sorterplugin3", "/1"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   137
        plugins.add(createPlugin("sorterplugin4", "/1"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   138
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   139
        PluginsConfiguration config = new Jlink.PluginsConfiguration(plugins,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   140
                null, "sorterplugin5");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   141
        try {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   142
            ImagePluginConfiguration.parseConfiguration(config);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   143
            throw new AssertionError("Unknown plugin should have failed.");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   144
        } catch (Exception ex) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   145
            // XXX OK expected
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   146
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   147
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   148
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   149
    private void checkOrderAfterLastSorter() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   150
        List<Plugin> plugins = new ArrayList<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   151
        plugins.add(createPlugin("sorterplugin1", "/c"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   152
        plugins.add(createPlugin("sorterplugin2", "/b"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   153
        plugins.add(createPlugin("sorterplugin3", "/a"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   154
        plugins.add(createPlugin("sorterplugin4", "/d"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   155
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   156
        PluginsConfiguration config = new Jlink.PluginsConfiguration(plugins,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   157
                null, "sorterplugin3");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   158
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   159
        ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(config);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   160
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   161
        // check order
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: 39321
diff changeset
   162
        ResourcePoolManager res = fillOutResourceResourcePool();
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   163
        try {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   164
            stack.visitResources(res);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   165
            throw new AssertionError("Order was changed after the last sorter, but no exception occurred");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   166
        } catch (Exception ex) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   167
            // XXX OK expected
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   168
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   169
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   170
39321
c60f34e8c057 8160641: PostProcessingPlugin and ExecutableImage should not be part of plugin API
sundar
parents: 39129
diff changeset
   171
    public static class SorterPlugin implements Plugin {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   172
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   173
        private final String name;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   174
        private String starts;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   175
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   176
        private SorterPlugin(String name) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   177
            this.name = name;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   178
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   179
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   180
        @Override
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: 39321
diff changeset
   181
        public ResourcePool transform(ResourcePool resources, ResourcePoolBuilder output) {
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
   182
            List<ResourcePoolEntry> paths = new ArrayList<>();
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   183
            resources.entries().forEach(res -> {
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: 39321
diff changeset
   184
                if (res.path().startsWith(starts)) {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   185
                    paths.add(0, res);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   186
                } else {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   187
                    paths.add(res);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   188
                }
38320
e24c7029e8ba 8156914: jlink API minor cleanups
sundar
parents: 36511
diff changeset
   189
            });
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   190
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: 39321
diff changeset
   191
            for (ResourcePoolEntry r : paths) {
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   192
                output.add(r);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   193
            }
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: 39321
diff changeset
   194
53a6fb443c20 8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents: 39321
diff changeset
   195
            return output.build();
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   196
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   197
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   198
        @Override
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   199
        public String getName() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   200
            return name;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   201
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   202
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   203
        @Override
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   204
        public void configure(Map<String, String> config) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   205
            String arguments = config.get(name);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   206
            this.starts = arguments;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   207
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   208
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   209
}