Library Articles
New Features in StreamBase Studio
Authors: Eddie Galvez, Dr. John Lifter
StreamBase Systems
Applicable To: StreamBase 5.0
Date: 01-September-2007
Beginning with StreamBase 5.0, the functionality of StreamBase Studio has been built as an extension to the Eclipse Integrated Development Environment for Java Developers. In previous StreamBase releases, Studio was implemented within the Eclipse Rich Client Platform. As a result of this change, StreamBase EventFlow and StreamSQL applications as well as Java code written against the StreamBase Java API can be developed in a common development tool.
This article discusses use of the new version of StreamBase Studio.
When you install StreamBase, a full Eclipse IDE updated with approximately twelve StreamBase related plugins is also installed. When you launch StreamBase Studio, the Welcome page will include links to the Eclipse introductory material, tutorials, and samples as well as links that open the StreamBase Studio workspace or a wizard used to import projects from earlier StreamBase releases.
If you click on the link to the StreamBase workspace, the StreamBase Demos perspective will open.
You can use this perspective to load and run the fully implemented demos that are shipped with StreamBase, or you can open the workspace and move to the StreamBase Authoring perspective by either selecting the Window > Open Perspective > StreamBase Authoring menu item or clicking on the Go to Authoring link (circled) in the upper right-hand corner.
If this is the first time you have opened the workspace, note the links in the StreamBase Properties view. You can use these links to load the sample code provided in the StreamBase product, create a new StreamBase project, or migrate a project written with an earlier release of StreamBase into this workspace. You can also load the sample code and start a new project using entries under the File menu.
Once you start using Studio, there are several ways you can create a new StreamBase project.
- Select the File > New > StreamBase Project menu item.
- Right-click in the Package Explorer view and select New > StreamBase Project or New > Project from the popup menu.
- Selecting New > StreamBase Project opens the New StreamBase Project, StreamBase Project, Create a New StreamBase Project window.
- Selecting New > Project opens the New Project, Select a Wizard window. Highlight the StreamBase project entry, or the StreamBase/StreamBase Project entry, and click the Next command button to open the New StreamBase Project, StreamBase Project, Create a New StreamBase Project window.
- Click on the New StreamBase Project tool bar button.
In the New StreamBase Project, StreamBase Project, Create a New StreamBase Project window:
-
Give your project a meaningful name.
-
Select, if desired, the type of StreamBase files you want the project to include:
-
Add, if the project will include a custom operator, custom embedded adapter, custom aggregate function, and/or network clients, the StreamBase Client API to the Java build path.
If this is the first project you have added to the workspace, the Next command button will be disabled. Simply click the Finish command button to complete the process. If you have other projects in the workspace, the Next command button will be enabled. Clicking this button opens the New StreamBase Project, Project References window, which you use to make modules and operator resources in other projects available to the new project.
By selecting projects in this window, any .sbapp or .ssql files in these projects can be used as modules in the new project. Adding project references is optional; if your new application does not use modules from other projects, you can skip over this window. Note that if you want to use as a module an .sbapp or .ssql file from a different workspace or directory location, you will need to import the file into your project, as described below.
Click the Finish command button to complete the process.
Once you have a StreamBase project, you can use it to develop:
-
Custom operators
-
Custom embedded adapters
-
Aggregate custom functions
-
Simple custom functions
-
Network clients (for example, external adapters)
-
StreamBase applications (EventFlow and StreamSQL)
Any of the components built on the StreamBase Client API can be developed in a dedicated project or in a project that also includes StreamBase applications, although it generally is a better practice to develop each type of component in a dedicated project.
If your project will only include StreamBase applications and/or simple custom functions, you do not need to add the StreamBase Client API to the Java build path; this library is only required when a project includes custom operators, custom embedded adapters, aggregate custom functions, and network clients.
If, while working on a project, you decide that you do want to include Java code that depends on the StreamBase Client API and you did not configure this option when creating the project, you can easily add the StreamBase Client API library to the project's build path. In the Package Explorer, highlight the project whose build path you need to modify, right-click, and select Build Path > Add Libraries... from the popup menu. This opens the Add Library, Add Library window; select the StreamBase Client API entry and click the Next command button.
Alternatively, after highlighting the project in the Package Explorer, right-click and select Properties from the popup menu, or select the Project > Properties menu item. These actions open the Properties for ... window. In the left-hand panel select the Java Build Path entry and in the right-hand panel select the Libraries tab and click the Add Library... command button. The Add Library, Add Library window opens, in which you select the StreamBase Client API entry.
Create a StreamBase or standard Java project. If you choose to create a StreamBase project, the New StreamBase Project, StreamBase Project window will give you the opportunity to add the StreamBase Client API to the Java build path. If you choose to create a standard Java project, the New Java Project, Java Settings window will give you an opportunity to add the StreamBase Client API to the project. If you neglect to add the StreamBase Client API when creating the project, you can modify the Java build path as described in the previous section.
In the Package Explorer, highlight the project, right-click, and select New > Other... from the popup menu. Alternatively, select the File > New > Other... menu item. In the New, Select a Wizard window, expand the selections under the StreamBase Java Wizards entry and highlight the StreamBase Java Operator entry. Click the Next command button to start the New StreamBase Java Operator wizard. The details of using this wizard and coding a custom Java operator are discussed in a separate article: Using the StreamBase Studio Java Operator Wizard.
Create a StreamBase or standard Java project. If you choose to create a StreamBase project, the New StreamBase Project, StreamBase Project window will give you the opportunity to add the StreamBase Client API to the Java build path. If you choose to create a standard Java project, the New Java Project, Java Settings window will give you an opportunity to add the StreamBase Client API to the project. If you neglect to add the StreamBase Client API when creating the project, you can modify the Java build path as described in a previous section of this document.
In the Package Explorer, highlight the project, right-click, and select New > Other... from the popup menu. Alternatively, select the File > New > Other... menu item. In the New, Select a Wizard window, expand the selections under the StreamBase Java Wizards entry and highlight the StreamBase Embedded Adapter entry. Click the Next command button to start the New StreamBase Embedded Adapter wizard.
Create a StreamBase or standard Java project. If you choose to create a StreamBase project, the New StreamBase Project, StreamBase Project window will give you the opportunity to add the StreamBase Client API to the Java build path. If you choose to create a standard Java project, the New Java Project, Java Settings window will give you an opportunity to add the StreamBase Client API to the project. If you neglect to add the StreamBase Client API when creating the project, you can modify the Java build path as described in a previous section of this document.
In the Package Explorer, highlight the project, right-click, and select New > Other... from the popup menu. Alternatively, select the File > New > Other... menu item. In the New, Select a Wizard window, expand the selections under the StreamBase Java Wizards entry and highlight the StreamBase Java Function entry. Click the Next command button to start the New StreamBase Custom Java Function wizard. The details of using this wizard and coding a custom Java operator are discussed in a separate article: Using the StreamBase Studio Custom Function Wizard.
Create a StreamBase or standard Java project. Since simple custom functions are implemented through static public functions in a standard Java class, there is no requirement to include the StreamBase Client API on the project's build path.
In the Package Explorer, highlight the project, right-click, and select New > Other... from the popup menu. Alternatively, select the File > New > Other... menu item. In the New, Select a Wizard window, expand the selections under the StreamBase Java Wizards entry and highlight the StreamBase Java Function entry. Click the Next command button to start the New StreamBase Custom Java Function wizard. The details of using this wizard and coding a custom Java operator are discussed in a separate article: Using the StreamBase Studio Custom Function Wizard.
Create a StreamBase or standard Java project. If you choose to create a StreamBase project, the New StreamBase Project, StreamBase Project window will give you the opportunity to add the StreamBase Client API to the Java build path. If you choose to create a standard Java project, the New Java Project, Java Settings window will give you an opportunity to add the StreamBase Client API to the project. If you neglect to add the StreamBase Client API when creating the project, you can modify the Java build path as described in a previous section of this document.
In the Package Explorer, highlight the project, right-click, and select New > Other... from the popup menu. Alternatively, select the File > New > Other... menu item. In the New, Select a Wizard window, expand the selections under the StreamBase Java Wizards entry and highlight the StreamBase Client entry. Click the Next command button to start the New StreamBase Client wizard. The details of using this wizard and coding a custom Java operator are discussed in a separate article: Using the StreamBase Studio Client Wizard.
The procedures for developing an EventFlow Application Diagram or StreamSQL document have not changed. However you will observe a different arrangement of icons within the Palette view. More significant is that individual icons representing each of the embedded adapters provided with StreamBase can be found within the Global Adapters grouping in the Palette view, icons representing custom embedded adapters can be found within the Project Adapters grouping in the Palette view, and icons representing custom operators can be found within the Project Operators grouping in the Palette view.
Note that all StreamBase projects are also Eclipse Java projects and include the Java system libraries and a project specific source code directory – java-src – on the project's build path. However, if you create an Eclipse Java project (which is fine if all you want to do is write custom Java code using the StreamBase Client API) it is not possible to subsequently promote the project to a StreamBase project.
Adding Project References
Note that all StreamBase projects are also Eclipse Java projects and include the Java system libraries and a project specific source code directory – java-src – on the project's build path. However, if you create an Eclipse Java project (which is fine if all you want to do is write custom Java code using the StreamBase Client API) it is not possible to subsequently promote the project to a StreamBase project.
In the left-hand panel, select the Project References entry and in the right-hand panel select the checkbox(es) adjacent to the projects that contain applications you want to reuse as modules.
Importing a SteamBase Application from Another File Location
In the Package Explorer, highlight the project into which you want to import an .sbapp or .ssql file, right-click, and select Import... from the popup menu. Alternatively, select the File > Import... menu item. The Import, Select window opens.
Expand the listing under the General category and highlight the File System entry; then click the Next command button to open the Import, File System window. Click the Browse command button and move to the directory location of the file you want to import into the project. Then click the Finish command button to complete the process; a copy of the file is included in the project.
Note: In StreamBase 5, Import... is not used to add archive files – such as JAR files containing the code for custom Java operators, embedded adapters, or custom functions – to a project. To make the code within an archive file available to your project, include the archive in the project's build path as described in the next section.
Modifying the Java Build Path to Include Another Project in the Same Workspace
If your StreamBase application uses the functionality of a custom operator, custom embedded adapter, and/or custom function that you developed in a different project in the same workspace you will need to include that project in your current project's build path.
In the Package Explorer, highlight the project whose build path you wish to modify, right-click, and select Build Path > Configure Build Path... from the popup menu. Alternatively, select the File > Properties or Project > Properties menu item. All three actions open the Properties for ... window.
In the left-hand panel, select the Java Build Path entry and in the right-hand panel select the Projects tab then click the Add command button, which opens the Required Project Selection window. Select the checkbox(es) adjacent to the projects that contain your custom code, then click the OK command button twice to conclude the process.
Modifying the Java Build Path to Include Custom Code Contained in JAR Files
Perhaps another developer has written custom StreamBase code that they have packaged into a JAR file and you now want to use this code in your current project. In earlier versions of StreamBase Studio, you would import this JAR file into your project. This is not, however, the approach used with StreamBase 5; now you add the file, which remains in a directory location outside of the current workspace, to the project's build path.
In the Package Explorer, highlight the project whose build path you wish to modify, right-click, and select Build Path > Configure Build Path... from the popup menu. Alternatively, select the File > Properties or Project > Properties menu item. All three actions open the Properties for ... window.
In the left-hand panel, select the Java Build Path entry and in the right-hand panel select the Libraries tab then click the Add External JARs... button, which opens a file browser window. Move to the directory that contains the desired JAR file(s), select the file(s) and click the Open command button. This adds the desired JAR file(s) to the current project build path. Click the OK command button to conclude the process.
Since StreamBase Studio now uses the Eclipse launch features to run applications, how you run applications from within Studio has changed from earlier product versions. You will be able to use Studio to run both your StreamBase applications and network clients. Additionally, you do not need to pre-compile your custom Java code into JAR files prior to testing your application.
Running StreamBase Applications
You have three options for running a StreamBase application: you can simply use a toolbar button, you can run the application by using the Run As > Local StreamBase Application option, or you can set up a launch configuration by using the Run... option.
Using the toolbar option is the least involved. In the canvas, open the application you want to run and select the application so its tab is highlighted. Then click the Run the StreamBase Application (Default launch) toolbar button, which is located on the right end of the toolbar adjacent to the Rearranges Components and Connections for Best Layout toolbar button. Don't select the Run toolbar button, which is located on the left end of the toolbar.
There are four ways to use the Run As > Local StreamBase Application or Run... options.
Using the Run As > Local StreamBase Application option is similar to using the toolbar button and the procedure used in earlier product releases. Each of the approaches described in the following listing will compile and run the application in the Test/Debug perspective.
- In the Project Explorer, highlight the .sbapp or .ssql StreamBase application file you wish to run, right-click, and select Run As > Local StreamBase Application from the popup menu.
- In the Project Explorer, highlight the .sbapp or .ssql StreamBase application file you wish to run and select the Run > Run As > Local StreamBase Application menu item.
- In the Project Explorer, highlight the .sbapp or .ssql StreamBase application file you wish to run and click on the down arrow associated with the Run toolbar button; then select Run As > Local StreamBase Application from the dropdown menu. Do not simply click the Run toolbar icon itself; this will rerun the most recently run launch configuration, which is not necessarily the application you have selected in the Package Explorer.
- Open the application file in the canvas, right-click within the application diagram or StreamSQL document, and select Run As > Local StreamBase Application from the popup menu.
Using the Run... option allows you to set up an Eclipse launch configuration. By using a launch configuration, you will be able to start an application without specifically selecting it in the Package Explorer. The advantages to using a launch configuration are that the application may be run without switching to the Test/Debug perspective, and you can set the data directory for persistent query table functionality without editing the configuration file. Each of the approaches described in the following listing will open the Run — Create, manage, and run configurations window.
- In the Project Explorer, highlight the .sbapp or .ssql StreamBase application file you wish to run, right-click, and select Run As > Run... from the popup menu.
- In the Project Explorer, highlight the .sbapp or .ssql StreamBase application file you wish to run and select the Run > Run ... menu item.
- In the Project Explorer, highlight the .sbapp or .ssql StreamBase application file you wish to run and click on the down arrow associated with the Run toolbar button; then select Run... from the dropdown menu.
- Open the application file in the canvas, right-click within the application diagram or StreamSQL document, and select Run As > Run... from the popup menu.
In the Run — Create, manage, and run configurations window, select, in the left-hand panel, the StreamBase Application entry, right-click, and choose New from the popup menu.
Then on the Main tab, which opens in the right-hand panel, enter a meaningful name into the Name: text box, click the Browse command button, and, in the Choose a StreamBase Application window, select the application file you want to associate with this configuration.
On the Advanced and Common tabs, configure the specifics of your launch configuration, for example, whether to run the application in the background, on a local or remote StreamBase server, the details of persistent data storage, and the log level.
When you have completed describing the launch configuration, click the Apply and Close command buttons to save the configuration, or the Apply and Run command buttons to immediately run the application. As the application starts, even if you selected the Launch in Background option on the Common tab, you will be asked whether you want to switch to the Test/Debug perspective. If you choose not to switch perspectives, a Console view will appear in the Authoring perspective. Regardless of which perspective the application is running in, you can stop the application by selecting the Run > Stop StreamBase Application menu item, pressing the F9 function key, or clicking on the Stops the Running StreamBase Application tool bar button.
Now that a launch configuration has been defined, you can run the StreamBase application by simply opening the Run — Create, manage, and run configurations window, selecting the desired launch configuration, and clicking the Run command button. Additionally, by clicking the arrow associated with the run toolbar button, you can select a previously defined launch configuration from the dropdown menu; simply clicking the run toolbar button will rerun the most recently run launch configuration.
The advantage of defining a launch configuration for a StreamBase application is that you will be able to run the application and stay in the Authoring perspective, which will allow you to run associated network client applications directly from the Package Explorer.
Running Network Client Applications
As far as StreamBase Studio is concerned, a network client is a Java application that may be run from within Studio. Again, you have the option of running a network client application from the Package Explorer or by defining a launch configuration. The advantage of defining a launch configuration is that you will be able to run the network client without switching out of the Test/Debug perspective that you are using to run the related StreamBase application.
To run a network client as a Java application, take one of the following actions.
- In the Package Explorer highlight the file that includes the main method, right-click and select Run As > Java Application from the popup menu.
- In the Package Explorer highlight the file that includes the main method, select the Run > Run As > Java Application from the menu.
- In the Package Explorer highlight the file that includes the main method, click on the down arrow associated with the Run toolbar button; then select Run As > Java Application from the dropdown menu.
- Open the file containing the main method in the canvas, right-click within the editor, and select Run As > Java Application from the popup menu.
Regardless of which approach you choose, a Console view will appear in the Authoring perspective. If you switch to the Test/Debug perspective, the Console view will remain open.
To run a network client through a launch configuration, take one of the following steps to open the Run — Create, manage, and run configurations window.
- In the Package Explorer highlight the file that includes the main method, right-click and select Run As > Run... from the popup menu.
- In the Package Explorer highlight the file that includes the main method, select the Run > Run... from the menu.
- In the Package Explorer highlight the file that includes the main method, click on the down arrow associated with the Run toolbar button; then select Run... from the dropdown menu.
- Open the file containing the main method in the canvas, right-click within the editor, and select Run As > Run... from the popup menu.
In the Run — Create, manage, and run configurations window, set up a launch configuration for a Java (not StreamBase) application. Once the configuration is defined, you may run it by reopening the Run — Create, manage, and run configurations window, selecting the desired launch configuration, and clicking the Run command button. You can also select a this launch configuration from the dropdown menu that opens when you click on the down arrow associated with the run toolbar button.
The advantage of defining a launch configuration for network client applications is that you will be able to run these applications while Studio is in the Test/Debug perspective. Without a launch configuration, you would need to switch to the Authoring perspective to run a network client directly as a Java application, and then, perhaps, switch back to the Test/Debug perspective to use one of the input/output views or run a feed simulation.
To stop a network client application, click the Terminate tool bar button associated with the Console view.
You can use the Insert menu item or keyboard shortcuts to add components.
You either select the component you want from the dropdown menu, or enter the two-key shortcut (for example, S followed by I to add an input stream or O followed by M to include a map operator) for the desired component. Keyboard shortcuts are case insensitive.
Another keyboard shortcut will add output streams to a selected operator. For example, select an operator and then enter X followed by O; an output stream is added to the operator’s output port. If the operator has multiple output ports, this shortcut will connect a separate output stream to each port.
Finally, the keyboard shortcut X followed by X will draw an arc between the two operators most recently placed onto the canvas.
Using the StreamBase Studio Java Operator Wizard
Using the StreamBase Studio Custom Function Wizard
Using the StreamBase Studio Client Wizard