Contents
Your StreamBase installation provides a local Maven repository containing several StreamBase artifacts. Find the repository
under your StreamBase installation directory in sdk/maven/repo
. The repository includes:
Artifact ID | Contents |
---|---|
com.streambase.sbclient | The StreamBase Java client API library |
com.streambase.sbtest-unit | The StreamBase unit test library |
com.streambase.embedded-server | Enables running a StreamBase Server in-process |
This repository can be used in any Maven project, independent of the toolset you use. The following sections describe how to use the repository with Eclipse Maven integration (m2e), a plug-in you can install in StreamBase Studio and Eclipse. The first section tells you how to download m2e and install it in Studio.
For a quick Maven tutorial, see Maven in 5 Minutes at apache.org.
StreamBase Studio does not include m2e by default. You can install m2e to use the Maven repository artifacts shown above. To do this:
-
Go to http://download.eclipse.org/technology/m2e/releases/ and follow the instructions for adding a new software update site to Eclipse. See the documentation at http://eclipse.org/m2e.
-
Restart Studio as requested when m2e has finished downloading.
In StreamBase Studio 7.6.x, which is based on Eclipse 4.4, follow these steps:
-
From Studio's top-level menu, select
→ . -
In Available Software dialog, click the button. In the resulting dialog, enter:
Name Eclipse 4.4 Update Site Location http://download.eclipse.org/eclipse/updates/4.4 Click
. -
Click the
button again. In the resulting dialog, enter:Name Orbit Repository for Eclipse 4.4.2 Location http://download.eclipse.org/tools/orbit/downloads/drops/R20150124073747/repository/ Click
. -
Click the
button one more time. In the resulting dialog, enter:Name M2E Update Site Location http://download.eclipse.org/technology/m2e/releases Click
. -
Back in the Available Software dialog, in the Work with field, select the M2E Update Site.
-
Make sure the following check box is cleared:
Group items by category Select m2e - Maven Integration for Eclipse. For StreamBase Studio 7.6.x, select the version m2e 1.6.2, which is the latest available version at this writing. You can experimentally select a later version if available, but 1.6.2 is known to work with Studio 7.6.x.
-
Click I accept the terms and click . Studio downloads and installs the m2e package.
until you get to the license agreement. There, select -
When prompted to restart Studio, click
. -
When Studio restarts, it opens onto the Welcome Overview page. Click the
item, as shown below, for more information about m2e.
- Configuring StreamBase Dependencies in Maven Projects
-
StreamBase projects have optional Java Build Path Library entries that point to the StreamBase Client API library files and the StreamBase Unit Test API libraries.
Because Maven provides an alternative way of describing dependencies in an Eclipse project, TIBCO does not recommend having both Studio Library entries and using Maven dependency management in the same project. Studio projects rely on the Eclipse project Java Build Path, and can be configured to use either Maven or the Studio Library entries equally well.
- Adding Maven Support to an Existing StreamBase Project
-
You can add Maven support to an existing StreamBase project by selecting the project folder in the Package Explorer view and invoking
→ .If your project already has Java Build Path Library entries for the StreamBase APIs, remember to remove those entries so that Maven can manage the dependencies.
- Creating a New StreamBase Project with Maven Support
-
When creating a new StreamBase project to which you intend to add Maven support, be sure to clear the controls that select adding the StreamBase API libraries to the Java Build Path.
Goal: Configure a Studio project to obtain the StreamBase Client library as a Maven dependency.
In StreamBase Studio's SB Authoring perspective:
-
Create a new Maven Project named MyEmbeddedOperator:
-
From
→ → select → and press . -
Select
and press . -
In the New Maven Project dialog, enter:
Group Id com.streambase.sample Artifact Id MyEmbeddedOperator -
Click
.
-
-
In the newly created project, edit the project's
pom.xml
file to add a project repository from the shipped StreamBase local repository directory:-
In the Package Explorer view, open the
pom.xml
file at your Maven project's root. -
Select the pom.xml bottom tab to edit the source directly. Its initial contents are:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.streambase.sample</groupId> <artifactId>MyEmbeddedOperator</artifactId> <version>0.0.1-SNAPSHOT</version> </project>
-
At the end of the
project
element, after<version>0.0.1-SNAPSHOT</version>
, enter the following element for Windows:<repositories> <repository> <id>SB76-local-repo</id> <url>file:///c:/TIBCO/sb-cep/7.6/sdk/maven/repo</url> </repository> </repositories>
Substitute your two-digit StreamBase release number in the path in the
url
element. You may need to adjust that path if you installed StreamBase in a non-default location.On Linux, use a path like the following:
<url>file:///opt/streambase/sdk/maven/repo</url>
On Mac OS X, the installation location is user-dependent. If you installed into the
~/Applications
folder, use a path like the following:<url>file:///Users/sbuser/Applications/TIBCO StreamBase 7.6.0/sdk/maven/repo</url>
-
Save the
pom.xml
file. -
Now that the
pom.xml
file contains the custom repository, make sure that m2e recognizes the new repository by performing these steps:-
Open the Maven Repositories view by selecting
→ → , and then under , select . -
Open the
item and select theSB76-local-repo
project. -
Click the
icon (opposing yellow arrows) in the upper right-hand of the Maven Repositories view to make the Maven Repositories view to refresh the list of repositories from the selected project and your configured Maven settings. -
If you get a Reload settings.xml dialog asking “Are you sure you want to reload the settings?” click .
-
Important! Wait for the Maven indexes to update, as reported in the Studio status bar.
Tip
You can double-click the animated progress icon in the lower right corner of Studio's status bar to open the Progress view.
-
-
Select the Dependencies tab of the
pom.xml
edit view, and select (on the left side, under Dependencies). Enter the following values:Group Id com.streambase Artifact Id sbclient Version your-three-digit-streambase-version
(Example: 7.6.0)Click
. -
Save the
pom.xml
file.
-
-
Create a new Java operator in StreamBase Studio as follows:
-
Select
→ → . In the resulting dialog, specify:Source Folder Browse for MyEmbeddedOperator/src/main/java
Package com.streambase.sample Name MyEmbeddedOperator -
Click
, then . -
This generates two Java files and opens and editor on
MyEmbeddedOperator.java
. This is the framework for you to add your operator's functionality, but the framework file is a complete pass-through operator as generated, and will compile and run. All tuples that enter the operator's input port are passed unchanged to its output port.
-
-
Confirm that the code compiles with Maven without errors:
-
Select the project folder in the Package Explorer view.
-
Right-click, and select
→ -
Watch the Console view for Maven's BUILD SUCCESS message. In the
MyEmbeddedOperator/target
folder, look for the newly generated JAR file:MyEmbeddedOperator-0.0.1-SNAPSHOT.jar
.
-
-
You can use the new pass-through operator in an EventFlow module by completing the following steps:
-
Select your StreamBase project folder in the Package Explorer view.
-
Right-click and select
→ . -
In the resulting Properties dialog, select Libraries.
-
Click
and browse to select theMyEmbeddedOperator-0.0.1-SNAPSHOT.jar
file generated above. -
Next, click Add Library. Select StreamBase Client and click , then .
-
Click
. -
With the project still selected, run Ctrl+T on Windows, Command+R on OS X.
→ or press -
You can now drag the Adapters, Java Operators icon from the Palette to an EventFlow module's canvas and find your new operator in the Project folder.
-