How do I Map a Service?

There are several methods available on the injector for mapping your Service classes for injection into your framework actors. In addition, these methods can be used for injecting virtually ANY class into your classes.

To map an existing instance for injection that will be treated as a singleton, use the following syntax:

injector.mapValue(MyServiceClass, myServiceClassInstance)

To map a new instance of a class for each injection, use the following syntax:

injector.mapClass(MyServiceClass, MyServiceClass)

Additionally, this can be used to map interfaces for injection, with a concrete class that implements the interface being injected:

injector.mapClass(IMyServiceClass, MyServiceClass)

To map a singleton instance of an interface or class, use the following syntax:

injector.mapSingleton(MyServiceClass, MyServiceClass)

It is important to note that when referring to a singleton above, it is not a Singleton. It is not enforced outside of the Context as a Singleton. The injector simply insures that one and only one instance of the class will be injected.