Package org.eclipse.m2m.atl.emftvm.util

## Class ExecEnvPool

- java.lang.Object
- - org.eclipse.m2m.atl.emftvm.util.ExecEnvPool

    public class ExecEnvPool
    extends java.lang.Object

Pool of reusable `ExecEnv`s.

### Constructor Summary

Constructors
`ExecEnvPool()`

### Method Summary

All Methods Instance Methods Concrete Methods
`ExecEnv` `getExecEnv()` Returns the first available `ExecEnv` instance from this pool.
`protected java.util.Queue<java.lang.ref.SoftReference<ExecEnv>>` `getFreePool()` Returns the pool of all free `ExecEnv` instances.
`protected java.util.Map<java.lang.String,​Metamodel>` `getMetamodels()`
`protected ModuleResolverFactory` `getModuleResolverFactory()`
`protected java.util.List<java.lang.String>` `getModules()`
`protected java.util.Collection<java.lang.ref.SoftReference<ExecEnv>>` `getPool()` Returns the pool of all `ExecEnv` instances created by this `ExecEnvPool`.
`boolean` `isFrozen()` Returns whether this `ExecEnvPool` has been frozen, i.e.
`void` `loadModule​(java.lang.String name)` Loads the module with the given `name` and its imports closure, and registers its contents for execution.
`void` `registerMetaModel​(java.lang.String name, Metamodel metamodel)` Registers `metamodel` under `name`.
`void` `returnExecEnv​(ExecEnv env)` Returns `env` to this pool.
`protected void` `setFrozen​(boolean frozen)`
`void` `setModuleResolverFactory​(ModuleResolverFactory moduleResolverFactory)` Sets the `ModuleResolverFactory` to use for loading modules.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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