Using Application Modules

Introduction

A StreamBase application can be referenced by one or more other applications. The referenced application is called an application module, to distinguish it from the main application that references it. Developing with modules enables you to avoid replicating code by reusing the same functionality in multiple applications.

Following is a general workflow for working with application modules. Please follow the links to other topics for details on each step:

  1. Create a new application module or use an existing application as a module. In either case, the application module's functionality and the data that it uses should be compatible with the applications that will reference it. The methods for creating EventFlow Applications and StreamSQL Applications are different:

    • You can create an EventFlow by clicking FileNewEventFlow Application.

      Recall that you can also use an existing application as a module. What if you want to reuse only a subset of functions in an application? In that case, you can create a new application by extracting the components you want. Refer to Extracting an Application Module for details.

    • To create a new StreamSQL application, click FileNewStreamSQL Application. You cannot extract StreamSQL applications graphically from an existing application.

  2. Optionally define parameters for your application and use the parameters in expressions within its operators. See Using Module Parameters for details. You must also bind a value to each parameter: either in the application, or later in a module reference to this application (as described in Step 4). The parameters are replaced by the values at run time.

    Now that you have prepared your application module, turn your attention to the main application that will reference the module.

  3. Ensure that the main application is able to locate the module, as described in the Resource Search Path Order of Precedence section of StreamBase Project Properties.

    • If you want to use modules or operator and adapter resources that are not visible in your Project Explorer (that is, they are outside of your workspace), you must add search paths for those resources in your project's sbd.sbconf configuration file, as described in Managing Studio Resource Files.

    • If the module is outside of your StreamBase Studio workspace, one option may be to import the module into a project. Otherwise, you must add search paths for those resources in your project's sbd.sbconf configuration file, as described in Managing Studio Resource Files.

  4. Save the sbd.sbconf file.

  5. In the main application, reference the application module. See Referencing an Application Module for details.

  6. If the referenced application contains parameters, you can set their values in the module reference, as described in Using Module Parameters. This overrides any values previously set in the referenced application.

  7. If your application references a module that contains tables, your application can query that data, as described in Using Module Parameters.

  8. When you are ready to deploy an application that contains module references, you must configure it to run outside of StreamBase Studio, as described in Deploying Applications.

Note

When you use an application module in multiple applications, keep in mind that any changes to the module itself are inherited in every module reference to it. Conversely, changing the properties of an individual module reference does not change the module or any other applications that reference it.