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
// Dummy ID (00000000-0000-0000-0000-000000000000)
// 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
// Limit of 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)
// new ThreadPoolActionEngine(1)

Constructing a ForkJoinActionEngine:

// new ForkJoinActionEngine(4)
// new ForkJoinActionEngine()

Constructing a ManualActionEngine:

// new ManualActionEngine()

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

// ForkJoinActionEngine.commonPoolEngine()

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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.