Caplin Trader 4.8.0

Class: module:br/AliasRegistryClass

module:br/AliasRegistryClass

The AliasRegistryClass class provides access to the aliases used within the application.

An alias is simply an alternate logical name for a class, such that specifying this logical name in your source code, whether it be Javascript, HTML or CSS, will cause the class to be bundled and sent to the browser. It is therefore, at it's simplest, a mechanism for ensuring that all the code your app needs, and no more, is bundled and sent to the browser. Though class dependencies are usually specified by directly referring to other classes, there are times when this is inappropriate:

  1. We sometimes need a level of indirection, so that dependencies can be expressed without knowing the concrete class that will end up being used (e.g. services).
  2. It is sometimes useful to specify components declaratively, where it would be confusing to have to refer to the classes that provide some feature, rather than talking in terms of the feature itself.

Another useful facet of aliases is that they can be used to automatically discover all of the classes which implement a particular interface, which makes it a good candidate for creating SPI type, auto-discovery mechanisms.

Constructor

new module:br/AliasRegistryClass()

Methods

getAliasesByInterface(requiredInterface)

Returns a filtered subset of the aliases provided by module:br/AliasRegistry/getAllAliases.

An alias is considered to be associated with an interface if the XML configuration for that alias specifically mentions the given interface, or if the class the alias points to happens to implement the given interface.

Parameters:
Name Type Description
requiredInterface function the interface being used to filter the aliases by.

getAllAliases()

Returns an array containing the names of all aliases in use within the application.

getClass(aliasName)

Returns a class corresponding to the requested alias name.
Parameters:
Name Type Description
aliasName String alias name.
Throws:
if the given alias doesn't exist.
Type
Errors.IllegalState

isAlias(aliasName)

Returns whether the given alias is defined.
Parameters:
Name Type Description
aliasName String alias name.

isAliasAssigned(aliasName)

Returns whether the given alias has been assigned a value — i.e. whether an alias has a class value.
Parameters:
Name Type Description
aliasName String alias name.