Packageorg.robotlegs.core
Interfacepublic interface IInjector
Implementors SwiftSuspendersInjector

The Robotlegs Injector contract



Public Properties
 PropertyDefined By
  applicationDomain : ApplicationDomain
IInjector
Public Methods
 MethodDefined By
  
createChild(applicationDomain:ApplicationDomain = null):IInjector
Create an injector that inherits rules from its parent
IInjector
  
getInstance(clazz:Class, named:String):*
Create or retrieve an instance of the given class
IInjector
  
hasMapping(clazz:Class, named:String):Boolean
Does a rule exist to satsify such a request?
IInjector
  
injectInto(target:Object):void
Perform an injection into an object, satisfying all it's dependencies The IInjector should throw an Error if it can't satisfy all dependencies of the injectee.
IInjector
  
instantiate(clazz:Class):*
Create an object of the given class, supplying its dependencies as constructor parameters if the used DI solution has support for constructor injection Adapters for DI solutions that don't support constructor injection should just create a new instance and perform setter and/ or method injection on that. NOTE: This method will always create a new instance.
IInjector
  
mapClass(whenAskedFor:Class, instantiateClass:Class, named:String):*
When asked for an instance of the class whenAskedFor inject a new instance of instantiateClass.
IInjector
  
mapRule(whenAskedFor:Class, useRule:*, named:String):*
When asked for an instance of the class whenAskedFor use rule useRule to determine the correct injection.
IInjector
  
mapSingleton(whenAskedFor:Class, named:String):*
When asked for an instance of the class whenAskedFor inject an instance of whenAskedFor.
IInjector
  
mapSingletonOf(whenAskedFor:Class, useSingletonOf:Class, named:String):*
When asked for an instance of the class whenAskedFor inject an instance of useSingletonOf.
IInjector
  
mapValue(whenAskedFor:Class, useValue:Object, named:String):*
When asked for an instance of the class whenAskedFor inject the instance useValue.
IInjector
  
unmap(clazz:Class, named:String):void
Remove a rule from the injector
IInjector
Property Detail
applicationDomainproperty
applicationDomain:ApplicationDomain


Implementation
    public function get applicationDomain():ApplicationDomain
    public function set applicationDomain(value:ApplicationDomain):void
Method Detail
createChild()method
public function createChild(applicationDomain:ApplicationDomain = null):IInjector

Create an injector that inherits rules from its parent

Parameters

applicationDomain:ApplicationDomain (default = null)

Returns
IInjector — The injector
getInstance()method 
public function getInstance(clazz:Class, named:String):*

Create or retrieve an instance of the given class

Parameters

clazz:Class
 
named:String — An optional name (id)

Returns
* — An instance
hasMapping()method 
public function hasMapping(clazz:Class, named:String):Boolean

Does a rule exist to satsify such a request?

Parameters

clazz:Class — A class or interface
 
named:String — An optional name (id)

Returns
Boolean — Whether such a mapping exists
injectInto()method 
public function injectInto(target:Object):void

Perform an injection into an object, satisfying all it's dependencies

The IInjector should throw an Error if it can't satisfy all dependencies of the injectee.

Parameters

target:Object — The object to inject into - the Injectee

instantiate()method 
public function instantiate(clazz:Class):*

Create an object of the given class, supplying its dependencies as constructor parameters if the used DI solution has support for constructor injection

Adapters for DI solutions that don't support constructor injection should just create a new instance and perform setter and/ or method injection on that.

NOTE: This method will always create a new instance. If you need to retrieve an instance consider using getInstance

The IInjector should throw an Error if it can't satisfy all dependencies of the injectee.

Parameters

clazz:Class — The class to instantiate

Returns
* — The created instance
mapClass()method 
public function mapClass(whenAskedFor:Class, instantiateClass:Class, named:String):*

When asked for an instance of the class whenAskedFor inject a new instance of instantiateClass.

This will create a new instance for each injection.

Parameters

whenAskedFor:Class — A class or interface
 
instantiateClass:Class — A class to instantiate
 
named:String — An optional name (id)

Returns
* — A reference to the rule for this injection. To be used with mapRule
mapRule()method 
public function mapRule(whenAskedFor:Class, useRule:*, named:String):*

When asked for an instance of the class whenAskedFor use rule useRule to determine the correct injection.

This will use whatever injection is set by the given injection rule as created using one of the other mapping methods.

Parameters

whenAskedFor:Class — A class or interface
 
useRule:* — The rule to use for the injection
 
named:String — An optional name (id)

Returns
* — A reference to the rule for this injection. To be used with mapRule
mapSingleton()method 
public function mapSingleton(whenAskedFor:Class, named:String):*

When asked for an instance of the class whenAskedFor inject an instance of whenAskedFor.

This will create an instance on the first injection, but will re-use that instance for subsequent injections.

Parameters

whenAskedFor:Class — A class or interface
 
named:String — An optional name (id)

Returns
* — A reference to the rule for this injection. To be used with mapRule
mapSingletonOf()method 
public function mapSingletonOf(whenAskedFor:Class, useSingletonOf:Class, named:String):*

When asked for an instance of the class whenAskedFor inject an instance of useSingletonOf.

This will create an instance on the first injection, but will re-use that instance for subsequent injections.

Parameters

whenAskedFor:Class — A class or interface
 
useSingletonOf:Class — A class to instantiate
 
named:String — An optional name (id)

Returns
* — A reference to the rule for this injection. To be used with mapRule
mapValue()method 
public function mapValue(whenAskedFor:Class, useValue:Object, named:String):*

When asked for an instance of the class whenAskedFor inject the instance useValue.

This is used to register an existing instance with the injector and treat it like a Singleton.

Parameters

whenAskedFor:Class — A class or interface
 
useValue:Object — An instance
 
named:String — An optional name (id)

Returns
* — A reference to the rule for this injection. To be used with mapRule
unmap()method 
public function unmap(clazz:Class, named:String):void

Remove a rule from the injector

Parameters

clazz:Class — A class or interface
 
named:String — An optional name (id)