Apama 10.3 | Apama Documentation | Developing Apama Applications | Developing Apama Applications in EPL | Common EPL Patterns in Monitors | Factory pattern
 
Factory pattern
 
Canonical factory pattern
Alternate factory pattern
The factory pattern creates a new monitor instance to handle each new item/request. Its essential features include:
*The onload() action sets up an event listener for creation events,
*Each creation event causes a monitor instance to be spawned.
There are two common forms of the factory pattern:
*Canonical form
The monitor instance spawns to an action that initializes the state of the new monitor instance and creates event listeners specific to that monitor instance. The spawned monitor instances use local variables for coassignment and passes them into the action.
It is likely that some of the data from the creation event is copied into global variables.
*Alternate form
The initial monitor instance uses coassignment to global variables to set some state before spawning.
This is a "lazy" form in that it stores the complete creation event inside the monitor. You should not use this form if you are spawning large number of monitor instances and you have a large creation event, where only part of the creation event data needs to be retained.
As an exercise, consider rewriting the example in Translation using spawning, to use the alternate factory form.

Copyright © 2013-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.