Interface ReloadableModule

  • All Superinterfaces:
    SModule
    All Known Implementing Classes:
    Generator, Language, ReloadableModuleBase, Solution, StubSolution, TempModule, TestLanguage

    public interface ReloadableModule
    extends SModule
    Represents a module which can be associated with some class loader, it is a unit in the MPS class loading subsystem. The naming is poor: the better choice would be "DeployedModule". Only some of ReloadableModule can be really reloaded at runtime. (to be precise the modules which have CustomClassLoadingFacet could not be reloaded) For example suppose there is a language module L in MPS. Also let there be a solution S which uses the language L. Imagine that at some point you decide to change the language L, e.g. change the editor representation for some concept C in the language L. Obviously you expect MPS to change the UI appearance for the instances of the concept C in the solution S. Moreover you want MPS to change the UI representation right after the used language L is generated and compiled. To enable such workflow MPS introduces its own class loading subsystem. Also it brings in a notion of reloadable modules such modules which can be redeployed during design-time in MPS (the idea plugin modules are the exception) So the language L in the given example is clearly a reloadable module. As for 191 the common workflow must look like this: default void invokeMethodFoo(@NotNull ReloadableModule module) { DeploymentStatus status = module.getStatus(); if (!status.canBeDeployed()) { return; } try { Class main = module.getClass("Main"); Object instance = main.newInstance(); } catch (ClassNotFoundException e) { } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } }
    See Also:
    -- the central place for class managing in the MPS, however that class should not be accessed by anyone anymore.
    • Method Detail

      • getClass

        @NotNull
        Class<?> getClass​(@NotNull
                          String classFqName)
                   throws ClassNotFoundException
        Returns:
        a class which can be obtained by calling #getclass from getClassLoader() method. a ModuleClassLoader. ModuleClassLoader's #loadClass method yields some additional information about the reasons of class which could not be found. Clients of this API are supposed to process it on their own behalf. * @see jetbrains.mps.classloading.ModuleClassNotFoundException * @see jetbrains.mps.classloading.ModuleIsNotLoadableException warning: this method is lazy implemented!
        Throws:
        ClassNotFoundException
      • getClassLoader

        @Nullable
        @Deprecated
        default ClassLoader getClassLoader()
        Deprecated.
        Returns:
        the class loader associated with the module. Currently it can be either MPS ModuleClassLoader or IdeaPlugin PluginClassLoader. The latter is returned in the case when IDEA plugin manages the module's classes. Use it if you want to get a class from the module with IdeaPluginFacet. warning: this method is lazy implemented! if getStatus().isDeployed() || getStatus().canBeDeployed() is true then the return value is guaranteed to be not null
      • getClassLoader0

        @NotNull
        MPSModuleClassLoader getClassLoader0()
        Returns:
        not null classloader, if a specific module-related class loader is not found than the system classloader is returned
      • willLoad

        @Deprecated
        default boolean willLoad()
        Deprecated.
        bad naming, use #canLoadClasses or sometimes it is more convenient to use getStatus#isDeployed
        Returns:
        true if it will load classes. For some subclasses it is possible to disable class loading for ReloadableModule. E.g. solution without idea/mps facet cannot load classes
        See Also:
        Solution
      • canLoadClasses

        default boolean canLoadClasses()
        For some subclasses it is possible to disable class loading for ReloadableModule. E.g. solution without idea/mps facet cannot load classes
        See Also:
        Solution