Configure the Service Factory
Assemblies can only be written in Workspaces. This enables greater flexibility, extraction, and packaging, and it provides the ability to create dynamic dashboards, dynamic cubes, dynamic Cube Views, and dynamic grids.
You can implement a service factory to use capabilities in Workspaces.
Runtime Logic
The service factory is a dispatcher object that routes requests to run rules to specific objects called services that can satisfy these requests.
In a basic setup, a service factory can have a single service for each type of rule.
Example: One rule is for data management calls, and one rule is for XFBR calls.
However, a service factory can also invoke multiple services of a specific type, depending on context variables.
Example: Route calls for data management jobs to one service from Monday to Friday and then to a different service from Saturday to Sunday.
It is not required to provide a service for each supported type.
Example: If the service factory is not used for requests of that type, it may use the traditional approach, and everything will function correctly.
The following image is an example of the service factory process.
Create a Maintenance Unit for All Assemblies within a Workspace
This first step is organizational and designed to keep all rules within a single location. Create a maintenance unit within the Workspace to hold all necessary assemblies. The following image displays multiple maintenance units in the Workspace, but only the DynamicCode maintenance unit contains assemblies. This will be the central location for all rules.
Create an Assembly File for the Service Factory
The second step is to create an assembly file with the Source Code Type of Service Factory.
The service factory assembly file is needed to leverage all items used within assemblies. It should look similar to the following image. This example uses C#.
The code enables you to create the following objects:
-
Components
-
Dashboards
-
DataManagementStep
-
DataSet
-
Dynamic dashboard
-
Dynamic Cube View
-
Finance business rules
-
SqlTableEditor
-
TableViews
-
XFBRString
If you are not using any of the objects listed, keep them commented out in the code. Otherwise, you will receive a syntax error when compiling.
Example: If you only need the DynamicDashboard call, the service factory would look similar to the following image.
Configure the Workspace Assembly Service Property
This last step enables the entire Workspace to use the new service factory file so that your rules run correctly.
IMPORTANT: Assembly files will not run correctly if you skip this step.
Go to the Workspace, and update the Workspace Assembly Service to follow this format: {WsAssemblyName}.{ServiceFactoryName}
Example: DynamicCode.WsAssemblyFactory
You can also do this on any maintenance unit. As a best practice, keep all assembly files in a single maintenance unit. You can designate the Workspace and maintenance unit level in all actions.
Reference the Service Factory in Properties
Service factories can be referenced from configuration properties in different ways, depending on their location.
-
assemblyName.factoryName: This will look for a service factory file called factoryName in the assembly called assemblyName. This can be used on the maintenance unit and Workspace properties.
-
WSMU: This will look for the service factory specified on the maintenance unit containing the object. If it cannot find it, it will search for the service factory specified on the Workspace containing the object. It will fail if it is empty. This can be used on the Dashboard Components properties.
-
WS: This will look for the service factory specified on the Workspace containing the object. It will fail if it is empty. This can be used on the Dashboard Components properties.
-
Workspace.workspaceName.maintenanceUnitName.WSMU: This will look for the service factory specified on the maintenance unit called maintenanceUnitName in Workspace called workspaceName. It will fail if it is empty.
NOTE: You can specify a Namespace Prefix as workspaceName.
If the specified maintenance unit is not in the Workspace containing the object that originates the call or if this syntax is used in Cube Views, the specified Workspace must be set to Is Shareable Workspaces. This can be used on the Cube View, Dashboard Components, and Data Management Steps properties.
-
Workspace.workspaceName.WS: This will look for the service factory specified on Workspace workspaceName. It will fail if it is empty.
NOTE: You can specify a Namespace Prefix as workspaceName.
If the specified Workspace is not the one containing the object that originates the call or if this syntax is used in Cube Views or Cube Properties, the specified Workspace must be set to Is Shareable. This can be used on the Cube Properties, Cube Views, Dashboard Components, and Data Management Steps properties.
-
Workspace.Current.maintenanceUnitName.WSMU, Workspace.Current.Current.WSMU, and Workspace.Current.WS: The Current keyword can be used to reference the Workspace or maintenance unit without having to fully spell out their names when they contain the object originating the call. This makes the configuration more robust because references will not break if these containers are renamed or copied. This syntax will still follow the same Workspace Is Shareable and application restrictions and behave the same as the explicit syntax. These can be used on the Cube Views, Dashboard Components, and Data Management Steps properties.
Dashboard Components Example
In this example, a component service was implemented with the function name SaveRecord. This service is enabled by the MyFactory Service Factory - Assembly File specified on the same MyMU maintenance unit within the MyWorkspace Workspace, which contains the Button component that will invoke the function when selected on a dashboard.
In the MyButton component, the Selection Changed Server Task Arguments field displays the following format: {WSMU}{SaveRecord}{}
To invoke the same rule from a Button component in another maintenance unit named MyMU in the same Workspace, use the following format: {Workspace.Current.MyMU.WSMU}{SaveRecord}{}
To invoke the same action from a Button component in another Workspace named MyWorkspace, you must set the property of MyWorkspace, and change the Is Shareable Workspace field in the Workspace to True, and then use the following format: {Workspace.MyWorkspace.MyMU.WSMU}{SaveRecord}{}
Data Management Steps Example
Data management steps require the expanded syntax.
Example: Workspace.MyWorkspace.MyMU.WSMU
However, to make the configuration more robust, if the factory is specified on the same maintenance unit that contains the step, use the Current keyword.
Example: Workspace.Current.Current.WSMU
Member Lists Example
Cube Views require all referenced factories to be in a shareable Workspaces even if service factories are in the same Workspace as the Cube View. The syntax must be explicit.
In this example, a Member List parameter called MyMemberList was created, provided by a service factory specified in the properties of maintenance unit MyMU in Workspace MyWorkspace.
To invoke it from a Cube View, use the following syntax: [Workspace.MyWorkspace.MyMU.WSMU,MyMemberList]
GetDataCell Example
The same considerations apply for GetDataCell as for Member Lists.
Example: GetDataCell(“BR#[Workspace.MyWorkspace.MyMU.WSMU,MyDataCellFunction]”):Name(My Check)
Organize Service Factory Assembly Files
With the service factory set up, you can build any necessary assembly files to bring the Workspace to life. The following image provides an example of the organizational structure of assembly files.
Notice that the service factory assembly file is separate, and a folder contains all the necessary factory controller files. The Workspaces use one of each of the calls from the service factory assembly file.
You can refer to business rules created as assemblies in other Workspaces, but you cannot refer to service types from other Workspaces. So, a lighter syntax is required when calling business rules throughout the Workspace.
See the following sections:
See the following sections for additional service types: