IBM Streams 4.2

Creating a sample Java native function

You can create Java™ native functions in Streams Studio.

Before you begin

Create or import an SPL project.

Procedure

To create a sample native function:

  1. In the Project Explorer view, right-click an SPL project, and click New > Java Native Function
  2. In the New Java Native Function window, select the SPL project in which you want to create the native function. By default, this field already contains the current selection from the Project Explorer view. To choose another project, click Browse.
  3. From the Namespace list, select an existing namespace or specify the namespace in which to create the native function. If the namespace does not exist, a new namespace is created.
  4. Specify a name for your Java function.
  5. Define the return type and add parameters as required. You can also select to make your function stateful.
  6. To change the package name, the implementation name, or the source location of your Java class, click Next.
  7. Click Finish to create the Java class, the static function, and the @Function annotation.
  8. In the editor, implement the code for the function.
  9. Compile the Java code and package the class and its nested classed in a .jar file in the lib or impl/lib subdirectory of the toolkit directory.
  10. Build your SPL project. When the project is built, it generates the SPL artifacts that are necessary to call the Java method from an SPL operator.