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

# Class ExecEnvPool

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

public class ExecEnvPool extends Object
Pool of reusable `ExecEnv`s.

## Constructor Summary

Constructors
Constructor
Description
`ExecEnvPool()`

## Method Summary

Modifier and Type
Method
Description
`ExecEnv`
`getExecEnv()`
Returns the first available `ExecEnv` instance from this pool.
`protected Queue<SoftReference<ExecEnv>>`
`getFreePool()`
Returns the pool of all free `ExecEnv` instances.
`protected Map<String,Metamodel>`
`getMetamodels()`
`protected ModuleResolverFactory`
`getModuleResolverFactory()`
`protected List<String>`
`getModules()`
`protected Collection<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(String name)`
Loads the module with the given `name` and its imports closure, and registers its contents for execution.
`void`
`registerMetaModel(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 Details

### ExecEnvPool

public ExecEnvPool()

## Method Details

### registerMetaModel

public void registerMetaModel(String name, Metamodel metamodel)
Registers `metamodel` under `name`.

Parameters:
  `name` - the name under which to register
  `metamodel` - the metamodel to register
Throws:
  `IllegalStateException` - if `getExecEnv()` has already been called on this pool

### loadModule

public void loadModule(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:
  `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:
  `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 Map<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:
  `IllegalStateException` - if `getExecEnv()` has already been called on this pool

### getModules

protected List<String> getModules()

Returns:
  the modules

### getPool

protected Collection<SoftReference<ExecEnv>> getPool()
Returns the pool of all `ExecEnv` instances created by this `ExecEnvPool`.

Returns:
  the pool

### getFreePool

protected Queue<SoftReference<ExecEnv>> getFreePool()
Returns the pool of all free `ExecEnv` instances. Subset of `getPool()`.

Returns:
  the freePool