StreamBase Interfaces

A StreamBase interface is a contract to which the behavior of a module can adhere. An interface is a set of definitions of input streams, output streams, Query Tables, constants, named schemas, and table schemas. An interface can consist of only schema definitions, or of any combination of streams, tables, and schemas. Streams must be defined with named schemas, while tables must be defined with table schemas.

Interfaces are used in two ways:

  • As templates to enforce strict compliance with its definitions in new and existing EventFlow modules that implement and extend the interface.

  • With an Extension Point operator that references an interface and hosts one or more module instances that implement that interface.

This page discusses interfaces in general and discusses the use of interfaces as templates for modules. See Using Interfaces with Extension Points to learn about using interfaces with Extension Points.

Opening and Editing Interfaces

StreamBase interfaces are stored as files with the .sbint extension in your Studio project folders. Interfaces are created and edited with the Interface Editor. Open the Interface Editor in one of the following ways:

  • Create a new interface from scratch with File>New>StreamBase Interface, as described on Creating a New EventFlow Interface.

  • Drag an .sbint file from the Project Explorer to the canvas.

  • Double-click an .sbint file in the Project Explorer.

  • Double-click an .sbint file in the Module Explorer.

  • For interfaces referenced by an Extension Point operator:

    • Select the operator and press F3, or select Open Declaration from the context menu.

    • Open the Modules tab of the Properties view for the operator and click the Interface link.

By contrast, the following actions that you might expect to open the Interface Editor do not:

  • Dragging an .sbint file from the Module Explorer to the canvas creates an Extension Point operator that references the dragged interface.

  • Double-clicking an .sbint file in the StreamBase Extension Points view or Module Call Hierarchy view does not directly open the Interface Editor. Instead, double-clicking in these views opens the EventFlow Editor for the module that contains the Extension Point operator that references that interface, with that Extension Point operator selected in the canvas. To continue on to the Interface Editor, press F3.

Interfaces as Templates

When a module implements an interface, the interface enforces compliance with the stream and table definitions in the interface. Since an interface's stream and table definitions must be based on named schemas and table schemas, using an interface also enforces the use of centrally defined schemas throughout your application.

This lets you design an interface with a known set of streams, tables, and schemas that many modules can implement in different ways. For example, an interface named Multiply might define a set of input and output streams with certain schemas. You can then create several modules such as Doubler.sbapp and Tripler.sbapp that implement that interface and add the actual multiplication logic. Any module that implements an interface can be invoked interchangeably with another module that implements the same interface.

Interfaces can implement other interfaces. This lets you nest a set of definitions in layers and use them in the combinations most appropriate for your applications. For example, interface A can consist of only schema definitions. Interface B can then define input and output streams, extending and importing from interface A for its schema definitions. Then interface C could define a set of Query Table placeholders, extending and importing from interface B, and so on.

New Module Based on Interface

Create a new EventFlow module based on an interface with these steps:

  1. If your interface does not yet exist, use the File>New>StreamBase Interface as described in Create a New, Empty Interface File to create a new interface. Define the set of schemas, streams, and tables for the interface and save the .sbint file.

  2. Create a new, blank EventFlow application module with File>New>EventFlow Application as described in Create an EventFlow Module from an Interface, specifying the interface file with the Implement interface checkbox.

New Interface Based on Interface

Create a new interface that extends an existing interface using the steps described in Create an Interface from an Interface.

Adding an Interface to an Existing Module

Add an interface to an existing EventFlow application module with these steps:

  1. Make sure the interface that you want to add exists in the module search path of the module's project.

  2. Open the EventFlow Editor for the module of interest, and open the Definitions tab.

  3. In the Manage Interfaces panel at the bottom of the tab, select Add Interface.

  4. In the Choose Interfaces dialog, select the interface file of interest, and press OK.

  5. Studio adds the interface and opens the Editor tab of the EventFlow Editor. Notice that Studio has added a stream and Query Table component to the module's canvas for each stream and table definition in the interface.

  6. Continue editing the module, connecting the newly added streams or tables to other components in the module.

See the Manage Interfaces section of the EventFlow Editor Definitions Tab page for further details.

Enforcing An Interface

You might base a module on an interface definition and then later find yourself inadvertently removing one or more stream or table components that were based on the interface. Studio reports this as a typecheck error, and places a banner line across the top of the canvas like the following example:

To correct this condition, open the Definitions tab of the EventFlow Editor. In the Manage Interfaces panel at the bottom, select the name of the interface as reported in the error message, and click Add Missing Items.

This opens the Add Missing Items dialog. Select the checkbox for one or more missing components and click OK.

Back to Top^