Packageorg.spicefactory.parsley.inject
Classpublic class Inject
InheritanceInject Inheritance Object

API for defining injections to be passed to configurations for property values, method invocations or constructor injection. The values will be resolved at the time the value gets injected.



Public Methods
 MethodDefined By
  
byId(id:String):Object
[static] Specifies an injection by id.
Inject
  
byType(type:Class = null):Object
[static] Specifies an injection by type.
Inject
  
[static] Specifies an injection based on an existing object definition.
Inject
  
ifIdAvailable(id:String, defaultValue:Object = null):Object
[static] Specifies an optional injection by id.
Inject
  
ifTypeAvailable(type:Class = null, defaultValue:Object = null):Object
[static] Specifies an optional injection by type.
Inject
Method Detail
byId()method
public static function byId(id:String):Object

Specifies an injection by id. If the Context does not contain an object of the specified id an error will be thrown.

Parameters

id:String — the id the dependency is configured with in the Context

Returns
Object — an object that can get passed to various configuration methods that accept values for setting properties or invoking methods
byType()method 
public static function byType(type:Class = null):Object

Specifies an injection by type. If the Context does not contain an object with a matching type (or subtype) an error will be thrown. If the type parameter is omitted, the type will get deduced from the target member (constructor, property, method). This option can only be used with injection targets the container can reflect on.

Parameters

type:Class (default = null) — the id the dependency is configured with in the Context

Returns
Object — an object that can get passed to various configuration methods that accept values for setting properties or invoking methods
fromDefinition()method 
public static function fromDefinition(definition:DynamicObjectDefinition):Object

Specifies an injection based on an existing object definition. At injection time the definition will be used to create a new instance.

Parameters

definition:DynamicObjectDefinition — the definition to use for creating the instance to inject

Returns
Object — an object that can get passed to various configuration methods that accept values for setting properties or invoking methods
ifIdAvailable()method 
public static function ifIdAvailable(id:String, defaultValue:Object = null):Object

Specifies an optional injection by id. If the Context does not contain an object of the specified id the specified default value will get injected (or nothing if omitted).

Parameters

id:String — the id the dependency is configured with in the Context
 
defaultValue:Object (default = null) — the value to inject if the dependency is not found

Returns
Object — an object that can get passed to various configuration methods that accept values for setting properties or invoking methods
ifTypeAvailable()method 
public static function ifTypeAvailable(type:Class = null, defaultValue:Object = null):Object

Specifies an optional injection by type. If the Context does not contain an object with a matching type (or subtype) the specified default value will get injected (or nothing if omitted). If the type parameter is omitted, the type will get deduced from the target member (constructor, property, method). This option can only be used with injection targets the container can reflect on.

Parameters

type:Class (default = null) — the id the dependency is configured with in the Context
 
defaultValue:Object (default = null) — the value to inject if the dependency is not found

Returns
Object — an object that can get passed to various configuration methods that accept values for setting properties or invoking methods