jdk/test/tools/jlink/customplugin/plugin/RogueAdderPlugin.java
changeset 40556 27f68990ba9d
equal deleted inserted replaced
40555:face0a3ae86c 40556:27f68990ba9d
       
     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.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 package plugin;
       
    24 
       
    25 import java.io.File;
       
    26 import java.io.IOException;
       
    27 import java.io.UncheckedIOException;
       
    28 import java.lang.module.ModuleDescriptor;
       
    29 import java.util.Collections;
       
    30 import java.util.Map;
       
    31 import java.util.function.Function;
       
    32 import jdk.tools.jlink.plugin.ResourcePool;
       
    33 import jdk.tools.jlink.plugin.ResourcePoolBuilder;
       
    34 import jdk.tools.jlink.plugin.ResourcePoolEntry;
       
    35 import jdk.tools.jlink.plugin.ResourcePoolModule;
       
    36 import jdk.tools.jlink.plugin.Plugin;
       
    37 
       
    38 /**
       
    39  * Rogue adder plugin
       
    40  */
       
    41 public final class RogueAdderPlugin implements Plugin {
       
    42     public static final String NAME = "rogue-adder";
       
    43     private String resName;
       
    44 
       
    45     @Override
       
    46     public String getName() {
       
    47         return NAME;
       
    48     }
       
    49 
       
    50     @Override
       
    51     public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
       
    52         in.transformAndCopy(Function.identity(), out);
       
    53         out.add(ResourcePoolEntry.create(resName, new byte[1]));
       
    54         return out.build();
       
    55     }
       
    56 
       
    57     @Override
       
    58     public String getDescription() {
       
    59         return NAME + "-description";
       
    60     }
       
    61 
       
    62     @Override
       
    63     public Category getType() {
       
    64         return Category.FILTER;
       
    65     }
       
    66 
       
    67     @Override
       
    68     public boolean hasArguments() {
       
    69         return true;
       
    70     }
       
    71 
       
    72     @Override
       
    73     public void configure(Map<String, String> config) {
       
    74         resName = config.get(NAME);
       
    75     }
       
    76 }