Using Third-Party JARs and Native Libraries with Adapters and Java Operators

Custom adapters and Java operators are built using the StreamBase Client API libraries, as documented elsewhere in this guide. As this topic describes, you can also use third-party JARs or native so or DLL libraries.

However, StreamBase Studio is not normally configured to load Third-party JARs and native libraries directly. Unlike StreamBase client API libraries, they are not automatically discovered by Studio when they are on the project build path. As a result, your adapter or operator cannot be instantiated, and typechecking fails for the application that includes it.

Third-party JARs and native libraries are normally processed separately from StreamBase. For example, if your adapter includes a third-party JAR and that JAR in turn calls a DLL or so library, the location of that library is resolved by the Java process. If there is still another level of dependency (for example, Java > JAR > DLL > DLL ), the second-level of DLL is resolved by the operating system.

This topic describes how to work around these limitations by locating these resources correctly and performing a simple reconfiguration of StreamBase Studio.

Local Adapters and Operators

This section describes scenarios using different combinations of third-party JARs and native libraries, and indicates where you should locate them. To keep things simple, we assume that you create the base code using one of the StreamBase wizards for creating adapters or Java operators:

Scenario 1: No third-party dependencies

In the simplest case, your adapter or operator uses no third-party JARs and no native libraries:

The adapter or operator source is generated into the java-src folder by default. You might also move the source to another location on the project build path.

Scenario 2: Adapters or operators and 3rd-party JARs

If your adapter or operator uses third-party JARs but no native libraries:

  • Adapter and operator resources can be in the same locations as in Scenario 1. In addition:

  • Put your third-party JARs on the project build path.

Scenario 3: Adapters or operators and native libraries

If your adapter or operator uses native libraries but no third-party JARs:

  • Put your native libraries in system32.

    For native libraries, java.library.path always includes the system32 directory. On Windows, the library path is specified in %PATH% or LD_LIB_PATH.

  • Edit sbstudio.ini as described in Configuring StreamBase Studio to Use Native Libraries.

  • Open StreamBase Studio by running the sbstudio.exe file in

    • streambase-install-dir\lib\studio (on Windows)

    • streambase-install-dir/lib/studio (on UNIX)

    instead of the sbstudio.exe file in the bin directory.

Scenario 4: Adapters or operators and 3rd-party JARs and native libraries

If your adapter or operator uses both native libraries but no third-party JARs, use this procedure:

  1. Put your native libraries in system32.

    For native libraries, java.library.path always includes the system32 directory. On Windows, the library path is specified in %PATH% or LD_LIB_PATH.

  2. Put your third-party JARs in your JRE's lib/ext directory (not in $STREAMBASE_HOME/lib/ext).

  3. Edit sbstudio.ini as described in Configuring StreamBase Studio to Use Native Libraries.

  4. Open StreamBase Studio by running the sbstudio.exe file in

    • streambase-install-dir\lib\studio (on Windows)

    • streambase-install-dir/lib/studio (on UNIX)

    instead of the sbstudio.exe file in the bin directory.

Configuring StreamBase Studio to Use Native Libraries

This section describes how to modify StreamBase Studio's initialization file so that you can use native libraries with your custom adapter or Java operator.

  1. Look up and note these paths on your system:

    Java path

    The relative path to the Java executable file from the JRE that is used with your StreamBase installation.

    Example 1. 

    bin\java.exe (on Windows, where In Windows where a JDK is installed with StreamBase)

    bin/java (on UNIX, where the JDK is normally installed separately, and is identified in your system's path).


    default configuration path

    The path to the default configuration path used by StreamBase Studio. To find it, open Studio and click HelpAbout StreamBase Studio n.m (where n.m is the StreamBase version number). In the About dialog, click Configuration Details. Look for the osgi.configuration.area field in the Configuration Details window.

    Example 2. 

    file:/C:/Documents and Settings/user/Application Data/StreamBase/StreamBase Studio n.m Configuration/ (Windows)

    file:/home/user/.streambase/streambase-studio-n.m-configuration/ (UNIX)


  2. Edit sbstudio.ini at this location:

    • streambase-install-dir\lib\studio (on Windows)

    • streambase-install-dir/lib/studio (on UNIX)

  3. Add these lines at the beginning of sbstudio.ini, using the paths described in the previous step:

    -vm
    java path
    -configuration
    default configuration path
    

    For example:

    -vm
    bin\java.exe
    -configuration
    file:/C:/Documents and Settings/eduardo/Application Data/StreamBase/StreamBase Studio 5.2 Configuration/
    
  4. Add this line at the end of sbstudio.ini:

    -Dosgi.parentClassloader=ext