Packageorg.spicefactory.parsley.core.context.impl
Classpublic class DefaultContext
InheritanceDefaultContext Inheritance flash.events.EventDispatcher
Implements Context, InitializingService

Default implementation of the Context interface.

This implementation is not capable of handling a parent Context. A big part of the internal work is delegated to the collaborators fetched from the ContextStrategyProvider passed to the constructor: The ObjectDefinitionRegistry, ObjectLifecycleManager, ViewManager and ScopeManager implementations.



Public Properties
 PropertyDefined By
  configured : Boolean
[read-only] Indicates whether configuration for this Context has been fully processed.
DefaultContext
  destroyed : Boolean
[read-only] Indicates whether this Context has been destroyed.
DefaultContext
  domain : ApplicationDomain
[read-only] The ApplicationDomain used to reflect on instance of this Context.
DefaultContext
  initialized : Boolean
[read-only] Indicates whether this Context has been fully initialized.
DefaultContext
  lifecycleManager : ObjectLifecycleManager
[read-only] The manager that handles the lifecycle for all objects in this Context.
DefaultContext
  parents : Array
[read-only] All parent Contexts that this Context inherits from.
DefaultContext
  registry : ObjectDefinitionRegistry
[read-only] The registry used by this Context.
DefaultContext
  scopeManager : ScopeManager
[read-only] The scope manager that handles all scopes that this Context belongs to.
DefaultContext
  viewManager : ViewManager
[read-only] The view manager used to dynamically wire view instances to this Context.
DefaultContext
Public Methods
 MethodDefined By
  
Creates an object from the specified definition and dynamically adds it to the Context.
DefaultContext
  
addDynamicObject(instance:Object, definition:DynamicObjectDefinition = null):DynamicObject
Dynamically adds the specified instance to the Context.
DefaultContext
  
containsObject(id:String):Boolean
Checks whether this Contex contains an object with the specified id.
DefaultContext
  
Returns a new dynamic object for the specified id.
DefaultContext
  
Returns a new dynamic object for the specified type.
DefaultContext
  
destroy():void
Destroys this Context.
DefaultContext
  
findAllDefinitionsByType(type:Class, status:LookupStatus = null):Array
Returns all definitions for the specified type.
DefaultContext
  
findDefinition(id:String, status:LookupStatus = null):ObjectDefinition
Returns the definition for the object with the specified id or null if no such object exists.
DefaultContext
  
Returns one definition for the specified type.
DefaultContext
  
getAllObjectsByType(type:Class):Array
Returns all objects that match the specified type.
DefaultContext
  
getObject(id:String):Object
Returns the singleton object with the specified id.
DefaultContext
  
getObjectByType(type:Class):Object
Returns a singleton object of the specified type.
DefaultContext
  
getObjectCount(type:Class = null):uint
Returns the number of objects in this Context that match the specified type.
DefaultContext
  
init(info:BootstrapInfo):void
DefaultContext
  
toString():String
[override]
DefaultContext
Protected Methods
 MethodDefined By
  
Instantiates all non-lazy singletons.
DefaultContext
Property Detail
configuredproperty
configured:Boolean  [read-only]

Indicates whether configuration for this Context has been fully processed. This includes loading configuration files, reflecting on classes, processing metadata tags or validating the configuration. After this property is set the configuration of the Context is sealed an can no longer be modified. If you try to access the content of this Context with methods like getObject before this property has been set to true, an Error will be thrown. In case this property is set to false after Context creation you can listen to the ContextEvent.CONFIGURED event.


Implementation
    public function get configured():Boolean
destroyedproperty 
destroyed:Boolean  [read-only]

Indicates whether this Context has been destroyed. When this property is set to true, the Context can no longer be used and most of its methods will throw an Error.


Implementation
    public function get destroyed():Boolean
domainproperty 
domain:ApplicationDomain  [read-only]

The ApplicationDomain used to reflect on instance of this Context.


Implementation
    public function get domain():ApplicationDomain
initializedproperty 
initialized:Boolean  [read-only]

Indicates whether this Context has been fully initialized. This includes processing the configuration (thus configured is always true if this property is true) and instantiating all objects that were configured as non-lazy singleton (the default). This includes processing all objects which were configured to be asynchronously initializing, waiting until all these objects have been fully initialized. In case this property is set to false after Context creation you can listen to the ContextEvent.INITIALIZED event.

The objects contained in this Context can already be accessed before this property is set to true (as long as the configured property is set to true). This is necessary since objects that are instantiated and configured during the initialization process of the Context may need access to their dependencies. But you should be aware that you might mix up the initialization order so you should use the Context with caution before this property is set to true.


Implementation
    public function get initialized():Boolean
lifecycleManagerproperty 
lifecycleManager:ObjectLifecycleManager  [read-only]

The manager that handles the lifecycle for all objects in this Context.


Implementation
    public function get lifecycleManager():ObjectLifecycleManager
parentsproperty 
parents:Array  [read-only]

All parent Contexts that this Context inherits from.


Implementation
    public function get parents():Array
registryproperty 
registry:ObjectDefinitionRegistry  [read-only]

The registry used by this Context.


