Packageorg.spicefactory.parsley.core.bootstrap
Interfacepublic interface Service
Implementors DefaultService

Represents the configuration of a single IOC kernel service. It allows to either specify or replace the implementation of this service or add decorators.



Public Properties
 PropertyDefined By
  factory : ServiceFactory
[read-only] The factory for the service implementation.
Service
  serviceInterface : Class
[read-only] The interface all implementations of this service must implement.
Service
Public Methods
 MethodDefined By
  
addDecorator(type:Class, ... params):void
Adds a decorator for this service.
Service
  
getDecorators(status:LookupStatus = null):Array
All decorators added to this service.
Service
  
newInstance(initCallback:Function = null):Object
Creates a new instance of this service, using the specified implementation and applying all decorators added to this service.
Service
  
setImplementation(type:Class, ... params):void
Sets the implementation for this service, replacing the existing registration.
Service
Property Detail
factoryproperty
factory:ServiceFactory  [read-only]

The factory for the service implementation. This factory produces an instance where the decorators added to this service have not yet been applied.


Implementation
    public function get factory():ServiceFactory
serviceInterfaceproperty 
serviceInterface:Class  [read-only]

The interface all implementations of this service must implement.


Implementation
    public function get serviceInterface():Class
Method Detail
addDecorator()method
public function addDecorator(type:Class, ... params):void

Adds a decorator for this service. Decorating services is the recommended way of adding funcitonality to the kernel services, as it allows to stack multiple third party decorators without overriding each others extension. The decorator class must implement the same interface as the decorated service and come with a constructor that accepts the decorated service as the first parameter. If you pass additional parameters to this method they must be added as additional constructor parameters after this required first parameter.

Parameters

type:Class — the implementation type of the service
 
... params — the parameters to pass to the constructor of the decorator, after the first parameter which is always the decorated service itself

getDecorators()method 
public function getDecorators(status:LookupStatus = null):Array

All decorators added to this service. An Array of ServiceFactory instances.

Parameters

status:LookupStatus (default = null) — optional paramater to avoid duplicate lookups, for internal use only

Returns
Array — all decorators added to this service
newInstance()method 
public function newInstance(initCallback:Function = null):Object

Creates a new instance of this service, using the specified implementation and applying all decorators added to this service.

Parameters

initCallback:Function (default = null) — the callback to invoke immediately after instantiation of service and decorator instances

Returns
Object — a new instance of this service
setImplementation()method 
public function setImplementation(type:Class, ... params):void

Sets the implementation for this service, replacing the existing registration.

Parameters

type:Class — the implementation type of the service
 
... params — the parameters to pass to the constructor of the service