Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CompositeFactory

Aggregates multiple factories into a single factory component. When a new component is requested, it iterates through factories to locate the one able to create the requested component.

This component is used to conveniently keep all supported factories in a single place.

Example

let factory = new CompositeFactory();
factory.add(new DefaultLoggerFactory());
factory.add(new DefaultCountersFactory());

let loggerLocator = new Descriptor("*", "logger", "*", "*", "1.0");
factory.canCreate(loggerLocator);         // Result: Descriptor("pip-service", "logger", "null", "default", "1.0")
factory.create(loggerLocator);             // Result: created NullLogger

Hierarchy

  • CompositeFactory

Implements

Index

Constructors

Methods

Constructors

constructor

Methods

add

canCreate

  • canCreate(locator: any): any
  • Checks if this factory is able to create component by given locator.

    This method searches for all registered components and returns a locator for component it is able to create that matches the given locator. If the factory is not able to create a requested component is returns null.

    Parameters

    • locator: any

      a locator to identify component to be created.

    Returns any

    a locator for a component that the factory is able to create.

create

  • create(locator: any): any
  • Creates a component identified by given locator.

    throws

    a CreateException if the factory is not able to create the component.

    Parameters

    • locator: any

      a locator to identify component to be created.

    Returns any

    the created component.

remove

Generated using TypeDoc