Implementation
    public function get registry():ObjectDefinitionRegistry
scopeManagerproperty 
scopeManager:ScopeManager  [read-only]

The scope manager that handles all scopes that this Context belongs to. This includes scopes inherited from parent Contexts as well as scopes created for this Context.


Implementation
    public function get scopeManager():ScopeManager
viewManagerproperty 
viewManager:ViewManager  [read-only]

The view manager used to dynamically wire view instances to this Context.


Implementation
    public function get viewManager():ViewManager
Method Detail
addDynamicDefinition()method
public function addDynamicDefinition(definition:DynamicObjectDefinition):DynamicObject

Creates an object from the specified definition and dynamically adds it to the Context.

Parameters

definition:DynamicObjectDefinition — the definition to create an object from

Returns
DynamicObject — an instance representing the dynamically created object and its definition
addDynamicObject()method 
public function addDynamicObject(instance:Object, definition:DynamicObjectDefinition = null):DynamicObject

Dynamically adds the specified instance to the Context.

Parameters

instance:Object — the object to add to the Context
 
definition:DynamicObjectDefinition (default = null) — optional definition to apply to the existing instance

Returns
DynamicObject — an instance representing the dynamically created object and its definition
containsObject()method 
public function containsObject(id:String):Boolean

Checks whether this Contex contains an object with the specified id.

Parameters

id:String — the id to check

Returns
Boolean — true if this Context contains an object with the specified id
createDynamicObject()method 
public function createDynamicObject(id:String):DynamicObject

Returns a new dynamic object for the specified id. Throws an Error if no such object exists. Dynamic objects can only be created from DynamicObjectDefinitions, such as those created by the <DynamicObject> MXML tag or the <dynamic-object> XML tag.

Parameters

id:String — the id of the object

Returns
DynamicObject — a new dynamic object for the specified id
createDynamicObjectByType()method 
public function createDynamicObjectByType(type:Class):DynamicObject

Returns a new dynamic object for the specified type. This method will throw an Error if no object with a matching type exists in this Context or if it finds more than one match. Dynamic objects can only be created from DynamicObjectDefinitions, such as those created by the <DynamicObject> MXML tag or the <dynamic-object> XML tag.

Parameters

type:Class — the type of the object to return

Returns
DynamicObject — a new dynamic object for the specified type
destroy()method 
public function destroy():void

Destroys this Context. This includes processing all lifecycle listeners for all objects that this Context has instantiated and calling their methods marked with [Destroy]. The Context may no longer be used after calling this method.

findAllDefinitionsByType()method 
public function findAllDefinitionsByType(type:Class, status:LookupStatus = null):Array

Returns all definitions for the specified type.

Parameters

type:Class — the type of the objects to return
 
status:LookupStatus (default = null) — internal status to avoid duplicate lookups, not used in normal application code

Returns
Array — all definitions for the specified type
findDefinition()method 
public function findDefinition(id:String, status:LookupStatus = null):ObjectDefinition

Returns the definition for the object with the specified id or null if no such object exists.

Parameters

id:String — the id of the object
 
status:LookupStatus (default = null) — internal status to avoid duplicate lookups, not used in normal application code

Returns
ObjectDefinition — the definition for the object with the specified id or null
findDefinitionByType()method 
public function findDefinitionByType(type:Class, status:LookupStatus = null):ObjectDefinition

Returns one definition for the specified type. Throws an Error if there is more than one definition for the specified type. If this Context has parents, it should only look into parent Contexts if the definition cannot be found in the local Context.

Parameters

type:Class — the type of the object to return
 
status:LookupStatus (default = null) — internal status to avoid duplicate lookups, not used in normal application code

Returns
ObjectDefinition — one definition for the specified type
getAllObjectsByType()method 
public function getAllObjectsByType(type:Class):Array

Returns all objects that match the specified type. This includes subclasses or objects implementing the interface in case the type parmeter is an interface. When no match is found an empty Array will be returned.

Parameters

type:Class — the type of the objects to return

Returns
Array — all objects that match the specified type
getObject()method 
public function getObject(id:String):Object

Returns the singleton object with the specified id. Throws an Error if no such object exists.

Parameters

id:String — the id of the object

Returns
Object — the object with the specified id
getObjectByType()method 
public function getObjectByType(type:Class):Object

Returns a singleton object of the specified type. This method will throw an Error if no object with a matching type exists in this Context or if it finds more than one match.

Parameters

type:Class — the type of the object to return

Returns
Object — an object of the specified type
getObjectCount()method 
public function getObjectCount(type:Class = null):uint

Returns the number of objects in this Context that match the specified type. If the type parameter is omitted the number of all objects in this Context will be returned.

Parameters

type:Class (default = null) — the type to check for matches

Returns
uint — the number of objects in this Context that match the specified type
init()method 
public function init(info:BootstrapInfo):void

Parameters

info:BootstrapInfo

initializeSingletons()method 
protected function initializeSingletons():void

Instantiates all non-lazy singletons. In case the Context contains objects with an AsyncInit configuration this operation may execute asynchronously. After all singletons have been instantiated the initialized Event will be fired.

toString()method 
override public function toString():String

Returns
String