Class ExecEnvPool


  • public class ExecEnvPool
    extends java.lang.Object
    Pool of reusable ExecEnvs.
    • Constructor Detail

      • ExecEnvPool

        public ExecEnvPool()
    • Method Detail

      • registerMetaModel

        public void registerMetaModel​(java.lang.String name,
                                      Metamodel metamodel)
        Registers metamodel under name.
        Parameters:
        name - the name under which to register
        metamodel - the metamodel to register
        Throws:
        java.lang.IllegalStateException - if getExecEnv() has already been called on this pool
      • loadModule

        public void loadModule​(java.lang.String name)
        Loads the module with the given name and its imports closure, and registers its contents for execution.
        Parameters:
        name - the module name
        Throws:
        java.lang.IllegalStateException - if getExecEnv() has already been called on this pool
      • getExecEnv

        public ExecEnv getExecEnv()
        Returns the first available ExecEnv instance from this pool. Creates a new instance if necessary.
        Returns:
        the first available ExecEnv instance from this pool
      • returnExecEnv

        public void returnExecEnv​(ExecEnv env)
        Returns env to this pool. env must have been created by this pool.
        Parameters:
        env - the ExecEnv to return to this pool
        Throws:
        java.lang.IllegalArgumentException - if env was not created by this pool
      • isFrozen

        public boolean isFrozen()
        Returns whether this ExecEnvPool has been frozen, i.e. no new metamodels or modules can be loaded.
        Returns:
        whether this ExecEnvPool has been frozen, i.e. no new metamodels or modules can be loaded
      • setFrozen

        protected void setFrozen​(boolean frozen)
        Parameters:
        frozen - the frozen to set
      • getMetamodels

        protected java.util.Map<java.lang.String,​Metamodel> getMetamodels()
        Returns:
        the metamodels
      • getModuleResolverFactory

        protected ModuleResolverFactory getModuleResolverFactory()
        Returns:
        the moduleResolverFactory
      • setModuleResolverFactory

        public void setModuleResolverFactory​(ModuleResolverFactory moduleResolverFactory)
        Sets the ModuleResolverFactory to use for loading modules.
        Parameters:
        moduleResolverFactory - the moduleResolverFactory to set
        Throws:
        java.lang.IllegalStateException - if getExecEnv() has already been called on this pool
      • getModules

        protected java.util.List<java.lang.String> getModules()
        Returns:
        the modules
      • getPool

        protected java.util.Collection<java.lang.ref.SoftReference<ExecEnv>> getPool()
        Returns the pool of all ExecEnv instances created by this ExecEnvPool.
        Returns:
        the pool
      • getFreePool

        protected java.util.Queue<java.lang.ref.SoftReference<ExecEnv>> getFreePool()
        Returns the pool of all free ExecEnv instances. Subset of getPool().
        Returns:
        the freePool