UNPKG

1.23 kBTypeScriptView Raw
1/** @module build */
2/**
3 * Interface for component factories.
4 *
5 * Factories use locators to identify components to be created.
6 *
7 * The locators are similar to those used to locate components in references.
8 * They can be of any type like strings or integers. However Pip.Services toolkit
9 * most often uses Descriptor objects as component locators.
10 */
11export interface IFactory {
12 /**
13 * Checks if this factory is able to create component by given locator.
14 *
15 * This method searches for all registered components and returns
16 * a locator for component it is able to create that matches the given locator.
17 * If the factory is not able to create a requested component is returns null.
18 *
19 * @param locator a locator to identify component to be created.
20 * @returns a locator for a component that the factory is able to create.
21 */
22 canCreate(locator: any): any;
23 /**
24 * Creates a component identified by given locator.
25 *
26 * @param locator a locator to identify component to be created.
27 * @returns the created component.
28 *
29 * @throws a CreateException if the factory is not able to create the component.
30 */
31 create(locator: any): any;
32}