Skip to content

Building a JALSE instance

Elliot Ford edited this page Jun 28, 2015 · 9 revisions

What is a JALSE instance?

A JALSE instance is the root of the tree - this can be used to create the top level entities, process the entire tree and control the ActionEngine (see What is a JALSE instance? for more information).

DefaultJALSE.Builder builder = new DefaultJALSE.Builder();

Setting the ID

JALSE is an Identifiable so it must have an ID:

// Random ID
builder.setRandomID();
// Dummy ID (00000000-0000-0000-0000-000000000000)
builder.setDummyID();
// Specific ID
builder.setID(/* Some ID */);

Setting the Entity limit

JALSE is an EntityContainer so an EntityFactory is required to populate the tree. JALSEBuilder supplies a DefaultEntityFactory instance and DefaultEntityFactory takes in an Entity limit:

// Integer.MAX_VALUE
builder.setNoEntityLimit();
// Limit of 15
builder.setEntityLimit(15);

Setting the ActionEngine

JALSE is an ActionEngine and wraps an engine instance. This ActionEngine instance is supplied to the EntityFactory.

Constructing a ThreadPoolActionEngine:

// new ThreadPoolActionEngine(4)
builder.setThreadPoolEngine().setParallelism(4);
// new ThreadPoolActionEngine(1)
builder.setThreadPoolEngine().setSingleThread();

Constructing a ForkJoinActionEngine:

// new ForkJoinActionEngine(4)
builder.setForkJoinActionEngine().setParallelism(4);
// new ForkJoinActionEngine()
builder.setForkJoinActionEngine().setParallelismToProcessors();

Constructing a ManualActionEngine:

// new ManualActionEngine()
builder.setManualActionEngine();

Using the common pool engine (see Picking an ActionEngine implementation):

// ForkJoinActionEngine.commonPoolEngine()
builder.setCommonPoolEngine();

Building the instance

Below is an example of building a JALSE instance using a random ID, ThreadPoolActionEngine with 8 threads and an Entity limit of 50:

JALSE jalse = new DefaultJALSE.Builder.setRandomID().setThreadPoolEngine().setParallelism(8).setEntityLimit(50).build();

Clone this wiki locally