< prev index next >

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginConfiguration.java

Print this page




  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.internal;
  26 
  27 import java.io.DataOutputStream;
  28 
  29 import java.io.IOException;
  30 import java.util.ArrayList;
  31 import java.util.LinkedHashMap;
  32 import java.util.List;
  33 import java.util.Map;
  34 import java.util.Map.Entry;

  35 import jdk.tools.jlink.builder.ImageBuilder;
  36 import jdk.tools.jlink.plugin.Plugin;
  37 import jdk.tools.jlink.plugin.PluginException;
  38 import jdk.tools.jlink.plugin.Plugin.Category;
  39 import jdk.tools.jlink.plugin.ResourcePool;
  40 
  41 /**
  42  * Plugins configuration.
  43  */
  44 public final class ImagePluginConfiguration {
  45 
  46     private static final List<Category> CATEGORIES_ORDER = new ArrayList<>();
  47 
  48     static {
  49         CATEGORIES_ORDER.add(Category.FILTER);
  50         CATEGORIES_ORDER.add(Category.TRANSFORMER);
  51         CATEGORIES_ORDER.add(Category.MODULEINFO_TRANSFORMER);
  52         CATEGORIES_ORDER.add(Category.SORTER);
  53         CATEGORIES_ORDER.add(Category.COMPRESSOR);
  54         CATEGORIES_ORDER.add(Category.METAINFO_ADDER);


 104         if (pluginsConfiguration.getLastSorterPluginName() != null && lastSorter == null) {
 105             throw new IOException("Unknown last plugin "
 106                     + pluginsConfiguration.getLastSorterPluginName());
 107         }
 108         ImageBuilder builder = pluginsConfiguration.getImageBuilder();
 109         if (builder == null) {
 110             // This should be the case for jimage only creation or post-install.
 111             builder = new ImageBuilder() {
 112 
 113                 @Override
 114                 public DataOutputStream getJImageOutputStream() {
 115                     throw new PluginException("No directory setup to store files");
 116                 }
 117 
 118                 @Override
 119                 public ExecutableImage getExecutableImage() {
 120                     throw new PluginException("No directory setup to store files");
 121                 }
 122 
 123                 @Override
 124                 public void storeFiles(ResourcePool files) {
 125                     throw new PluginException("No directory setup to store files");
 126                 }
 127             };
 128         }
 129 
 130         return new ImagePluginStack(builder, orderedPlugins, lastSorter);
 131     }
 132 }


  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.internal;
  26 
  27 import java.io.DataOutputStream;
  28 
  29 import java.io.IOException;
  30 import java.util.ArrayList;
  31 import java.util.LinkedHashMap;
  32 import java.util.List;
  33 import java.util.Map;
  34 import java.util.Map.Entry;
  35 import java.util.Set;
  36 import jdk.tools.jlink.builder.ImageBuilder;
  37 import jdk.tools.jlink.plugin.Plugin;
  38 import jdk.tools.jlink.plugin.PluginException;
  39 import jdk.tools.jlink.plugin.Plugin.Category;
  40 import jdk.tools.jlink.plugin.ResourcePool;
  41 
  42 /**
  43  * Plugins configuration.
  44  */
  45 public final class ImagePluginConfiguration {
  46 
  47     private static final List<Category> CATEGORIES_ORDER = new ArrayList<>();
  48 
  49     static {
  50         CATEGORIES_ORDER.add(Category.FILTER);
  51         CATEGORIES_ORDER.add(Category.TRANSFORMER);
  52         CATEGORIES_ORDER.add(Category.MODULEINFO_TRANSFORMER);
  53         CATEGORIES_ORDER.add(Category.SORTER);
  54         CATEGORIES_ORDER.add(Category.COMPRESSOR);
  55         CATEGORIES_ORDER.add(Category.METAINFO_ADDER);


 105         if (pluginsConfiguration.getLastSorterPluginName() != null && lastSorter == null) {
 106             throw new IOException("Unknown last plugin "
 107                     + pluginsConfiguration.getLastSorterPluginName());
 108         }
 109         ImageBuilder builder = pluginsConfiguration.getImageBuilder();
 110         if (builder == null) {
 111             // This should be the case for jimage only creation or post-install.
 112             builder = new ImageBuilder() {
 113 
 114                 @Override
 115                 public DataOutputStream getJImageOutputStream() {
 116                     throw new PluginException("No directory setup to store files");
 117                 }
 118 
 119                 @Override
 120                 public ExecutableImage getExecutableImage() {
 121                     throw new PluginException("No directory setup to store files");
 122                 }
 123 
 124                 @Override
 125                 public void storeFiles(Set<String> rootModules, ResourcePool files) {
 126                     throw new PluginException("No directory setup to store files");
 127                 }
 128             };
 129         }
 130 
 131         return new ImagePluginStack(builder, orderedPlugins, lastSorter);
 132     }
 133 }
< prev index next >