Class LayerModuleFinder

  • All Implemented Interfaces:
    java.lang.module.ModuleFinder

    public class LayerModuleFinder
    extends java.lang.Object
    implements java.lang.module.ModuleFinder
    ModuleFinder implementation used by the module installed by LayerFactory to locate class definitions when an attempt is made to load a class into the module. The finder uses a ModuelReader which passes the request back to the installer of the module, allowing it either to generate or load the class definition as it sees fit.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String moduleName
      the name of the single module this module finder finds classes for
      private java.lang.module.ModuleReference reference
      a module reference describing this finder's module
    • Constructor Summary

      Constructors 
      Constructor Description
      LayerModuleFinder​(java.lang.String moduleName, java.lang.String[] exportsNames, java.lang.String[] requiresNames, java.util.function.Function<java.lang.String,​byte[]> classMapper)
      construct a finder for a single module populated with classes by the supplier classmapper
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<java.lang.module.ModuleReference> find​(java.lang.String name)  
      java.util.Set<java.lang.module.ModuleReference> findAll()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • moduleName

        private final java.lang.String moduleName
        the name of the single module this module finder finds classes for
      • reference

        private java.lang.module.ModuleReference reference
        a module reference describing this finder's module
    • Constructor Detail

      • LayerModuleFinder

        public LayerModuleFinder​(java.lang.String moduleName,
                                 java.lang.String[] exportsNames,
                                 java.lang.String[] requiresNames,
                                 java.util.function.Function<java.lang.String,​byte[]> classMapper)
        construct a finder for a single module populated with classes by the supplier classmapper
        Parameters:
        moduleName - the name of the one module to be installed in the layer
        exportsNames - an array of names of packages to be exported by the module
        requiresNames - an array of names of modules to be imported by the module
        classMapper - a function provided by the caller to populate the module with classes which accepts a class name and returns the corresponding class file format byte array. The name will be presented in the format "x/y/z/MyClass.class".
    • Method Detail

      • find

        public java.util.Optional<java.lang.module.ModuleReference> find​(java.lang.String name)
        Specified by:
        find in interface java.lang.module.ModuleFinder
      • findAll

        public java.util.Set<java.lang.module.ModuleReference> findAll()
        Specified by:
        findAll in interface java.lang.module.ModuleFinder