Contents
This topic describes how to add a custom Java operator to a StreamBase application.
Prerequisite steps (described in Developing Java Operators in the API Guide):
-
You have created one or more custom Java operators (for example, by using the StreamBase Java Operator wizard), and edited the generated Java source to add the functionality you want, or placed a JAR file containing one or more custom Java operators in your project.
-
The StreamBase Java Client library is on your project's build path.
-
You have refreshed the project's Typecheck Environment.
To add a Java operator to an EventFlow application:
-
Open the application to which you want to add the Java operator.
-
Open the Project Operators drawer of the Palette and find the Java operator you want to use. If you are using an operator whose files are stored outside the current project, make sure that its location is in the resource search path of the application (as described in Resource Search Path).
-
Drag the Java operator icon from the Palette into your EventFlow Editor.
-
Connect the new Java operator instance into your application's flow, by drawing arcs from the operator ports to the appropriate components.
-
Open the Properties view for the operator and define its properties in the tabs, as described in the remainder of this topic.
To add a Java operator to a StreamSQL application:
-
Open the ssql application to which you want to add the Java operator.
-
Add a StreamSQL APPLY statement, as described in the StreamSQL Guide.
This simple example shows a Java operator used to convert strings to lowercase, and pass the result directly through on the output stream. Possibly, the ConversionType value could have been set to "Upper Case" instead.
CREATE INPUT STREAM InputPrice ( symbol string, price double ); CREATE OUTPUT STREAM OutputStream1; APPLY JAVA "StringCase" ( ConversionType = "Lower Case" ) FROM InputPrice INTO OutputStream1;
-
Save the application. When you are ready to test it, click the
button.
For details about using the APPLY JAVA statement, refer to the APPLY Statement topic in the StreamSQL Guide.
Name: Use this field to specify or change the component's name, which must be unique in the application. The name must contain only alphabetic characters, numbers, and underscores, and no hyphens or other special characters. The first character must be alphabetic or an underscore.
Operator: A read-only field that shows the formal name of the operator.
Class: A field that shows the fully qualified class name that implements the functionality of this operator. Use this class name when loading the operator in StreamSQL programs with the APPLY JAVA statement. You can right-click this field and select Copy from the context menu to place the full class name in the system clipboard.
Start with application: If this field is set to Yes or to a module parameter that evaluates to true, an instance of this operator starts as part of the containing StreamBase Server. If this field is set to No or to a module parameter that evaluates to false, the adapter is loaded with the server, but does not start until you send an sbadmin resume command, or until you start the component with StreamBase Manager. With this option set to No or false, the operator does not start even if the application as a whole is suspended and later resumed. The recommended setting is selected by default.
Enable Error Output Port: Select this check box to add an Error Port to this component. In the EventFlow canvas, the Error Port shows as a red output port, always the last port for the component. See Using Error Ports and Error Streams to learn about Error Ports.
Description: Optionally enter text to briefly describe the component's purpose and function. In the EventFlow canvas, you can see the description by pressing Ctrl while the component's tooltip is displayed.
The Operator Properties tab displays the parameters that you or another developer implemented in the custom Java Operator class. For example, the Operator class may present a radio button choice for a Boolean field, a text box for a Double, a drop-down selector for an Int, a table for a String Array, and a text field for a String.
For example:
![]() |
The contents and functionality of the Parameters tab are set entirely by your implementation of the Java Operator class. For
implementation details, see Using the Java Operator API in the API Guide. Also refer to the com.streambase.sb.operator.*
Javadoc for the StreamBase Java Client library. Also run the Java Operator sample, view the source for StringCase.java, and see the sample's documentation.
Use the Concurrency tab to specify parallel regions for this instance of this component, or multiplicity options, or both. The Concurrency tab settings are described in Concurrency Options, and dispatch styles are described in Dispatch Styles.
Caution
Concurrency settings are not suitable for every application, and using these settings requires a thorough analysis of your application. For details, see Execution Order and Concurrency, which includes important guidelines for using the concurrency options.
To avoid hard-coding Java operator property values within StreamBase applications, variables can be defined in the StreamBase
configuration file and referenced from Java operator properties. For example, the value for a property can be entered as ${MyIntegerValue}
if the following element exists in the StreamBase configuration file:
<operator-parameters> <operator-parameter name="MyIntegerValue" value="123"/> </operator-parameters>