net.sourceforge.jabm
Class SpringSimulationController

java.lang.Object
  extended by net.sourceforge.jabm.event.AbstractModel
      extended by net.sourceforge.jabm.SimulationController
          extended by net.sourceforge.jabm.SpringSimulationController
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Runnable, Model, EventScheduler, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean
Direct Known Subclasses:
GameTheoreticSimulationController

public class SpringSimulationController
extends SimulationController
implements org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean

SpringSimulationController is responsible for running one or more independent JABM simulations which are configured using the Spring Framework.

It is responsible for running one or more Monte-carlo simulations; that is, any object implementing the Simulation interface. Typically a simulation will be run several hundred times with different realisations of random variables. In order to ensure that each sample is independent, the underlying simulation is initialised as a freshly constructed bean from the Spring factory for every run.

A simulation model is constructed using dependency injection by creating a Spring beans configuration file which specifies which classes to use in the simulation and the values of any attributes (parameters). The Spring configuration file is specified using the system property jabm.config.

See Also:
Simulation, Serialized Form
 

Field Summary
protected  org.springframework.beans.factory.BeanFactory beanFactory
           
protected  java.lang.String simulationBeanName
          The name of the bean representing the Simulation.
protected  boolean simulationInitialised
           
protected  SimulationScope simulationScope
          The container for beans with scope="simulation".
 
Fields inherited from class net.sourceforge.jabm.SimulationController
batch, isRunning, listenersInitialised, modelDescription, numSimulations, reports, simulation, simulationFactory, slowSleepInterval
 
Fields inherited from class net.sourceforge.jabm.event.AbstractModel
deleteQueue, genericListeners, specificListeners
 
Constructor Summary
SpringSimulationController()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  void constructSimulation()
           
 org.springframework.beans.factory.BeanFactory getBeanFactory()
           
 java.lang.String getSimulationBeanName()
           
 void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
           
 void setSimulationBeanName(java.lang.String simulationBean)
          The name of bean representing the Simulation to be run as part of this experiment.
protected  void tearDownSimulation()
          Remove listeners prior to reconstructing the simulation object.
 
Methods inherited from class net.sourceforge.jabm.SimulationController
addReport, fireEvent, getModelDescription, getNumSimulations, getPopulation, getReports, getSimulation, getSimulationFactory, getSimulationTime, getSlowSleepInterval, isRunning, run, runSingleSimulation, setListeners, setModelDescription, setNumSimulations, setReports, setSimulation, setSimulationFactory, setSlowSleepInterval, slow, terminate, wireReports, wireSimulation
 
Methods inherited from class net.sourceforge.jabm.event.AbstractModel
addListener, addListener, clearListeners, clone, notifyGenericListeners, notifySpecificListeners, processDeleteQueue, removeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.jabm.EventScheduler
addListener, addListener, removeListener
 

Field Detail

simulationBeanName

protected java.lang.String simulationBeanName
The name of the bean representing the Simulation.


simulationScope

protected SimulationScope simulationScope
The container for beans with scope="simulation".


beanFactory

protected org.springframework.beans.factory.BeanFactory beanFactory

simulationInitialised

protected boolean simulationInitialised
Constructor Detail

SpringSimulationController

public SpringSimulationController()
Method Detail

tearDownSimulation

protected void tearDownSimulation()
Description copied from class: SimulationController
Remove listeners prior to reconstructing the simulation object.

Overrides:
tearDownSimulation in class SimulationController

constructSimulation

protected void constructSimulation()
Specified by:
constructSimulation in class SimulationController

getSimulationBeanName

public java.lang.String getSimulationBeanName()

setSimulationBeanName

public void setSimulationBeanName(java.lang.String simulationBean)
The name of bean representing the Simulation to be run as part of this experiment.

Parameters:
simulationBean -
See Also:
Simulation

setBeanFactory

public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
                    throws org.springframework.beans.BeansException
Specified by:
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
Throws:
org.springframework.beans.BeansException

getBeanFactory

public org.springframework.beans.factory.BeanFactory getBeanFactory()

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception