Extracting a Module

Instead of creating a new module, you can also extract a subset of components from an existing EventFlow module. StreamBase creates the new module for you, and inserts a Module Reference in the parent module that references the new child module.

The procedure described in this topic is only available for EventFlow applications. StreamBase Studio does not provide a method to extract an application module from a StreamSQL application.

  1. In the StreamBase Studio SB Authoring perspective, open the application that contains the components you want to extract.

  2. In the EventFlow Editor, select a contiguous group of components to include in the application module. In the following example, the selected group includes two Map operators and a Gather operator:

    Observe the following rules for selecting components:

    • Extractable components do not include the streams going into and out of the group of components you select, and by default, such streams are omitted from your selection. StreamBase uses an internal representation of input and output streams for the selected components when it creates the module.

      If you explicitly add any of these streams or arcs to your selection, the Extract as Module command is not available.

    • Do not omit any components that a selected operator or data construct depends on. For example, if you select a Query operator but omit its associated Query Table data construct, you cannot extract your selection into a module.

    • If one or more components that you select for extraction already have their concurrency multiplicity option enabled, those settings are preserved in the new module's EventFlow settings. However, multiplicity concurrency for components inside a module is probably no longer appropriate. (See Execution Order and Concurrency for further information.) In the most likely scenario, take the following steps:

      • Disable the concurrency options for each individual operator inside the module.

      • Instead, enable the concurrency option for the Module Reference itself.

  3. Select RefactorExtract as Module from the EventFlow menu, or right-click the selection and select RefactorExtract as Module from the context menu.

  4. In the Extract as Module dialog:

    • Specify a name for the new module, or accept the name suggested by StreamBase.

    • Optionally specify an alternate workspace location for the new module, such as a subfolder of the current project, or another project folder in the module search path.

    • Specify whether to open the new module in the EventFlow Editor.

    • Specify whether the new module is to have its Separate thread concurrency option set.

  5. Click OK. StreamBase creates a new EventFlow module file with the name you entered, containing the components you selected. By default, the new module is created in the project folder of the module you extracted it from.

    In the parent module, the selected components are replaced with a single Module Reference component that references the newly created module.

    Notice the input and output ports on the Module Reference icon, which StreamBase has connected to appropriate components in the parent module.

    Open the new module by selecting the Module Reference and pressing F3, or by right-clicking the Module Reference and selecting Open Declaration from the context menu. The following example shows the EventFlow canvas of the child module created in the preceding steps. Compare it to the first figure in this topic, which shows the initial selection of elements. Notice that where the selection omitted the outer arcs, StreamBase has added input and output streams. These streams have the same schemas as the corresponding connections in the application:

  6. Verify that the new Module Reference has no typecheck errors. If it does, you may need to edit the Module Reference's properties, as described in Using the Module Reference Component.

    Changing Module Reference properties does not change the module being referenced, but only makes local changes that affect only the referencing module. By contrast, if you change the child module, the changes affect every application that references it.

  7. Save your application.

Back to Top ^