# Upgrade an Application to use Aliases

Aliasing was made available in BladeRunner versions 3.3.0 and greater. Although it is not mandatory to use aliasing following the upgrade, it will greatly simplify future extensions of your code as well as making it cleaner. BladeRunner/Caplin Trader 3 releases that include the new alias mechanism offer a default alias configuration for all the components you need to use in your application.

You will need to replace the old class references with their corresponding aliases in the BladeRunner/CT3 default alias configuration files. You can even replace these default components with your own personalised ones if you want.

To get started with using aliases, just do the following:

1. Change the following XML tags in all XML files:

   | Old XML tag | New XML tag | Notes  |
   | --- | --- | --- |
   | grid  | caplin.grid-component | Except in _gridDefinitions.xml_ files |
   | Presenter | br.presenter-component | - |
2. Remove the factory attribute from the `<grid Definitions>` tags in any _gridDefinitions.xml_ files.
3. Change the following controls in all HTML template files. If you have registered any custom control under any of the following names, it either should not be registered or you should override the alias at your application level with the one you have defined:

   | Old HTML tag | New HTML tag  |
   | --- | --- |
   | jquery-date-picker  | br.date-picker |
   | ext-combo-box | br.combo-box |
   | ext-select-box | br.select-box |
   | jquery-autocomplete-box | br.autocomplete-box |
   | caplin-toggle-switch | br.toggle-switch |
4. Remove references to the following classes from all files (mainly JavaScript files and _resources.xml_ files):
   * `caplin.presenter.control.datefield.JQueryDatePickerControlAdaptor`
   * `caplin.presenter.control.selectionfield.ExtJsComboBoxControlAdaptor`
   * `caplin.presenter.control.selectionfield.ExtJsSelectBoxControlAdaptor`
   * `caplin.presenter.control.selectionfield.CaplinToggleSwitchControl`
   * `caplin.presenter.control.selectionfield.JQueryAutoCompleteControl`
   * `caplin.presenter.control.selectionfield.JQueryAutoCompleteControlAdapter`
5. In any _gridDefinitions.xml_ files, remove `<decoratorMapping>` tags for the following classes, and replace all references to the mappings with the given aliases:

   | Old Reference | New Alias  |
   | --- | --- |
   | caplin.grid.decorator.ColumnMenuDecorator | caplin.column-header-menu-decorator |
   | caplin.grid.decorator.ColumnReorderingDecorator | caplin.column-reordering-decorator |
   | caplin.grid.decorator.ColumnResizingDecorator | caplin.column-resizing-decorator |
   | caplin.grid.decorator.ColumnSortDecorator | caplin.column-sort-decorator |
   | caplin.grid.decorator.LoadingDataDecorator | caplin.grid-data-loading-decorator |
   | caplin.grid.decorator.HoverDecorator | caplin.grid-hover-decorator |
   | caplin.grid.decorator.SelectionDecorator | caplin.grid-selection-decorator |
   | caplin.grid.decorator.ScrollTipDecorator | caplin.grid-scroll-tip-decorator |
   | caplin.grid.decorator.RowLoadingDecorator  | caplin.row-loading-decorator |
   | caplin.grid.decorator.NoDataFoundBubbleMessageDecorator  | caplin.grid-data-not-found-decorator |
   | caplin.grid.decorator.DragDecorator | caplin.grid-drag-decorator |
   | caplin.grid.decorator.DropDecorator | caplin.grid-drop-decorator |
   | caplin.grid.decorator.RemoveRowDecorator  | caplin.row-removal-decorator |
   | caplin.grid.decorator.ResetColumnsDecorator | caplin.column-reset-decorator |
   | caplin.grid.decorator.StatusDecorator  | caplin.grid-statusdecorator |
   | caplin.grid.decorator.GroupHeaderDecorator | caplin.grid-group-header-decorator |
6. In any _gridDefinitions.xml_ files, remove `<dataProviderMapping>` tags for the following classes, and replace all references to the mappings with the given aliases:

   | Old Reference | New Alias  |
   | --- | --- |
   | caplin.grid.dataprovider.expandable.ExpandableRowGridDataProvider  | caplin.expandable-row-grid-data-provider |
   | caplin.grid.dataprovider.ChainedGridDataProvider | caplin.chained-grid-data-provider |
   | caplin.grid.RttpContainerGridDataProvider | caplin.rttp-container-grid-data-provider |
   | caplin.grid.PersonalGridDataProvider | caplin.personal-grid-data-provider |
   | caplin.grid.dataprovider.WatchListGridDataProvider  | caplin.watchlist-grid-data-provider |
   | caplin.grid.dataprovider.sljs.SLJSContainerDataProvider | caplin.sljs-container-grid-data-provider |
   | caplin.grid.WebServiceGridDataProvider | caplin.webService-grid-data-provider |
7. If any user has a layout that was serialised before the aliases release, they will need to keep registering any non- Caplin components that were being used.
8. [StreamLink](../../../caplin-platform/streamlink/index.md) won’t need to be registered as a service any more. Instead, you will need to create a `caplin.sljsadapter.providers.StreamLinkConnectionService` StreamLink object, and pass it in the constructor. You will also need to register it in the `ServiceRegistry` through the `caplin.connection-service` alias name. You can then get StreamLink any time you need it using the getStreamLink method on that service.
9. You might need to refer to this link before carrying out the following steps. It will give you a better understanding of using scenarios with BladeRunner to enable different aliases.Let’s say your workbenches or tests use services that are not defined within the "dev scenario", or you wish to override the default classes defined for "dev scenario". You will need to override them in the aliases.xml file, in both the workbenches and test directories.

After which, the _aliases.xml_ file should then look something like this:

```xml
<aliases xmlns="http://schema.caplin.com/CaplinTrader/aliases" useScenario="dev">
  <alias name="caplin.trade-permission-service" class="caplinx.permissioning.CaplinPermissionService"/>
  <alias name="caplin.tobo-user-service" class="caplinb.mock.SingleUserTOBOServiceProvider"/>
</aliases>
```

You should note that the "useScenario" attribute tells BladeRunner to use any aliases defined for the dev scenario _in addition_ to the ones you defined manually in this file.
