Class
caplin.core

AliasRegistry

The AliasRegistry is used to provide access to the aliases used within the application.

A 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 (e.g. presenter & grid), 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 capable of implementing a particular interface, which makes it a good candidate for creating SPI type, auto-discovery mechanisms.

Constructor Summary

Attributes Name and Description
caplin.core.AliasRegistry()

The AliasRegistry is a static class and does not need to be constructed.

Method Summary

Attributes Name and Description
<static> void clear()

Resets the AliasRegistry back to its initial state.

<static> Array getAliasesByInterface(Function fInterface)

Returns a filtered subset of the aliases provided by caplin.core.AliasRegistry.getAllAliases.

<static> Array getAllAliases()

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

<static> Function getClass(String sAliasName)

Returns a class corresponding to the requested alias name.

<static> boolean isAlias(String sAliasName)

Returns whether the given alias is defined.

<static> boolean isAliasAssigned(String sAliasName)

Returns whether the given alias has been assigned a value — i.e.

Constructor Detail

caplin.core.AliasRegistry()

The AliasRegistry is a static class and does not need to be constructed.

Method Detail

<static> void clear()

Resets the AliasRegistry back to its initial state.

This method isn't normally called within an application, but is called automatically before each test is run.

See
caplin.core.ServiceRegistry.clear

<static> Array getAliasesByInterface(Function fInterface)

Returns a filtered subset of the aliases provided by caplin.core.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
Function fInterface the interface being used to filter the aliases by.

<static> Array getAllAliases()

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

<static> Function getClass(String sAliasName)

Returns a class corresponding to the requested alias name.

Parameters
String sAliasName alias name.
Throws
caplin.core.Error.ILLEGAL_STATE
if the given alias doesn't exist.

<static> boolean isAlias(String sAliasName)

Returns whether the given alias is defined.

Parameters
String sAliasName alias name.

<static> boolean isAliasAssigned(String sAliasName)

Returns whether the given alias has been assigned a value — i.e. whether an alias has a class value.

Parameters
String sAliasName alias name.