StreamBase Maven Artifacts

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.

Installing Maven Integration for Studio (m2e)

StreamBase Studio does not include m2e by default. You can install m2e to use the Maven repository artifacts shown above. To do this:

  1. 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.

  2. Restart Studio as requested when m2e has finished downloading.

Detailed Maven Integration Instructions

In StreamBase Studio 7.6.x, which is based on Eclipse 4.4, follow these steps:

  1. From Studio's top-level menu, select HelpInstall New Software.

  2. In Available Software dialog, click the Add button. In the resulting dialog, enter:

    Name Eclipse 4.4 Update Site
    Location http://download.eclipse.org/eclipse/updates/4.4

    Click OK.

  3. Click the Add 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 OK.

  4. Click the Add button one more time. In the resulting dialog, enter:

    Name M2E Update Site
    Location http://download.eclipse.org/technology/m2e/releases

    Click OK.

  5. Back in the Available Software dialog, in the Work with field, select the M2E Update Site.

  6. 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.

  7. Click Next until you get to the license agreement. There, select I accept the terms and click Finish. Studio downloads and installs the m2e package.

  8. When prompted to restart Studio, click Yes.

  9. When Studio restarts, it opens onto the Welcome Overview page. Click the Maven Integration for Eclipse item, as shown below, for more information about m2e.

Further Considerations

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 ConfigureConvert to Maven Project.

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.

Example: Creating a StreamBase Java Operator Using m2e

Goal: Configure a Studio project to obtain the StreamBase Client library as a Maven dependency.

In StreamBase Studio's SB Authoring perspective:

  1. Create a new Maven Project named MyEmbeddedOperator:

    • From FileNewProject, select MavenMaven Project and press Next.

    • Select Create a simple project and press Next.

    • In the New Maven Project dialog, enter:

      Group Id com.streambase.sample
      Artifact Id MyEmbeddedOperator
    • Click Finish.

  2. 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 WindowShow ViewOther, and then under Maven, select Maven Repositories.

      • Open the Project Repositories item and select the SB76-local-repo project.

      • Click the Refresh 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 OK.

      • 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 Add (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 OK.

    • Save the pom.xml file.

  3. Create a new Java operator in StreamBase Studio as follows:

    • Select FileNewStreamBase Java Operator. In the resulting dialog, specify:

      Source Folder Browse for MyEmbeddedOperator/src/main/java
      Package com.streambase.sample
      Name MyEmbeddedOperator
    • Click Next, then Finish.

    • 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.

  4. Confirm that the code compiles with Maven without errors:

    • Select the project folder in the Package Explorer view.

    • Right-click, and select Run AsMaven Install

    • 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.

  5. 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 Build PathConfigure Build Path.

    • In the resulting Properties dialog, select Libraries.

    • Click Add JARs and browse to select the MyEmbeddedOperator-0.0.1-SNAPSHOT.jar file generated above.

    • Next, click Add Library. Select StreamBase Client and click Next, then Finish.

    • Click OK.

    • With the project still selected, run StreamBaseRefresh Project Typecheck Environment or press Ctrl+T on Windows, Command+R on OS X.

    • 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.