This sample illustrates the use of the TableAccessor class in the Java Client API. This class lets Java code (such as custom Java operators) interact with data sources in various ways. In particular, this class lets you insert rows, replace rows, read a single row based on the primary index, perform more complex multi-row queries, delete rows, get table size, and truncate entire tables.
This sample includes seven custom Java operators, each of which illustrates a single aspect of the TableAccessor class:
Code shared by these operators exists in a common abstract superclass, AbstractTableOperator. So, for example, the InsertJavaOperator.processTuple method illustrates the use of the corresponding TableAccessor.insert method.
The StreamBase application
TableOperator.sbapp includes an instance of each of those seven Java operators, along with related input, output, and error streams, as appropriate.
To demonstrate Java operator input and output, this sample also includes a StreamBase unit test suite,
UnitTest.java. Thus, instead of running the
TableOperator.sbapp EventFlow application and enqueuing tuples, you just run the unit test. This starts the
TableOperator.sbapp application, populates its Query Table, then runs each of the application's seven Java operators, and reports the results.
A solid green bar in the JUnit view indicates a successful run.
Follow these steps:
In the Project Explorer view, open the
java-srcfolder tree to expose the
UnitTest.java, right-click, and from its context menu, select → .
The JUnit view appears and displays the successful execution of the six tests specified in the
You can then explore the sample in other ways. For example:
Read the source of
UnitTest.javato see samples of Java operator input and expected output.
java-srctree, read the sources of the Java operators:
TableOperator.sbappand interact manually with the operators. Follow these steps:
In the Project Explorer, double-click to open the
TableOperator.sbappapplication. Make sure the application is the currently active tab in the EventFlow Editor.
Click the Run button. This opens the SB Test/Debug perspective and starts the application.
In the Manual Input view, select the
Insertstream, and send tuples that populate the application's Query Table with values.
Once you have a small set of data in the Query Table, select the other input streams one at a time to manage and manipulate the data in the Query Table.
When done, press F9 or click the Stop Running Application button.
In StreamBase Studio, import this sample with the following steps:
From the top menu, click→ .
Select this application from the Applications list.
StreamBase Studio creates a project for each sample.
When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.
Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.
Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:
See Default Installation Directories for the location of
studio-workspace on your system.
In the default TIBCO StreamBase installation, this sample's files are initially installed in:
See Default Installation Directories for the default location of
studio-workspace on your system.