Dev:Initialization

From WCell

Jump to: navigation, search

Contents

[edit] Hooking to WCell's startup routine

WCell and all its Addons initialize its different Modules during startup through several Initialization Steps.
All public static methods that have the InitializationAttribute are automatically added to the Initialization-Routine. The order of steps is determined through the InitializationPass - Property.
The code-files can be found in the WCell repository.

[edit] Initialization Step

An Initialization Step is a public static method with either void or bool return-type. If the return-type is bool and the method returns false or if an exception is raised, Initialization will fail unless the Step explicitely set the IsRequired-Property to false.
The method should either have no arguments or only one argument of type InitMgr in which case the instance of the currently initializing InitMgr can be used to for example add further InitializationSteps or change or analyze the InitMgr's behavior.


[edit] Initialization Attribute

The InitializationAttribute is used to define Initialization Steps. It holds the following Properties:

[edit] Name

The name of the Initialization Step.

[edit] Pass

The Pass decides the order in which Initialization Steps are executed. If a step depends on another step, it needs a higher pass. It is ensured that steps are always executed before steps of a higher pass. The sequence of steps with the same pass is not ensured at any time and might even be executed parallely due to load-balancing.

[edit] IsRequired

If one required step failed (by returning false or raising an exception), the server will not be able to finish its startup routine and shutdown immediately.

[edit] InitMgr

The InitMgr holds all steps of Initialization. It allows you to add further steps, add Assemblies that contain other steps or remove already added steps. You get access to the instance of the currently running InitMgr by adding it as only argument to the step's method signature. Steps of assemblies that are added while initialization is already commencing, will be retro-actively executed if they are of a pass that is equal to or lower than the InitMgr's CurrentPass.

[edit] Initializing Addons

WCell Addons are loaded during the first Pass of initialization. You can add further Initialization steps to it which will be added to the order of the WCell-Core startup. If you are unsure which Pass to specify, use the Last Pass, which ensures that all Core-Steps already finished before execution of this step.

Personal tools