Packageorg.spicefactory.parsley.core.bootstrap.impl
Classpublic class DefaultService
InheritanceDefaultService Inheritance Object
Implements Service

Default implementation of the Service interface.



Public Properties
 PropertyDefined By
  factory : ServiceFactory
[read-only] The factory for the service implementation.
DefaultService
  serviceInterface : Class
[read-only] The interface all implementations of this service must implement.
DefaultService
Public Methods
 MethodDefined By
  
DefaultService(serviceInterface:Class)
Creates a new instance.
DefaultService
  
addDecorator(type:Class, ... params):void
Adds a decorator for this service.
DefaultService
  
addParent(parent:Service):void
Adds a parent service to be used to pull additional decorators and the default implementation from.
DefaultService
  
getDecorators(status:LookupStatus = null):Array
All decorators added to this service.
DefaultService
  
newInstance(initCallback:Function = null):Object
Creates a new instance of this service, using the specified implementation and applying all decorators added to this service.
DefaultService
  
setImplementation(type:Class, ... params):void
Sets the implementation for this service, replacing the existing registration.
DefaultService
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
Constructor Detail
DefaultService()Constructor
public function DefaultService(serviceInterface:Class)

Creates a new instance.

Parameters
serviceInterface:Class — the interface all implementations of this service must implement
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

addParent()method 
public function addParent(parent:Service):void

Adds a parent service to be used to pull additional decorators and the default implementation from.

Parameters

parent:Service — a parent service to add to this service

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